-
Notifications
You must be signed in to change notification settings - Fork 14
Migrate Separator and Spacer to SCSS modules #731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
fd0e402
d6e16a1
6831cc3
9fde7a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| .cuiThemeBlock { | ||
| position: absolute; | ||
| inset: 0.5rem 0 0 0; // top, right, bottom, left | ||
| height: fit-content; | ||
| overflow: auto; | ||
| padding: 1rem; | ||
| box-sizing: border-box; | ||
| background: var(--click-storybook-global-background); | ||
|
|
||
| &.cuiLeft { | ||
| left: 0; | ||
| } | ||
|
|
||
| &.cuiRight { | ||
| left: 50vw; | ||
| } | ||
|
|
||
| &.cuiFill { | ||
| left: 0; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,43 @@ | ||
| import _ from "lodash"; | ||
| import { registerTransforms, transforms } from "@tokens-studio/sd-transforms"; | ||
| import StyleDictionary from "style-dictionary"; | ||
|
|
||
| registerTransforms(StyleDictionary); | ||
| const themes = ["dark", "light"]; | ||
|
|
||
| function generateThemeFromDictionary(dictionary, valueFunc = (value) => value) { | ||
| const setWith = (obj, path, value) => { | ||
| if (!obj || typeof obj !== "object") return obj; | ||
|
|
||
| const keys = Array.isArray(path) | ||
| ? path | ||
| : path.replace(/\[(\d+)\]/g, ".$1").split("."); | ||
|
|
||
| let current = obj; | ||
|
|
||
| for (let i = 0; i < keys.length; i++) { | ||
| const key = keys[i]; | ||
|
|
||
| if (i === keys.length - 1) { | ||
| // Last key → set value | ||
| current[key] = value; | ||
| } else { | ||
| // Ensure object exists | ||
| if (current[key] == null || typeof current[key] !== "object") { | ||
| current[key] = {}; | ||
| } | ||
| current = current[key]; | ||
| } | ||
| } | ||
|
|
||
| return obj; | ||
| }; | ||
|
|
||
| const generateThemeFromDictionary = (dictionary, valueFunc = value => value) => { | ||
| const theme = {}; | ||
| dictionary.allTokens.forEach((token) => { | ||
| _.setWith(theme, token.name, valueFunc(token.value), Object) | ||
| dictionary.allTokens.forEach(token => { | ||
| setWith(theme, token.name, valueFunc(token.value), Object) | ||
| }); | ||
| return theme; | ||
| } | ||
| }; | ||
|
|
||
| StyleDictionary.registerTransform({ | ||
| type: "name", | ||
|
|
@@ -27,16 +53,16 @@ StyleDictionary.registerTransform({ | |
|
|
||
| StyleDictionary.registerFormat({ | ||
| name: "ThemeFormat", | ||
| formatter: function ({ dictionary, platform, options, file }) { | ||
| formatter: ({ dictionary }) => { | ||
| const theme = generateThemeFromDictionary(dictionary); | ||
| return JSON.stringify(theme, null, 2); | ||
| } | ||
| }); | ||
|
|
||
| StyleDictionary.registerFormat({ | ||
| name: "TypescriptFormat", | ||
| formatter: function ({ dictionary, platform, options, file }) { | ||
| const theme = generateThemeFromDictionary(dictionary, (value) => typeof value); | ||
| formatter: ({ dictionary }) => { | ||
| const theme = generateThemeFromDictionary(dictionary, value => typeof value); | ||
|
|
||
| // Convert the theme object to a TypeScript interface string | ||
| // Prettier will format this automatically via the generate-tokens script | ||
|
|
@@ -51,7 +77,7 @@ StyleDictionary.registerFormat({ | |
| }); | ||
|
|
||
| StyleDictionary.extend({ | ||
| source: [`./tokens/**/!(${themes.join("|*.")}).json`], | ||
| source: [`./tokens/**/*.json`], | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes me a little nervous
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The issue I faced was missing types when the types where generated so I had to combine all the theme json to complete the complete list of the types we are using
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could actually remove the css from being build as we are not using it at all |
||
| platforms: { | ||
| css: { | ||
| transforms: [...transforms, "name/cti/kebab"], | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling @serdec as there's quite a lot of changes to the build-tokens.js and I don't know why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are only using lodash increases the packages size and we are only using lodash for only here and one another place
So I was thinking like it would be better to remove these to remove dependencies and reduce the package size