UNPKG

@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

27 lines 953 B
import { useTheme } from 'styled-components'; import { mergeObjects } from '../../utils/mergeObjects/mergeObjects'; import { structuredClone } from '../../utils/structuredClone/structuredClone'; export const useStylesV2 = ({ styleName, variantName, customTokens, isOptional, }) => { const theme = useTheme(); if (styleName in theme) { const style = theme[styleName]; if (!variantName) { return style; } else if (variantName in style) { if (customTokens) { return mergeObjects(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`); }; //# sourceMappingURL=useStylesV2.js.map