nice-ui
Version:
React design system, components, and utilities
33 lines (32 loc) • 1.06 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.Text = void 0;
const react_1 = require("react");
const nano_theme_1 = require("nano-theme");
const createClassName = (0, nano_theme_1.drule)({
...nano_theme_1.lightTheme.font.sans,
});
const Text = ({ as = 'span', nowrap, children, style, size, font, kind = 'mid', ...rest }) => {
const theme = (0, nano_theme_1.useTheme)();
const className = createClassName({
col: theme.g(0.1, 0.8),
});
const style2 = style ? { ...style } : {};
if (nowrap)
style2.whiteSpace = 'nowrap';
if (size) {
style2.fontSize = 1.1 ** size + 'em';
}
if (font) {
const f = theme.font[font];
if (f) {
const ff = f[kind];
if (ff) {
style2.fontFamily = ff.ff;
style2.fontWeight = ff.fw;
}
}
}
return (0, react_1.createElement)(as, { ...rest, className: (rest.className || '') + className, style: style2 }, children);
};
exports.Text = Text;
;