@godxjp/ui 28.7.0 → 28.8.0

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 (85) hide show
  1. package/dist/components/data-display/index.d.ts +2 -0
  2. package/dist/components/data-display/index.js +2 -0
  3. package/dist/components/data-display/marquee.d.ts +16 -0
  4. package/dist/components/data-display/marquee.js +155 -0
  5. package/dist/components/general/reveal.d.ts +23 -2
  6. package/dist/components/general/reveal.js +37 -7
  7. package/dist/components/general/typography.d.ts +4 -1
  8. package/dist/components/general/typography.js +14 -1
  9. package/dist/components/layout/affix.d.ts +86 -0
  10. package/dist/components/layout/affix.js +187 -0
  11. package/dist/components/layout/index.d.ts +4 -0
  12. package/dist/components/layout/index.js +4 -0
  13. package/dist/components/layout/legal-document-shell.js +4 -3
  14. package/dist/components/layout/masonry.d.ts +74 -0
  15. package/dist/components/layout/masonry.js +214 -0
  16. package/dist/components/layout/page-container.js +5 -20
  17. package/dist/components/navigation/anchor.d.ts +64 -0
  18. package/dist/components/navigation/anchor.js +284 -0
  19. package/dist/components/navigation/index.d.ts +4 -0
  20. package/dist/components/navigation/index.js +4 -0
  21. package/dist/components/navigation/mega-menu.d.ts +21 -0
  22. package/dist/components/navigation/mega-menu.js +526 -0
  23. package/dist/contracts/measurement.json +1 -1
  24. package/dist/i18n/messages/en.json +517 -0
  25. package/dist/i18n/messages/ja.json +513 -0
  26. package/dist/i18n/messages/vi.json +513 -0
  27. package/dist/lib/hooks.d.ts +68 -0
  28. package/dist/lib/hooks.js +52 -0
  29. package/dist/lib/platform.d.ts +14 -0
  30. package/dist/lib/platform.js +10 -1
  31. package/dist/lib/utils.d.ts +1 -1
  32. package/dist/lib/utils.js +3 -2
  33. package/dist/props/components/data-display.prop.d.ts +95 -1
  34. package/dist/props/components/general.prop.d.ts +47 -3
  35. package/dist/props/components/layout.prop.d.ts +194 -0
  36. package/dist/props/components/navigation.prop.d.ts +263 -0
  37. package/dist/props/registry.d.ts +359 -4
  38. package/dist/props/registry.js +472 -3
  39. package/dist/props/vocabulary/index.d.ts +1 -1
  40. package/dist/props/vocabulary/interaction.prop.d.ts +39 -2
  41. package/dist/styles/control.css +5 -6
  42. package/dist/styles/data-display-layout.css +2 -1
  43. package/dist/styles/density.css +4 -0
  44. package/dist/styles/layout.css +79 -0
  45. package/dist/styles/motion.css +121 -1
  46. package/dist/styles/navigation-layout.css +397 -1
  47. package/dist/styles/shell-layout.css +3 -0
  48. package/dist/styles/text-layout.css +52 -4
  49. package/dist/tokens/base.css +5 -0
  50. package/dist/tokens/components/affix.css +7 -0
  51. package/dist/tokens/components/anchor.css +17 -0
  52. package/dist/tokens/components/control.css +3 -3
  53. package/dist/tokens/components/form.css +1 -1
  54. package/dist/tokens/components/marquee.css +7 -0
  55. package/dist/tokens/components/masonry.css +6 -0
  56. package/dist/tokens/components/mega-menu.css +62 -0
  57. package/dist/tokens/components/shell.css +3 -0
  58. package/dist/tokens/foundation.css +11 -0
  59. package/dist/tokens/semantic/layout.css +7 -0
  60. package/docs/COMPOSITION-VS-COMPONENT.md +19 -1
  61. package/docs/DESIGN-AUTHORITY.md +99 -18
  62. package/docs/FRAME-COVERAGE-REPORT.md +7 -2
  63. package/docs/data-display/marquee.tsx +254 -0
  64. package/docs/foundation/_theme-editor-scope.ts +222 -0
  65. package/docs/foundation/density.tsx +12 -2
  66. package/docs/foundation/spacing.tsx +5 -0
  67. package/docs/foundation/theme-editor.tsx +645 -0
  68. package/docs/general/activity.tsx +65 -0
  69. package/docs/general/reveal.tsx +290 -22
  70. package/docs/general/typography.tsx +91 -1
  71. package/docs/layout/affix.tsx +209 -0
  72. package/docs/layout/masonry.tsx +291 -0
  73. package/docs/navigation/anchor.tsx +285 -0
  74. package/docs/navigation/mega-menu-panel.tsx +86 -0
  75. package/docs/navigation/mega-menu.tsx +254 -0
  76. package/docs/roadmap/website-components.md +779 -0
  77. package/docs/showcase/acme-website.tsx +75 -39
  78. package/docs/showcase/futurelastic-web.tsx +91 -49
  79. package/docs/showcase/marketing-page.tsx +885 -0
  80. package/docs/showcase/table-footer-totals.tsx +12 -2
  81. package/docs/showcase/theme-customization.tsx +1259 -0
  82. package/package.json +5 -3
  83. package/scripts/brand-accent.generated.mjs +27 -0
  84. package/scripts/ui-audit.mjs +66 -0
  85. package/scripts/visual-audit-rules.mjs +46 -2
@@ -0,0 +1,254 @@
1
+ import { useState } from "react";
2
+
3
+ import {
4
+ Badge,
5
+ Card,
6
+ CardContent,
7
+ CardDescription,
8
+ CardHeader,
9
+ CardTitle,
10
+ Marquee,
11
+ } from "@godxjp/ui/data-display";
12
+ import { Switch } from "@godxjp/ui/data-entry";
13
+ import { Heading, Link, Text } from "@godxjp/ui/general";
14
+ import { Flex, PageContainer, Separator } from "@godxjp/ui/layout";
15
+
16
+ /**
17
+ * Marquee · a track of content that travels continuously, and the WCAG 2.2.2 pause control that
18
+ * makes that legal.
19
+ *
20
+ * Every card on this page is an EDGE, because the tidy demo is the one that hides the defects this
21
+ * component actually has:
22
+ * · ONE item in a full-width track, which is the case that needs the most clones;
23
+ * · FORTY items, which is the case that proves the pace is measured and not per-cycle;
24
+ * · a 71-character unbreakable string, wider than a phone;
25
+ * · a track NARROWER than one item, where there is nothing to clone into;
26
+ * · CJK beside Latin beside Vietnamese, at three different optical widths;
27
+ * · the paused state, which is where the content has to stay readable;
28
+ * · a controlled "stop all motion" switch driving two tracks at once.
29
+ *
30
+ * Composed only from real @godxjp/ui components. All copy is consumer-owned and localized.
31
+ */
32
+
33
+ const PARTNERS = [
34
+ "フジワラ運輸",
35
+ "Meridian Foods",
36
+ "Công ty Đại Việt",
37
+ "北陸電機",
38
+ "Halden Systems",
39
+ "三和商会",
40
+ "Vinh Phat Logistics",
41
+ "東海システム",
42
+ ];
43
+
44
+ /** Forty items · the case a per-cycle duration would send across the screen forty times too fast. */
45
+ const FORTY = Array.from({ length: 40 }, (_, index) => `SKU-${String(index + 1).padStart(4, "0")}`);
46
+
47
+ /** 71 characters, no break opportunity anywhere in it. */
48
+ const UNBREAKABLE = "SUPPLYCHAINRECONCILIATIONBATCHIDENTIFIER2026Q3NOBREAKOPPORTUNITY0000001";
49
+
50
+ export default function MarqueeDoc() {
51
+ const [motion, setMotion] = useState(true);
52
+
53
+ return (
54
+ <PageContainer title="Marquee" subtitle="連続して流れるトラックと、それを止める操作">
55
+ <Flex direction="col" gap="lg">
56
+ <Card>
57
+ <CardHeader>
58
+ <CardTitle level={2}>ロゴウォール · 既定のかたち</CardTitle>
59
+ <CardDescription>
60
+ `fade` で両端をマスクし、`pauseOnHover` を足した 8 件。コピー数は測って決まる(内容幅
61
+ ÷ 表示幅 + 1)ので、ウィンドウを横に伸ばせばクローンが増える。停止ボタンは常にあり、
62
+ Tab で到達できる。各社名はリンクなので、トラック内にフォーカスが入ると自動で止まる
63
+ (動いているリンクは押せないため)。クローン側のリンクは Tab の順路に出てこない。
64
+ </CardDescription>
65
+ </CardHeader>
66
+ <CardContent>
67
+ <Marquee fade pauseOnHover label="取引先ロゴ">
68
+ {PARTNERS.map((name) => (
69
+ <Link key={name} href={`#partner-${encodeURIComponent(name)}`}>
70
+ {name}
71
+ </Link>
72
+ ))}
73
+ </Marquee>
74
+ </CardContent>
75
+ </Card>
76
+
77
+ <Card>
78
+ <CardHeader>
79
+ <CardTitle level={2}>1 件 と 40 件 · 速度は件数で変わらない</CardTitle>
80
+ <CardDescription>
81
+ 1 周の所要時間ではなく「1 画面ぶんを流れる時間」が `--marquee-interval` なので、1
82
+ 件でも 40 件でも見た目の速さは同じ。1 件のトラックはクローンが最も多く、 40
83
+ 件のトラックはクローンが 1 枚で足りる。
84
+ </CardDescription>
85
+ </CardHeader>
86
+ <CardContent>
87
+ <Flex direction="col" gap="md">
88
+ <Heading level={3}>1 件</Heading>
89
+ <Marquee label="在庫同期の状態">
90
+ <Badge tone="info">在庫同期 · 実行中</Badge>
91
+ </Marquee>
92
+ <Separator />
93
+ <Heading level={3}>40 件</Heading>
94
+ <Marquee label="処理中の SKU">
95
+ {FORTY.map((sku) => (
96
+ <Text key={sku} size="xs" tone="muted">
97
+ {sku}
98
+ </Text>
99
+ ))}
100
+ </Marquee>
101
+ </Flex>
102
+ </CardContent>
103
+ </Card>
104
+
105
+ <Card>
106
+ <CardHeader>
107
+ <CardTitle level={2}>折り返せない 71 文字と、1 件より狭いトラック</CardTitle>
108
+ <CardDescription>
109
+ 分割点のない 71 文字は電話の画面より広い。狭い枠に入れると「表示幅 ÷ 内容幅」は 1
110
+ を下回るので、クローンは最小の 1 枚になり、それでも継ぎ目なく回る。
111
+ </CardDescription>
112
+ </CardHeader>
113
+ <CardContent>
114
+ <Flex direction="col" gap="md">
115
+ <Heading level={3}>全幅</Heading>
116
+ <Marquee label="照合バッチ識別子">
117
+ <Text size="sm">{UNBREAKABLE}</Text>
118
+ </Marquee>
119
+ <Separator />
120
+ <Heading level={3}>幅 14rem · 1 件より狭い枠</Heading>
121
+ <div style={{ inlineSize: "14rem", maxInlineSize: "100%" }}>
122
+ <Marquee label="照合バッチ識別子・狭い枠">
123
+ <Text size="sm">{UNBREAKABLE}</Text>
124
+ </Marquee>
125
+ </div>
126
+ </Flex>
127
+ </CardContent>
128
+ </Card>
129
+
130
+ <Card>
131
+ <CardHeader>
132
+ <CardTitle level={2}>日本語 · Latin · Tiếng Việt が同じ行に並ぶ</CardTitle>
133
+ <CardDescription>
134
+ 全角の仮名漢字、欧文、そしてダイアクリティカルの付いたベトナム語は 1 文字あたりの幅も
135
+ 行の高さも違う。同じトラックに置いたときの継ぎ目とベースラインはここで見る。
136
+ `direction="end"` は読み方向の逆に流れる版で、`dir="rtl"` では両方が反転する。
137
+ </CardDescription>
138
+ </CardHeader>
139
+ <CardContent>
140
+ <Flex direction="col" gap="md">
141
+ <Marquee gap={6} speed="slow" label="多言語の見出し">
142
+ <Text size="sm">品質保証部 · 月次レビュー</Text>
143
+ <Text size="sm">Quality Assurance · Monthly review</Text>
144
+ <Text size="sm">Đảm bảo chất lượng · Đánh giá hàng tháng</Text>
145
+ </Marquee>
146
+ <Separator />
147
+ <Marquee gap={6} speed="fast" direction="end" label="多言語の見出し・逆方向">
148
+ <Text size="sm">品質保証部 · 月次レビュー</Text>
149
+ <Text size="sm">Quality Assurance · Monthly review</Text>
150
+ <Text size="sm">Đảm bảo chất lượng · Đánh giá hàng tháng</Text>
151
+ </Marquee>
152
+ </Flex>
153
+ </CardContent>
154
+ </Card>
155
+
156
+ <Card>
157
+ <CardHeader>
158
+ <CardTitle level={2}>止まった状態 · WebAIM の推奨する既定</CardTitle>
159
+ <CardDescription>
160
+ `defaultPlay={false}` で始めると、内容は止まったまま読める。停止中もリンクは Tab
161
+ で辿れて、押せる。動いている最中にトラック内へフォーカスが入った場合も自動で止まる
162
+ (動いているリンクは押せないため)。ボタンの名前は「次に起きること」を言う。
163
+ </CardDescription>
164
+ </CardHeader>
165
+ <CardContent>
166
+ <Marquee defaultPlay={false} fade label="社内のお知らせ">
167
+ <Text size="sm">2026-10-01 · 社内システム定期メンテナンス</Text>
168
+ <Link href="#maintenance">詳細</Link>
169
+ <Text size="sm">2026-10-14 · 新しい経費申請フォームに切替</Text>
170
+ <Link href="#expense">申請の手順</Link>
171
+ </Marquee>
172
+ </CardContent>
173
+ </Card>
174
+
175
+ <Card>
176
+ <CardHeader>
177
+ <CardTitle level={2}>`play` で外から止める</CardTitle>
178
+ <CardDescription>
179
+ 制御された `play` / `onPlayChange` は、画面全体の「動きを止める」1
180
+ つのスイッチから複数のトラックを同時に止めるためにある。各トラックの停止ボタンは
181
+ そのまま残る(2.2.2 の要件は個々の操作で満たす)。
182
+ </CardDescription>
183
+ </CardHeader>
184
+ <CardContent>
185
+ <Flex direction="col" gap="md">
186
+ <Flex align="center" gap="sm">
187
+ <Switch
188
+ id="stop-all-motion"
189
+ checked={motion}
190
+ onCheckedChange={setMotion}
191
+ aria-label="このページの動きを有効にする"
192
+ />
193
+ <Text size="sm">
194
+ {motion ? "このページの動きは有効" : "このページの動きは停止中"}
195
+ </Text>
196
+ </Flex>
197
+ <Marquee play={motion} onPlayChange={setMotion} label="取引先ロゴ・上段">
198
+ {PARTNERS.slice(0, 4).map((name) => (
199
+ <Text key={name} size="sm" tone="muted">
200
+ {name}
201
+ </Text>
202
+ ))}
203
+ </Marquee>
204
+ <Marquee
205
+ play={motion}
206
+ onPlayChange={setMotion}
207
+ direction="end"
208
+ label="取引先ロゴ・下段"
209
+ >
210
+ {PARTNERS.slice(4).map((name) => (
211
+ <Text key={name} size="sm" tone="muted">
212
+ {name}
213
+ </Text>
214
+ ))}
215
+ </Marquee>
216
+ </Flex>
217
+ </CardContent>
218
+ </Card>
219
+
220
+ <Card>
221
+ <CardHeader>
222
+ <CardTitle level={2}>使う前に読むこと</CardTitle>
223
+ </CardHeader>
224
+ <CardContent>
225
+ <Flex direction="col" gap="sm">
226
+ <Heading level={3}>止められる動きでも、止まっている方が良いことは多い</Heading>
227
+ <Text tone="muted">
228
+ 自動で流れる内容は Nielsen Norman Group も WebAIM も勧めていない。NN/g
229
+ は「ユーザーが操作していないのに画面が動くのは不快で、読み終える前に消える」と書き、
230
+ WebAIM は「アニメーションは既定で止めておくことを勧める」と書いている。この
231
+ コンポーネントはその判断を奪わない。止める操作は必ず付いてくるし、`defaultPlay=
232
+ {"{false}"}` は 1 つのプロパティで済む。動かす理由が言えないなら、静止した `Flex
233
+ wrap` や `ResponsiveGrid` のロゴウォールの方が良い。
234
+ </Text>
235
+ <Heading level={3}>OS のモーション低減設定では一切動かない</Heading>
236
+ <Text tone="muted">
237
+ `prefers-reduced-motion: reduce` のとき、クローンも停止ボタンも作らず、1
238
+ 件ぶんの内容を横スクロールできる領域として出す。横方向の平行移動は前庭系の
239
+ トリガーそのもので、控えめにする版というものが無いため(WCAG 2.2 SC 2.2.2 / SC
240
+ 2.3.3)。
241
+ </Text>
242
+ <Heading level={3}>テーマ側のつまみ</Heading>
243
+ <Text tone="muted">
244
+ --marquee-interval · --marquee-interval-slow · --marquee-interval-fast ·
245
+ --marquee-gap-inline · --marquee-mask-width。時間はモーション層
246
+ (foundation.css)に、幾何はコンポーネント層(tokens/components/marquee.css)にある。
247
+ </Text>
248
+ </Flex>
249
+ </CardContent>
250
+ </Card>
251
+ </Flex>
252
+ </PageContainer>
253
+ );
254
+ }
@@ -0,0 +1,222 @@
1
+ /**
2
+ * What the Theme Editor page needs that is NOT React: the repo's own brand derivation, the two
3
+ * stylesheet facts it takes as arguments, and the ONE style object that makes a previewed seed
4
+ * actually reach the components under it.
5
+ *
6
+ * `deriveBrand` is `scripts/gen-brand.mjs`'s body (src/tokens/__tests__/brand-derivation.ts).
7
+ * Importing it — rather than porting it — is why the page's export and `pnpm gen:brand` emit the
8
+ * same bytes for the same hex. `wcag-contrast.ts`'s own opening line says why there is one copy of
9
+ * the luminance formula; this is the same argument one level up.
10
+ */
11
+ import type { CSSProperties } from "react";
12
+
13
+ import {
14
+ asTriplet,
15
+ deriveBrand,
16
+ triplet,
17
+ type BrandChannels,
18
+ type BrandTheme,
19
+ type Hsl,
20
+ } from "../../src/tokens/__tests__/brand-derivation";
21
+
22
+ export {
23
+ AA_TEXT,
24
+ NON_TEXT,
25
+ asTriplet,
26
+ contrast,
27
+ deriveBrand,
28
+ hslToRgb,
29
+ parseHex,
30
+ toHex,
31
+ toHsl,
32
+ round,
33
+ } from "../../src/tokens/__tests__/brand-derivation";
34
+ export type {
35
+ Brand,
36
+ BrandChannels,
37
+ BrandTheme,
38
+ ContrastRow,
39
+ Hsl,
40
+ } from "../../src/tokens/__tests__/brand-derivation";
41
+
42
+ /* ── what the stylesheet says, asked of the browser rather than copied here ─────────────────── */
43
+
44
+ /**
45
+ * `gen:brand` reads `--background` and the three `-channels` expressions out of `foundation.css`
46
+ * and `derived.css` with `node:fs`. A page has no filesystem, and a literal copied into this file
47
+ * would be a third place the canvas colour lives — stale the first time someone retunes the spine.
48
+ * So the page asks the DOCUMENT, which is the same declarations after the same cascade.
49
+ *
50
+ * The CANVASES come from the CSSOM rather than `getComputedStyle`, because the page needs BOTH at
51
+ * once and an element can only be in one theme at a time: read live, a page rendered under
52
+ * `data-theme="dark"` would report the dark canvas as the light one and the whole dark-seed search
53
+ * would target the wrong number, silently. The CSSOM carries both declarations side by side no
54
+ * matter which theme is on screen.
55
+ *
56
+ * The CHANNELS are the opposite case: `--primary-hover-darken-channels` and its three siblings are
57
+ * declared once at `:root` and never re-scoped (`.dark` only repoints `--primary-hover-channels`
58
+ * AT one of them), so a computed read is correct under any theme and is one line instead of a walk.
59
+ */
60
+ export type ThemeSpine = { lightCanvas: Hsl; darkCanvas: Hsl; channels: BrandChannels };
61
+
62
+ /** Every style rule in the document, walking into `@layer` / `@media` / `@supports` and nesting. */
63
+ function* styleRules(rules: CSSRuleList): Generator<CSSStyleRule> {
64
+ for (const rule of Array.from(rules)) {
65
+ if ("selectorText" in rule) yield rule as CSSStyleRule;
66
+ const nested = (rule as CSSGroupingRule).cssRules;
67
+ if (nested) yield* styleRules(nested);
68
+ }
69
+ }
70
+
71
+ /** The LAST `--background` declared by a rule this selector test accepts — cascade order. */
72
+ function canvasFrom(accepts: (selector: string) => boolean): Hsl | null {
73
+ let found: Hsl | null = null;
74
+ for (const sheet of Array.from(document.styleSheets)) {
75
+ let rules: CSSRuleList;
76
+ try {
77
+ rules = sheet.cssRules;
78
+ } catch {
79
+ /* A cross-origin sheet refuses `cssRules`. Ours are same-origin; skip anything else. */
80
+ continue;
81
+ }
82
+ for (const rule of styleRules(rules)) {
83
+ if (!accepts(rule.selectorText)) continue;
84
+ const value = rule.style.getPropertyValue("--background").trim();
85
+ if (!value) continue;
86
+ try {
87
+ found = triplet(value);
88
+ } catch {
89
+ /* Not a plain `H S% L%` triple — not a canvas this derivation can use. */
90
+ }
91
+ }
92
+ }
93
+ return found;
94
+ }
95
+
96
+ /**
97
+ * The probe fallback, for the one case the CSSOM cannot answer: a sheet the document can paint from
98
+ * but not read. It costs a layout, so it only runs when the walk came back empty.
99
+ */
100
+ function canvasByProbe(dark: boolean): Hsl | null {
101
+ const probe = document.createElement("div");
102
+ if (dark) probe.className = "dark";
103
+ document.body.append(probe);
104
+ try {
105
+ const value = getComputedStyle(probe).getPropertyValue("--background").trim();
106
+ return value ? triplet(value) : null;
107
+ } catch {
108
+ return null;
109
+ } finally {
110
+ probe.remove();
111
+ }
112
+ }
113
+
114
+ const channel = (name: string) =>
115
+ getComputedStyle(document.documentElement).getPropertyValue(name).trim();
116
+
117
+ /** The spine this document is actually painting, or `null` when it cannot be read at all. */
118
+ export function readThemeSpine(): ThemeSpine | null {
119
+ const lightCanvas = canvasFrom((s) => s.trim() === ":root") ?? canvasByProbe(false);
120
+ const darkCanvas = canvasFrom((s) => /\[data-theme=["']?dark/.test(s)) ?? canvasByProbe(true);
121
+ const channels: BrandChannels = {
122
+ hoverDarken: channel("--primary-hover-darken-channels"),
123
+ activeDarken: channel("--primary-active-darken-channels"),
124
+ hoverLighten: channel("--primary-hover-lighten-channels"),
125
+ };
126
+ if (!lightCanvas || !darkCanvas) return null;
127
+ if (!channels.hoverDarken || !channels.activeDarken || !channels.hoverLighten) return null;
128
+ return { lightCanvas, darkCanvas, channels };
129
+ }
130
+
131
+ /* ── the scope a preview pane declares ──────────────────────────────────────────────────────── */
132
+
133
+ /**
134
+ * THE THREE TOKENS `gen:brand` EMITS ARE THE THREE A SCOPE MUST DECLARE, and that is not a
135
+ * coincidence — it is the freeze rule (docs/TOKENS.md) read from the other end.
136
+ *
137
+ * `--primary` and `--primary-foreground` are ordinary roles: declare them on the pane and every
138
+ * descendant paints from them, including `--primary-hover` and `--text-link`, which are `initial`
139
+ * knobs whose defaults re-resolve at the element that paints (gh#678, gh#664). Writing THOSE here
140
+ * is the drift `gen:brand` refuses to emit, so this does not write them either.
141
+ *
142
+ * `--ring` is the one that bites. `derived.css` declares `--ring: var(--primary)` — and a `var()`
143
+ * substitutes where it is DECLARED, so at `:root` it computed against the package's own seed and
144
+ * inherits that frozen answer into every subtree. The dark pane escapes by accident (it carries
145
+ * `.dark`, and `derived.css` re-declares `--ring: var(--primary)` in that block too, which
146
+ * re-substitutes on the pane); the LIGHT pane does not, and a focus ring in the old brand colour
147
+ * on a re-themed button is exactly the defect. `derived.css` says so in as many words: "a
148
+ * `--primary` scoped BELOW `<html>` does not reach `--ring` … a nested scope sets `--ring`
149
+ * itself". So both panes set it, which is also what a consumer's `:root` gets from `gen:brand`.
150
+ *
151
+ * The `-channels` PAIR is written only when the seed's label runs against the theme's default,
152
+ * because that is the one thing CSS cannot infer: the label decides which way a state steps, and
153
+ * only the author knows the label. It is a role-mirror, so it is written as `var(--…-channels)`
154
+ * and never as a resolved literal.
155
+ */
156
+ export function previewScope(theme: BrandTheme): CSSProperties {
157
+ const scope: Record<string, string> = {
158
+ "--primary": asTriplet(theme.seed),
159
+ "--primary-foreground": asTriplet(theme.label),
160
+ "--ring": asTriplet(theme.seed),
161
+ };
162
+ if (theme.repointsChannels) {
163
+ scope["--primary-hover-channels"] = `var(--primary-hover-${theme.polarity}-channels)`;
164
+ scope["--primary-active-channels"] = `var(--primary-active-${theme.polarity}-channels)`;
165
+ }
166
+ return scope as CSSProperties;
167
+ }
168
+
169
+ /* ── the seeds a demo must not avoid ────────────────────────────────────────────────────────── */
170
+
171
+ /**
172
+ * AN EDITOR THAT ONLY DEMOS A NICE BLUE PROVES NOTHING. Each of these is here because it produces
173
+ * an answer the happy path hides; `hex` is the only input, everything else is measured.
174
+ */
175
+ export type SeedPreset = {
176
+ id: "godx" | "blue" | "very-light" | "very-dark" | "sunflower";
177
+ hex: string;
178
+ };
179
+
180
+ export const SEED_PRESETS: SeedPreset[] = [
181
+ /* The package's own `--primary`: the export must reproduce foundation.css's light block. */
182
+ { id: "godx", hex: "#7A00FF" },
183
+ /* An ordinary, well-behaved brand — every row clears, so a passing readout is visible too. */
184
+ { id: "blue", hex: "#2563EB" },
185
+ /* Near-white: the label flips to black and the fill cannot clear 3:1 on a near-white canvas. */
186
+ { id: "very-light", hex: "#FFF9C4" },
187
+ /* Near-black: the dark-seed search runs all the way to pure white to hold parity. */
188
+ { id: "very-dark", hex: "#0B0B14" },
189
+ /* A dark label in light and a light label in dark — the seed that repoints the `-channels`
190
+ * pair in BOTH theme blocks, which nothing else here exercises. */
191
+ { id: "sunflower", hex: "#F5D60A" },
192
+ ];
193
+
194
+ /** One place that knows how a hex becomes a brand, so the page never calls `deriveBrand` twice. */
195
+ export function brandFor(
196
+ spine: ThemeSpine,
197
+ hex: string,
198
+ name: string,
199
+ foreground: string | null,
200
+ darkLightness: number | null,
201
+ ) {
202
+ return deriveBrand({ hex, name, foreground, darkLightness, ...spine });
203
+ }
204
+
205
+ /**
206
+ * THE COMMAND THAT REPRODUCES THIS EXPORT, or `null` when nothing does.
207
+ *
208
+ * The seed and the forced label are both `gen:brand` flags, so those exports are byte-identical to
209
+ * what the CLI writes and the page can say which command to run. An AUTHORED dark lightness is
210
+ * not: the generator searches for parity and has no flag to override it, so the page has to stop
211
+ * claiming agreement rather than print a command that emits something else.
212
+ */
213
+ export function genBrandCommand(
214
+ hex: string,
215
+ name: string,
216
+ foreground: string | null,
217
+ darkLightnessOverridden: boolean,
218
+ ): string | null {
219
+ if (darkLightnessOverridden) return null;
220
+ const flags = foreground ? ` --foreground '${foreground}'` : "";
221
+ return `pnpm gen:brand '${hex}' --name ${name}${flags}`;
222
+ }
@@ -123,7 +123,12 @@ export default function Demo() {
123
123
  </CardDescription>
124
124
  </CardHeader>
125
125
  <CardContent>
126
- <Flex direction="row" gap="lg" align="start" wrap>
126
+ {/* A STACK ON A PHONE, said with `direction` rather than left to `wrap`.
127
+ `wrap` never fired here: each column carries `min-w-0 flex-1`, and an item that
128
+ may shrink to nothing never reaches the wrap threshold — so at 375px this was
129
+ three 92px columns, and the unbreakable `density="comfortable"` label painted
130
+ 36px over its neighbour with no scrollport to reach it. */}
131
+ <Flex direction={{ base: "col", md: "row" }} gap="lg" align="start" wrap>
127
132
  {density.map((d) => (
128
133
  <Flex key={d.cls} direction="col" gap="sm" className="min-w-0 flex-1 sm:min-w-72">
129
134
  <Flex direction="row" align="center" justify="between" gap="sm">
@@ -154,7 +159,12 @@ export default function Demo() {
154
159
  </CardDescription>
155
160
  </CardHeader>
156
161
  <CardContent>
157
- <Flex direction="row" gap="lg" align="start" wrap>
162
+ {/* A STACK ON A PHONE, said with `direction` rather than left to `wrap`.
163
+ `wrap` never fired here: each column carries `min-w-0 flex-1`, and an item that
164
+ may shrink to nothing never reaches the wrap threshold — so at 375px this was
165
+ three 92px columns, and the unbreakable `density="comfortable"` label painted
166
+ 36px over its neighbour with no scrollport to reach it. */}
167
+ <Flex direction={{ base: "col", md: "row" }} gap="lg" align="start" wrap>
158
168
  <Flex direction="col" gap="sm" className="min-w-0 flex-1 sm:min-w-72">
159
169
  <Text size="xs" mono>
160
170
  density=&quot;compact&quot;
@@ -22,6 +22,9 @@ const rawScale = [
22
22
  "--space-8",
23
23
  "--space-10",
24
24
  "--space-12",
25
+ // The DISPLAY end of the grid (gh#831) — Carbon $spacing-11 / $spacing-12, for marketing bands.
26
+ "--space-20",
27
+ "--space-24",
25
28
  ];
26
29
 
27
30
  const phiScale = [
@@ -36,6 +39,8 @@ const layoutScale = [
36
39
  { token: "--space-page-x", role: "page gutter X (PageContainer)" },
37
40
  { token: "--space-page-y", role: "page gutter Y (PageContainer)" },
38
41
  { token: "--space-section", role: "section gap (= --phi-0)" },
42
+ { token: "--space-section-band", role: "marketing band padding-block (= --space-20)" },
43
+ { token: "--space-section-hero", role: "hero band padding-block (= --space-24)" },
39
44
  { token: "--space-stack-xs", role: "Flex gap='xs'" },
40
45
  { token: "--space-stack-sm", role: "Flex gap='sm'" },
41
46
  { token: "--space-stack-md", role: "Flex gap='md' (default · = --phi-0)" },