Skip to content
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

JSON representation for theme #4041

Open
6 tasks
origami-z opened this issue Aug 28, 2024 · 11 comments
Open
6 tasks

JSON representation for theme #4041

origami-z opened this issue Aug 28, 2024 · 11 comments
Assignees
Labels
package: theme Theme package

Comments

@origami-z
Copy link
Contributor

origami-z commented Aug 28, 2024

Catch all issue

Tasks

Some considerations

  • Structural representation (token names + 3 layers) + value references
  • Theme vs Theme next (+ data dense, etc.)
  • Potential different folder / file structure ?
  • Handle deprecation, versioning
  • Token naming difference between Figma and CSS
  • Figma only variables

Tools

Prototype in #3143

References

Would have avoided

@mark-tate
Copy link
Contributor

Latte Goal: review current state, kickoff to understand requirements at EOS

@origami-z
Copy link
Contributor Author

Oct 17: start in w2, after ag grid work

@origami-z
Copy link
Contributor Author

origami-z commented Oct 21, 2024

Oct 21: scheduled a scope meeting on 28 Oct, start looking at dependencies / feasibility this week (e.g. styled dictionary v4 release DTCG)

@mark-tate
Copy link
Contributor

Lungo Goal:
document what the JSON representation will NOT do

@origami-z
Copy link
Contributor Author

Met w/ @mark-tate @joshwooding @pseys @dplsek John on Monday

Primary goal for the JSON exercise is for safety and quality control, which would lay the foundation for further expansion for other BYOT requirements

  • For Salt, we can check between synchronization Figma and Code. e.g., See “Would have avoided” in GH issue description above.
    • We don't want to change existing process (e.g., editing Figma variables via Figma UI, Figma only variables) until risk and new process of syncing between Figma/Code can be fully understood. So the first step would be creating some "lint" tool to warn the user if anything is different is detected, e.g., as a Figma plugin, custom CSS stylelint
    • We should be able to produce CSS code via JSON, instead of manually construct them like now
    • Further usage could include theme configuration or virtualization tools (e.g., prototype using spectrum tokens)
  • For consumers, they can use the file to check their Salt “theming” compliance (with our documentation)
    • One example would be providing CSS linting to consumer's code, e.g., Saslt CSS token validation, deprecation
    • In Figma, this can be used to create / check custom Figma library

This does NOT cover

  • Any customization beyond @salt-ds/theme package, e.g., component level overrides.
  • Change Salt existing workflow, e.g., how variables are added to Figma

@mark-tate
Copy link
Contributor

Macc Goal: continue effort described in last comment, to be complete by end of quarter

@origami-z
Copy link
Contributor Author

Done some experiments on 4041-json-theme using style dictionary v4, with DTCG format. A few findings

  • Extracted JSON from Figma variables using Export styles plugin
  • Trying to keep some structure, e.g. alpha tree of color, which needs custom name transformer salt-ds/name/kebab to handle
  • Tried with loading multiple source token files from different modes
    • If loading each mode separately, there is no way to output different modes in the same file like we do today
      .salt-theme.salt-theme-next[data-mode="light"][data-accent="blue"] {
      .salt-theme.salt-theme-next[data-mode="dark"][data-accent="blue"] {
    • If loading all tokens from different modes, style dictionary will complain token conflicts and only output 1 mode, even if we can write custom formatter to append to the same file, like how rule in "css-advanced" custom format
    • The next approach would be using proposed $mode block, then write custom formatter to read value from $value (or swapped with different $mode value), then output to the same file. This requires a rewrite from style dictionary's formattedVariables function, which handles naming / output reference, as well as additional options to be passed down to the function (or formatter)

@origami-z
Copy link
Contributor Author

Spent some time debug internal StyleDictionary code, a few possibilities

  1. to use a custom version of formattedVariables (from "style-dictionary/utils"), so some $mode can be used instead of $value when resolving reference
    https://github.com/amzn/style-dictionary/blob/ef7b2f6cea9e820fd50c9c34ba7e2f3898b102af/lib/common/formatHelpers/createPropertyFormatter.js#L167
  2. continue using formattedVariables but alter dictionary.tokens so that $value block is replaced with $mode. This is preferred over above, given we can continue using majority of SD code. There is still some risk around this, given we're relying on knowing how SD internal functionary work
  3. Looks like the new preprocessors could also work for similar purpose

Continue investigating...

@mark-tate
Copy link
Contributor

Mocha Goal: initial MVP by EOS

@origami-z origami-z mentioned this issue Nov 25, 2024
3 tasks
@origami-z
Copy link
Contributor Author

Nov 29 - Make more progress in #4443, with the plan to replace next theme CSS to build from token files.

Found a couple of discrepancies between existing CSS and Figma variables, which needs to be fixed along the way.

@bhoppers2008
Copy link

bhoppers2008 commented Dec 2, 2024

Goal to publish one of the css theme files with the json theme.
Some discrepencies between figma and code with this exercise... ZC to summarise diff this sprint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: theme Theme package
Projects
Development

No branches or pull requests

3 participants