Skip to content

Commit

Permalink
fix: update token and theming
Browse files Browse the repository at this point in the history
- support non-subset theming overrides
- support spacing (with proper open typing)
  • Loading branch information
booc0mtaco committed May 16, 2024
1 parent 2f25f6b commit 590b1fe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
2 changes: 0 additions & 2 deletions bin/eds-apply-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@
});

try {
// Keys in the theme file must be a strict subset of those in the base file
isStrictSubset(baseTheme, localTheme);
EDSStyleDictionary.buildAllPlatforms();
} catch (error) {
// TODO: if theme has things not in base, error showing where the conflict
Expand Down
27 changes: 17 additions & 10 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ const {
...colorTokens
} = edsTokens.theme.color;

// Add a type to the token sizes to avoid literals for keys
const sizes: { [x: string]: string } = edsTokens.size;

const sizeTokens = {
// We pull the spacing tokens and format them such that names are like 'size-${name} = ${value}px'
...Object.keys(sizes)
.map((sizeKey) => {
return { [`size-${sizeKey}`]: `${sizes[sizeKey]}px` };
})
.reduce((accumulate, current) => {
const entry = Object.entries(current)[0];
accumulate[entry[0]] = entry[1];
return accumulate;
}, {}),
};

export default {
/**
* The main value in TW utility classes is for Storybook stories, etc..
Expand All @@ -34,16 +50,7 @@ export default {
...textColorTokens,
},
spacing: {
// We pull the spacing tokens and format them such that names are like 'size-${name} = ${value}px'
...Object.keys(edsTokens.size)
.map((sizeKey) => {
return { [`size-${sizeKey}`]: `${edsTokens.size[sizeKey]}px` };
})
.reduce((accumulate, current) => {
const entry = Object.entries(current)[0];
accumulate[entry[0]] = entry[1];
return accumulate;
}, {}),
...sizeTokens,
},
},
fontWeight: {
Expand Down

0 comments on commit 590b1fe

Please sign in to comment.