chore: adopt design tokens #41
Draft
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.
I've been learning about design tokens, and wanted to adopt them in SVGO.dev. This seems like a good workflow, so we'll be retaining the changes.
There will be a delay in getting this merged while the design tokens are actually defined, so this will be a draft for a while.
Publishing Design Documents
We're in the process of migrating from Figma to Penpot. When this transition is done, the Penpot document will be public, and linked somewhere. (Perhaps the README or a contribution guide.)
Design Tokens Format
We'll only use tooling that supports the latest Design Tokens Community Group (DTCG) draft — not any other standard for design tokens. Penpot supports this standard natively, and the style-dictionary package can convert this format to CSS variables.
I did explore @csstools/postcss-design-tokens too, but this only supports the style-dictionary3 format, which wasn't compatible with the the output from Penpot. Using style-dictionary directly appeared to offer a much better experience anyway in my opinion.
Proposed Workflow
Before, from my perspective there was no step 1. Meanwhile, step 2 was to open the design and copy and paste discernable variables one-by-one into CSS variables or to hardcode them. It wasn't an awful workflow, but the new workflow seems more streamlined.
tokens.json
(left)_variables.css
(middle)custom.css
(right)Important
This is a proof of concept — which variables should be tokens and naming conventions for the design tokens have not been defined yet, and we may still reconsider the workflow.
How to Contribute?
This gets a little pedantic, but we should consider how this may affect contributing to the repository. This isn't a blocker, but I think it's worth posing the question. Especially if it's worth being explicit that we welcome changes, etc.
The old approach was very contributor friendly, since the repository was a pseudo-source of truth for these CSS variables. Now, the source of truth for these variables reside in a design document, maintained outside the repository — it introduces complexity for contributors who may want to propose design changes.
~/tokens/tokens.json
? Fortunately, the format is very simple.No matter what they do in their contribution, it's not a big deal as if approved they can be synced up with the design, or amended before merging (preserving authorship).
I just want to make sure contributors know they're welcome to propose changes, even to
tokens.json
, even though the conventional workflow is that Penpot/Figma is the source of truth for it.