Skip to content

Commit 833b18e

Browse files
authored
Add more best practices (#41)
1 parent f920280 commit 833b18e

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

docs/src/pages/docs/guides/best-practices.md

+36
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ layout: ../../../layouts/docs.astro
77

88
Best practices are only community conventions meant to fill in opinions when you have none. Disregard any information in here if it doesn’t work with your organization, or if there is a conflict between this information and your configuration.
99

10+
## Aliasing
11+
12+
Use [aliases](/docs/tokens#aliasing)! They’re free and can help make your design system easier-to-use. Here are just a few ways you can use aliases:
13+
14+
- Common spelling differences, e.g. `color.gray``color.grey` (fun fact: CSS supports both spellings!)
15+
- Useful shortcuts, e.g. `color.white``color.gray.100`
16+
- Semantic colors e.g. `color.ui.action``color.blue`, `color.ui.error``color.red`, etc.
17+
1018
## Casing
1119

1220
Prefer **camelCased** properties when possible:
@@ -29,3 +37,31 @@ This will result in more predictable naming, and in many languages is simpler to
2937
- tokens.typography['base-heading'].$value;
3038
+ tokens.typography.baseHeading.$value;
3139
```
40+
41+
## Logical color numbering
42+
43+
Many design systems use [color ramps](https://ferdychristant.com/color-for-the-color-challenged-884c7aa04a56) which typically use numbers for greater flexiblity than relative terms like _dark_, _darker_, etc. But if possible, make your numbering follow some **logical** reasoning.
44+
45+
For example, since Cobalt supports [OKLCH](https://evilmartians.com/chronicles/oklch-in-css-why-quit-rgb-hsl), you could use **perceived lightness** as the number where `color.blue.60` is 60% light, `color.blue.70` is 70% light, and so on:
46+
47+
```json
48+
{
49+
"color": {
50+
"blue": {
51+
"10": {"$value": "oklch(10% 0.069574 264)"},
52+
"15": {"$value": "oklch(15% 0.102086 265)"},
53+
"20": {"$value": "oklch(20% 0.000304 265)"},
54+
"25": {"$value": "oklch(25% 0.172216 265)"},
55+
"30": {"$value": "oklch(30% 0.203543 266)"},
56+
"40": {"$value": "oklch(40% 0.216254 267)"},
57+
"50": {"$value": "oklch(50% 0.216583 268)"},
58+
"60": {"$value": "oklch(60% 0.216564 269)"},
59+
"70": {"$value": "oklch(70% 0.156718 268)"},
60+
"80": {"$value": "oklch(80% 0.100540 267)"},
61+
"85": {"$value": "oklch(85% 0.073053 266)"},
62+
"90": {"$value": "oklch(90% 0.048514 265)"},
63+
"95": {"$value": "oklch(95% 0.023788 264)"}
64+
}
65+
}
66+
}
67+
```

docs/src/pages/docs/tokens/index.astro

+2-2
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ const tokenDef = {
698698
}`}
699699
/>
700700

701-
<h2>Custom types</h2>
701+
<h2 id="custom-types">Custom types</h2>
702702

703703
<p>
704704
Any other <code>$type</code> will be treated as a custom type. <code>$value</code> may have any shape desired. But note that custom types will likely break existing plugins unless you configure them (the CSS and Sass plugins have a <b
@@ -708,7 +708,7 @@ const tokenDef = {
708708

709709
<p><i>Should a type be added?<a href="https://github.com/design-tokens/community-group">Suggest it be added!</a></i></p>
710710

711-
<h2>Aliasing</h2>
711+
<h2 id="aliasing">Aliasing</h2>
712712

713713
<p>
714714
Types can be aliased <a href="https://design-tokens.github.io/community-group/format/#aliases-references" target="_blank">as defined in the Design Tokens spec</a> by using dot-delimited path syntax, wrapped in curly braces (e.g., <code

docs/tokens.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"$value": "#00193f"
77
},
88
"blue": {
9-
"10": { "$value": "oklch(10% 0.069574 264 264)" },
9+
"10": { "$value": "oklch(10% 0.069574 264)" },
1010
"15": { "$value": "oklch(15% 0.102086 265)" },
1111
"20": { "$value": "oklch(20% 0.000304 265)" },
1212
"25": { "$value": "oklch(25% 0.172216 265)" },

0 commit comments

Comments
 (0)