@canonical/design-tokens 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -0
- package/assets.ruleset.json +19 -0
- package/package.json +19 -0
- package/terrazzo.config.ts +13 -0
- package/tokens/canonical/canonical.resolver.json +162 -0
- package/tokens/canonical/global/primitive/color.tokens.json +1097 -0
- package/tokens/canonical/global/primitive/dimension.tokens.json +571 -0
- package/tokens/canonical/global/primitive/number.tokens.json +600 -0
- package/tokens/canonical/global/primitive/typography.tokens.json +181 -0
- package/tokens/canonical/global/semantic/color/dark.tokens.json +4925 -0
- package/tokens/canonical/global/semantic/color/light.tokens.json +4925 -0
- package/tokens/canonical/global/semantic/dimension/large.tokens.json +3 -0
- package/tokens/canonical/global/semantic/dimension/medium.tokens.json +3 -0
- package/tokens/canonical/global/semantic/dimension/small.tokens.json +18 -0
- package/tokens/canonical/global/semantic/dimension/xLarge.tokens.json +12 -0
- package/tokens/canonical/global/semantic/modifier/anticipation/caution.tokens.json +61 -0
- package/tokens/canonical/global/semantic/modifier/anticipation/constructive.tokens.json +74 -0
- package/tokens/canonical/global/semantic/modifier/anticipation/destructive.tokens.json +74 -0
- package/tokens/canonical/global/semantic/modifier/criticality/error.tokens.json +87 -0
- package/tokens/canonical/global/semantic/modifier/criticality/information.tokens.json +61 -0
- package/tokens/canonical/global/semantic/modifier/criticality/success.tokens.json +87 -0
- package/tokens/canonical/global/semantic/modifier/criticality/warning.tokens.json +87 -0
- package/tokens/canonical/global/semantic/modifier/emphasis/branded.tokens.json +87 -0
- package/tokens/canonical/global/semantic/modifier/emphasis/highlighted.tokens.json +4 -0
- package/tokens/canonical/global/semantic/modifier/emphasis/muted.tokens.json +46 -0
- package/tokens/canonical/global/semantic/modifier/importance/primary.tokens.json +4 -0
- package/tokens/canonical/global/semantic/modifier/importance/secondary.tokens.json +4 -0
- package/tokens/canonical/global/semantic/modifier/importance/tertiary.tokens.json +4 -0
- package/tokens/canonical/global/semantic/modifier/surface/layer1.tokens.json +212 -0
- package/tokens/canonical/global/semantic/modifier/surface/layer2.tokens.json +212 -0
- package/tokens/canonical/global/semantic/modifier/surface/layer3.tokens.json +212 -0
- package/tokens/canonical/global/semantic/modifier/typography/apps.tokens.json +778 -0
- package/tokens/canonical/global/semantic/modifier/typography/docs.tokens.json +778 -0
- package/tokens/canonical/global/semantic/modifier/typography/global.tokens.json +866 -0
- package/tokens/canonical/global/semantic/modifier/typography/sites.tokens.json +62 -0
- package/tsconfig.json +4 -0
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# @canonical/design-tokens
|
|
2
|
+
|
|
3
|
+
Design tokens for the Canonical design system. Token definitions follow the [DTCG Community Group](https://www.designtokens.org/tr/2025.10/format/) specification.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @canonical/design-tokens
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Import the CSS output in your application entry point:
|
|
14
|
+
|
|
15
|
+
```css
|
|
16
|
+
@import "@canonical/design-tokens/dist/tokens.css";
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Tokens are available as CSS custom properties:
|
|
20
|
+
|
|
21
|
+
```css
|
|
22
|
+
.card {
|
|
23
|
+
background: var(--color-background-default);
|
|
24
|
+
padding: var(--spacing-medium);
|
|
25
|
+
border-radius: var(--radius-default);
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Token Tiers
|
|
30
|
+
|
|
31
|
+
| Tier | Path | Description |
|
|
32
|
+
|------|------|-------------|
|
|
33
|
+
| Primitive | `tokens/canonical/global/primitive/` | Raw values for colour, dimension, number, and typography. Not intended for direct use in application code. |
|
|
34
|
+
| Semantic | `tokens/canonical/global/semantic/` | Aliased tokens referencing primitives. These encode design intent and are the tokens consumed by components. |
|
|
35
|
+
|
|
36
|
+
## Building
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
bun run build
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This runs the Terrazzo pipeline with `@canonical/terrazzo-plugin-css` and produces CSS files and a `tokens.json` artifact in `dist/`.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/canonical/pragma/refs/heads/main/packages/webarchitect/src/schema.json",
|
|
3
|
+
"name": "assets",
|
|
4
|
+
"extends": ["base"],
|
|
5
|
+
"package-license": {
|
|
6
|
+
"file": {
|
|
7
|
+
"name": "package.json",
|
|
8
|
+
"contains": {
|
|
9
|
+
"type": "object",
|
|
10
|
+
"properties": {
|
|
11
|
+
"license": {
|
|
12
|
+
"const": "LGPL-3.0"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"required": ["license"]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@canonical/design-tokens",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Canonical design tokens (DTCG format) with CSS custom property output.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "LGPL-3.0",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tz build",
|
|
9
|
+
"build:all": "bun run build",
|
|
10
|
+
"check": "bun run check:webarchitect",
|
|
11
|
+
"check:webarchitect": "webarchitect assets"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@canonical/webarchitect": "^0.17.1",
|
|
15
|
+
"@canonical/terrazzo-plugin-css": "workspace:*",
|
|
16
|
+
"@terrazzo/cli": "2.0.0-beta.6",
|
|
17
|
+
"@terrazzo/parser": "2.0.0-beta.6"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineConfig } from "@terrazzo/cli";
|
|
2
|
+
import { canonicalPlugin } from "@canonical/terrazzo-plugin-css";
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
tokens: ["./tokens/canonical/canonical.resolver.json"],
|
|
6
|
+
outDir: "./dist/",
|
|
7
|
+
lint: {
|
|
8
|
+
rules: {
|
|
9
|
+
"core/consistent-naming": ["warn", { format: "camelCase" }],
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
plugins: [canonicalPlugin()],
|
|
13
|
+
});
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://designtokens.org/schemas/2025.10/resolver.json",
|
|
3
|
+
"version": "2025.10",
|
|
4
|
+
"sets": {
|
|
5
|
+
"primitive": {
|
|
6
|
+
"description": "Base primitive tokens: color palette, dimensions, numbers, typography primitives.",
|
|
7
|
+
"sources": [
|
|
8
|
+
{ "$ref": "global/primitive/color.tokens.json" },
|
|
9
|
+
{ "$ref": "global/primitive/dimension.tokens.json" },
|
|
10
|
+
{ "$ref": "global/primitive/number.tokens.json" },
|
|
11
|
+
{ "$ref": "global/primitive/typography.tokens.json" }
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"modifiers": {
|
|
16
|
+
"breakpoint": {
|
|
17
|
+
"description": "Breakpoint modifier for responsive dimension tokens.",
|
|
18
|
+
"default": "small",
|
|
19
|
+
"contexts": {
|
|
20
|
+
"small": [{ "$ref": "global/semantic/dimension/small.tokens.json" }],
|
|
21
|
+
"medium": [{ "$ref": "global/semantic/dimension/medium.tokens.json" }],
|
|
22
|
+
"large": [{ "$ref": "global/semantic/dimension/large.tokens.json" }],
|
|
23
|
+
"xLarge": [{ "$ref": "global/semantic/dimension/xLarge.tokens.json" }]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"theme": {
|
|
27
|
+
"description": "Theme modifier for light/dark color tokens. Output uses light-dark() per DE015B section 2.E.a.",
|
|
28
|
+
"default": "light",
|
|
29
|
+
"contexts": {
|
|
30
|
+
"light": [{ "$ref": "global/semantic/color/light.tokens.json" }],
|
|
31
|
+
"dark": [{ "$ref": "global/semantic/color/dark.tokens.json" }]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"typography": {
|
|
35
|
+
"description": "Typography modifier with per-product contexts. Replaces three separate resolvers.",
|
|
36
|
+
"default": "global",
|
|
37
|
+
"contexts": {
|
|
38
|
+
"global": [
|
|
39
|
+
{ "$ref": "global/semantic/modifier/typography/global.tokens.json" }
|
|
40
|
+
],
|
|
41
|
+
"apps": [
|
|
42
|
+
{ "$ref": "global/semantic/modifier/typography/global.tokens.json" },
|
|
43
|
+
{ "$ref": "global/semantic/modifier/typography/apps.tokens.json" }
|
|
44
|
+
],
|
|
45
|
+
"docs": [
|
|
46
|
+
{ "$ref": "global/semantic/modifier/typography/global.tokens.json" },
|
|
47
|
+
{ "$ref": "global/semantic/modifier/typography/docs.tokens.json" }
|
|
48
|
+
],
|
|
49
|
+
"sites": [
|
|
50
|
+
{ "$ref": "global/semantic/modifier/typography/global.tokens.json" },
|
|
51
|
+
{ "$ref": "global/semantic/modifier/typography/sites.tokens.json" }
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"anticipation": {
|
|
56
|
+
"description": "Anticipation modifier family (WD433). Contexts: constructive, destructive, caution.",
|
|
57
|
+
"default": "none",
|
|
58
|
+
"contexts": {
|
|
59
|
+
"none": [],
|
|
60
|
+
"constructive": [
|
|
61
|
+
{
|
|
62
|
+
"$ref": "global/semantic/modifier/anticipation/constructive.tokens.json"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"destructive": [
|
|
66
|
+
{
|
|
67
|
+
"$ref": "global/semantic/modifier/anticipation/destructive.tokens.json"
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"caution": [
|
|
71
|
+
{
|
|
72
|
+
"$ref": "global/semantic/modifier/anticipation/caution.tokens.json"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"criticality": {
|
|
78
|
+
"description": "Criticality modifier family (WD433). Contexts: success, error, warning, information.",
|
|
79
|
+
"default": "none",
|
|
80
|
+
"contexts": {
|
|
81
|
+
"none": [],
|
|
82
|
+
"success": [
|
|
83
|
+
{ "$ref": "global/semantic/modifier/criticality/success.tokens.json" }
|
|
84
|
+
],
|
|
85
|
+
"error": [
|
|
86
|
+
{ "$ref": "global/semantic/modifier/criticality/error.tokens.json" }
|
|
87
|
+
],
|
|
88
|
+
"warning": [
|
|
89
|
+
{ "$ref": "global/semantic/modifier/criticality/warning.tokens.json" }
|
|
90
|
+
],
|
|
91
|
+
"information": [
|
|
92
|
+
{
|
|
93
|
+
"$ref": "global/semantic/modifier/criticality/information.tokens.json"
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"emphasis": {
|
|
99
|
+
"description": "Emphasis modifier family (WD433). Contexts: muted, highlighted, branded.",
|
|
100
|
+
"default": "none",
|
|
101
|
+
"contexts": {
|
|
102
|
+
"none": [],
|
|
103
|
+
"muted": [
|
|
104
|
+
{ "$ref": "global/semantic/modifier/emphasis/muted.tokens.json" }
|
|
105
|
+
],
|
|
106
|
+
"highlighted": [
|
|
107
|
+
{
|
|
108
|
+
"$ref": "global/semantic/modifier/emphasis/highlighted.tokens.json"
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
"branded": [
|
|
112
|
+
{ "$ref": "global/semantic/modifier/emphasis/branded.tokens.json" }
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"importance": {
|
|
117
|
+
"description": "Importance modifier family (WD433). Contexts: primary, secondary, tertiary. Placeholder bindings.",
|
|
118
|
+
"default": "none",
|
|
119
|
+
"contexts": {
|
|
120
|
+
"none": [],
|
|
121
|
+
"primary": [
|
|
122
|
+
{ "$ref": "global/semantic/modifier/importance/primary.tokens.json" }
|
|
123
|
+
],
|
|
124
|
+
"secondary": [
|
|
125
|
+
{
|
|
126
|
+
"$ref": "global/semantic/modifier/importance/secondary.tokens.json"
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
"tertiary": [
|
|
130
|
+
{ "$ref": "global/semantic/modifier/importance/tertiary.tokens.json" }
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
"surface": {
|
|
135
|
+
"description": "Surface modifier for layer-aware token rebinding. Contexts: layer1, layer2, layer3. CSS output uses compound .surface selectors (depth-based compounding).",
|
|
136
|
+
"default": "none",
|
|
137
|
+
"contexts": {
|
|
138
|
+
"none": [],
|
|
139
|
+
"layer1": [
|
|
140
|
+
{ "$ref": "global/semantic/modifier/surface/layer1.tokens.json" }
|
|
141
|
+
],
|
|
142
|
+
"layer2": [
|
|
143
|
+
{ "$ref": "global/semantic/modifier/surface/layer2.tokens.json" }
|
|
144
|
+
],
|
|
145
|
+
"layer3": [
|
|
146
|
+
{ "$ref": "global/semantic/modifier/surface/layer3.tokens.json" }
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
"resolutionOrder": [
|
|
152
|
+
{ "$ref": "#/sets/primitive" },
|
|
153
|
+
{ "$ref": "#/modifiers/breakpoint" },
|
|
154
|
+
{ "$ref": "#/modifiers/theme" },
|
|
155
|
+
{ "$ref": "#/modifiers/typography" },
|
|
156
|
+
{ "$ref": "#/modifiers/anticipation" },
|
|
157
|
+
{ "$ref": "#/modifiers/criticality" },
|
|
158
|
+
{ "$ref": "#/modifiers/emphasis" },
|
|
159
|
+
{ "$ref": "#/modifiers/importance" },
|
|
160
|
+
{ "$ref": "#/modifiers/surface" }
|
|
161
|
+
]
|
|
162
|
+
}
|