@godxjp/ui 28.7.0 → 28.9.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 (119) 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/lib/variants.js +4 -1
  34. package/dist/props/components/data-display.prop.d.ts +95 -1
  35. package/dist/props/components/general.prop.d.ts +47 -3
  36. package/dist/props/components/layout.prop.d.ts +194 -0
  37. package/dist/props/components/navigation.prop.d.ts +263 -0
  38. package/dist/props/registry.d.ts +359 -4
  39. package/dist/props/registry.js +472 -3
  40. package/dist/props/vocabulary/index.d.ts +1 -1
  41. package/dist/props/vocabulary/interaction.prop.d.ts +39 -2
  42. package/dist/props/vocabulary/layout.prop.d.ts +1 -1
  43. package/dist/styles/base.css +47 -14
  44. package/dist/styles/card-layout.css +2 -2
  45. package/dist/styles/chart-layout.css +6 -6
  46. package/dist/styles/control.css +15 -10
  47. package/dist/styles/data-display-layout.css +22 -6
  48. package/dist/styles/density.css +6 -0
  49. package/dist/styles/dialog-layout.css +4 -1
  50. package/dist/styles/focus-ring.css +4 -1
  51. package/dist/styles/layout.css +92 -3
  52. package/dist/styles/motion.css +121 -1
  53. package/dist/styles/navigation-layout.css +397 -1
  54. package/dist/styles/shell-layout.css +28 -21
  55. package/dist/styles/text-layout.css +134 -15
  56. package/dist/tokens/base.css +5 -0
  57. package/dist/tokens/components/activity.css +13 -4
  58. package/dist/tokens/components/affix.css +7 -0
  59. package/dist/tokens/components/anchor.css +17 -0
  60. package/dist/tokens/components/attachments.css +1 -1
  61. package/dist/tokens/components/badge.css +1 -1
  62. package/dist/tokens/components/card.css +28 -7
  63. package/dist/tokens/components/chart.css +4 -1
  64. package/dist/tokens/components/chat-composer.css +4 -1
  65. package/dist/tokens/components/control.css +72 -33
  66. package/dist/tokens/components/conversations.css +4 -1
  67. package/dist/tokens/components/data-display.css +42 -15
  68. package/dist/tokens/components/data-entry.css +8 -2
  69. package/dist/tokens/components/descriptions.css +1 -1
  70. package/dist/tokens/components/feedback.css +8 -5
  71. package/dist/tokens/components/float-button.css +8 -2
  72. package/dist/tokens/components/form.css +1 -1
  73. package/dist/tokens/components/legal-document.css +12 -3
  74. package/dist/tokens/components/logo.css +15 -6
  75. package/dist/tokens/components/marquee.css +7 -0
  76. package/dist/tokens/components/masonry.css +6 -0
  77. package/dist/tokens/components/mega-menu.css +71 -0
  78. package/dist/tokens/components/navigation.css +37 -13
  79. package/dist/tokens/components/segmented.css +4 -1
  80. package/dist/tokens/components/separator.css +4 -1
  81. package/dist/tokens/components/shell.css +99 -31
  82. package/dist/tokens/components/table.css +11 -5
  83. package/dist/tokens/components/thought-chain.css +4 -1
  84. package/dist/tokens/components/toggle.css +4 -1
  85. package/dist/tokens/components/tree.css +1 -1
  86. package/dist/tokens/components/upload.css +21 -9
  87. package/dist/tokens/foundation.css +35 -30
  88. package/dist/tokens/semantic/layout.css +26 -5
  89. package/docs/COMPOSITION-VS-COMPONENT.md +19 -1
  90. package/docs/DESIGN-AUTHORITY.md +99 -18
  91. package/docs/FRAME-COVERAGE-REPORT.md +7 -2
  92. package/docs/TOKENS.md +16 -1
  93. package/docs/data-display/marquee.tsx +254 -0
  94. package/docs/foundation/_theme-editor-scope.ts +222 -0
  95. package/docs/foundation/density.tsx +12 -2
  96. package/docs/foundation/spacing.tsx +5 -0
  97. package/docs/foundation/theme-editor.tsx +645 -0
  98. package/docs/general/activity.tsx +65 -0
  99. package/docs/general/reveal.tsx +290 -22
  100. package/docs/general/typography.tsx +91 -1
  101. package/docs/layout/affix.tsx +209 -0
  102. package/docs/layout/masonry.tsx +291 -0
  103. package/docs/navigation/anchor.tsx +285 -0
  104. package/docs/navigation/mega-menu-panel.tsx +86 -0
  105. package/docs/navigation/mega-menu.tsx +254 -0
  106. package/docs/roadmap/website-components.md +779 -0
  107. package/docs/showcase/acme-website.tsx +75 -39
  108. package/docs/showcase/case4-login.tsx +10 -2
  109. package/docs/showcase/case5-shift-calendar.tsx +1 -1
  110. package/docs/showcase/case6-agency-handy.tsx +6 -6
  111. package/docs/showcase/futurelastic-web.tsx +89 -49
  112. package/docs/showcase/marketing-page.tsx +885 -0
  113. package/docs/showcase/table-expandable-rows.tsx +4 -1
  114. package/docs/showcase/table-footer-totals.tsx +12 -2
  115. package/docs/showcase/theme-customization.tsx +1259 -0
  116. package/package.json +6 -3
  117. package/scripts/brand-accent.generated.mjs +27 -0
  118. package/scripts/ui-audit.mjs +66 -0
  119. package/scripts/visual-audit-rules.mjs +46 -2
@@ -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)" },