@hitachivantara/uikit-react-utils
Version:
UI Kit utilities package.
19 lines (18 loc) • 488 B
JavaScript
//#region src/utils/styles.ts
function stripEmpty(obj) {
return Object.entries(obj).reduce((acc, [key, value]) => {
if (value || value === 0) acc[key] = value;
return acc;
}, {});
}
/**
* Utility that merges the `style` prop (`styleProp`) with an external `style` object.
*
* The external object accepts CSS vars (`--var`) and removes empty style entries.
*/
var mergeStyles = (styleProp, styles) => ({
...stripEmpty(styles),
...styleProp
});
//#endregion
export { mergeStyles };