@canonical/react-tokens 0.17.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.
Files changed (72) hide show
  1. package/README.md +271 -0
  2. package/dist/esm/index.js +2 -0
  3. package/dist/esm/index.js.map +1 -0
  4. package/dist/esm/lib/TokenTable/TokenSwatch.css +173 -0
  5. package/dist/esm/lib/TokenTable/TokenSwatch.js +2 -0
  6. package/dist/esm/lib/TokenTable/TokenSwatch.js.map +1 -0
  7. package/dist/esm/lib/TokenTable/TokenTable.css +236 -0
  8. package/dist/esm/lib/TokenTable/TokenTable.js +152 -0
  9. package/dist/esm/lib/TokenTable/TokenTable.js.map +1 -0
  10. package/dist/esm/lib/TokenTable/TokenTable.ssr.test.js +13 -0
  11. package/dist/esm/lib/TokenTable/TokenTable.ssr.test.js.map +1 -0
  12. package/dist/esm/lib/TokenTable/TokenTable.test.js +24 -0
  13. package/dist/esm/lib/TokenTable/TokenTable.test.js.map +1 -0
  14. package/dist/esm/lib/TokenTable/common/TokenSwatch/TokenSwatch.js +134 -0
  15. package/dist/esm/lib/TokenTable/common/TokenSwatch/TokenSwatch.js.map +1 -0
  16. package/dist/esm/lib/TokenTable/common/TokenSwatch/TokenSwatch.ssr.test.js +13 -0
  17. package/dist/esm/lib/TokenTable/common/TokenSwatch/TokenSwatch.ssr.test.js.map +1 -0
  18. package/dist/esm/lib/TokenTable/common/TokenSwatch/TokenSwatch.test.js +26 -0
  19. package/dist/esm/lib/TokenTable/common/TokenSwatch/TokenSwatch.test.js.map +1 -0
  20. package/dist/esm/lib/TokenTable/common/TokenSwatch/index.js +2 -0
  21. package/dist/esm/lib/TokenTable/common/TokenSwatch/index.js.map +1 -0
  22. package/dist/esm/lib/TokenTable/common/TokenSwatch/styles.css +191 -0
  23. package/dist/esm/lib/TokenTable/common/TokenSwatch/types.js +2 -0
  24. package/dist/esm/lib/TokenTable/common/TokenSwatch/types.js.map +1 -0
  25. package/dist/esm/lib/TokenTable/common/index.js +2 -0
  26. package/dist/esm/lib/TokenTable/common/index.js.map +1 -0
  27. package/dist/esm/lib/TokenTable/dtcg.js +71 -0
  28. package/dist/esm/lib/TokenTable/dtcg.js.map +1 -0
  29. package/dist/esm/lib/TokenTable/index.js +4 -0
  30. package/dist/esm/lib/TokenTable/index.js.map +1 -0
  31. package/dist/esm/lib/TokenTable/styles.css +260 -0
  32. package/dist/esm/lib/TokenTable/types.js +2 -0
  33. package/dist/esm/lib/TokenTable/types.js.map +1 -0
  34. package/dist/esm/lib/Tokens.css +474 -0
  35. package/dist/esm/lib/Typography.css +151 -0
  36. package/dist/esm/lib/index.js +3 -0
  37. package/dist/esm/lib/index.js.map +1 -0
  38. package/dist/esm/lib/mockTokens.js +458 -0
  39. package/dist/esm/lib/mockTokens.js.map +1 -0
  40. package/dist/types/index.d.ts +2 -0
  41. package/dist/types/index.d.ts.map +1 -0
  42. package/dist/types/lib/TokenTable/TokenSwatch.d.ts +3 -0
  43. package/dist/types/lib/TokenTable/TokenSwatch.d.ts.map +1 -0
  44. package/dist/types/lib/TokenTable/TokenTable.d.ts +13 -0
  45. package/dist/types/lib/TokenTable/TokenTable.d.ts.map +1 -0
  46. package/dist/types/lib/TokenTable/TokenTable.ssr.test.d.ts +2 -0
  47. package/dist/types/lib/TokenTable/TokenTable.ssr.test.d.ts.map +1 -0
  48. package/dist/types/lib/TokenTable/TokenTable.test.d.ts +2 -0
  49. package/dist/types/lib/TokenTable/TokenTable.test.d.ts.map +1 -0
  50. package/dist/types/lib/TokenTable/common/TokenSwatch/TokenSwatch.d.ts +14 -0
  51. package/dist/types/lib/TokenTable/common/TokenSwatch/TokenSwatch.d.ts.map +1 -0
  52. package/dist/types/lib/TokenTable/common/TokenSwatch/TokenSwatch.ssr.test.d.ts +2 -0
  53. package/dist/types/lib/TokenTable/common/TokenSwatch/TokenSwatch.ssr.test.d.ts.map +1 -0
  54. package/dist/types/lib/TokenTable/common/TokenSwatch/TokenSwatch.test.d.ts +2 -0
  55. package/dist/types/lib/TokenTable/common/TokenSwatch/TokenSwatch.test.d.ts.map +1 -0
  56. package/dist/types/lib/TokenTable/common/TokenSwatch/index.d.ts +3 -0
  57. package/dist/types/lib/TokenTable/common/TokenSwatch/index.d.ts.map +1 -0
  58. package/dist/types/lib/TokenTable/common/TokenSwatch/types.d.ts +7 -0
  59. package/dist/types/lib/TokenTable/common/TokenSwatch/types.d.ts.map +1 -0
  60. package/dist/types/lib/TokenTable/common/index.d.ts +3 -0
  61. package/dist/types/lib/TokenTable/common/index.d.ts.map +1 -0
  62. package/dist/types/lib/TokenTable/dtcg.d.ts +30 -0
  63. package/dist/types/lib/TokenTable/dtcg.d.ts.map +1 -0
  64. package/dist/types/lib/TokenTable/index.d.ts +7 -0
  65. package/dist/types/lib/TokenTable/index.d.ts.map +1 -0
  66. package/dist/types/lib/TokenTable/types.d.ts +53 -0
  67. package/dist/types/lib/TokenTable/types.d.ts.map +1 -0
  68. package/dist/types/lib/index.d.ts +4 -0
  69. package/dist/types/lib/index.d.ts.map +1 -0
  70. package/dist/types/lib/mockTokens.d.ts +3 -0
  71. package/dist/types/lib/mockTokens.d.ts.map +1 -0
  72. package/package.json +72 -0
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Local mirror of the DTCG token vocabulary used by the token explorer.
3
+ */
4
+ export const DTCG_TOKEN_TYPES = [
5
+ "color",
6
+ "dimension",
7
+ "number",
8
+ "fontFamily",
9
+ "fontWeight",
10
+ "duration",
11
+ "cubicBezier",
12
+ "gradient",
13
+ "border",
14
+ "shadow",
15
+ "typography",
16
+ "transition",
17
+ "strokeStyle",
18
+ ];
19
+ export const DTCG_TOKEN_TYPE_LABELS = {
20
+ color: "Color",
21
+ dimension: "Dimension",
22
+ number: "Number",
23
+ fontFamily: "Font family",
24
+ fontWeight: "Font weight",
25
+ duration: "Duration",
26
+ cubicBezier: "Cubic bezier",
27
+ gradient: "Gradient",
28
+ border: "Border",
29
+ shadow: "Shadow",
30
+ typography: "Typography",
31
+ transition: "Transition",
32
+ strokeStyle: "Stroke style",
33
+ };
34
+ export const DTCG_TOKEN_TYPE_TO_CSS = {
35
+ color: "<color>",
36
+ number: "<number>",
37
+ fontFamily: "<family-name>",
38
+ fontWeight: "<number>",
39
+ duration: "<time>",
40
+ cubicBezier: "<easing-function>",
41
+ gradient: "<gradient>",
42
+ border: "<unknown>",
43
+ shadow: "<unknown>",
44
+ typography: "<unknown>",
45
+ transition: "<unknown>",
46
+ strokeStyle: "<unknown>",
47
+ dimension: "<length>",
48
+ };
49
+ export const TOKEN_LENS_DESCRIPTIONS = {
50
+ tier: {
51
+ title: "Tier lens",
52
+ why: "Use this when deciding what to consume versus what only exists as implementation infrastructure.",
53
+ },
54
+ prefix: {
55
+ title: "Family lens",
56
+ why: "Use this when looking for all text, border, icon, foreground, or motion tokens in one semantic family.",
57
+ },
58
+ derivation: {
59
+ title: "Derivation lens",
60
+ why: "Use this when debugging how modifiers, surfaces, and interaction states are produced from a base token.",
61
+ },
62
+ cssOutputFile: {
63
+ title: "Output-file lens",
64
+ why: "Use this when validating how the build emitted tokens into CSS layers and generated artifacts.",
65
+ },
66
+ type: {
67
+ title: "DTCG type lens",
68
+ why: "Use this when you need the rendering and assignability semantics defined by the DTCG model, not just design-system naming.",
69
+ },
70
+ };
71
+ //# sourceMappingURL=dtcg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dtcg.js","sourceRoot":"","sources":["../../../../src/lib/TokenTable/dtcg.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,OAAO;IACP,WAAW;IACX,QAAQ;IACR,YAAY;IACZ,YAAY;IACZ,UAAU;IACV,aAAa;IACb,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,YAAY;IACZ,YAAY;IACZ,aAAa;CACL,CAAC;AAIX,MAAM,CAAC,MAAM,sBAAsB,GAAkC;IACnE,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,WAAW;IACtB,MAAM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S, } from "./dtcg.js";
3
+ export { TokenTable } from "./TokenTable.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/TokenTable/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE5D,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,260 @@
1
+ :root {
2
+ --token-ui-canvas: #ffffff;
3
+ --token-ui-ink: #171717;
4
+ --token-table-cell-padding: 0.625rem 0.75rem;
5
+ --token-table-font-size: 0.8125rem;
6
+ }
7
+
8
+ .ds.token-table {
9
+ --token-ui-canvas: var(--token-story-canvas, #ffffff);
10
+ --token-ui-ink: var(--token-story-ink, #171717);
11
+
12
+ display: flex;
13
+ flex-direction: column;
14
+ gap: 0.75rem;
15
+ width: 100%;
16
+ color: var(--token-ui-ink, #171717);
17
+ }
18
+
19
+ .ds.token-table.dense {
20
+ --token-table-cell-padding: 0.5rem 0.625rem;
21
+ --token-table-font-size: 0.78125rem;
22
+ }
23
+
24
+ .ds.token-table {
25
+ & .toolbar {
26
+ display: flex;
27
+ align-items: flex-end;
28
+ justify-content: space-between;
29
+ gap: 0.75rem;
30
+ flex-wrap: wrap;
31
+ }
32
+
33
+ & .heading {
34
+ display: flex;
35
+ flex-direction: column;
36
+ gap: 0.25rem;
37
+ min-width: 0;
38
+ }
39
+
40
+ & .title {
41
+ margin: 0;
42
+ font-size: 1rem;
43
+ font-weight: 600;
44
+ color: inherit;
45
+ }
46
+
47
+ & .caption {
48
+ margin: 0;
49
+ max-width: 72ch;
50
+ font-size: 0.8125rem;
51
+ line-height: 1.5;
52
+ color: color-mix(in srgb, var(--token-ui-ink, #171717) 72%, transparent);
53
+ }
54
+
55
+ & .controls {
56
+ display: flex;
57
+ align-items: center;
58
+ gap: 0.5rem;
59
+ flex-wrap: wrap;
60
+ }
61
+
62
+ & .count {
63
+ display: inline-flex;
64
+ align-items: center;
65
+ min-height: 2rem;
66
+ padding: 0.25rem 0.625rem;
67
+ border-radius: 999px;
68
+ background: color-mix(
69
+ in srgb,
70
+ var(--token-ui-ink, #171717) 7%,
71
+ transparent
72
+ );
73
+ color: color-mix(in srgb, var(--token-ui-ink, #171717) 72%, transparent);
74
+ font-size: 0.75rem;
75
+ font-weight: 600;
76
+ letter-spacing: 0.02em;
77
+ white-space: nowrap;
78
+ }
79
+
80
+ & .search {
81
+ width: min(100%, 22rem);
82
+ min-width: 15rem;
83
+ min-height: 2rem;
84
+ padding: 0.4375rem 0.75rem;
85
+ border: 1px solid
86
+ color-mix(in srgb, var(--token-ui-ink, #171717) 16%, transparent);
87
+ border-radius: 0.5rem;
88
+ font-family: inherit;
89
+ font-size: 0.8125rem;
90
+ color: inherit;
91
+ background: color-mix(
92
+ in srgb,
93
+ var(--token-ui-ink, #171717) 3%,
94
+ transparent
95
+ );
96
+ }
97
+
98
+ & .search:focus {
99
+ outline: 2px solid
100
+ color-mix(in srgb, var(--token-ui-ink, #171717) 28%, transparent);
101
+ outline-offset: 2px;
102
+ }
103
+
104
+ & .scroll {
105
+ overflow: auto;
106
+ max-height: 38rem;
107
+ border: 1px solid
108
+ color-mix(in srgb, var(--token-ui-ink, #171717) 10%, transparent);
109
+ border-radius: 0.75rem;
110
+ background: color-mix(
111
+ in srgb,
112
+ var(--token-ui-canvas, #ffffff) 92%,
113
+ var(--token-ui-ink, #171717) 1.5%
114
+ );
115
+ }
116
+
117
+ & .grid {
118
+ width: 100%;
119
+ border-collapse: separate;
120
+ border-spacing: 0;
121
+ font-family: inherit;
122
+ color: inherit;
123
+ font-size: var(--token-table-font-size, 0.8125rem);
124
+ }
125
+
126
+ & .grid th,
127
+ & .grid td {
128
+ padding: var(--token-table-cell-padding, 0.625rem 0.75rem);
129
+ border-bottom: 1px solid
130
+ color-mix(in srgb, var(--token-ui-ink, #171717) 8%, transparent);
131
+ vertical-align: top;
132
+ }
133
+
134
+ & .grid thead th {
135
+ position: sticky;
136
+ top: 0;
137
+ z-index: 1;
138
+ text-align: left;
139
+ background: color-mix(
140
+ in srgb,
141
+ var(--token-ui-canvas, #ffffff) 92%,
142
+ var(--token-ui-ink, #171717) 3%
143
+ );
144
+ font-size: 0.6875rem;
145
+ font-weight: 700;
146
+ text-transform: uppercase;
147
+ letter-spacing: 0.06em;
148
+ color: color-mix(in srgb, var(--token-ui-ink, #171717) 62%, transparent);
149
+ }
150
+
151
+ & .group-row th {
152
+ background: color-mix(
153
+ in srgb,
154
+ var(--token-ui-ink, #171717) 5%,
155
+ transparent
156
+ );
157
+ color: color-mix(in srgb, var(--token-ui-ink, #171717) 75%, transparent);
158
+ font-size: 0.6875rem;
159
+ font-weight: 700;
160
+ letter-spacing: 0.06em;
161
+ text-transform: uppercase;
162
+ }
163
+
164
+ & .row:hover td {
165
+ background: color-mix(
166
+ in srgb,
167
+ var(--token-ui-ink, #171717) 3%,
168
+ transparent
169
+ );
170
+ }
171
+
172
+ & .token-cell {
173
+ display: flex;
174
+ flex-direction: column;
175
+ gap: 0.375rem;
176
+ min-width: 16rem;
177
+ }
178
+
179
+ & .var-name {
180
+ font-family: ui-monospace, monospace;
181
+ font-size: 0.8125rem;
182
+ font-weight: 600;
183
+ color: inherit;
184
+ }
185
+
186
+ & .meta {
187
+ display: flex;
188
+ flex-wrap: wrap;
189
+ gap: 0.25rem;
190
+ }
191
+
192
+ & .meta-item,
193
+ & .derivation,
194
+ & .stability {
195
+ display: inline-flex;
196
+ align-items: center;
197
+ min-height: 1.375rem;
198
+ padding: 0.0625rem 0.375rem;
199
+ border-radius: 0.375rem;
200
+ font-size: 0.6875rem;
201
+ font-weight: 600;
202
+ line-height: 1.2;
203
+ white-space: nowrap;
204
+ }
205
+
206
+ & .meta-item {
207
+ background: color-mix(
208
+ in srgb,
209
+ var(--token-ui-ink, #171717) 6%,
210
+ transparent
211
+ );
212
+ color: color-mix(in srgb, var(--token-ui-ink, #171717) 68%, transparent);
213
+ }
214
+
215
+ & .value {
216
+ font-family: ui-monospace, monospace;
217
+ font-size: 0.75rem;
218
+ color: color-mix(in srgb, var(--token-ui-ink, #171717) 72%, transparent);
219
+ }
220
+
221
+ & .wrap {
222
+ white-space: normal;
223
+ word-break: break-word;
224
+ }
225
+
226
+ & .stability.stable {
227
+ background: color-mix(in srgb, green 12%, transparent);
228
+ color: color-mix(in srgb, green 78%, var(--token-ui-ink, #171717) 22%);
229
+ }
230
+
231
+ & .stability.wip {
232
+ background: color-mix(in srgb, orange 12%, transparent);
233
+ color: color-mix(in srgb, orange 78%, var(--token-ui-ink, #171717) 22%);
234
+ }
235
+
236
+ & .stability.experimental {
237
+ background: color-mix(in srgb, purple 12%, transparent);
238
+ color: color-mix(in srgb, purple 78%, var(--token-ui-ink, #171717) 22%);
239
+ }
240
+
241
+ & .derivation {
242
+ background: color-mix(
243
+ in srgb,
244
+ var(--token-ui-ink, #171717) 7%,
245
+ transparent
246
+ );
247
+ color: color-mix(in srgb, var(--token-ui-ink, #171717) 72%, transparent);
248
+ }
249
+
250
+ & .empty {
251
+ margin: 0;
252
+ padding: 1.5rem;
253
+ border: 1px dashed
254
+ color-mix(in srgb, var(--token-ui-ink, #171717) 16%, transparent);
255
+ border-radius: 0.75rem;
256
+ text-align: center;
257
+ color: color-mix(in srgb, var(--token-ui-ink, #171717) 55%, transparent);
258
+ font-style: italic;
259
+ }
260
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/TokenTable/types.ts"],"names":[],"mappings":""}