-
Notifications
You must be signed in to change notification settings - Fork 1
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
Docs: Introduce Tokens Structure Decision #1763
Open
crishpeen
wants to merge
1
commit into
main
Choose a base branch
from
docs/tokens-decision
base: main
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.
+49
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,49 @@ | ||||||
# Tokens Structure | ||||||
|
||||||
Date: 2024-11-19 | ||||||
|
||||||
Status: accepted | ||||||
|
||||||
## Context | ||||||
|
||||||
Our Design System uses design tokens. | ||||||
|
||||||
## Decision | ||||||
|
||||||
This is what we decided on: | ||||||
|
||||||
1. We divide tokens into `Global Tokens` and `Theme Tokens`. The `Global Tokens` are non-themed tokens – their | ||||||
values are the same in all themes, for example breakpoints. The `Theme Tokens` have the same structure, but in each theme, | ||||||
their value can differ, for example colors. | ||||||
2. Global tokens are divided into `Borders`, `Gradients`, `Other`, `Radii`, `Shadows`, `Spacing` and `Typography`. Each category | ||||||
has its own file and contains tokens that are related to the category. The `Other` category contains tokens that do not fit | ||||||
into any other category. | ||||||
3. The `Gradients` and `Shadows` tokens use CSS variables to define the colors. This allows us to theme them. | ||||||
4. We use scales for tokens that have multiple values. For example, the `Spacing` category contains `space-0`, `space-100`, `space-200`, etc. | ||||||
We use hundreds for the scale, so our users have plenty of space to add their own values between the predefined ones. | ||||||
5. The `Theme Tokens` contains folders for each theme. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick (if-minor):
Suggested change
|
||||||
6. In `Theme Tokens` we provide a list of SCSS variables and also a mixin with CSS variables. The mixin is used to generate CSS variables | ||||||
for the theme. The SCSS variables are used to define the values of the tokens. | ||||||
|
||||||
### Color token structure | ||||||
|
||||||
These are decisions related to the color tokens: | ||||||
|
||||||
1. We decided to create a `component` group which contains tokens for unique components. This way, we can easily find the colors | ||||||
that are used in a specific component and we know that these colors are not used anywhere else. | ||||||
2. We decided to add infix `-state-` to the state tokens before the state. This way, we know which tokens are used for states | ||||||
and are related to each other. | ||||||
3. We decided to have a `disabled` group which covers the disabled state and is used for all components. | ||||||
4. We decided to have suffixes `-basic` and `-subtle` for tokens for components which need two different contrast levels. | ||||||
5. We decided to have `form-field` group which contains tokens for form fields. This group has a subgroup `filled` for | ||||||
tokens which are used for filled part of the form field. In the future, we can add more subgroups for different form field types. | ||||||
6. We decided to have a `neutral` group which contains tokens for neutral colors. | ||||||
7. We decided to create color tokens for gradients and shadows. These tokens are used in the `Gradients` and `Shadows` categories. | ||||||
To support multiple shadow or gradients colors in one `Gradients` or `Shadows` token, we use `-color-01`, `-color-02`, etc. suffixes. | ||||||
|
||||||
## Consequences | ||||||
|
||||||
By following this structure, we can easily find tokens and we know where to add new tokens. We can also easily add new themes | ||||||
and we know where to add new tokens for the themes. This structure is easy to understand and maintain. | ||||||
|
||||||
Our tokens follow the structure described in this decision. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (if-minor): I think this sentence is unnecessary. |
Oops, something went wrong.
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.
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.
suggestion (if-minor): Can you please provide some experience? Like that, we have started to use Figma variables and thus the tokens are exported based on this. Or if there were some pain points with the tokens, so we have created a new structure that solves these issues and so on...
I would like to have here more about why we are doing this, please :-)