@baleada/tailwind-theme-utils
Version:
Utility functions for Tailwind config files.
34 lines (31 loc) • 904 B
JavaScript
function toMidfixed({ midfix, config }) {
return Object.keys(config)
.reduce((midfixed, value) => ({
...midfixed,
[`${midfix}-${value}`]: config[value],
}), {});
}
function rem(config) {
return toMidfixed({ midfix: 'rem', config });
}
function em(config) {
return toMidfixed({ midfix: 'em', config });
}
function px(config) {
return toMidfixed({ midfix: 'px', config });
}
function screen(config) {
return toMidfixed({ midfix: 'screen', config });
}
function withoutColorPalettes(colors) {
const hues = Object.keys(colors);
return hues
.filter(hueOrKeyword => typeof colors[hueOrKeyword] === 'string')
.reduce((keywords, keyword) => ({ ...keywords, [keyword]: colors[keyword] }), {});
}
function apply(classes) {
return {
[`@apply ${classes}`]: {}
};
}
export { apply, em, px, rem, screen, withoutColorPalettes };