-
Notifications
You must be signed in to change notification settings - Fork 49
🧪 [SPIKE] [Project Solar / Phase 1 / Engineering Follow-ups] Fix issues with outputReferences and isThemeable
#3435
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
30
commits into
project-solar/phase-1-main-feature-branch
Choose a base branch
from
project-solar/phase-1/HDS-5669-5667/experiments
base: project-solar/phase-1-main-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.
|
7405723 to
796f186
Compare
796f186 to
cee36c9
Compare
35d4292 to
a3d6178
Compare
ed7b2be to
c3491eb
Compare
outputReferences and isThemeableoutputReferences and isThemeable
outputReferences and isThemeableoutputReferences and isThemeable
02753e5 to
dc80dea
Compare
(when `pnpm build` is run, “common” is different, so something still to fix)
2f7115b to
4398a7e
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.
🚨 DO NOT MERGE 🚨
Note
If this PR is informally approved, I'll open a proper one with a cleaner commit history to make proper formal review easier.
📌 Summary
This (spike) PR has been quite a rabbit hole to go down into, exploring the StyleDictionary APIs and codebase to understand exactly how to change our logic to achieve a reliable way to do two fundamental things in the processing of themed tokens:
var()values)default+cds-g0/10/90/100)These two things are strictly intertwined. And together with 1) the existence of private tokens that should referenced by their value, not aliased, and 2) the fact that there are some custom transforms applied to the values themselves, some of which are "transitive", made the whole logic really hard to grasp and make sure worked as expected (and could not rely on the existing APIs for references because they're only approximate and in many cases didn't work for us, so we had to pivot to using custom helpers, which was... an interesting journey to do.
Anyway, apparently everything works as I think should, so I am going to open the draft PR for initial review; once we're happy with its overarching architecture/logic, I'll open a proper PR with a clear history to make the final/proper review eaiser.
🔎 How to review
Tip
Don't look at the commit history (unless you want to go down the same rabbit hole I went into).
It's not probably worth it to look a the diffs for the files under the
packages/tokens/dist/products/andshowcase/public/assets/styles/@hashicorp/folders, since the tokens in output have now been sorted alphabethically, plus due to the change in the processing logic some of them have been moved from the "themed" to the "common" and vice-versa.Focus instead on the changes to the files under the
buildfolder, which contain all the meaningful changes to the logic of how we generate "themed" tokens. And remember, there will be a proper PR opened instead of this one.🛠️ How to test
There are different ways in which it would be great to stress test this approach. For all of them I suggest you checkout the PR's branch and play with the code in your local environment.
Test tokens
This is the simplest one, that I suggest to start with, to familiarize yourself with the changes introduces and the logic behind it. In the file
packages/tokens/scripts/build-parts/getStyleDictionaryConfig.tsuncomment the twosrc/test/**/*.jsonentries (and comment the three below it), then runpnpm build. This will use the tokens found in thepackages/tokens/src/test/test.jsonfile and generate the CSS files in output. The first block of tokens follow the schema included below, and the second block have been added later to test more use cases I was finding. Can you think of any other combination of tokens that is not covered? If so, add them to the test files and regenerate the CSS files in output and see if the location ("common" vs "themed") and values (static vsvar()alias) of the newly added tokens are correct and where/how you would expect them.Production tokens
This actually is more complex to play with, because there are a lot of tokens with different formats/values, and they have been moved around when comparing the generated files with the ones in the main feature branch #3237. If you want, you can try (or can try to think of ways of how we could reliably test this more complex set of tokens).
[Note: among the many test I did, I compared the merged "common" + "themed" files between the old and the new output, and all the tokens are the same, except for their values (some have been replaced with aliases
var()instead of static values, which means we've not lost any token in the new filtering logic; here are the files if you want to see the outcome: Archive.zip]📸 Screenshots
This is the initial schema that I used to prepare a set of test tokens to validate different combinations of token formats (private, with aliases/references, with theming, etc)
Later I added more test tokens, including some from the HDS set that were not working with the changes I was making. The final set used for testing can be found in
packages/tokens/src/test/test.json🔗 External links
Jira tickets:
Figma file used to brainstorm possible tokens combinations (in case we need it in the future): https://www.figma.com/design/BDq7Atokyf5Aq9pA5rIaYd/Untitled?m=auto&t=z4fx1cp1BcpzE6Ti-6
StyleDictionary API documentation:
👀 Component checklist
💬 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.