-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: Extract design tokens to JSON #4809
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
package.json
Outdated
| "storybook": "start-storybook -p 6006 --quiet", | ||
| "storybook:build": "yarn run copy-polaris-tokens && build-storybook -o build-internal/storybook/static" | ||
| "storybook:build": "yarn run copy-polaris-tokens && build-storybook -o build-internal/storybook/static", | ||
| "validate-tokens": "ajv validate -s tokens/schema.token-group.json -d 'tokens/_!(color)*.json' && ajv validate -s tokens/schema.color.json -d 'tokens/_color.json'" |
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.
Could this be simpler by breaking the color files into individual JSON files? color.light.json
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.
Great idea 👍
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.
This will allow us to remove the color specific json schema 🙌
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.
Okay this commit:
- Removed the
_prefix from all token files - Extracted color scheme tokens into individual files (e.g.
color.light.json&color.dark.json) - Simplified the
validate-tokensscript
size-limit report
|
alex-page
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.
Love this. One thought, we separated the .ts files by adding the _. Now it's not as needed as the tokens are in .json files. We could just remove the _ now.
tokens/schemas/token-group.json
Outdated
| { | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
| "title": "Token group schema", | ||
| "type": "object", | ||
| "additionalProperties": { | ||
| "type": "string" | ||
| } | ||
| } |
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'd love to see a demo of how these files can get included by the source code |
kyledurand
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.
This looks good but we're back to px values for spacing and shape. Can we follow up to be sure we're converting these to rems?
If possible I would prefer the values to be pixel based in JSON file and converted to rems in ts. Unsure how complex that would be though. Happy to ship rem values in JSON to speed this up for now. |
Pretty much how our convo went in slack. Namely because rems are pretty hard to read, hard to convert from figma and that could lead to a misunderstanding of the values and increased friction in use / contribution. I can't see it being too difficult to build but getting it to be performant could get tricky |
|
@kyledurand @alex-page Here is my first pass: 9856314. Thoughts? |
1236e66 to
66e6bab
Compare
|
In an unfortunate git accident this PR was wiped and automatically closed by GitHub. Luckily all the commits we're preserved in the Update CustomProperty component PR# 4811 . There doesn't appear to be a way to restore this PR and thus the contents have been moved to the following PR: #4818 |

WHAT is this pull request doing?
This PR extracts the Polaris design tokens, previously implemented in TypeScript, to JSON files.
ajv-clito validate JSON token filesvalidate-tokensscript and integrated in our CIFollow up tasks
CustomPropertiescomponent to use these JSON tokenscustom-properties-allowed-listStylelint plugin to use these JSON tokensHow to 🎩
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
Copy-paste this code in
playground/Playground.tsx:🎩 checklist
README.mdwith documentation changes