braid-design-system
Version:
Themeable design system for the SEEK Group
48 lines (47 loc) • 1.71 kB
JavaScript
const jsxRuntime = require("react/jsx-runtime");
const assert = require("assert");
const react = require("react");
const lib_css_typography_cjs = require("../../css/typography.cjs");
const lib_components_private_Typography_Typography_cjs = require("../private/Typography/Typography.cjs");
const lib_components_private_defaultTextProps_cjs = require("../private/defaultTextProps.cjs");
const lib_components_Text_TextContext_cjs = require("./TextContext.cjs");
const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
const assert__default = /* @__PURE__ */ _interopDefaultCompat(assert);
const Text = ({
size: sizeProp,
tone: toneProp,
weight: weightProp,
maxLines: maxLinesProp,
baseline = true,
...typographyProps
}) => {
assert__default.default(
!react.useContext(lib_components_Text_TextContext_cjs.TextContext),
"Text components should not be nested within each other"
);
const { size, weight, tone, maxLines } = lib_components_private_defaultTextProps_cjs.useDefaultTextProps({
size: sizeProp,
weight: weightProp,
tone: toneProp,
maxLines: maxLinesProp
});
const textStylingProps = react.useMemo(
() => ({
tone,
size,
weight,
baseline
}),
[tone, size, weight, baseline]
);
return /* @__PURE__ */ jsxRuntime.jsx(lib_components_Text_TextContext_cjs.TextContext.Provider, { value: textStylingProps, children: /* @__PURE__ */ jsxRuntime.jsx(
lib_components_private_Typography_Typography_cjs.Typography,
{
maxLines,
...typographyProps,
className: lib_css_typography_cjs.textStyles(textStylingProps)
}
) });
};
exports.Text = Text;
;