Skip to content

Commit

Permalink
feat(storefront): Add brand colors and variations to UnoCSS config (u…
Browse files Browse the repository at this point in the history
…tils)
  • Loading branch information
leomp12 committed Sep 15, 2022
1 parent 291c419 commit 6698930
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/storefront/uno.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ import {
import presetAttributify from '@unocss/preset-attributify';
import presetIcons from '@unocss/preset-icons';

const brandColorVariations = [
'whiter',
'white',
'lightest',
'lighter',
'light',
'lighten',
'base',
'darken',
'dark',
'darker',
'darkest',
'black',
];
if (global.storefront_color_variations) {
Object.keys(global.storefront_color_variations).forEach((variation) => {
brandColorVariations.push(variation);
});
}

const genUnoCSSConfig = ({
brandIcons = 'logos',
generalIcons = 'heroicons',
Expand Down Expand Up @@ -41,6 +61,21 @@ const genUnoCSSConfig = ({
{ 'i-shopping-cart': `i-${generalIcons}:${shoppingCartIcon}` },
[/^i-([^:]+)$/, ([, icon]) => `i-${generalIcons}:${icon}`],
],
theme: {
colors: ['primary', 'secondary', 'contrast'].reduce((colors, color) => {
const colorVariations = ['hover', 'focus', 'inverse'];
if (color !== 'contrast') {
colorVariations.push(...brandColorVariations);
}
colors[color] = colorVariations.reduce((colorPalette, variation) => {
colorPalette[variation] = `var(--${color}-${variation})`;
return colorPalette;
}, {
DEFAULT: `var(--${color})`,
});
return colors;
}, {}),
},
transformers: [
transformerDirectives(),
],
Expand Down

0 comments on commit 6698930

Please sign in to comment.