This repository has been archived by the owner on May 17, 2023. It is now read-only.
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.
This PR is an attempt at defining our tokens strategy.
I'll use the example of colors because that's the one I understand the most.
Tokens solve 2 purposes for us:
Purpose 1: Serves as an inventory of our brand guidelines.
Check out tokens/values/colors.js
This file stores all the values we have in the application.
Purpose 2: Hold all the design conventions/guidelines that our applications should follow.
Check out tokens/conventions/colors.js
These are essentially rules that every application should comply with to feel like they are from the same company.
The point to note here is the conventions are based on meaning or usage.
Check out the implementation of button.js to see changes.
That means, an anchor tag, a button of type link and a tab link should all have the same color (even though they have different UX patterns)
What tokens are not: A way to theme our application
Tokens are a way to make repeatable variables that can be used across the application, making it more consistent and
easypredictable for change.When you change a token, you should be able to say which component it effects and which one it doesn't with confidence.
They are not a way to theme our application with variables. We don't have rules specific to components in tokens. It's tempting to do so, but that's doesn't contribute towards our goal and will make the system complex without any rewards.
We don't have component overrides in the tokens. Example:
Sidebar
links do not conform to conventions of link, they use the values differently to create their own UX pattern. Components are allowed to do that.The code for that sits inside the
Sidebar
component.This brings us to the next section:
What is the criteria for a variable to become a token?
It's useful to repeat:
When you see a pattern emerging, tokenise it. Pure tokenisation is only possible if you start with an inventory of consistent components. Because, our goal is the opposite (starting with inconsistent components and taking them to consistent), we will end up pure tokens eventually rather than starting with them.
Variables that are only used in one use case/component are not worth tokenising (example: Sidebar links)
Beware of early tokenisation
Hot take: Moving variables into tokens early on can make changing design slower and less predictable. Breaking a convention is much harder than creating a new one.
Example: While building forms, it might be tempting to tokenise the height of form elements. After all, buttons and inputs should be perfectly aligned. But, the moment we introduce
EmptyState
component, buttons have a different behaviour there. (sorry @landitus)2nd example: If you notice, you'll find that
conventions/colors
does not talk about border indestructive
andlink
. This is intentional. Most (maybe all) of components with backgrounds (like buttons, switch), have the samebackground
andborder-color
.This is our convention. Maybe one day in the future, we will break this convention. At that point, we will have to introduce a new variable in conventions and change a bunch of components. This is not a bad thing.
predictability > ease
Sounds horrible? Let's talk about it. This implementation is based on what I have learned till now and is still naive.
Sounds good? Here's how we get there:
values
andconventions
, they serve the 2 purposes defined above.conventions
instead ofold tokens
values
until we find a right home for it 馃彔