@qn-pandora/pandora-visualization
Version:
Pandora 通用可视化库
27 lines (26 loc) • 1.17 kB
JavaScript
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import React, { useCallback, useMemo } from 'react';
export default function Affix(props) {
var defaultStyle = props.defaultStyle, affix = props.affix;
var value = affix.value, font = affix.font;
var getDisplayStyle = useCallback(function (layout) {
return layout === "horizontal" /* Horizontal */ ? 'inline-block' : 'block';
}, []);
var currentStyle = useMemo(function () {
return __assign(__assign({}, defaultStyle), { fontSize: font.fontSize || defaultStyle.fontSize, display: getDisplayStyle(font.layout), color: font.fontColor || defaultStyle.color });
}, [font, defaultStyle, getDisplayStyle]);
if (!value || value.length === 0) {
return null;
}
return React.createElement("span", { style: currentStyle }, value);
}