@atom63/styles 0.1.0-beta.5 → 0.1.0-beta.6

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 (97) hide show
  1. package/README.md +14 -8
  2. package/generated/atom63.figma-sync.json +3763 -1108
  3. package/generated/atom63.tokens.json +3809 -829
  4. package/package.json +5 -6
  5. package/src/compat/a63-from-shadcn.css +10 -0
  6. package/src/contracts/action.css +4 -3
  7. package/src/contracts/action.native.css +11 -0
  8. package/src/contracts/action.tokens.json +66 -0
  9. package/src/contracts/badge.css +28 -19
  10. package/src/contracts/badge.resolver.json +366 -0
  11. package/src/contracts/choice.css +4 -1
  12. package/src/contracts/choice.native.css +9 -0
  13. package/src/contracts/choice.tokens.json +66 -0
  14. package/src/contracts/control.css +43 -52
  15. package/src/contracts/control.native.css +13 -0
  16. package/src/contracts/control.tokens.json +245 -0
  17. package/src/contracts/environment.css +45 -49
  18. package/src/contracts/environment.native.css +23 -0
  19. package/src/contracts/environment.resolver.json +569 -0
  20. package/src/contracts/field.css +3 -1
  21. package/src/contracts/field.tokens.json +40 -0
  22. package/src/contracts/marker.css +6 -4
  23. package/src/contracts/marker.tokens.json +15 -0
  24. package/src/contracts/menu.css +25 -61
  25. package/src/contracts/menu.native.css +10 -0
  26. package/src/contracts/menu.resolver.json +122 -0
  27. package/src/contracts/overlay.css +11 -13
  28. package/src/contracts/overlay.native.css +13 -0
  29. package/src/contracts/overlay.tokens.json +103 -0
  30. package/src/contracts/segment.css +22 -68
  31. package/src/contracts/segment.tokens.json +19 -0
  32. package/src/contracts/selection.css +3 -1
  33. package/src/contracts/selection.tokens.json +37 -0
  34. package/src/contracts/skeleton.css +3 -0
  35. package/src/contracts/skeleton.resolver.json +66 -0
  36. package/src/contracts/surface.css +13 -24
  37. package/src/contracts/surface.native.css +17 -0
  38. package/src/contracts/surface.tokens.json +97 -0
  39. package/src/contracts/toggle.css +3 -1
  40. package/src/contracts/toggle.tokens.json +49 -0
  41. package/src/contracts/track.css +3 -1
  42. package/src/contracts/track.tokens.json +39 -0
  43. package/src/contracts/trigger.css +5 -2
  44. package/src/contracts/trigger.native.css +9 -0
  45. package/src/contracts/trigger.tokens.json +58 -0
  46. package/src/contracts/widget.css +41 -51
  47. package/src/contracts/widget.native.css +23 -0
  48. package/src/contracts/widget.resolver.json +1104 -0
  49. package/src/tailwind/theme.css +0 -2
  50. package/src/themes/aqua.css +24 -89
  51. package/src/themes/aqua.native.css +80 -0
  52. package/src/themes/aqua.resolver.json +1292 -0
  53. package/src/themes/modern.css +10 -14
  54. package/src/themes/modern.native.css +16 -0
  55. package/src/themes/modern.resolver.json +350 -0
  56. package/src/themes/retro.css +21 -26
  57. package/src/themes/retro.native.css +16 -0
  58. package/src/themes/retro.resolver.json +788 -0
  59. package/src/themes/terminal.css +34 -41
  60. package/src/themes/terminal.native.css +22 -0
  61. package/src/themes/terminal.resolver.json +517 -0
  62. package/src/tokens/brand-action.css +50 -0
  63. package/src/tokens/brand-action.resolver.json +118 -0
  64. package/src/tokens/brand-ramp.css +108 -0
  65. package/src/tokens/brand-ramp.resolver.json +418 -0
  66. package/src/tokens/brand.css +6 -146
  67. package/src/tokens/color-mix-space.browser.test.ts +79 -0
  68. package/src/tokens/contrast.browser.test.ts +47 -3
  69. package/src/tokens/figma-parity.browser.test.ts +257 -0
  70. package/src/tokens/font.css +6 -0
  71. package/src/tokens/font.resolver.json +107 -0
  72. package/src/tokens/foundation/effects.css +13 -13
  73. package/src/tokens/foundation/effects.resolver.json +433 -0
  74. package/src/tokens/foundation/fonts.css +3 -1
  75. package/src/tokens/foundation/fonts.tokens.json +6 -1
  76. package/src/tokens/foundation/radius.css +6 -9
  77. package/src/tokens/foundation/radius.tokens.json +100 -0
  78. package/src/tokens/foundation/typography.css +25 -12
  79. package/src/tokens/foundation/typography.native.css +11 -0
  80. package/src/tokens/foundation/typography.resolver.json +936 -0
  81. package/src/tokens/foundation.css +0 -1
  82. package/src/tokens/motion.css +3 -1
  83. package/src/tokens/motion.resolver.json +135 -0
  84. package/src/tokens/native-values.json +38 -0
  85. package/src/tokens/personalization-axes.browser.test.ts +5 -3
  86. package/src/tokens/radius.css +12 -8
  87. package/src/tokens/radius.resolver.json +138 -0
  88. package/src/tokens/semantics.css +59 -43
  89. package/src/tokens/semantics.resolver.json +402 -0
  90. package/src/tokens/space.css +8 -6
  91. package/src/tokens/space.tokens.json +78 -0
  92. package/src/tokens/swift-parity.browser.test.ts +137 -0
  93. package/src/tokens/type-scale.css +6 -0
  94. package/src/tokens/type-scale.resolver.json +67 -0
  95. package/generated/atom63.figma-tokens.json +0 -21661
  96. package/src/tokens/foundation/aliases.css +0 -32
  97. package/src/tokens/foundation/aliases.tokens.json +0 -105
@@ -0,0 +1,402 @@
1
+ {
2
+ "version": "2025.10",
3
+ "description": "Canonical semantic layer.\n\nThis is the single source of semantic truth for the new system. Values are\nsourced directly from the token foundation (surface aliases + primitives),\nwith .dark overrides where the mode differs. shadcn (--background/--primary…)\nand Tailwind are opt-in adapters that re-reference THESE names — never the\nreverse. See packages/styles/README.md (the mirror rule).",
4
+ "sets": {
5
+ "base": {
6
+ "sources": [
7
+ {
8
+ "a63": {
9
+ "surface": {
10
+ "tint": {
11
+ "$type": "number",
12
+ "$value": 0,
13
+ "$extensions": {
14
+ "io.atom63.derive": "0%"
15
+ }
16
+ }
17
+ },
18
+ "scrim": {
19
+ "$type": "color",
20
+ "$value": "{color.black.100}",
21
+ "$extensions": {
22
+ "io.atom63.derive": "color-mix(in oklch, black 40%, transparent)"
23
+ },
24
+ "$description": "Scrim — the modal/drawer/sheet backdrop veil behind overlays."
25
+ },
26
+ "media": {
27
+ "stage": {
28
+ "$type": "color",
29
+ "$value": "{color.black.100}",
30
+ "$description": "Media stage — behind full-screen photos and video: black in every theme, so letterboxing matches the picture."
31
+ },
32
+ "scrim": {
33
+ "$type": "color",
34
+ "$value": "{color.black.70}",
35
+ "$description": "Media scrim — the dim behind a video dialog; heavier than --a63-scrim because the video is the only thing on screen."
36
+ }
37
+ },
38
+ "on-media": {
39
+ "foreground": {
40
+ "$type": "color",
41
+ "$value": "{color.white.100}",
42
+ "$description": "On media — icons and text on controls that float over photos and video, whose colors are unknowable."
43
+ },
44
+ "surface": {
45
+ "$type": "color",
46
+ "$value": "{color.black.60}",
47
+ "$description": "On media — the backplate of a floating control, dark enough that its foreground reads over any picture."
48
+ },
49
+ "surface-strong": {
50
+ "$type": "color",
51
+ "$value": "{color.black.70}",
52
+ "$description": "On media — the backplate at rest for a primary control (play) and on hover for the others."
53
+ },
54
+ "border": {
55
+ "$type": "color",
56
+ "$value": "{color.white.20}",
57
+ "$description": "On media — the hairline that separates a floating control from a dark picture."
58
+ },
59
+ "ring": {
60
+ "$type": "color",
61
+ "$value": "{color.white.90}",
62
+ "$description": "On media — the focus ring for controls over media."
63
+ },
64
+ "veil": {
65
+ "$type": "color",
66
+ "$value": "{color.black.10}",
67
+ "$description": "On media — a light veil over a poster while it waits."
68
+ },
69
+ "veil-strong": {
70
+ "$type": "color",
71
+ "$value": "{color.black.20}",
72
+ "$description": "On media — the veil over a poster while a control on it is shown."
73
+ }
74
+ }
75
+ }
76
+ }
77
+ ],
78
+ "$extensions": {
79
+ "io.atom63.css": {
80
+ "selector": ":root"
81
+ }
82
+ }
83
+ }
84
+ },
85
+ "modifiers": {
86
+ "mode": {
87
+ "default": "light",
88
+ "contexts": {
89
+ "light": [
90
+ {
91
+ "a63": {
92
+ "surface": {
93
+ "page": {
94
+ "$type": "color",
95
+ "$value": "{surface.light.2}",
96
+ "$extensions": {
97
+ "io.atom63.derive": "color-mix( in oklab, {surface.light.2} calc(100% - {a63.surface.tint}), {a63.brand.100} {a63.surface.tint} )"
98
+ },
99
+ "$description": "Surfaces — neutral, optionally bent toward the brand hue by --a63-surface-tint\n(0% = pure neutral). Each mixes with a lightness-matched --a63-brand-* step."
100
+ },
101
+ "panel": {
102
+ "$type": "color",
103
+ "$value": "{surface.light.1}",
104
+ "$extensions": {
105
+ "io.atom63.derive": "color-mix( in oklab, {surface.light.1} calc(100% - {a63.surface.tint}), {a63.brand.50} {a63.surface.tint} )"
106
+ }
107
+ },
108
+ "overlay": {
109
+ "$type": "color",
110
+ "$value": "{surface.light.1}",
111
+ "$extensions": {
112
+ "io.atom63.derive": "color-mix( in oklab, {surface.light.1} calc(100% - {a63.surface.tint}), {a63.brand.50} {a63.surface.tint} )"
113
+ }
114
+ },
115
+ "muted": {
116
+ "$type": "color",
117
+ "$value": "{surface.light.3}",
118
+ "$extensions": {
119
+ "io.atom63.derive": "color-mix( in oklab, {surface.light.3} calc(100% - {a63.surface.tint}), {a63.brand.200} {a63.surface.tint} )"
120
+ }
121
+ },
122
+ "control": {
123
+ "$root": {
124
+ "$type": "color",
125
+ "$value": "{surface.light.1}",
126
+ "$extensions": {
127
+ "io.atom63.derive": "color-mix( in oklab, {surface.light.1} calc(100% - {a63.surface.tint}), {a63.brand.50} {a63.surface.tint} )"
128
+ },
129
+ "$description": "Recessed input surface (the field fill). Brightest surface in light mode so a\nfield reads as a clean well recessed into its panel via --a63-field-shadow."
130
+ },
131
+ "hover": {
132
+ "$type": "color",
133
+ "$value": "{surface.light.4}",
134
+ "$extensions": {
135
+ "io.atom63.derive": "color-mix( in srgb, color-mix( in oklab, {surface.light.4} calc(100% - {a63.surface.tint}), {a63.brand.300} {a63.surface.tint} ), transparent 20% )"
136
+ },
137
+ "$description": "Translucent hover plate. The BASE bends toward the brand hue by the surface\ntint (same surface-4 -> brand-300 step as --a63-border-subtle) so it stays in\nfamily on tinted themes instead of reading as a raw neutral grey; the outer\nmix keeps the 20% translucency (value-identical at tint 0)."
138
+ }
139
+ }
140
+ },
141
+ "text": {
142
+ "primary": {
143
+ "$type": "color",
144
+ "$value": "{surface.light.12}",
145
+ "$description": "Text"
146
+ },
147
+ "secondary": {
148
+ "$type": "color",
149
+ "$value": "{surface.light.11}"
150
+ },
151
+ "accent": {
152
+ "$type": "color",
153
+ "$value": "{a63.brand.text}",
154
+ "$description": "The brand as text (links, accents) on light surfaces; brand.css picks the\nramp step per brand. Use --a63-action-primary for fills."
155
+ },
156
+ "danger": {
157
+ "$type": "color",
158
+ "$value": "{color.danger.600}",
159
+ "$description": "Danger text: error messages and destructive labels on surfaces. Step 600 on\nlight surfaces; --a63-action-danger stays the fill for danger buttons."
160
+ }
161
+ },
162
+ "border": {
163
+ "subtle": {
164
+ "$type": "color",
165
+ "$value": "{surface.light.4}",
166
+ "$extensions": {
167
+ "io.atom63.derive": "color-mix( in oklab, {surface.light.4} calc(100% - {a63.surface.tint}), {a63.brand.300} {a63.surface.tint} )"
168
+ },
169
+ "$description": "Border"
170
+ },
171
+ "control": {
172
+ "$type": "color",
173
+ "$value": "{surface.light.5}",
174
+ "$extensions": {
175
+ "io.atom63.derive": "color-mix( in oklab, {surface.light.5} calc(100% - {a63.surface.tint}), {a63.brand.400} {a63.surface.tint} )"
176
+ }
177
+ }
178
+ },
179
+ "action": {
180
+ "neutral": {
181
+ "$root": {
182
+ "$type": "color",
183
+ "$value": "{surface.light.12}",
184
+ "$description": "Action — primary + focus ring live in tokens/brand.css (brand-ramp scoped).\nNeutral = the default variant's fill; sourced from surfaces (NOT --a63-text-*)\nso a theme can recolor text without turning the default button into a fill."
185
+ },
186
+ "foreground": {
187
+ "$type": "color",
188
+ "$value": "{surface.light.2}"
189
+ }
190
+ },
191
+ "danger": {
192
+ "$root": {
193
+ "$type": "color",
194
+ "$value": "{color.danger.600}"
195
+ },
196
+ "hover": {
197
+ "$type": "color",
198
+ "$value": "{a63.action.danger}",
199
+ "$extensions": {
200
+ "io.atom63.derive": "color-mix(in oklch, {a63.action.danger} 90%, transparent)"
201
+ }
202
+ },
203
+ "foreground": {
204
+ "$type": "color",
205
+ "$value": "{color.white.100}",
206
+ "$extensions": {
207
+ "io.atom63.derive": "white"
208
+ }
209
+ }
210
+ }
211
+ },
212
+ "status": {
213
+ "info": {
214
+ "$root": {
215
+ "$type": "color",
216
+ "$value": "{color.info.600}",
217
+ "$description": "Status (danger's status role is served by --a63-action-danger). The base is\nthe accent used for tinted callouts (bg = mix toward transparent, text/border\n= the accent); -foreground is the text/icon color ON a SOLID status fill.\nStep 600 on light surfaces and 500 on dark ones (the .dark block), so icons\ndrawn in the accent reach WCAG's 3:1 for graphics in both modes."
218
+ },
219
+ "foreground": {
220
+ "$type": "color",
221
+ "$value": "{color.white.100}",
222
+ "$extensions": {
223
+ "io.atom63.derive": "white"
224
+ }
225
+ }
226
+ },
227
+ "success": {
228
+ "$root": {
229
+ "$type": "color",
230
+ "$value": "{color.success.600}"
231
+ },
232
+ "foreground": {
233
+ "$type": "color",
234
+ "$value": "{color.white.100}",
235
+ "$extensions": {
236
+ "io.atom63.derive": "white"
237
+ }
238
+ }
239
+ },
240
+ "warning": {
241
+ "$root": {
242
+ "$type": "color",
243
+ "$value": "{color.warning.600}"
244
+ },
245
+ "foreground": {
246
+ "$type": "color",
247
+ "$value": "{color.white.100}",
248
+ "$extensions": {
249
+ "io.atom63.derive": "white"
250
+ }
251
+ }
252
+ }
253
+ }
254
+ }
255
+ }
256
+ ],
257
+ "dark": [
258
+ {
259
+ "a63": {
260
+ "surface": {
261
+ "page": {
262
+ "$type": "color",
263
+ "$value": "{surface.dark.1}",
264
+ "$extensions": {
265
+ "io.atom63.derive": "color-mix( in oklab, {surface.dark.1} calc(100% - {a63.surface.tint}), {a63.brand.950} {a63.surface.tint} )"
266
+ }
267
+ },
268
+ "panel": {
269
+ "$type": "color",
270
+ "$value": "{surface.dark.2}",
271
+ "$extensions": {
272
+ "io.atom63.derive": "color-mix( in oklab, {surface.dark.2} calc(100% - {a63.surface.tint}), {a63.brand.900} {a63.surface.tint} )"
273
+ }
274
+ },
275
+ "overlay": {
276
+ "$type": "color",
277
+ "$value": "{surface.dark.4}",
278
+ "$extensions": {
279
+ "io.atom63.derive": "color-mix( in oklab, {surface.dark.4} calc(100% - {a63.surface.tint}), {a63.brand.800} {a63.surface.tint} )"
280
+ }
281
+ },
282
+ "muted": {
283
+ "$type": "color",
284
+ "$value": "{surface.dark.3}",
285
+ "$extensions": {
286
+ "io.atom63.derive": "color-mix( in oklab, {surface.dark.3} calc(100% - {a63.surface.tint}), {a63.brand.800} {a63.surface.tint} )"
287
+ }
288
+ },
289
+ "control": {
290
+ "$root": {
291
+ "$type": "color",
292
+ "$value": "{surface.dark.1}",
293
+ "$extensions": {
294
+ "io.atom63.derive": "color-mix( in oklab, {surface.dark.1} calc(100% - {a63.surface.tint}), {a63.brand.950} {a63.surface.tint} )"
295
+ },
296
+ "$description": "Recessed input surface — darkest surface in dark mode, so a field reads as a\nsunken well relative to its panel."
297
+ },
298
+ "hover": {
299
+ "$type": "color",
300
+ "$value": "{surface.dark.6}",
301
+ "$extensions": {
302
+ "io.atom63.derive": "color-mix( in srgb, color-mix( in oklab, {surface.dark.6} calc(100% - {a63.surface.tint}), {a63.brand.600} {a63.surface.tint} ), transparent 20% )"
303
+ },
304
+ "$description": "Tint-aware translucent hover plate (dark) — surface-6 -> brand-600, matching\n--a63-border-subtle; outer mix keeps the 20% translucency."
305
+ }
306
+ }
307
+ },
308
+ "text": {
309
+ "primary": {
310
+ "$type": "color",
311
+ "$value": "{surface.dark.12}"
312
+ },
313
+ "secondary": {
314
+ "$type": "color",
315
+ "$value": "{surface.dark.11}"
316
+ },
317
+ "accent": {
318
+ "$type": "color",
319
+ "$value": "{a63.brand.400}",
320
+ "$description": "The primary fill is too dark to read as text on dark surfaces."
321
+ },
322
+ "danger": {
323
+ "$type": "color",
324
+ "$value": "{color.danger.400}",
325
+ "$description": "Danger text on dark surfaces: step 400 reaches WCAG AA 4.5:1 on every theme's\ndark page and panel (step 600, the fill, is about 2.7:1 there)."
326
+ }
327
+ },
328
+ "border": {
329
+ "subtle": {
330
+ "$type": "color",
331
+ "$value": "{surface.dark.6}",
332
+ "$extensions": {
333
+ "io.atom63.derive": "color-mix( in oklab, {surface.dark.6} calc(100% - {a63.surface.tint}), {a63.brand.600} {a63.surface.tint} )"
334
+ }
335
+ },
336
+ "control": {
337
+ "$type": "color",
338
+ "$value": "{surface.dark.7}",
339
+ "$extensions": {
340
+ "io.atom63.derive": "color-mix( in oklab, {surface.dark.7} calc(100% - {a63.surface.tint}), {a63.brand.500} {a63.surface.tint} )"
341
+ }
342
+ }
343
+ },
344
+ "action": {
345
+ "neutral": {
346
+ "$root": {
347
+ "$type": "color",
348
+ "$value": "{surface.dark.12}"
349
+ },
350
+ "foreground": {
351
+ "$type": "color",
352
+ "$value": "{surface.dark.1}"
353
+ }
354
+ },
355
+ "danger": {
356
+ "hover": {
357
+ "$type": "color",
358
+ "$value": "{a63.action.danger}",
359
+ "$extensions": {
360
+ "io.atom63.derive": "color-mix(in oklch, {a63.action.danger} 82%, white 8%)"
361
+ }
362
+ }
363
+ }
364
+ },
365
+ "status": {
366
+ "info": {
367
+ "$type": "color",
368
+ "$value": "{color.info.500}"
369
+ },
370
+ "success": {
371
+ "$type": "color",
372
+ "$value": "{color.success.500}"
373
+ },
374
+ "warning": {
375
+ "$type": "color",
376
+ "$value": "{color.warning.500}"
377
+ }
378
+ }
379
+ }
380
+ }
381
+ ]
382
+ }
383
+ }
384
+ },
385
+ "resolutionOrder": [
386
+ {
387
+ "$ref": "#/sets/base"
388
+ },
389
+ {
390
+ "$ref": "#/modifiers/mode"
391
+ }
392
+ ],
393
+ "$extensions": {
394
+ "io.atom63.css": {
395
+ "attribute": "data-a63-mode",
396
+ "selectors": {
397
+ "light": ":root,\n.light,\n[data-a63-mode='light']",
398
+ "dark": ":is(.dark, [data-a63-mode='dark'])"
399
+ }
400
+ }
401
+ }
402
+ }
@@ -1,21 +1,23 @@
1
1
  /*
2
+ * Generated from src/tokens/space.tokens.json by scripts/build-css-from-dtcg.mjs. Do not edit;
3
+ * change the DTCG source and run `pnpm --filter @atom63/styles generate:tokens`.
4
+ *
2
5
  * Space contract.
3
6
  *
4
7
  * A proportional unit + the compact set of aliases the system actually uses, so
5
8
  * density can tune rhythm without component-local spacing scales. Raw --spacing-*
6
9
  * primitives remain available for anything outside this set.
7
10
  */
8
-
9
11
  :root {
10
- --a63-space-unit: var(--spacing-1);
11
- --a63-space-0_5: calc(var(--a63-space-unit) * 0.5);
12
12
  --a63-space-1: var(--a63-space-unit);
13
- --a63-space-1_5: calc(var(--a63-space-unit) * 1.5);
14
13
  --a63-space-2: calc(var(--a63-space-unit) * 2);
15
- --a63-space-2_5: calc(var(--a63-space-unit) * 2.5);
16
14
  --a63-space-3: calc(var(--a63-space-unit) * 3);
17
- --a63-space-3_5: calc(var(--a63-space-unit) * 3.5);
18
15
  --a63-space-4: calc(var(--a63-space-unit) * 4);
19
16
  --a63-space-5: calc(var(--a63-space-unit) * 5);
20
17
  --a63-space-6: calc(var(--a63-space-unit) * 6);
18
+ --a63-space-unit: var(--spacing-1);
19
+ --a63-space-0_5: calc(var(--a63-space-unit) * 0.5);
20
+ --a63-space-1_5: calc(var(--a63-space-unit) * 1.5);
21
+ --a63-space-2_5: calc(var(--a63-space-unit) * 2.5);
22
+ --a63-space-3_5: calc(var(--a63-space-unit) * 3.5);
21
23
  }
@@ -0,0 +1,78 @@
1
+ {
2
+ "$description": "Space contract.\n\nA proportional unit + the compact set of aliases the system actually uses, so\ndensity can tune rhythm without component-local spacing scales. Raw --spacing-*\nprimitives remain available for anything outside this set.",
3
+ "a63": {
4
+ "space": {
5
+ "unit": {
6
+ "$type": "dimension",
7
+ "$value": "{spacing.1}"
8
+ },
9
+ "0_5": {
10
+ "$type": "dimension",
11
+ "$value": "{a63.space.unit}",
12
+ "$extensions": {
13
+ "io.atom63.derive": "calc({a63.space.unit} * 0.5)"
14
+ }
15
+ },
16
+ "1": {
17
+ "$type": "dimension",
18
+ "$value": "{a63.space.unit}"
19
+ },
20
+ "1_5": {
21
+ "$type": "dimension",
22
+ "$value": "{a63.space.unit}",
23
+ "$extensions": {
24
+ "io.atom63.derive": "calc({a63.space.unit} * 1.5)"
25
+ }
26
+ },
27
+ "2": {
28
+ "$type": "dimension",
29
+ "$value": "{a63.space.unit}",
30
+ "$extensions": {
31
+ "io.atom63.derive": "calc({a63.space.unit} * 2)"
32
+ }
33
+ },
34
+ "2_5": {
35
+ "$type": "dimension",
36
+ "$value": "{a63.space.unit}",
37
+ "$extensions": {
38
+ "io.atom63.derive": "calc({a63.space.unit} * 2.5)"
39
+ }
40
+ },
41
+ "3": {
42
+ "$type": "dimension",
43
+ "$value": "{a63.space.unit}",
44
+ "$extensions": {
45
+ "io.atom63.derive": "calc({a63.space.unit} * 3)"
46
+ }
47
+ },
48
+ "3_5": {
49
+ "$type": "dimension",
50
+ "$value": "{a63.space.unit}",
51
+ "$extensions": {
52
+ "io.atom63.derive": "calc({a63.space.unit} * 3.5)"
53
+ }
54
+ },
55
+ "4": {
56
+ "$type": "dimension",
57
+ "$value": "{a63.space.unit}",
58
+ "$extensions": {
59
+ "io.atom63.derive": "calc({a63.space.unit} * 4)"
60
+ }
61
+ },
62
+ "5": {
63
+ "$type": "dimension",
64
+ "$value": "{a63.space.unit}",
65
+ "$extensions": {
66
+ "io.atom63.derive": "calc({a63.space.unit} * 5)"
67
+ }
68
+ },
69
+ "6": {
70
+ "$type": "dimension",
71
+ "$value": "{a63.space.unit}",
72
+ "$extensions": {
73
+ "io.atom63.derive": "calc({a63.space.unit} * 6)"
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
@@ -0,0 +1,137 @@
1
+ import { afterEach, describe, expect, it } from 'vitest'
2
+ import swiftTokens from '../../../ui-ios/Sources/Atom63UI/Generated/Atom63Tokens.generated.swift?raw'
3
+ // @ts-expect-error -- plain ESM module shared with the Swift generator, no types
4
+ import {
5
+ brands,
6
+ createResolver,
7
+ skins,
8
+ surfaces,
9
+ } from '../../../ui-ios/Scripts/lib/theme-graph.mjs'
10
+ import computedValues from '../../generated/atom63.computed-values.json'
11
+ import figmaModel from '../../generated/atom63.figma-sync.json'
12
+ import { resetRoot, root } from '../test/apply-styles'
13
+
14
+ /*
15
+ * Web/iOS parity: every color in the generated Swift tokens must equal what the
16
+ * browser paints for its token, in light and dark mode, with the defaults an
17
+ * app starts with (modern theme, brand b1, surface n1). The Swift generator
18
+ * reads the Figma sync model; this test checks that model against the real CSS
19
+ * cascade, so a drift in either shows up here.
20
+ */
21
+
22
+ interface Rgba {
23
+ r: number
24
+ g: number
25
+ b: number
26
+ a: number
27
+ }
28
+
29
+ const colorPattern =
30
+ /\/\/\/ (--[\w-]+)\n\s+public static let (\w+) = AtomDynamicColor\(light: AtomColorComponents\(red: ([\d.]+), green: ([\d.]+), blue: ([\d.]+), opacity: ([\d.]+)\), dark: AtomColorComponents\(red: ([\d.]+), green: ([\d.]+), blue: ([\d.]+), opacity: ([\d.]+)\)\)/g
31
+
32
+ const swiftColors = [...swiftTokens.matchAll(colorPattern)].map(match => {
33
+ const [, token, name, ...channels] = match
34
+ const n = channels.map(Number)
35
+ return {
36
+ token,
37
+ name,
38
+ light: { r: n[0] * 255, g: n[1] * 255, b: n[2] * 255, a: n[3] },
39
+ dark: { r: n[4] * 255, g: n[5] * 255, b: n[6] * 255, a: n[7] },
40
+ }
41
+ })
42
+
43
+ /** Paints the token on one pixel and reads it back as sRGB. */
44
+ function paint(token: string): Rgba {
45
+ const probe = document.createElement('div')
46
+ probe.style.color = `var(${token})`
47
+ document.body.append(probe)
48
+ const color = getComputedStyle(probe).color
49
+ probe.remove()
50
+ const canvas = document.createElement('canvas')
51
+ canvas.width = 1
52
+ canvas.height = 1
53
+ const context = canvas.getContext('2d', { colorSpace: 'srgb' })!
54
+ context.fillStyle = color
55
+ context.fillRect(0, 0, 1, 1)
56
+ const [r, g, b, a] = context.getImageData(0, 0, 1, 1).data
57
+ return { r, g, b, a: a / 255 }
58
+ }
59
+
60
+ function setMode(mode: 'light' | 'dark') {
61
+ root().setAttribute('data-a63-design-language', 'ios')
62
+ root().setAttribute('data-a63-mode', mode)
63
+ root().classList.remove('light', 'dark')
64
+ root().classList.add(mode)
65
+ }
66
+
67
+ afterEach(() => {
68
+ resetRoot()
69
+ for (const attribute of ['data-a63-mode', 'data-a63-theme', 'data-a63-surface'])
70
+ root().removeAttribute(attribute)
71
+ root().classList.remove('light', 'dark')
72
+ })
73
+
74
+ describe('web/iOS color parity', () => {
75
+ it('reads the Swift colors', () => {
76
+ expect(swiftColors.length).toBeGreaterThan(20)
77
+ })
78
+
79
+ it('matches every Swift color to the browser value in light and dark mode', () => {
80
+ const failures: string[] = []
81
+ for (const mode of ['light', 'dark'] as const) {
82
+ setMode(mode)
83
+ for (const color of swiftColors) {
84
+ const web = paint(color.token)
85
+ const swift = color[mode]
86
+ // One 8-bit step for rounding; alpha is premultiplied by the canvas read.
87
+ const drift = Math.max(
88
+ Math.abs(web.r - swift.r),
89
+ Math.abs(web.g - swift.g),
90
+ Math.abs(web.b - swift.b),
91
+ Math.abs(web.a - swift.a) * 255
92
+ )
93
+ if (drift > 1.5) {
94
+ failures.push(
95
+ `${mode} ${color.name} (${color.token}): web rgba(${web.r}, ${web.g}, ${web.b}, ${web.a.toFixed(2)}), ` +
96
+ `swift rgba(${swift.r.toFixed(1)}, ${swift.g.toFixed(1)}, ${swift.b.toFixed(1)}, ${swift.a})`
97
+ )
98
+ }
99
+ }
100
+ }
101
+ expect(failures, failures.join('\n')).toEqual([])
102
+ })
103
+
104
+ /*
105
+ * AtomTheme(skin:brand:surface:) resolves through the token graph the Swift
106
+ * generator emits, with the same algorithm as Scripts/lib/theme-graph.mjs (the
107
+ * Swift tests check the port against that module). Here the module's result is
108
+ * checked against the browser for every skin, brand, surface and mode.
109
+ */
110
+ it('matches every color the Swift theme resolves, for every skin × brand × surface × mode', () => {
111
+ const resolver = createResolver(figmaModel, computedValues)
112
+ const failures: string[] = []
113
+ for (const skin of skins as string[])
114
+ for (const brand of brands as string[])
115
+ for (const surface of surfaces as string[])
116
+ for (const mode of ['light', 'dark'] as const) {
117
+ setMode(mode)
118
+ root().setAttribute('data-a63-theme', skin)
119
+ root().setAttribute('data-a63-brand', brand)
120
+ root().setAttribute('data-a63-surface', surface)
121
+ for (const color of swiftColors) {
122
+ const web = paint(color.token)
123
+ const graph = resolver.resolve(color.token, { skin, brand, surface, mode })
124
+ // Compare premultiplied, as the canvas stores it: a translucent
125
+ // color's channels are only exact to 1/255 after multiplying by alpha.
126
+ const drift = Math.max(
127
+ Math.abs(web.r * web.a - graph.r * 255 * graph.a),
128
+ Math.abs(web.g * web.a - graph.g * 255 * graph.a),
129
+ Math.abs(web.b * web.a - graph.b * 255 * graph.a),
130
+ Math.abs(web.a - graph.a) * 255
131
+ )
132
+ if (drift > 1.5) failures.push(`${skin}/${brand}/${surface}/${mode} ${color.name}`)
133
+ }
134
+ }
135
+ expect(failures.slice(0, 20), `${failures.length} differences`).toEqual([])
136
+ })
137
+ })
@@ -1,4 +1,7 @@
1
1
  /*
2
+ * Generated from src/tokens/type-scale.resolver.json by scripts/build-css-from-dtcg.mjs. Do not edit;
3
+ * change the DTCG source and run `pnpm --filter @atom63/styles generate:tokens`.
4
+ *
2
5
  * Typography personalization axis.
3
6
  *
4
7
  * [data-a63-type-scale] sets the multiplier the responsive type scale
@@ -9,12 +12,15 @@
9
12
  [data-a63-type-scale='compact'] {
10
13
  --typography-scale: 0.9;
11
14
  }
15
+
12
16
  [data-a63-type-scale='normal'] {
13
17
  --typography-scale: 1;
14
18
  }
19
+
15
20
  [data-a63-type-scale='comfortable'] {
16
21
  --typography-scale: 1.1;
17
22
  }
23
+
18
24
  [data-a63-type-scale='large'] {
19
25
  --typography-scale: 1.2;
20
26
  }