@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
package/README.md ADDED
@@ -0,0 +1,271 @@
1
+ # @canonical/react-tokens
2
+
3
+ Token explorer components for the Pragma design system. This package provides `TokenTable` and `TokenSwatch` — reusable visualization components for browsing, comparing, and understanding the design token system inside Storybook.
4
+
5
+ ## Prerequisites
6
+
7
+ - React 19 or higher
8
+ - `@canonical/styles` for global design tokens (the token CSS custom properties that swatches reference)
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ bun add @canonical/react-tokens
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ Import the components and pass token data:
19
+
20
+ ```tsx
21
+ import { TokenTable, type TokenEntry } from "@canonical/react-tokens";
22
+
23
+ const tokens: TokenEntry[] = [
24
+ {
25
+ cssVar: "--color-text",
26
+ id: "color.text",
27
+ type: "color",
28
+ tier: "semantic",
29
+ stability: "wip",
30
+ cssOutputFile: "modifiers.theme.css",
31
+ isPaired: true,
32
+ valueLight: "oklch(12.2% 0 0)",
33
+ valueDark: "oklch(93.5% 0 0)",
34
+ },
35
+ ];
36
+
37
+ function TokenReference() {
38
+ return (
39
+ <TokenTable
40
+ tokens={tokens}
41
+ title="Semantic colors"
42
+ columns={["token", "swatch", "light", "dark", "stability"]}
43
+ searchable
44
+ groupBy="prefix"
45
+ />
46
+ );
47
+ }
48
+ ```
49
+
50
+ Color swatches render live `var()` references, so they update automatically when the Storybook theme switches between light and dark modes.
51
+
52
+ ## Components
53
+
54
+ ### TokenTable
55
+
56
+ A dense, scannable table for browsing design tokens. Supports search, grouping, column selection, and auto-detected column layouts.
57
+
58
+ ```tsx
59
+ import { TokenTable } from "@canonical/react-tokens";
60
+ ```
61
+
62
+ #### Props
63
+
64
+ | Prop | Type | Default | Description |
65
+ |------|------|---------|-------------|
66
+ | `tokens` | `TokenEntry[]` | — | **Required.** Token data to display. |
67
+ | `title` | `string` | — | Title shown above the table. |
68
+ | `caption` | `string` | — | Supporting copy shown below the title. |
69
+ | `columns` | `TokenColumnId[]` | Auto-detected | Which columns to render. When omitted, columns are inferred from the token data shape. |
70
+ | `searchable` | `boolean` | `false` | Show a search input that filters across all token metadata. |
71
+ | `showCount` | `boolean` | `true` | Show the filtered token count in the toolbar. |
72
+ | `dense` | `boolean` | `true` | Use compact padding optimized for scanning. |
73
+ | `groupBy` | `TokenGroupBy` | — | Group tokens under inline section headers. |
74
+ | `searchPlaceholder` | `string` | `"Search tokens, ids, or files…"` | Placeholder text for the search input. |
75
+ | `emptyMessage` | `string` | `"No tokens match the current filters."` | Text shown when no tokens pass the filter. |
76
+ | `className` | `string` | — | Additional CSS class on the root element. |
77
+
78
+ #### Column identifiers
79
+
80
+ | Column | Content |
81
+ |--------|---------|
82
+ | `token` | CSS variable name with inline metadata (DTCG ID, type, tier, output file). |
83
+ | `swatch` | Visual preview rendered by `TokenSwatch`. |
84
+ | `light` | Light-mode resolved value. |
85
+ | `dark` | Dark-mode resolved value. |
86
+ | `value` | Single resolved value (for unpaired tokens). |
87
+ | `type` | DTCG token type. |
88
+ | `tier` | Token tier (primitive, semantic, derived). |
89
+ | `stability` | Maturity badge (stable, WIP, experimental). |
90
+ | `derivedFrom` | Parent token CSS variable name. |
91
+ | `derivation` | Derivation mechanism (hover, active, channel-modifier, etc.). |
92
+
93
+ #### Column auto-detection
94
+
95
+ When `columns` is omitted, TokenTable infers a layout:
96
+
97
+ - Tokens with `isPaired: true` → `token, swatch, light, dark, stability`
98
+ - Tokens with `derivedFrom` and no values → `token, swatch, derivedFrom, derivation, stability`
99
+ - Tokens with a single value → `token, swatch, value, stability`
100
+
101
+ #### Grouping modes
102
+
103
+ | Mode | Groups by | Use when |
104
+ |------|-----------|----------|
105
+ | `type` | DTCG token type | Checking rendering and CSS assignability semantics. |
106
+ | `tier` | Token tier | Deciding what to consume vs. what is infrastructure. |
107
+ | `cssOutputFile` | Generated CSS file | Validating build output and cascade layers. |
108
+ | `derivation` | Derivation mechanism | Debugging modifier, surface, and state relationships. |
109
+ | `prefix` | Semantic family (text, border, icon, foreground) | Finding all tokens in a domain. |
110
+
111
+ ### TokenSwatch
112
+
113
+ A compact visual preview for a single token. Renders type-specific representations: color patches, dimension bars, font samples, curve indicators, gradient strips, border/shadow/stroke previews, and derivation references.
114
+
115
+ ```tsx
116
+ import { TokenSwatch } from "@canonical/react-tokens";
117
+ ```
118
+
119
+ #### Props
120
+
121
+ | Prop | Type | Default | Description |
122
+ |------|------|---------|-------------|
123
+ | `token` | `TokenEntry` | — | **Required.** The token to visualize. |
124
+ | `contextClass` | `string` | — | CSS class for modifier context (e.g., `"error"`). Reserved for Phase 2. |
125
+ | `className` | `string` | — | Additional CSS class on the root element. |
126
+
127
+ `TokenSwatch` also accepts all standard `HTMLDivElement` attributes via prop spreading.
128
+
129
+ #### Rendering by type
130
+
131
+ | Token type | Rendering |
132
+ |------------|-----------|
133
+ | `color` | 2rem × 2rem filled square using `var(--token-css-var)`. Shows L/D chip when paired. |
134
+ | `dimension` | Horizontal bar scaled to `min(var(--token), 8rem)` with value label. |
135
+ | `number` | Numeric chip (Δ prefix for delta tokens) with formatted value. |
136
+ | `fontFamily` | "Ag" sample text in the referenced font family. |
137
+ | `fontWeight` | "Ag" sample text at the referenced weight. |
138
+ | `typography` | "Aa Bb 123" sample inheriting semantic text color. |
139
+ | `duration` | `ms` chip with duration value. |
140
+ | `cubicBezier` | Curve indicator with truncated function value. |
141
+ | `gradient` | Mini gradient strip using `var(--token)`. |
142
+ | `border` | Mini box with the token applied as `border`. |
143
+ | `shadow` | Mini box with the token applied as `box-shadow`. |
144
+ | `transition` | Arrow indicator (↔) with truncated transition shorthand. |
145
+ | `strokeStyle` | 2px line with the token applied as `border-top-style`. |
146
+ | Derived (no value) | Arrow → parent token name + derivation badge. |
147
+
148
+ ## Data model
149
+
150
+ ### TokenEntry
151
+
152
+ The core data structure representing a single design token.
153
+
154
+ ```typescript
155
+ interface TokenEntry {
156
+ // Identification
157
+ cssVar: string; // "--color-background"
158
+ id: string | null; // "color.background" (DTCG ID)
159
+ description?: string; // Human-readable description
160
+ aliasChain?: string[]; // Full alias resolution chain
161
+
162
+ // Classification
163
+ type: TokenType; // "color" | "dimension" | ... (13 DTCG types)
164
+ tier: TokenTier; // "primitive" | "semantic" | "derived"
165
+ stability: Stability; // "stable" | "wip" | "experimental"
166
+
167
+ // CSS output
168
+ cssOutputFile: string; // "modifiers.theme.css"
169
+ cssSelector?: string; // ".surface" (where token is declared)
170
+ cssType?: string; // "<color>" (CSS syntax descriptor)
171
+
172
+ // Values
173
+ isPaired: boolean; // true if light ≠ dark
174
+ valueLight?: string; // "oklch(100% 0 0)"
175
+ valueDark?: string; // "oklch(12.21% 0 0)"
176
+ hexLight?: string; // "#ffffff"
177
+ hexDark?: string; // "#1f1f1f"
178
+
179
+ // Derivation
180
+ derivedFrom?: string; // "--color-foreground-primary"
181
+ derivation?: Derivation; // "hover" | "active" | "channel-modifier" | ...
182
+
183
+ // @property registration
184
+ registered?: boolean;
185
+ syntax?: string | null;
186
+ inherits?: boolean | null;
187
+ initialValue?: string | null;
188
+ }
189
+ ```
190
+
191
+ ### Token types (DTCG-aligned)
192
+
193
+ `color`, `dimension`, `number`, `fontFamily`, `fontWeight`, `duration`, `cubicBezier`, `gradient`, `border`, `shadow`, `typography`, `transition`, `strokeStyle`
194
+
195
+ ### Token tiers
196
+
197
+ | Tier | Role | Consumption rule |
198
+ |------|------|-----------------|
199
+ | **Primitive** | Raw values (palette colors, spacing units) | Never reference directly in component styles. |
200
+ | **Semantic** | Intent-bearing tokens (color-text, color-background) | The component-facing API. Use these. |
201
+ | **Derived** | Modifier channels, surface channels, interaction states | Resolved through fallback chains. Infrastructure. |
202
+
203
+ ### Stability levels
204
+
205
+ | Level | Meaning | Guidance |
206
+ |-------|---------|----------|
207
+ | **Stable** | Locked for production. | Safe to depend on. |
208
+ | **WIP** | May change; codemods will be provided. | Use with awareness that names or values may shift. |
209
+ | **Experimental** | Under active design; expect breaking changes. | Internal use only. |
210
+
211
+ ## Styles
212
+
213
+ TokenTable and TokenSwatch co-locate their CSS under `.ds.token-table` and `.ds.token-swatch` namespaces. Styles use the `color-mix(in srgb, currentColor X%, transparent)` pattern for adaptive borders and backgrounds, so the components work correctly in both light and dark Storybook themes without additional configuration.
214
+
215
+ Import the global styles package in your Storybook preview to make token CSS custom properties available:
216
+
217
+ ```css
218
+ @import "@canonical/styles";
219
+ ```
220
+
221
+ ## Storybook
222
+
223
+ The package includes reference stories and page-level documentation stories:
224
+
225
+ ```bash
226
+ cd packages/react/tokens
227
+ bun run storybook
228
+ ```
229
+
230
+ ### Story structure
231
+
232
+ | Story | Diataxis quadrant | Content |
233
+ |-------|-------------------|---------|
234
+ | `Foundations/Tokens/Internal/TokenTable` | Reference | Component API demonstration with default and grouped variants. |
235
+ | `Foundations/Tokens/Internal/TokenSwatch` | Reference | Individual swatch rendering for color and derived tokens. |
236
+ | `Foundation/Design Tokens — Overview` | Explanation | Token architecture summary, tier hierarchy, rules of thumb. |
237
+ | `Foundation/Design Tokens — Explorer` | Reference | Dense token catalog with all grouping lenses. |
238
+ | `Foundation/Design Tokens — Patterns` | Explanation | Live modifier, surface, and interaction state demonstrations. |
239
+ | `Foundation/Design Tokens — Consumer Guidance` | How-to | Do/don't guidance, code patterns, change management. |
240
+
241
+ ## Token landscape
242
+
243
+ The design token system currently comprises 730 tokens across 7 CSS output files:
244
+
245
+ | Output file | Token count | Content |
246
+ |-------------|-------------|---------|
247
+ | `sets.primitive.css` | 202 | Palette colors, spacing dimensions. |
248
+ | `modifiers.theme.css` | 332 | Semantic colors (light/dark paired). |
249
+ | `modifiers.typography.css` | 143 | Font families, weights, and typographic scales. |
250
+ | `states.css` | 30 | Hover, active, disabled interaction states. |
251
+ | `modifiers.surfaces.css` | 15 | Surface depth channels. |
252
+ | `modifiers.emphasis.css` | 6 | Emphasis modifier channels. |
253
+ | `modifiers.criticality.css` | 2 | Criticality modifier channels. |
254
+
255
+ By DTCG type: 488 color, 135 typography, 79 dimension, 16 number, 8 fontWeight, 4 fontFamily.
256
+
257
+ ## Exported constants
258
+
259
+ ```typescript
260
+ import {
261
+ DTCG_TOKEN_TYPES, // All 13 DTCG type strings
262
+ DTCG_TOKEN_TYPE_LABELS, // Human-readable labels per type
263
+ DTCG_TOKEN_TYPE_TO_CSS, // DTCG type → CSS syntax descriptor
264
+ TOKEN_LENS_DESCRIPTIONS, // Titles and rationale for each grouping lens
265
+ mockTokens, // 45 curated tokens for development and testing
266
+ } from "@canonical/react-tokens";
267
+ ```
268
+
269
+ ## Component specifications
270
+
271
+ Token visualization components are specified by the design-system ontology. See `specs/` for the token vocabulary extension and SHACL validation shapes that align the TypeScript `TokenEntry` interface with the `ds:Token` class.
@@ -0,0 +1,2 @@
1
+ export * from "./lib/index.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,173 @@
1
+ /* Compatibility shim: styles live in common/TokenSwatch/styles.css */
2
+
3
+ .token-swatch--color-group,
4
+ .token-swatch--sample,
5
+ .token-swatch--numeric,
6
+ .token-swatch--curve,
7
+ .token-swatch--color {
8
+ flex-shrink: 0;
9
+ }
10
+
11
+ .token-swatch--color-group,
12
+ .token-swatch--sample,
13
+ .token-swatch--numeric,
14
+ .token-swatch--curve,
15
+ .token-swatch--dimension,
16
+ .token-swatch--reference {
17
+ max-width: 100%;
18
+ }
19
+
20
+ .token-swatch--color {
21
+ width: 1.5rem;
22
+ height: 1.5rem;
23
+ border-radius: 0.25rem;
24
+ border: 1px solid
25
+ color-mix(in srgb, var(--token-ui-ink, currentColor) 15%, transparent);
26
+ box-shadow: inset 0 0 0 1px
27
+ color-mix(in srgb, var(--token-ui-canvas, #fff) 55%, transparent);
28
+ }
29
+
30
+ .token-swatch__chip {
31
+ display: inline-flex;
32
+ align-items: center;
33
+ min-height: 1.125rem;
34
+ padding: 0 0.3125rem;
35
+ border-radius: 0.3125rem;
36
+ background: color-mix(
37
+ in srgb,
38
+ var(--token-ui-ink, currentColor) 8%,
39
+ transparent
40
+ );
41
+ color: color-mix(in srgb, var(--token-ui-ink, currentColor) 72%, transparent);
42
+ font-size: 0.625rem;
43
+ font-weight: 700;
44
+ letter-spacing: 0.04em;
45
+ text-transform: uppercase;
46
+ }
47
+
48
+ .token-swatch__chip--numeric {
49
+ min-width: 1.125rem;
50
+ justify-content: center;
51
+ }
52
+
53
+ .token-swatch--reference {
54
+ font-size: 0.75rem;
55
+ color: color-mix(in srgb, var(--token-ui-ink, currentColor) 70%, transparent);
56
+ flex-wrap: wrap;
57
+ }
58
+
59
+ .token-swatch__arrow {
60
+ color: color-mix(in srgb, var(--token-ui-ink, currentColor) 40%, transparent);
61
+ }
62
+
63
+ .token-swatch__parent {
64
+ font-family: ui-monospace, monospace;
65
+ font-size: 0.75rem;
66
+ }
67
+
68
+ .token-swatch__derivation {
69
+ padding: 0.0625rem 0.3125rem;
70
+ border-radius: 0.375rem;
71
+ background: color-mix(
72
+ in srgb,
73
+ var(--token-ui-ink, currentColor) 8%,
74
+ transparent
75
+ );
76
+ font-size: 0.6875rem;
77
+ font-weight: 600;
78
+ }
79
+
80
+ .token-swatch--dimension {
81
+ min-width: 8rem;
82
+ }
83
+
84
+ .token-swatch__bar {
85
+ height: 0.5rem;
86
+ background: color-mix(
87
+ in srgb,
88
+ var(--token-ui-ink, currentColor) 20%,
89
+ transparent
90
+ );
91
+ border-radius: 0.25rem;
92
+ min-width: 8px;
93
+ }
94
+
95
+ .token-swatch__value {
96
+ font-size: 0.6875rem;
97
+ font-family: ui-monospace, monospace;
98
+ color: color-mix(in srgb, var(--token-ui-ink, currentColor) 60%, transparent);
99
+ white-space: nowrap;
100
+ overflow: hidden;
101
+ text-overflow: ellipsis;
102
+ }
103
+
104
+ .token-swatch__sample-text {
105
+ min-width: 1.5rem;
106
+ color: var(
107
+ --modifier-color-text,
108
+ var(--color-text, var(--token-ui-ink, inherit))
109
+ );
110
+ font-size: 0.875rem;
111
+ line-height: 1;
112
+ }
113
+
114
+ .token-swatch__sample-text--typography {
115
+ font-size: 0.8125rem;
116
+ letter-spacing: 0.01em;
117
+ }
118
+
119
+ .token-swatch__mini-box {
120
+ width: 1.75rem;
121
+ height: 1.125rem;
122
+ border: 1px solid
123
+ color-mix(in srgb, var(--token-ui-ink, currentColor) 16%, transparent);
124
+ border-radius: 0.25rem;
125
+ background: color-mix(
126
+ in srgb,
127
+ var(--token-ui-ink, currentColor) 6%,
128
+ transparent
129
+ );
130
+ flex-shrink: 0;
131
+ }
132
+
133
+ .token-swatch__mini-box--gradient {
134
+ border-color: transparent;
135
+ }
136
+
137
+ .token-swatch__mini-box--shadow {
138
+ background: var(--token-ui-canvas, #fff);
139
+ }
140
+
141
+ .token-swatch__curve {
142
+ position: relative;
143
+ width: 1.75rem;
144
+ height: 1.125rem;
145
+ border-radius: 0.25rem;
146
+ border: 1px solid
147
+ color-mix(in srgb, var(--token-ui-ink, currentColor) 14%, transparent);
148
+ background:
149
+ linear-gradient(
150
+ 135deg,
151
+ transparent 0 38%,
152
+ var(--token-ui-ink, currentColor) 38% 46%,
153
+ transparent 46% 100%
154
+ ),
155
+ color-mix(in srgb, var(--token-ui-ink, currentColor) 4%, transparent);
156
+ opacity: 0.75;
157
+ flex-shrink: 0;
158
+ }
159
+
160
+ .token-swatch__stroke-line {
161
+ width: 1.75rem;
162
+ border-top-width: 2px;
163
+ border-top-color: currentColor;
164
+ border-top-style: dashed;
165
+ opacity: 0.75;
166
+ flex-shrink: 0;
167
+ }
168
+
169
+ .token-swatch--text {
170
+ font-size: 0.75rem;
171
+ font-family: ui-monospace, monospace;
172
+ color: color-mix(in srgb, var(--token-ui-ink, currentColor) 60%, transparent);
173
+ }
@@ -0,0 +1,2 @@
1
+ export { TokenSwatch } from "./common/TokenSwatch/index.js";
2
+ //# sourceMappingURL=TokenSwatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TokenSwatch.js","sourceRoot":"","sources":["../../../../src/lib/TokenTable/TokenSwatch.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,236 @@
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
+ .token-table-container {
9
+ --token-table-cell-padding: 0.625rem 0.75rem;
10
+ --token-table-font-size: 0.8125rem;
11
+ --token-ui-canvas: var(--token-story-canvas, #ffffff);
12
+ --token-ui-ink: var(--token-story-ink, #171717);
13
+
14
+ display: flex;
15
+ flex-direction: column;
16
+ gap: 0.75rem;
17
+ width: 100%;
18
+ color: var(--token-ui-ink, #171717);
19
+ }
20
+
21
+ .token-table-container--dense {
22
+ --token-table-cell-padding: 0.5rem 0.625rem;
23
+ --token-table-font-size: 0.78125rem;
24
+ }
25
+
26
+ .token-table__toolbar {
27
+ display: flex;
28
+ align-items: flex-end;
29
+ justify-content: space-between;
30
+ gap: 0.75rem;
31
+ flex-wrap: wrap;
32
+ }
33
+
34
+ .token-table__heading {
35
+ display: flex;
36
+ flex-direction: column;
37
+ gap: 0.25rem;
38
+ min-width: 0;
39
+ }
40
+
41
+ .token-table__title {
42
+ margin: 0;
43
+ font-size: 1rem;
44
+ font-weight: 600;
45
+ color: inherit;
46
+ }
47
+
48
+ .token-table__caption {
49
+ margin: 0;
50
+ max-width: 72ch;
51
+ font-size: 0.8125rem;
52
+ line-height: 1.5;
53
+ color: color-mix(in srgb, var(--token-ui-ink, #171717) 72%, transparent);
54
+ }
55
+
56
+ .token-table__controls {
57
+ display: flex;
58
+ align-items: center;
59
+ gap: 0.5rem;
60
+ flex-wrap: wrap;
61
+ }
62
+
63
+ .token-table__count {
64
+ display: inline-flex;
65
+ align-items: center;
66
+ min-height: 2rem;
67
+ padding: 0.25rem 0.625rem;
68
+ border-radius: 999px;
69
+ background: color-mix(in srgb, var(--token-ui-ink, #171717) 7%, transparent);
70
+ color: color-mix(in srgb, var(--token-ui-ink, #171717) 72%, transparent);
71
+ font-size: 0.75rem;
72
+ font-weight: 600;
73
+ letter-spacing: 0.02em;
74
+ white-space: nowrap;
75
+ }
76
+
77
+ .token-table__search {
78
+ width: min(100%, 22rem);
79
+ min-width: 15rem;
80
+ min-height: 2rem;
81
+ padding: 0.4375rem 0.75rem;
82
+ border: 1px solid
83
+ color-mix(in srgb, var(--token-ui-ink, #171717) 16%, transparent);
84
+ border-radius: 0.5rem;
85
+ font-family: inherit;
86
+ font-size: 0.8125rem;
87
+ color: inherit;
88
+ background: color-mix(in srgb, var(--token-ui-ink, #171717) 3%, transparent);
89
+ }
90
+
91
+ .token-table__search:focus {
92
+ outline: 2px solid
93
+ color-mix(in srgb, var(--token-ui-ink, #171717) 28%, transparent);
94
+ outline-offset: 2px;
95
+ }
96
+
97
+ .token-table__scroll {
98
+ overflow: auto;
99
+ max-height: 38rem;
100
+ border: 1px solid
101
+ color-mix(in srgb, var(--token-ui-ink, #171717) 10%, transparent);
102
+ border-radius: 0.75rem;
103
+ background: color-mix(
104
+ in srgb,
105
+ var(--token-ui-canvas, #ffffff) 92%,
106
+ var(--token-ui-ink, #171717) 1.5%
107
+ );
108
+ }
109
+
110
+ .token-table {
111
+ width: 100%;
112
+ border-collapse: separate;
113
+ border-spacing: 0;
114
+ font-family: inherit;
115
+ color: inherit;
116
+ font-size: var(--token-table-font-size, 0.8125rem);
117
+ }
118
+
119
+ .token-table th,
120
+ .token-table td {
121
+ padding: var(--token-table-cell-padding, 0.625rem 0.75rem);
122
+ border-bottom: 1px solid
123
+ color-mix(in srgb, var(--token-ui-ink, #171717) 8%, transparent);
124
+ vertical-align: top;
125
+ }
126
+
127
+ .token-table thead th {
128
+ position: sticky;
129
+ top: 0;
130
+ z-index: 1;
131
+ text-align: left;
132
+ background: color-mix(
133
+ in srgb,
134
+ var(--token-ui-canvas, #ffffff) 92%,
135
+ var(--token-ui-ink, #171717) 3%
136
+ );
137
+ font-size: 0.6875rem;
138
+ font-weight: 700;
139
+ text-transform: uppercase;
140
+ letter-spacing: 0.06em;
141
+ color: color-mix(in srgb, var(--token-ui-ink, #171717) 62%, transparent);
142
+ }
143
+
144
+ .token-table__group-row th {
145
+ background: color-mix(in srgb, var(--token-ui-ink, #171717) 5%, transparent);
146
+ color: color-mix(in srgb, var(--token-ui-ink, #171717) 75%, transparent);
147
+ font-size: 0.6875rem;
148
+ font-weight: 700;
149
+ letter-spacing: 0.06em;
150
+ text-transform: uppercase;
151
+ }
152
+
153
+ .token-table__row:hover td {
154
+ background: color-mix(in srgb, var(--token-ui-ink, #171717) 3%, transparent);
155
+ }
156
+
157
+ .token-table__token-cell {
158
+ display: flex;
159
+ flex-direction: column;
160
+ gap: 0.375rem;
161
+ min-width: 16rem;
162
+ }
163
+
164
+ .token-table__var {
165
+ font-family: ui-monospace, monospace;
166
+ font-size: 0.8125rem;
167
+ font-weight: 600;
168
+ color: inherit;
169
+ }
170
+
171
+ .token-table__meta {
172
+ display: flex;
173
+ flex-wrap: wrap;
174
+ gap: 0.25rem;
175
+ }
176
+
177
+ .token-table__meta-item,
178
+ .token-table__derivation,
179
+ .token-table__stability {
180
+ display: inline-flex;
181
+ align-items: center;
182
+ min-height: 1.375rem;
183
+ padding: 0.0625rem 0.375rem;
184
+ border-radius: 0.375rem;
185
+ font-size: 0.6875rem;
186
+ font-weight: 600;
187
+ line-height: 1.2;
188
+ white-space: nowrap;
189
+ }
190
+
191
+ .token-table__meta-item {
192
+ background: color-mix(in srgb, var(--token-ui-ink, #171717) 6%, transparent);
193
+ color: color-mix(in srgb, var(--token-ui-ink, #171717) 68%, transparent);
194
+ }
195
+
196
+ .token-table__value {
197
+ font-family: ui-monospace, monospace;
198
+ font-size: 0.75rem;
199
+ color: color-mix(in srgb, var(--token-ui-ink, #171717) 72%, transparent);
200
+ }
201
+
202
+ .token-table__value--wrap {
203
+ white-space: normal;
204
+ word-break: break-word;
205
+ }
206
+
207
+ .token-table__stability--stable {
208
+ background: color-mix(in srgb, green 12%, transparent);
209
+ color: color-mix(in srgb, green 78%, var(--token-ui-ink, #171717) 22%);
210
+ }
211
+
212
+ .token-table__stability--wip {
213
+ background: color-mix(in srgb, orange 12%, transparent);
214
+ color: color-mix(in srgb, orange 78%, var(--token-ui-ink, #171717) 22%);
215
+ }
216
+
217
+ .token-table__stability--experimental {
218
+ background: color-mix(in srgb, purple 12%, transparent);
219
+ color: color-mix(in srgb, purple 78%, var(--token-ui-ink, #171717) 22%);
220
+ }
221
+
222
+ .token-table__derivation {
223
+ background: color-mix(in srgb, var(--token-ui-ink, #171717) 7%, transparent);
224
+ color: color-mix(in srgb, var(--token-ui-ink, #171717) 72%, transparent);
225
+ }
226
+
227
+ .token-table__empty {
228
+ margin: 0;
229
+ padding: 1.5rem;
230
+ border: 1px dashed
231
+ color-mix(in srgb, var(--token-ui-ink, #171717) 16%, transparent);
232
+ border-radius: 0.75rem;
233
+ text-align: center;
234
+ color: color-mix(in srgb, var(--token-ui-ink, #171717) 55%, transparent);
235
+ font-style: italic;
236
+ }