-
Notifications
You must be signed in to change notification settings - Fork 51
[WIP-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
Open
didoo
wants to merge
26
commits into
project-solar/phase-1/HDS-5216_modes/modes-feature-branch
Choose a base branch
from
project-solar/phase-1/HDS-5216_modes/modes-pipeline-implementation
base: project-solar/phase-1/HDS-5216_modes/modes-feature-branch
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
$modes support to tokens pipeline$modes support to tokens pipeline
7 tasks
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
This was referenced Oct 9, 2025
f4d5ff3 to
ce5300d
Compare
ce5300d to
ba2e78d
Compare
3a4d9f2 to
d7609e3
Compare
723b081 to
c6dae3e
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
📌 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.🗒️ TODOs
Things that still need to be done before merging
:where()to reduce the specificity, something I've seen being done somewhere else with theming files)(not (prefers-color-scheme: dark))instead of(prefers-color-scheme: 'light')per @KristinLBradley suggestionThings that still need to be done (in fast-follow-up PRs)
outputReferenceslogic and thethemeabletransformoutputReferencesfunction (in which case, understand which references should be outputted and which shouldn't) or we keep it tofalseattributes/themeabletransformation non working when the alias is composed🔗 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.