-
Notifications
You must be signed in to change notification settings - Fork 89
refactor(tokens): Update JSON files to support Tokens Studio management #11852
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0419c1d
Established initial Tokens Studio color themes
matgalla 0ef29fa
Split semantic color JSON into 2 files for light and dark
matgalla b74d50b
Updated Tokens Studio themes for semantic dark mode colors
matgalla 088b5bf
Updated light.json to only include semantic light mode values
matgalla 76f5195
Updated dark.json to only include semantic dark mode values
matgalla b06b91b
Updated core size token's type from "size" to "sizing"
matgalla 91f5b8b
Updated semantic container-size token's type from "breakpoint" to "di…
matgalla 65a62dc
Updated semantic size token type from "size" to "sizing"
matgalla 231ed5a
Updated semantic space token type from "space" to "spacing"
matgalla 1ea418e
Created Tokens Studio themes for different token types
matgalla 099a526
Fixed syntax error for semantic-colors-light tokens foreground-3 and …
matgalla 3b6f653
Merge branch 'dev' into matgalla/optimize-for-tokens-studio
jcfranco bd83d5b
update token build
jcfranco 2e325bf
tidy up
jcfranco a6378bd
fix themed color output
jcfranco 41e128a
update test snapshots
jcfranco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| import { semantic } from "./build/dictionaries/index.js"; | ||
| import { dark, light, semantic } from "./build/dictionaries/index.js"; | ||
|
|
||
| await dark.buildAllPlatforms(); | ||
| await light.buildAllPlatforms(); | ||
| await semantic.buildAllPlatforms(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/calcite-design-tokens/src/build/preprocessors/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,10 @@ | ||
| import { registerPreprocessorStoreSameValueThemeTokens } from "./store-same-value-theme-tokens.js"; | ||
| import { registerPreprocessorStorePostMergeDictionary } from "./store-post-merge-dictionary.js"; | ||
|
|
||
| export function registerPreprocessors(): void { | ||
| registerPreprocessorStorePostMergeDictionary(); | ||
| registerPreprocessorStoreSameValueThemeTokens(); | ||
| } | ||
|
|
||
| export * from "./store-same-value-theme-tokens.js"; | ||
| export * from "./store-post-merge-dictionary.js"; |
29 changes: 29 additions & 0 deletions
29
packages/calcite-design-tokens/src/build/preprocessors/store-same-value-theme-tokens.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import StyleDictionary from "style-dictionary"; | ||
| import { DesignToken } from "style-dictionary/types"; | ||
| import { dark, light } from "../dictionaries/index.js"; | ||
| import { isThemed } from "../utils/token-types.js"; | ||
| import { state } from "../shared/state.js"; | ||
|
|
||
| export function registerPreprocessorStoreSameValueThemeTokens(): void { | ||
| StyleDictionary.registerPreprocessor({ | ||
| name: PreprocessorStoreSameValueThemeTokens, | ||
| preprocessor: async (dictionary) => { | ||
| const sameValueThemeTokens = light.allTokens | ||
| .filter((token) => isThemed(token)) | ||
| .filter((token, index) => token.value === dark.allTokens[index].value); | ||
| const keyToToken = new Map<string, DesignToken>(); | ||
|
|
||
| sameValueThemeTokens.forEach((token) => { | ||
| if (token.key) { | ||
| keyToToken.set(token.key, token); | ||
| } | ||
| }); | ||
|
|
||
| state.sameValueThemeTokens = keyToToken; | ||
|
|
||
| return dictionary; | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| export const PreprocessorStoreSameValueThemeTokens = "calcite/preprocessor/store-same-value-theme-tokens"; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,12 @@ | ||
| const sharedBuildState: any = { | ||
| postMergeDictionary: undefined, | ||
| } as const; | ||
| import { DesignToken, PreprocessedTokens } from "style-dictionary/types"; | ||
|
|
||
| type State = { | ||
| postMergeDictionary: PreprocessedTokens; | ||
| sameValueThemeTokens: Map<string, DesignToken>; | ||
| }; | ||
|
|
||
| const sharedBuildState = { | ||
| // populated by preprocessors | ||
| } as unknown as State; | ||
|
|
||
| export { sharedBuildState as state }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
I think this could be simplified, can you confirm?
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.
Nice! I'll add that to #11860.