@kubit-ui-web/react-components
Version:
Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience
31 lines • 1.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.useStylesV2 = void 0;
const styled_components_1 = require("styled-components");
const mergeObjects_1 = require("../../utils/mergeObjects/mergeObjects");
const structuredClone_1 = require("../../utils/structuredClone/structuredClone");
const useStylesV2 = ({ styleName, variantName, customTokens, isOptional, }) => {
const theme = (0, styled_components_1.useTheme)();
if (styleName in theme) {
const style = theme[styleName];
if (!variantName) {
return style;
}
else if (variantName in style) {
if (customTokens) {
return (0, mergeObjects_1.mergeObjects)((0, structuredClone_1.structuredClone)(style[variantName]), customTokens);
}
return style[variantName];
}
if (isOptional) {
return undefined;
}
throw Error(`type ${variantName} does not exist`);
}
if (isOptional) {
return undefined;
}
throw Error(`styles ${styleName} does not exist`);
};
exports.useStylesV2 = useStylesV2;
//# sourceMappingURL=useStylesV2.js.map