-
Notifications
You must be signed in to change notification settings - Fork 50
[02] [Project Solar / Phase 1 / Tokens Pipeline] Add $modes support to tokens pipeline
#3239
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
$modes support to tokens pipeline$modes support to tokens pipeline
bcb7219 to
fa4bad2
Compare
1803ce4 to
66b876e
Compare
66b876e to
1a855c1
Compare
1a855c1 to
57ea7fa
Compare
$modes support to tokens pipeline$modes support to tokens pipeline
f4d5ff3 to
ce5300d
Compare
ce5300d to
ba2e78d
Compare
…efers-color-scheme`-only case, generalized `css-selectors`)
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.
Pull Request Overview
Copilot reviewed 9 out of 35 changed files in this pull request and generated no new comments.
$modes support to tokens pipeline$modes support to tokens pipeline
dchyun
left a comment
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.
Overall looking good to me. All my local testing worked as expected.
packages/tokens/dist/products/css/themed-tokens/with-css-selectors--migration/tokens.css
Show resolved
Hide resolved
packages/tokens/dist/products/css/themed-tokens/with-css-selectors--advanced/tokens.css
Show resolved
Hide resolved
packages/tokens/dist/products/css/themed-tokens/with-css-selectors--advanced/tokens.css
Show resolved
Hide resolved
packages/tokens/dist/products/css/themed-tokens/with-css-selectors--advanced/tokens.css
Show resolved
Hide resolved
|
|
||
| import StyleDictionary from 'style-dictionary'; | ||
| import type { Config, DesignToken, Platform } from 'style-dictionary/types'; | ||
| // import { getReferences, usesReferences } from "style-dictionary/utils"; |
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.
[Question] Can this be removed?
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.
It's a memo for myself, will be used when working on this: https://hashicorp.atlassian.net/browse/HDS-5667
b883034
into
project-solar/phase-1/HDS-5216_modes/modes-feature-branch
📌 Summary
This is the implementation PR for adding support to co-located
$modesvalues in the design tokens JSON files, the processing of such values, and the generation of distinct "themed" CSS files in output, with different formats.This is built on top of #3238
🛠️ Detailed description
In this PR I have:
build.tsscriptgetStyleDictionaryConfig.tsfile, so there's less noise in the main file, and it's much easier to see what the configurations are and how they're set upreplace-value-for-mode-${mode}that tricks Style Dictionary (SD) by replacing all the expected$valueentries/values with the corresponding$modes[mode]values, before the tokens are processed by SDattributes/themeablethat adds athemeable: trueentry to a token object, if the token itself has a$modeskey, or one of its alias references/ancestors has a$modeskey"{foo.bar.baz} {xxx.yyy.zzz}") it's not working; this will be tackled in a separate PR, since it's a very specific code change to make, and it can be done in isolationgenerate-extra-theming-filesthat executes the code of thegenerateExtraThemingFiles.tswhich post-processes the single-theme CSS files generated by SD (underthemed-tokens/with-root-selector) and combines them in different formatswith-prefers-color-schemefor consumers (eg Boundary) that use only@media(prefers-color-scheme)to control the theme of their applicationg0andg100are availablewith-css-selectorsfor consumers that will use the HDS-provided theme switcher or follow the HDS guidance of how to implement theming by themselves (this uses[data-hds-theme=***]and.hds-theme-***as CSS selectorsg0,g10,g90,g100are available (in the future this may change, and we may want to expose onlyg0andg100also for this approachwith-combined-strategiesis a mix of the previous two, where consumers may want to give their end-user the option to choose betweenlight,dark, andauto(system settings via prefers-color-scheme)g0,g10,g90,g100are available (in the future this may change, and we may want to expose onlyg0andg100also for this approachwith-scss-mixinsis unlikely to be used, but it was super east to implement, and it provides a simple way for consumers to include theming in their codebase in an extremely customized wayFor testing purposes I have also:
color.palette.neutral-0,color.foreground.primary, and a few typography tokens) adding an extra$modesblock of values (some of them, referencing the Carbon tokens extracted by our pipeline from the@carbon/***packages)🔎 How to review
$modesare defined in thesrcJSON files, and see if that makes sense to you as future code maintainergetStyleDictionaryConfigand see if the code as is makes sense to you, as possible future maintainer, if that's enough understandable on what it does, on how things are named, etcgenerateExtraThemingFilesand see if the code as is makes sense to you, as possible future maintainer, if that's enough understandable on what it does, on how things are named, etc:where()to reduce the specificity, something I've seen being done somewhere else with theming files)🛠️ How to test
Add more
$modesentries to thesrcJSON tokens (taking inspiration by the existing ones) and then run thepnpm buildcommand, and see how the different values are reflected in the generated CSS token files. Try to test different combinations of aliasing, edge cases you can think of, etc. In particular check that the different theme values are reflected in the corresponding theme files, under the correct CSS selectors, and that the themed and non-themed tokens are correctly split in common and themed files. If you add only$modesvalues, the "old" tokens should remain unaltered.🔗 External links
Jira tickets
👀 Component checklist
A changelog entry was added via Changesets if needed (see templates here)💬 Please consider using conventional comments when reviewing this PR.
📋 PCI review checklist
Examples of changes to controls include access controls, encryption, logging, etc.
Examples include changes to operating systems, ports, protocols, services, cryptography-related components, PII processing code, etc.