@podoba/tokens 0.0.32 → 0.0.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@podoba/tokens",
3
- "version": "0.0.32",
3
+ "version": "0.0.35",
4
4
  "type": "module",
5
5
  "description": "podoba design tokens — static DTCG tokens.json + generated CSS custom properties. Framework-agnostic.",
6
6
  "repository": {
@@ -19,8 +19,20 @@ function parseBlock(selector: string): Record<string, string> {
19
19
  const m = css.match(new RegExp(`${selector}\\s*\\{([^}]*)\\}`))
20
20
  if (!m) throw new Error(`selector ${selector} not found in variables.css`)
21
21
  const vars: Record<string, string> = {}
22
- for (const [, name, hex] of m[1].matchAll(/--color-([a-z0-9-]+):\s*(#[0-9a-fA-F]{6})\b/g)) {
23
- vars[name] = hex
22
+ // EVERY `--color-*` declaration is captured, whatever its value shape, and an
23
+ // unrecognised one is a hard error. Matching a narrow value pattern instead
24
+ // drops the token from `vars` with no signal — and for a token that appears
25
+ // only as a DARK override, the pair then silently re-tests the inherited LIGHT
26
+ // value and reports a fiction. That is the failure this harness exists to
27
+ // prevent, so it must not be able to happen to the harness itself.
28
+ for (const [, name, raw] of m[1].matchAll(/--color-([a-z0-9-]+):\s*([^;]+);/g)) {
29
+ const value = raw.trim()
30
+ if (!/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/.test(value)) {
31
+ throw new Error(
32
+ `--color-${name} in ${selector} is \`${value}\` — this harness only understands 6- or 8-digit hex. Teach it that form (and how to composite it) before the token lands.`,
33
+ )
34
+ }
35
+ vars[name] = value
24
36
  }
25
37
  return vars
26
38
  }
@@ -46,6 +58,20 @@ function luminance([r, g, b]: Rgb): number {
46
58
  return 0.2126 * lr + 0.7152 * lg + 0.0722 * lb
47
59
  }
48
60
 
61
+ /**
62
+ * A static pair only means something for an OPAQUE value: a translucent token's
63
+ * effective colour depends on whatever it is composited over, which is a property
64
+ * of the layout, not of the token. Fail loudly rather than measure a fiction.
65
+ */
66
+ function opaque(name: string, hex: string): string {
67
+ if (hex.length !== 7) {
68
+ throw new Error(
69
+ `token ${name} is translucent (${hex}) — its effective colour depends on what it composites over, so it cannot be an operand of a static pair`,
70
+ )
71
+ }
72
+ return hex
73
+ }
74
+
49
75
  function ratio(fgHex: string, bgHex: string): number {
50
76
  const [a, b] = [luminance(rgb(fgHex)), luminance(rgb(bgHex))]
51
77
  return (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05)
@@ -66,14 +92,24 @@ const SOLID_PAIRS: Array<[fg: string, bg: string]> = [
66
92
  ['fg-on-brand', 'accent-yellow'],
67
93
  // flipping inverted surface × flipping inverted ink (Badge dark, Tile dark)
68
94
  ['fg-inverted', 'surface-inverted'],
69
- // grey Badge (fg-muted on surface-muted was ~3.7:1 — below AA for caption text)
95
+ // grey Badge — full `fg` ink. #19 lifted `fg-muted` on `surface-muted` from 3.64:1
96
+ // to 4.96:1, so the pair is no longer disqualified, but a Badge is caption-size and
97
+ // keeps the stronger ink; this pair is what that choice is asserted against.
70
98
  ['fg', 'surface-muted'],
71
99
  // general body-copy sanity
72
100
  ['fg', 'surface'],
73
- // NOT listed: ['fg-muted', 'surface'] — #7d786f on #ffffff measures ~4.39:1,
74
- // just under AA, despite the token's "AA-compliant grey on white" description.
75
- // Pre-existing, system-wide, and owned by the upstream token source — tracked
76
- // as its own issue; add the pair here once the value is corrected.
101
+ // #19: `fg-muted` was #7d786f, which cleared NONE of its own surfaces (4.39:1 on
102
+ // white, 4.06:1 on surface-card, 3.64:1 on surface-muted) while its description
103
+ // called itself "AA-compliant grey on white". The upstream token source darkened
104
+ // it to #67635b; these four pairs are the ones that value was tuned against, and
105
+ // the binding one is `border`/`surface-muted` (#eceae1), not white.
106
+ ['fg-muted', 'surface'],
107
+ ['fg-muted', 'surface-card'],
108
+ ['fg-muted', 'surface-muted'],
109
+ // NOT listed: ['fg-muted', 'border'] — in light `border` IS #eceae1, so the pair
110
+ // is numerically identical to the line above, and in dark it is a translucent
111
+ // #ffffff1a hairline that `opaque()` rejects. `bg-border` is only ever a 1px rule
112
+ // in this repo (separator.tsx, dropdown-menu.tsx), never a text background.
77
113
  ]
78
114
 
79
115
  /** Alpha-blended muted tones used by Tile (`/60` dark, `/70` teal/yellow). */
@@ -82,6 +118,17 @@ const BLENDED_PAIRS: Array<[fg: string, alpha: number, bg: string]> = [
82
118
  ['fg-on-brand', 0.7, 'brand-secondary'],
83
119
  ['fg-on-brand', 0.7, 'brand-green'],
84
120
  ['fg-on-brand', 0.7, 'accent-yellow'],
121
+ // Button's inactive (disabled / pending) label: it softens the INK over the
122
+ // variant's own surface rather than fading the whole control, so every ink ×
123
+ // surface combination it can land on has to hold AA on its own.
124
+ // `primary` — inverted ink on the brand fill, kept so a submitting CTA stays
125
+ // brand-coloured.
126
+ ['fg-inverted', 0.7, 'brand-primary'],
127
+ // `secondary` (surface-card), `destructive` (surface-muted) and `ghost`, which
128
+ // is transparent and therefore inherits whichever surface it sits on.
129
+ ['fg', 0.6, 'surface-card'],
130
+ ['fg', 0.6, 'surface-muted'],
131
+ ['fg', 0.6, 'surface'],
85
132
  ]
86
133
 
87
134
  for (const [themeName, tokens] of Object.entries(THEMES)) {
@@ -89,11 +136,19 @@ for (const [themeName, tokens] of Object.entries(THEMES)) {
89
136
  test.each(SOLID_PAIRS)('%s on %s ≥ 4.5:1', (fg, bg) => {
90
137
  expect(tokens[fg]).toBeDefined()
91
138
  expect(tokens[bg]).toBeDefined()
92
- expect(ratio(tokens[fg], tokens[bg])).toBeGreaterThanOrEqual(4.5)
139
+ expect(ratio(opaque(fg, tokens[fg]), opaque(bg, tokens[bg]))).toBeGreaterThanOrEqual(4.5)
93
140
  })
94
141
 
95
142
  test.each(BLENDED_PAIRS)('%s at %d over %s ≥ 4.5:1', (fg, alpha, bg) => {
96
- expect(ratio(blend(tokens[fg], alpha, tokens[bg]), tokens[bg])).toBeGreaterThanOrEqual(4.5)
143
+ expect(tokens[fg]).toBeDefined()
144
+ expect(tokens[bg]).toBeDefined()
145
+
146
+ // `blend()` applies the alpha ITSELF, so both operands must be opaque here
147
+ // for the same reason they must be in the solid test — `rgb()` slices bytes
148
+ // 1–7 and would silently discard a token's own alpha channel.
149
+ const [inkHex, bgHex] = [opaque(fg, tokens[fg]), opaque(bg, tokens[bg])]
150
+
151
+ expect(ratio(blend(inkHex, alpha, bgHex), bgHex)).toBeGreaterThanOrEqual(4.5)
97
152
  })
98
153
  })
99
154
  }
package/src/tokens.json CHANGED
@@ -451,8 +451,8 @@
451
451
  },
452
452
  "muted": {
453
453
  "$type": "color",
454
- "$value": "#7d786f",
455
- "$description": "Foreground muted — secondary/body text (AA-compliant grey on white). Dark: gs neutral-200 #aba89c. NOTE: gs de-emphasized DECORATIVE text (e.g. dashboard greeting) uses a lighter grey (#b3b3b3 = fg-subtle territory) — that is a per-component token choice, not this value.",
454
+ "$value": "#67635b",
455
+ "$description": "Foreground muted — secondary/body text. Light #67635b clears the 4.5:1 normal-text floor (WCAG 2.1 AA, accessibility.md) on EVERY light surface it is paired with: 5.98:1 on surface #ffffff, 5.53:1 on surface.card #f7f6f2, 4.96:1 on surface.muted AND border #eceae1. The previous value #7d786f cleared NONE of them (4.39:1 / 4.06:1 / 3.64:1) while this very description claimed it was an \"AA-compliant grey on white\" — it missed white by 0.11. The binding surface is #eceae1, not white: its AA ceiling is L* 44.7 where white allows L* 49.9, so a value tuned to white alone still fails the panel-strong surface and the step-indicator track. Same warm-grey hue as before (~40°, ~6% sat), 8.5 L* points darker (50.6 → 42.1). Still reads as SECONDARY, not body: 3.25:1 away from fg #0d0d0d (L* 3.6) and further clear of the decorative fg.subtle #b3b3b3 (L* 72.9) than the old value was. Dark: gs neutral-200 #aba89c, unchanged and already compliant (6.52:1 on surface #242423, 5.30:1 on surface.muted #333333); --color-border is a translucent hairline on dark, so that pair is composite-dependent and not asserted. NOTE: gs de-emphasized DECORATIVE text (e.g. dashboard greeting) uses a lighter grey (#b3b3b3 = fg-subtle territory) — that is a per-component token choice, not this value.",
456
456
  "$extensions": {
457
457
  "graphicstandard": {
458
458
  "family": "color",
@@ -464,7 +464,7 @@
464
464
  "themeKey": "light",
465
465
  "online": {
466
466
  "colorSpace": "hex",
467
- "hex": "#7d786f"
467
+ "hex": "#67635b"
468
468
  }
469
469
  },
470
470
  {
@@ -1328,6 +1328,51 @@
1328
1328
  },
1329
1329
  "control": {
1330
1330
  "height": {
1331
+ "create-hub-full": {
1332
+ "$type": "dimension",
1333
+ "$value": "100vh",
1334
+ "$description": "Full mobile Create Hub sheet height from the GS Manager source.",
1335
+ "$extensions": {
1336
+ "graphicstandard": {
1337
+ "family": "dimension",
1338
+ "layer": "semantic",
1339
+ "value": {
1340
+ "kind": "scalar",
1341
+ "value": "100vh"
1342
+ }
1343
+ }
1344
+ }
1345
+ },
1346
+ "create-hub-partial": {
1347
+ "$type": "dimension",
1348
+ "$value": "40vh",
1349
+ "$description": "Partial mobile Create Hub sheet height from the GS Manager source.",
1350
+ "$extensions": {
1351
+ "graphicstandard": {
1352
+ "family": "dimension",
1353
+ "layer": "semantic",
1354
+ "value": {
1355
+ "kind": "scalar",
1356
+ "value": "40vh"
1357
+ }
1358
+ }
1359
+ }
1360
+ },
1361
+ "mobile-cta": {
1362
+ "$type": "dimension",
1363
+ "$value": "99px",
1364
+ "$description": "Minimum height of the collapsed mobile hero CTA from the GS Manager source.",
1365
+ "$extensions": {
1366
+ "graphicstandard": {
1367
+ "family": "dimension",
1368
+ "layer": "semantic",
1369
+ "value": {
1370
+ "kind": "scalar",
1371
+ "value": "99px"
1372
+ }
1373
+ }
1374
+ }
1375
+ },
1331
1376
  "tall": {
1332
1377
  "$type": "dimension",
1333
1378
  "$value": "3.625rem",
@@ -1363,6 +1408,37 @@
1363
1408
  }
1364
1409
  },
1365
1410
  "shadow": {
1411
+ "mobile-cta": {
1412
+ "$type": "shadow",
1413
+ "$value": [
1414
+ {
1415
+ "offsetX": "0",
1416
+ "offsetY": "-2px",
1417
+ "blur": "8px",
1418
+ "spread": "0",
1419
+ "color": "#00000014",
1420
+ "inset": false
1421
+ }
1422
+ ],
1423
+ "$description": "Collapsed mobile hero CTA shadow from the GS Manager source.",
1424
+ "$extensions": {
1425
+ "graphicstandard": {
1426
+ "family": "shadow",
1427
+ "layer": "semantic",
1428
+ "value": {
1429
+ "kind": "shadow",
1430
+ "value": [
1431
+ {
1432
+ "x": "0",
1433
+ "y": "-2px",
1434
+ "blur": "8px",
1435
+ "color": "#00000014"
1436
+ }
1437
+ ]
1438
+ }
1439
+ }
1440
+ }
1441
+ },
1366
1442
  "modal-surface": {
1367
1443
  "$type": "shadow",
1368
1444
  "$value": [
@@ -1410,6 +1486,119 @@
1410
1486
  }
1411
1487
  },
1412
1488
  "motion": {
1489
+ "create-hub": {
1490
+ "backdrop-duration": {
1491
+ "$type": "duration",
1492
+ "$value": "150ms",
1493
+ "$description": "Mobile Create Hub backdrop entrance duration.",
1494
+ "$extensions": {
1495
+ "graphicstandard": {
1496
+ "family": "motion",
1497
+ "layer": "semantic",
1498
+ "value": {
1499
+ "kind": "motion",
1500
+ "value": {
1501
+ "motion": "duration",
1502
+ "value": {
1503
+ "ms": 150
1504
+ }
1505
+ }
1506
+ }
1507
+ }
1508
+ }
1509
+ },
1510
+ "desktop-duration": {
1511
+ "$type": "duration",
1512
+ "$value": "400ms",
1513
+ "$description": "Desktop Create Hub right-to-left expansion duration.",
1514
+ "$extensions": {
1515
+ "graphicstandard": {
1516
+ "family": "motion",
1517
+ "layer": "semantic",
1518
+ "value": {
1519
+ "kind": "motion",
1520
+ "value": {
1521
+ "motion": "duration",
1522
+ "value": {
1523
+ "ms": 400
1524
+ }
1525
+ }
1526
+ }
1527
+ }
1528
+ }
1529
+ },
1530
+ "full-duration": {
1531
+ "$type": "duration",
1532
+ "$value": "300ms",
1533
+ "$description": "Mobile Create Hub transition from partial to full height.",
1534
+ "$extensions": {
1535
+ "graphicstandard": {
1536
+ "family": "motion",
1537
+ "layer": "semantic",
1538
+ "value": {
1539
+ "kind": "motion",
1540
+ "value": {
1541
+ "motion": "duration",
1542
+ "value": {
1543
+ "ms": 300
1544
+ }
1545
+ }
1546
+ }
1547
+ }
1548
+ }
1549
+ },
1550
+ "enter-easing": {
1551
+ "$type": "cubicBezier",
1552
+ "$value": [
1553
+ 0.16,
1554
+ 1,
1555
+ 0.3,
1556
+ 1
1557
+ ],
1558
+ "$description": "Create Hub source entrance easing.",
1559
+ "$extensions": {
1560
+ "graphicstandard": {
1561
+ "family": "motion",
1562
+ "layer": "semantic",
1563
+ "value": {
1564
+ "kind": "motion",
1565
+ "value": {
1566
+ "motion": "easing",
1567
+ "value": {
1568
+ "kind": "cubicBezier",
1569
+ "points": [
1570
+ 0.16,
1571
+ 1,
1572
+ 0.3,
1573
+ 1
1574
+ ]
1575
+ }
1576
+ }
1577
+ }
1578
+ }
1579
+ }
1580
+ },
1581
+ "sheet-duration": {
1582
+ "$type": "duration",
1583
+ "$value": "320ms",
1584
+ "$description": "Mobile Create Hub slide-up duration.",
1585
+ "$extensions": {
1586
+ "graphicstandard": {
1587
+ "family": "motion",
1588
+ "layer": "semantic",
1589
+ "value": {
1590
+ "kind": "motion",
1591
+ "value": {
1592
+ "motion": "duration",
1593
+ "value": {
1594
+ "ms": 320
1595
+ }
1596
+ }
1597
+ }
1598
+ }
1599
+ }
1600
+ }
1601
+ },
1413
1602
  "modal": {
1414
1603
  "content-enter-delay": {
1415
1604
  "$type": "duration",
package/src/variables.css CHANGED
@@ -20,7 +20,7 @@
20
20
  --color-danger-light: #fee2e2;
21
21
  --color-fg: #0d0d0d;
22
22
  --color-fg-inverted: #ffffff;
23
- --color-fg-muted: #7d786f;
23
+ --color-fg-muted: #67635b;
24
24
  --color-fg-on-brand: #0d0d0d;
25
25
  --color-fg-subtle: #b3b3b3;
26
26
  --color-fg-workflow-muted: #858585;
@@ -35,6 +35,9 @@
35
35
  --color-surface-inverted: #242423;
36
36
  --color-surface-muted: #eceae1;
37
37
  --color-surface-placeholder: #333333;
38
+ --control-height-mobile-cta: 99px;
39
+ --control-height-create-hub-full: 100vh;
40
+ --control-height-create-hub-partial: 40vh;
38
41
  --control-height-tall: 3.625rem;
39
42
  --effect-modal-backdrop-blur: 10px;
40
43
  --font-mono: 'GT America Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
@@ -69,6 +72,11 @@
69
72
  --line-height-panel-heading: 20px;
70
73
  --line-height-small: 18px;
71
74
  --motion-modal-content-enter-delay: 280ms;
75
+ --motion-create-hub-backdrop-duration: 150ms;
76
+ --motion-create-hub-desktop-duration: 400ms;
77
+ --motion-create-hub-full-duration: 300ms;
78
+ --motion-create-hub-enter-easing: cubic-bezier(0.16, 1, 0.3, 1);
79
+ --motion-create-hub-sheet-duration: 320ms;
72
80
  --motion-modal-content-enter-duration: 420ms;
73
81
  --motion-modal-content-enter-stagger: 60ms;
74
82
  --motion-modal-enter-duration: 520ms;
@@ -92,6 +100,7 @@
92
100
  --space-sm: 0.5rem;
93
101
  --space-xl: 2rem;
94
102
  --space-xs: 0.25rem;
103
+ --shadow-mobile-cta: 0 -2px 8px #00000014;
95
104
  --tracking-display-large: -0.0666667em;
96
105
  --tracking-normal: 0.01em;
97
106
  --tracking-tight: 0em;