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

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 (100) hide show
  1. package/README.md +16 -10
  2. package/generated/atom63.figma-sync.json +12897 -6323
  3. package/generated/atom63.tokens.json +8778 -3550
  4. package/package.json +8 -7
  5. package/src/compat/a63-from-shadcn.css +10 -0
  6. package/src/compat/shadcn.browser.test.ts +23 -0
  7. package/src/compat/shadcn.css +118 -16
  8. package/src/contracts/action.css +4 -3
  9. package/src/contracts/action.native.css +11 -0
  10. package/src/contracts/action.tokens.json +66 -0
  11. package/src/contracts/badge.css +83 -58
  12. package/src/contracts/badge.resolver.json +449 -0
  13. package/src/contracts/choice.css +4 -1
  14. package/src/contracts/choice.native.css +9 -0
  15. package/src/contracts/choice.tokens.json +66 -0
  16. package/src/contracts/control.css +43 -52
  17. package/src/contracts/control.native.css +13 -0
  18. package/src/contracts/control.tokens.json +245 -0
  19. package/src/contracts/environment.css +45 -49
  20. package/src/contracts/environment.native.css +23 -0
  21. package/src/contracts/environment.resolver.json +569 -0
  22. package/src/contracts/field.css +3 -1
  23. package/src/contracts/field.tokens.json +40 -0
  24. package/src/contracts/marker.css +6 -4
  25. package/src/contracts/marker.tokens.json +15 -0
  26. package/src/contracts/menu.css +25 -61
  27. package/src/contracts/menu.native.css +10 -0
  28. package/src/contracts/menu.resolver.json +122 -0
  29. package/src/contracts/overlay.css +11 -13
  30. package/src/contracts/overlay.native.css +13 -0
  31. package/src/contracts/overlay.tokens.json +103 -0
  32. package/src/contracts/segment.css +22 -68
  33. package/src/contracts/segment.tokens.json +19 -0
  34. package/src/contracts/selection.css +3 -1
  35. package/src/contracts/selection.tokens.json +37 -0
  36. package/src/contracts/skeleton.css +3 -0
  37. package/src/contracts/skeleton.resolver.json +66 -0
  38. package/src/contracts/surface.css +13 -24
  39. package/src/contracts/surface.native.css +17 -0
  40. package/src/contracts/surface.tokens.json +97 -0
  41. package/src/contracts/toggle.css +3 -1
  42. package/src/contracts/toggle.tokens.json +49 -0
  43. package/src/contracts/track.css +3 -1
  44. package/src/contracts/track.tokens.json +39 -0
  45. package/src/contracts/trigger.css +5 -2
  46. package/src/contracts/trigger.native.css +9 -0
  47. package/src/contracts/trigger.tokens.json +58 -0
  48. package/src/contracts/widget.css +41 -51
  49. package/src/contracts/widget.native.css +23 -0
  50. package/src/contracts/widget.resolver.json +1104 -0
  51. package/src/tailwind/roles.json +172 -0
  52. package/src/tailwind/theme.css +107 -23
  53. package/src/themes/aqua.css +24 -89
  54. package/src/themes/aqua.native.css +80 -0
  55. package/src/themes/aqua.resolver.json +1292 -0
  56. package/src/themes/modern.css +10 -14
  57. package/src/themes/modern.native.css +16 -0
  58. package/src/themes/modern.resolver.json +350 -0
  59. package/src/themes/retro.css +21 -26
  60. package/src/themes/retro.native.css +16 -0
  61. package/src/themes/retro.resolver.json +788 -0
  62. package/src/themes/terminal.css +34 -41
  63. package/src/themes/terminal.native.css +22 -0
  64. package/src/themes/terminal.resolver.json +517 -0
  65. package/src/tokens/brand-action.css +61 -0
  66. package/src/tokens/brand-action.resolver.json +137 -0
  67. package/src/tokens/brand-ramp.css +108 -0
  68. package/src/tokens/brand-ramp.resolver.json +418 -0
  69. package/src/tokens/brand.css +6 -146
  70. package/src/tokens/color-mix-space.browser.test.ts +79 -0
  71. package/src/tokens/contrast.browser.test.ts +82 -3
  72. package/src/tokens/figma-parity.browser.test.ts +270 -0
  73. package/src/tokens/font.css +6 -0
  74. package/src/tokens/font.resolver.json +107 -0
  75. package/src/tokens/foundation/effects.css +13 -13
  76. package/src/tokens/foundation/effects.resolver.json +433 -0
  77. package/src/tokens/foundation/fonts.css +3 -1
  78. package/src/tokens/foundation/fonts.tokens.json +6 -1
  79. package/src/tokens/foundation/radius.css +6 -9
  80. package/src/tokens/foundation/radius.tokens.json +100 -0
  81. package/src/tokens/foundation/typography.css +25 -12
  82. package/src/tokens/foundation/typography.native.css +11 -0
  83. package/src/tokens/foundation/typography.resolver.json +936 -0
  84. package/src/tokens/foundation.css +0 -1
  85. package/src/tokens/motion.css +3 -1
  86. package/src/tokens/motion.resolver.json +135 -0
  87. package/src/tokens/native-values.json +38 -0
  88. package/src/tokens/personalization-axes.browser.test.ts +5 -3
  89. package/src/tokens/radius.css +12 -8
  90. package/src/tokens/radius.resolver.json +138 -0
  91. package/src/tokens/semantics.css +211 -47
  92. package/src/tokens/semantics.resolver.json +1296 -0
  93. package/src/tokens/space.css +8 -6
  94. package/src/tokens/space.tokens.json +78 -0
  95. package/src/tokens/swift-parity.browser.test.ts +141 -0
  96. package/src/tokens/type-scale.css +6 -0
  97. package/src/tokens/type-scale.resolver.json +67 -0
  98. package/generated/atom63.figma-tokens.json +0 -21661
  99. package/src/tokens/foundation/aliases.css +0 -32
  100. package/src/tokens/foundation/aliases.tokens.json +0 -105
@@ -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,141 @@
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
+ // Atom63Theme always sets a theme, modern by default; the static Swift colors
63
+ // resolve that selection, and some contracts (the widget face) differ from
64
+ // the theme-less :root under it.
65
+ root().setAttribute('data-a63-theme', 'modern')
66
+ root().setAttribute('data-a63-mode', mode)
67
+ root().classList.remove('light', 'dark')
68
+ root().classList.add(mode)
69
+ }
70
+
71
+ afterEach(() => {
72
+ resetRoot()
73
+ for (const attribute of ['data-a63-mode', 'data-a63-theme', 'data-a63-surface'])
74
+ root().removeAttribute(attribute)
75
+ root().classList.remove('light', 'dark')
76
+ })
77
+
78
+ describe('web/iOS color parity', () => {
79
+ it('reads the Swift colors', () => {
80
+ expect(swiftColors.length).toBeGreaterThan(20)
81
+ })
82
+
83
+ it('matches every Swift color to the browser value in light and dark mode', () => {
84
+ const failures: string[] = []
85
+ for (const mode of ['light', 'dark'] as const) {
86
+ setMode(mode)
87
+ for (const color of swiftColors) {
88
+ const web = paint(color.token)
89
+ const swift = color[mode]
90
+ // One 8-bit step for rounding; alpha is premultiplied by the canvas read.
91
+ const drift = Math.max(
92
+ Math.abs(web.r - swift.r),
93
+ Math.abs(web.g - swift.g),
94
+ Math.abs(web.b - swift.b),
95
+ Math.abs(web.a - swift.a) * 255
96
+ )
97
+ if (drift > 1.5) {
98
+ failures.push(
99
+ `${mode} ${color.name} (${color.token}): web rgba(${web.r}, ${web.g}, ${web.b}, ${web.a.toFixed(2)}), ` +
100
+ `swift rgba(${swift.r.toFixed(1)}, ${swift.g.toFixed(1)}, ${swift.b.toFixed(1)}, ${swift.a})`
101
+ )
102
+ }
103
+ }
104
+ }
105
+ expect(failures, failures.join('\n')).toEqual([])
106
+ })
107
+
108
+ /*
109
+ * AtomTheme(skin:brand:surface:) resolves through the token graph the Swift
110
+ * generator emits, with the same algorithm as Scripts/lib/theme-graph.mjs (the
111
+ * Swift tests check the port against that module). Here the module's result is
112
+ * checked against the browser for every skin, brand, surface and mode.
113
+ */
114
+ it('matches every color the Swift theme resolves, for every skin × brand × surface × mode', () => {
115
+ const resolver = createResolver(figmaModel, computedValues)
116
+ const failures: string[] = []
117
+ for (const skin of skins as string[])
118
+ for (const brand of brands as string[])
119
+ for (const surface of surfaces as string[])
120
+ for (const mode of ['light', 'dark'] as const) {
121
+ setMode(mode)
122
+ root().setAttribute('data-a63-theme', skin)
123
+ root().setAttribute('data-a63-brand', brand)
124
+ root().setAttribute('data-a63-surface', surface)
125
+ for (const color of swiftColors) {
126
+ const web = paint(color.token)
127
+ const graph = resolver.resolve(color.token, { skin, brand, surface, mode })
128
+ // Compare premultiplied, as the canvas stores it: a translucent
129
+ // color's channels are only exact to 1/255 after multiplying by alpha.
130
+ const drift = Math.max(
131
+ Math.abs(web.r * web.a - graph.r * 255 * graph.a),
132
+ Math.abs(web.g * web.a - graph.g * 255 * graph.a),
133
+ Math.abs(web.b * web.a - graph.b * 255 * graph.a),
134
+ Math.abs(web.a - graph.a) * 255
135
+ )
136
+ if (drift > 1.5) failures.push(`${skin}/${brand}/${surface}/${mode} ${color.name}`)
137
+ }
138
+ }
139
+ expect(failures.slice(0, 20), `${failures.length} differences`).toEqual([])
140
+ })
141
+ })
@@ -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
  }
@@ -0,0 +1,67 @@
1
+ {
2
+ "version": "2025.10",
3
+ "description": "Typography personalization axis.\n\n[data-a63-type-scale] sets the multiplier the responsive type scale\n(foundation/typography.css) already multiplies every size + line-height by.\n`normal` = 1 restates the foundation default (--typography-scale defaults to 1\nvia its calc fallback) so a subtree can reset it.",
4
+ "modifiers": {
5
+ "type-scale": {
6
+ "default": "normal",
7
+ "contexts": {
8
+ "compact": [
9
+ {
10
+ "typography": {
11
+ "scale": {
12
+ "$type": "number",
13
+ "$value": 0.9
14
+ }
15
+ }
16
+ }
17
+ ],
18
+ "normal": [
19
+ {
20
+ "typography": {
21
+ "scale": {
22
+ "$type": "number",
23
+ "$value": 1
24
+ }
25
+ }
26
+ }
27
+ ],
28
+ "comfortable": [
29
+ {
30
+ "typography": {
31
+ "scale": {
32
+ "$type": "number",
33
+ "$value": 1.1
34
+ }
35
+ }
36
+ }
37
+ ],
38
+ "large": [
39
+ {
40
+ "typography": {
41
+ "scale": {
42
+ "$type": "number",
43
+ "$value": 1.2
44
+ }
45
+ }
46
+ }
47
+ ]
48
+ }
49
+ }
50
+ },
51
+ "resolutionOrder": [
52
+ {
53
+ "$ref": "#/modifiers/type-scale"
54
+ }
55
+ ],
56
+ "$extensions": {
57
+ "io.atom63.css": {
58
+ "attribute": "data-a63-type-scale",
59
+ "selectors": {
60
+ "compact": "[data-a63-type-scale='compact']",
61
+ "normal": "[data-a63-type-scale='normal']",
62
+ "comfortable": "[data-a63-type-scale='comfortable']",
63
+ "large": "[data-a63-type-scale='large']"
64
+ }
65
+ }
66
+ }
67
+ }