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

37 lines 1.24 kB
import { DecorativeType, } from '../../components/decorativeElement/types/decorativeElement'; export const buildPropsDecorativeElement = (element, styles, extraStyles) => { const arrayOfDecorativeType = Object.values(DecorativeType); let result = {}; const decorativeElement = arrayOfDecorativeType.find(item => element?.[item]); if (!decorativeElement) { return result; } result = { [decorativeElement]: { ...element?.[decorativeElement], }, }; // Convert snake_case to camelCase const toCamelCase = () => { return decorativeElement.toLowerCase().replace(/_[a-z]/g, match => match[1].toUpperCase()); }; if (styles?.[toCamelCase()]) { result = { [decorativeElement]: { ...element?.[decorativeElement], ...styles?.[toCamelCase()], }, }; } if (extraStyles && styles?.[toCamelCase()]) { result = { [decorativeElement]: { ...styles?.[toCamelCase()], ...extraStyles, ...element?.[decorativeElement], }, }; } return result; }; //# sourceMappingURL=buildPropsDecorativeElement.js.map