tailwindcss-css-variables-palette-plugin
Version:
Palette plugin using CSS variables for TailwindCSS
15 lines (12 loc) • 350 B
JavaScript
export const generateColorTokens = (name, palette) => {
const colors = {}
Object.keys(palette).map((key) => {
const hex = palette[key]
const cssToken = key === 'DEFAULT' ? `--color-${name}`: `--color-${name}-${key}`
colors[key] = `var(${cssToken}, ${hex})`
});
return {
colorsObject: colors,
colorName: name
}
}