@genesislcap/ai-assistant 15.71.0-FUI-2650.1 → 15.71.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 (139) hide show
  1. package/dist/ai-assistant.api.json +0 -97
  2. package/dist/ai-assistant.d.ts +0 -65
  3. package/dist/chat-driver.cjs +0 -18031
  4. package/dist/chat-driver.cjs.map +4 -4
  5. package/dist/chat-driver.mjs +0 -18024
  6. package/dist/chat-driver.mjs.map +4 -4
  7. package/dist/custom-elements.json +6856 -9696
  8. package/dist/dts/chat-driver-node.d.ts +0 -2
  9. package/dist/dts/chat-driver-node.d.ts.map +1 -1
  10. package/dist/dts/index.d.ts +0 -1
  11. package/dist/dts/index.d.ts.map +1 -1
  12. package/dist/dts/react.d.ts +0 -10
  13. package/dist/esm/chat-driver-node.js +0 -6
  14. package/dist/esm/index.js +0 -3
  15. package/dist/react.cjs +0 -7
  16. package/dist/react.mjs +0 -6
  17. package/package.json +17 -24
  18. package/scripts/smoke-chat-driver-node.mjs +0 -15
  19. package/dist/dts/code-review/code-review.types.d.ts +0 -76
  20. package/dist/dts/code-review/code-review.types.d.ts.map +0 -1
  21. package/dist/dts/code-review/code-reviewer.agent.d.ts +0 -77
  22. package/dist/dts/code-review/code-reviewer.agent.d.ts.map +0 -1
  23. package/dist/dts/code-review/code-reviewer.prompt.d.ts +0 -23
  24. package/dist/dts/code-review/code-reviewer.prompt.d.ts.map +0 -1
  25. package/dist/dts/code-review/gate.d.ts +0 -44
  26. package/dist/dts/code-review/gate.d.ts.map +0 -1
  27. package/dist/dts/code-review/index.d.ts +0 -27
  28. package/dist/dts/code-review/index.d.ts.map +0 -1
  29. package/dist/dts/code-review/review-changes.d.ts +0 -70
  30. package/dist/dts/code-review/review-changes.d.ts.map +0 -1
  31. package/dist/dts/code-review/rules/context-trigger-map.d.ts +0 -6
  32. package/dist/dts/code-review/rules/context-trigger-map.d.ts.map +0 -1
  33. package/dist/dts/code-review/rules/context.registry.d.ts +0 -123
  34. package/dist/dts/code-review/rules/context.registry.d.ts.map +0 -1
  35. package/dist/dts/code-review/rules/fui-ai-extensions.d.ts +0 -13
  36. package/dist/dts/code-review/rules/fui-ai-extensions.d.ts.map +0 -1
  37. package/dist/dts/code-review/rules/fui-blotter.d.ts +0 -16
  38. package/dist/dts/code-review/rules/fui-blotter.d.ts.map +0 -1
  39. package/dist/dts/code-review/rules/fui-chart.d.ts +0 -20
  40. package/dist/dts/code-review/rules/fui-chart.d.ts.map +0 -1
  41. package/dist/dts/code-review/rules/fui-column-defs.d.ts +0 -21
  42. package/dist/dts/code-review/rules/fui-column-defs.d.ts.map +0 -1
  43. package/dist/dts/code-review/rules/fui-components.d.ts +0 -9
  44. package/dist/dts/code-review/rules/fui-components.d.ts.map +0 -1
  45. package/dist/dts/code-review/rules/fui-criteria.d.ts +0 -32
  46. package/dist/dts/code-review/rules/fui-criteria.d.ts.map +0 -1
  47. package/dist/dts/code-review/rules/fui-custom-renderer.d.ts +0 -15
  48. package/dist/dts/code-review/rules/fui-custom-renderer.d.ts.map +0 -1
  49. package/dist/dts/code-review/rules/fui-dashboard.d.ts +0 -19
  50. package/dist/dts/code-review/rules/fui-dashboard.d.ts.map +0 -1
  51. package/dist/dts/code-review/rules/fui-dialogs.d.ts +0 -19
  52. package/dist/dts/code-review/rules/fui-dialogs.d.ts.map +0 -1
  53. package/dist/dts/code-review/rules/fui-entity-management.d.ts +0 -19
  54. package/dist/dts/code-review/rules/fui-entity-management.d.ts.map +0 -1
  55. package/dist/dts/code-review/rules/fui-error-boundary.d.ts +0 -9
  56. package/dist/dts/code-review/rules/fui-error-boundary.d.ts.map +0 -1
  57. package/dist/dts/code-review/rules/fui-eventing.d.ts +0 -8
  58. package/dist/dts/code-review/rules/fui-eventing.d.ts.map +0 -1
  59. package/dist/dts/code-review/rules/fui-flexlayout.d.ts +0 -17
  60. package/dist/dts/code-review/rules/fui-flexlayout.d.ts.map +0 -1
  61. package/dist/dts/code-review/rules/fui-flyout-panel.d.ts +0 -10
  62. package/dist/dts/code-review/rules/fui-flyout-panel.d.ts.map +0 -1
  63. package/dist/dts/code-review/rules/fui-form-component.d.ts +0 -9
  64. package/dist/dts/code-review/rules/fui-form-component.d.ts.map +0 -1
  65. package/dist/dts/code-review/rules/fui-formatters.d.ts +0 -12
  66. package/dist/dts/code-review/rules/fui-formatters.d.ts.map +0 -1
  67. package/dist/dts/code-review/rules/fui-foundation-comms.d.ts +0 -10
  68. package/dist/dts/code-review/rules/fui-foundation-comms.d.ts.map +0 -1
  69. package/dist/dts/code-review/rules/fui-global-filters.d.ts +0 -33
  70. package/dist/dts/code-review/rules/fui-global-filters.d.ts.map +0 -1
  71. package/dist/dts/code-review/rules/fui-import-surface.d.ts +0 -37
  72. package/dist/dts/code-review/rules/fui-import-surface.d.ts.map +0 -1
  73. package/dist/dts/code-review/rules/fui-inline-editing.d.ts +0 -10
  74. package/dist/dts/code-review/rules/fui-inline-editing.d.ts.map +0 -1
  75. package/dist/dts/code-review/rules/fui-layout.d.ts +0 -7
  76. package/dist/dts/code-review/rules/fui-layout.d.ts.map +0 -1
  77. package/dist/dts/code-review/rules/fui-notifications.d.ts +0 -12
  78. package/dist/dts/code-review/rules/fui-notifications.d.ts.map +0 -1
  79. package/dist/dts/code-review/rules/fui-primitives.d.ts +0 -26
  80. package/dist/dts/code-review/rules/fui-primitives.d.ts.map +0 -1
  81. package/dist/dts/code-review/rules/fui-rapid-grid-pro.d.ts +0 -18
  82. package/dist/dts/code-review/rules/fui-rapid-grid-pro.d.ts.map +0 -1
  83. package/dist/dts/code-review/rules/fui-redux-store.d.ts +0 -8
  84. package/dist/dts/code-review/rules/fui-redux-store.d.ts.map +0 -1
  85. package/dist/dts/code-review/rules/fui-reporting.d.ts +0 -19
  86. package/dist/dts/code-review/rules/fui-reporting.d.ts.map +0 -1
  87. package/dist/dts/code-review/rules/fui-styling.d.ts +0 -15
  88. package/dist/dts/code-review/rules/fui-styling.d.ts.map +0 -1
  89. package/dist/dts/code-review/rules/fui-trade-form.d.ts +0 -13
  90. package/dist/dts/code-review/rules/fui-trade-form.d.ts.map +0 -1
  91. package/dist/dts/code-review/submit-code-review.tool.d.ts +0 -12
  92. package/dist/dts/code-review/submit-code-review.tool.d.ts.map +0 -1
  93. package/dist/dts/code-review/unified-diff.d.ts +0 -7
  94. package/dist/dts/code-review/unified-diff.d.ts.map +0 -1
  95. package/dist/dts/code-review/verdict.d.ts +0 -23
  96. package/dist/dts/code-review/verdict.d.ts.map +0 -1
  97. package/dist/dts/components/code-review-result/code-review-result.d.ts +0 -26
  98. package/dist/dts/components/code-review-result/code-review-result.d.ts.map +0 -1
  99. package/dist/esm/code-review/code-review.types.js +0 -6
  100. package/dist/esm/code-review/code-reviewer.agent.js +0 -167
  101. package/dist/esm/code-review/code-reviewer.prompt.js +0 -103
  102. package/dist/esm/code-review/gate.js +0 -93
  103. package/dist/esm/code-review/index.js +0 -28
  104. package/dist/esm/code-review/review-changes.js +0 -123
  105. package/dist/esm/code-review/rules/context-trigger-map.js +0 -20
  106. package/dist/esm/code-review/rules/context.registry.js +0 -772
  107. package/dist/esm/code-review/rules/fui-ai-extensions.js +0 -306
  108. package/dist/esm/code-review/rules/fui-blotter.js +0 -596
  109. package/dist/esm/code-review/rules/fui-chart.js +0 -669
  110. package/dist/esm/code-review/rules/fui-column-defs.js +0 -862
  111. package/dist/esm/code-review/rules/fui-components.js +0 -245
  112. package/dist/esm/code-review/rules/fui-criteria.js +0 -538
  113. package/dist/esm/code-review/rules/fui-custom-renderer.js +0 -612
  114. package/dist/esm/code-review/rules/fui-dashboard.js +0 -604
  115. package/dist/esm/code-review/rules/fui-dialogs.js +0 -588
  116. package/dist/esm/code-review/rules/fui-entity-management.js +0 -1014
  117. package/dist/esm/code-review/rules/fui-error-boundary.js +0 -244
  118. package/dist/esm/code-review/rules/fui-eventing.js +0 -628
  119. package/dist/esm/code-review/rules/fui-flexlayout.js +0 -860
  120. package/dist/esm/code-review/rules/fui-flyout-panel.js +0 -432
  121. package/dist/esm/code-review/rules/fui-form-component.js +0 -898
  122. package/dist/esm/code-review/rules/fui-formatters.js +0 -415
  123. package/dist/esm/code-review/rules/fui-foundation-comms.js +0 -518
  124. package/dist/esm/code-review/rules/fui-global-filters.js +0 -778
  125. package/dist/esm/code-review/rules/fui-import-surface.js +0 -452
  126. package/dist/esm/code-review/rules/fui-inline-editing.js +0 -445
  127. package/dist/esm/code-review/rules/fui-layout.js +0 -431
  128. package/dist/esm/code-review/rules/fui-notifications.js +0 -439
  129. package/dist/esm/code-review/rules/fui-primitives.js +0 -1216
  130. package/dist/esm/code-review/rules/fui-rapid-grid-pro.js +0 -650
  131. package/dist/esm/code-review/rules/fui-redux-store.js +0 -522
  132. package/dist/esm/code-review/rules/fui-reporting.js +0 -506
  133. package/dist/esm/code-review/rules/fui-styling.js +0 -1229
  134. package/dist/esm/code-review/rules/fui-trade-form.js +0 -618
  135. package/dist/esm/code-review/submit-code-review.tool.js +0 -43
  136. package/dist/esm/code-review/unified-diff.js +0 -96
  137. package/dist/esm/code-review/verdict.js +0 -24
  138. package/dist/esm/components/code-review-result/code-review-result.js +0 -89
  139. package/docs/code-review.md +0 -137
@@ -1,1229 +0,0 @@
1
- /**
2
- * Context injected into the UI Builder system prompt.
3
- * Covers CSS best practices, design tokens, theming, and the modal-theme API
4
- * (injectThemeStyles / applyMode from @genesislcap/rapid-design-system)
5
- * for Genesis/Rapid design-system components.
6
- *
7
- * Sources verified against:
8
- * - foundation-ui/packages/foundation/foundation-ds/rapid-design-system/src/modal-theme/
9
- * - foundation-ui/packages/foundation/foundation-ds/rapid-design-system/src/_config/tokens/
10
- * - blank-app-seed/client-tmp/react/src (DefaultLayout, styles/default.theme.json, styles/active-theme.ts)
11
- * - showcase client-app/client/src (main.ts, styles/active-theme.ts, layouts/default.ts)
12
- */
13
- export const FUI_STYLING_TAGS = [
14
- 'design token',
15
- 'css variable',
16
- 'css token',
17
- '--design-unit',
18
- 'calc(var',
19
- 'background-color',
20
- 'padding',
21
- 'gap',
22
- 'color:',
23
- 'styling',
24
- 'dark mode',
25
- 'light mode',
26
- 'theme',
27
- 'luminance',
28
- 'dark theme',
29
- 'light theme',
30
- 'toggle theme',
31
- '--neutral-fill',
32
- '--accent-fill',
33
- '--neutral-layer',
34
- '--neutral-foreground',
35
- '--neutral-stroke',
36
- '--type-ramp',
37
- '--card-corner-radius',
38
- '--card-border',
39
- '--card-box-shadow',
40
- '--elevation-low',
41
- '--elevation-medium',
42
- '--control-corner-radius',
43
- 'border-radius',
44
- 'rounded corners',
45
- 'square corners',
46
- 'box-shadow',
47
- 'drop shadow',
48
- 'elevation',
49
- 'card border',
50
- 'card style',
51
- 'font-size',
52
- 'spacing',
53
- 'buy color',
54
- 'sell color',
55
- 'error color',
56
- 'success color',
57
- 'warning color',
58
- 'configureDesignSystem',
59
- 'design system provider',
60
- 'rapid-design-system-provider',
61
- 'baseLayerLuminance',
62
- 'StandardLuminance',
63
- 'customTokens',
64
- 'modal theme',
65
- 'default.theme.json',
66
- 'active-theme',
67
- 'modeToggleEnabled',
68
- 'injectThemeStyles',
69
- 'applyMode',
70
- 'resolveInitialMode',
71
- 'nextMode',
72
- 'isModeToggleEnabled',
73
- 'componentOverrides',
74
- 'defaultMode',
75
- 'showModeToggle',
76
- 'colorStrategy',
77
- 'z-index',
78
- 'zindex',
79
- 'stacking context',
80
- 'stacking order',
81
- 'position: sticky',
82
- 'position: relative',
83
- 'position: absolute',
84
- 'sticky header',
85
- 'sticky filter',
86
- 'layering',
87
- 'paints over',
88
- 'renders behind',
89
- 'behind the',
90
- 'hidden behind',
91
- 'covered by',
92
- 'overlaps',
93
- 'overlapping',
94
- 'clipped',
95
- 'cut off',
96
- 'dropdown is cut',
97
- 'popup behind',
98
- 'calendar behind',
99
- 'dropdown behind',
100
- 'not clickable',
101
- 'unclickable',
102
- ];
103
- export const FUI_STYLING_CONTEXT = `
104
- ## GENESIS UI — CSS & STYLING BEST PRACTICES
105
-
106
- ---
107
-
108
- ### Theme setup in a generated app (React)
109
-
110
- Every Genesis React app wraps its content in \`<rapid-design-system-provider>\` and ships with
111
- its theming ALREADY WIRED — do not re-implement it. The moving parts:
112
-
113
- | File | Role |
114
- |---|---|
115
- | \`src/styles/default.theme.json\` | The app's theme (modal format: shared tokens + light/dark modes) |
116
- | \`src/styles/active-theme.ts\` | Exports \`activeTheme\` (validated theme object) and \`modeToggleEnabled\` |
117
- | Layout owning the provider | Injects the theme once and applies the active mode |
118
-
119
- \`src/styles/active-theme.ts\` (already in the app):
120
-
121
- \`\`\`ts
122
- import { isModeToggleEnabled, toModalTheme } from '@genesislcap/rapid-design-system';
123
- import themeJson from './default.theme.json';
124
-
125
- export const activeTheme = toModalTheme(themeJson);
126
-
127
- export const modeToggleEnabled = isModeToggleEnabled(activeTheme);
128
- \`\`\`
129
-
130
- Layout wiring (already in the app's default layout) — inject the compiled theme sheet once in a
131
- \`useEffect\`, then apply the remembered/default mode; the header toggle advances to the next mode:
132
-
133
- \`\`\`tsx
134
- import React, { useEffect, useRef } from 'react';
135
- import {
136
- applyMode,
137
- injectThemeStyles,
138
- nextMode,
139
- resolveInitialMode,
140
- } from '@genesislcap/rapid-design-system';
141
- import { activeTheme, modeToggleEnabled } from '../../styles/active-theme';
142
-
143
- export const AppLayout: React.FC = () => {
144
- const providerRef = useRef<HTMLElement>(null);
145
- const themeModeRef = useRef<string>(resolveInitialMode(activeTheme));
146
-
147
- useEffect(() => {
148
- if (providerRef.current) {
149
- injectThemeStyles(providerRef.current, activeTheme); // compile + adopt the theme sheet once
150
- themeModeRef.current = resolveInitialMode(activeTheme); // remembered mode, else defaultMode
151
- applyMode(providerRef.current, activeTheme, themeModeRef.current);
152
- }
153
- }, []);
154
-
155
- const onLuminanceToggle = (): void => {
156
- if (providerRef.current) {
157
- themeModeRef.current = nextMode(activeTheme, themeModeRef.current);
158
- applyMode(providerRef.current, activeTheme, themeModeRef.current);
159
- }
160
- };
161
-
162
- return (
163
- <rapid-design-system-provider ref={providerRef}>
164
- <foundation-header
165
- onluminance-icon-clicked={onLuminanceToggle}
166
- show-luminance-toggle-button={modeToggleEnabled}
167
- />
168
- {/* app content */}
169
- </rapid-design-system-provider>
170
- );
171
- };
172
- \`\`\`
173
-
174
- **Do not restyle the app from \`src/styles/\`.** \`default.theme.json\` is regenerated from the
175
- project's own theme config on every generate, so its key resolves to nothing: the write is buffered,
176
- shows in the diff, and the preview service then skips it — the call succeeds and the theme is
177
- untouched. It is not a \`.ts\`/\`.tsx\`/\`.css\` file either, so you cannot even read it; this module is
178
- your view of it. \`styles/styles.css\` and \`active-theme.ts\` DO resolve to \`client/src/styles/…\` and
179
- a write to either lands, which is worse rather than better: \`styles.css\` is re-emitted from the
180
- theme's font config, so a copy of it pins the app's fonts for good, and \`active-theme.ts\` is the
181
- wiring the theme picker feeds, so hardcoding a theme there cuts the picker out of the app.
182
-
183
- **To restyle the app, SET the design tokens from a stylesheet you DO own** — a page or component
184
- \`.css\` file — and let them inherit into the components below:
185
-
186
- \`\`\`css
187
- /* Home/Home.css, applied to the page's outermost wrapper */
188
- .home-page {
189
- --card-corner-radius: 14px;
190
- --card-box-shadow: var(--elevation-medium, 0 4px 8px rgba(0,0,0,0.15));
191
- --control-corner-radius: 6; /* unitless */
192
- }
193
- \`\`\`
194
-
195
- Do not touch the provider/\`injectThemeStyles\` wiring above either. If the user wants a change that
196
- genuinely can only be made in the theme file (a new mode, a different accent across the whole app),
197
- say so plainly rather than writing a \`styles/\` file that will be silently discarded.
198
-
199
- **Import paths (verified):**
200
- \`\`\`ts
201
- import {
202
- applyMode, // (provider, theme, mode) — class swap + design-token recipe inputs
203
- injectThemeStyles, // (provider, theme) — compile + adopt the theme stylesheet once
204
- isModeToggleEnabled, // (theme) => boolean — showModeToggle ?? (mode count > 1)
205
- nextMode, // (theme, currentMode) => string — cycles mode names
206
- resolveInitialMode, // (theme) => string — remembered mode (localStorage) or defaultMode
207
- toModalTheme, // (json) => ModalTheme — validates a JSON theme import, throws if malformed
208
- } from '@genesislcap/rapid-design-system';
209
- \`\`\`
210
-
211
- ---
212
-
213
- ### default.theme.json structure (modal theme format)
214
-
215
- The theme lives at \`src/styles/default.theme.json\`. Top-level keys: \`id\`, \`colorStrategy\`
216
- (\`"adaptive"\` | \`"explicit"\`), \`defaultMode\`, optional \`showModeToggle\`, \`shared\`
217
- (mode-invariant) and \`modes\` (one entry per selectable mode):
218
-
219
- \`\`\`json
220
- {
221
- "id": "default",
222
- "colorStrategy": "adaptive",
223
- "defaultMode": "dark",
224
- "shared": {
225
- "design_tokens": {
226
- "color": {
227
- "accent": { "$value": "#0EAFE2", "$type": "color" },
228
- "neutral": { "$value": "#7C909B", "$type": "color" }
229
- },
230
- "fontFamily": {
231
- "bodyFont": { "$value": "Roboto, \\"Segoe UI\\", Arial, Helvetica, sans-serif", "$type": "fontFamily" }
232
- },
233
- "typography": {
234
- "baseFontSize": { "$value": "14px", "$type": "dimension" },
235
- "baseLineHeight": { "$value": "20px", "$type": "dimension" }
236
- },
237
- "style": {
238
- "density": { "$value": 0, "$type": "number" },
239
- "baseHeightMultiplier": { "$value": 10, "$type": "number" },
240
- "borderRadius": { "$value": 4, "$type": "number" },
241
- "strokeWidth": { "$value": 1, "$type": "number" }
242
- },
243
- "space": {
244
- "designUnit": { "$value": 4, "$type": "number" }
245
- }
246
- }
247
- },
248
- "modes": {
249
- "light": {
250
- "design_tokens": {
251
- "mode": { "luminance": { "$value": 1, "$type": "number" } }
252
- }
253
- },
254
- "dark": {
255
- "design_tokens": {
256
- "mode": { "luminance": { "$value": 0.23, "$type": "number" } }
257
- }
258
- }
259
- }
260
- }
261
- \`\`\`
262
-
263
- Both \`shared\` and each mode accept THREE sections — note the two different syntaxes:
264
-
265
- | Section | Syntax | Applied via | Emitted to CSS? |
266
- |---|---|---|---|
267
- | \`design_tokens\` | nested \`{ "$value", "$type" }\` groups | JS — FAST design-token recipes | No |
268
- | \`customTokens\` | **FLAT** \`"--var": "value"\` string map | compiled theme stylesheet | Yes |
269
- | \`componentOverrides\` | \`"selector": { "css-prop": "value" }\` | compiled theme stylesheet | Yes |
270
-
271
- - \`design_tokens\` are recipe inputs (accent palette, fonts, spacing…) — never emitted to CSS
272
- directly; the CSS custom properties listed below are what the recipes produce.
273
- - Mode-dependent values (e.g. \`mode.luminance\`) go under \`modes.<name>.design_tokens\`; at a
274
- given leaf the mode value overrides the \`shared\` value.
275
- - \`showModeToggle\` (optional) overrides the default "toggle shown when >1 modes" inference.
276
-
277
- ---
278
-
279
- ### \`--design-unit\` — THE MOST IMPORTANT RULE
280
-
281
- \`--design-unit\` is a **unitless number** (default value: \`4\`). It has no \`px\` unit attached.
282
-
283
- **WRONG — produces nothing (unitless result, ignored by browser):**
284
- \`\`\`css
285
- padding: calc(var(--design-unit) * 2); /* no unit — does nothing */
286
- gap: var(--design-unit); /* unitless — does nothing */
287
- \`\`\`
288
-
289
- **CORRECT — multiply the px unit into the expression:**
290
- \`\`\`css
291
- padding: calc(var(--design-unit) * 2px); /* = 8px */
292
- gap: calc(var(--design-unit) * 3px); /* = 12px */
293
- margin: calc(var(--design-unit) * 1px); /* = 4px */
294
- \`\`\`
295
-
296
- The pattern is always: \`calc(var(--design-unit) * <multiplier>px)\`
297
-
298
- For complex expressions (combining with other unitless tokens):
299
- \`\`\`css
300
- padding: calc((var(--design-unit) * 2 + 6) * 1px); /* = 14px */
301
- border-radius: calc(var(--control-corner-radius) * 1px);
302
- \`\`\`
303
-
304
- **Note:** \`--control-corner-radius\` and \`--stroke-width\` are also **unitless numbers** in
305
- the FAST token system — they require \`* 1px\` to become valid CSS lengths.
306
- Only tokens listed as "px value" below can be used bare.
307
-
308
- ---
309
-
310
- ### Spacing tokens
311
-
312
- | Token | Type | Default | Usage |
313
- |---|---|---|---|
314
- | \`--design-unit\` | unitless number | 4 | Base spacing — always \`calc(var(--design-unit) * Npx)\` |
315
- | \`--density\` | unitless number | 0 | Vertical density adjustment — use in compound calcs |
316
- | \`--base-height-multiplier\` | unitless number | 10 | Component height calculations |
317
- | \`--control-corner-radius\` | unitless number | 4 | Border radius of a CONTROL (button, input) — requires \`* 1px\`: \`calc(var(--control-corner-radius) * 1px)\` |
318
- | \`--stroke-width\` | unitless number | 1 | Border thickness — requires \`* 1px\`: \`calc(var(--stroke-width) * 1px)\` |
319
-
320
- ---
321
-
322
- ### Container / card chrome tokens
323
-
324
- These are the tokens a design-system CONTAINER paints itself with. They are **separate from the
325
- control tokens above** and they are the ones a theme actually sets — the default \`corporate-light\`
326
- theme ships \`--card-corner-radius: 10px\` and \`--card-border: 2px solid #eaeff4\` while leaving
327
- \`style.borderRadius\` (which becomes \`--control-corner-radius\`) at \`0\`. Reach for the control
328
- radius on a card and you square off a card the theme deliberately rounded.
329
-
330
- | Token | Fallback the component uses when the theme sets none | Read by |
331
- |---|---|---|
332
- | \`--card-corner-radius\` (CSS length, e.g. \`10px\`) | \`calc(var(--control-corner-radius) * 1px)\` | \`rapid-card\`, \`rapid-dialog\`, \`rapid-tabs\` |
333
- | \`--card-corner-radius\` | \`calc(var(--control-corner-radius) * 1.5px)\` | \`rapid-tab-panel\`, FlexLayout tabset/tab-content |
334
- | \`--card-border\` (CSS \`border\` shorthand) | \`1px solid var(--neutral-stroke-rest)\` (card, FlexLayout tabset); \`calc(var(--stroke-width) * 1px) solid var(--neutral-stroke-rest)\` (dialog); \`0\` (tabs) | \`rapid-card\`, \`rapid-dialog\`, \`rapid-tabs\`, FlexLayout |
335
- | \`--card-box-shadow\` (CSS \`box-shadow\`) | \`none\` | \`rapid-card\` |
336
- | \`--elevation-low\` (CSS \`box-shadow\`) | *(none — see "the elevation tokens can be missing" below)* | your CSS |
337
- | \`--elevation-medium\` (CSS \`box-shadow\`) | *(none — see "the elevation tokens can be missing" below)* | your CSS |
338
-
339
- **The fallback column is the COMMON case, not a guarantee.** Each component picks its own fallback
340
- and a few omit one entirely, so read the component you are actually next to rather than assuming
341
- this table covers it. Two live counter-examples: the \`foundation-layout\` web component writes
342
- \`border-bottom: var(--card-border, 0)\` (fallback \`0\`, *not* the \`1px solid …\` the "card, FlexLayout
343
- tabset" grouping suggests), and \`flexlayout-react.overrides.css\` writes a bare
344
- \`var(--card-corner-radius)\` with **no** fallback at all on the tabset's bottom corners — under a
345
- theme that sets no card radius, that declaration resolves to nothing.
346
-
347
- **Note the \`* 1.5px\` row.** \`rapid-tab-panel\`, \`flexlayout-react.overrides.css\` and
348
- \`foundation-layout\` multiply by **1.5**, not 1. So hand-writing
349
- \`calc(var(--control-corner-radius) * 1px)\` next to a FlexLayout tile does not reproduce the
350
- FlexLayout look even when \`--card-corner-radius\` is unset. Copy the WHOLE expression, with the
351
- multiplier the neighbouring component uses:
352
-
353
- \`\`\`css
354
- /* card / dialog / tabs: */
355
- border-radius: var(--card-corner-radius, calc(var(--control-corner-radius) * 1px));
356
- /* tab-panel / FlexLayout item: */
357
- border-radius: var(--card-corner-radius, calc(var(--control-corner-radius) * 1.5px));
358
- \`\`\`
359
-
360
- \`\`\`css
361
- /* WRONG — the control radius is 0 in the default theme, and an outer-tree class beats the
362
- component's own :host rule, so this squares off a rounded <Card>: */
363
- .kpi-card { border-radius: calc(var(--control-corner-radius) * 1px); }
364
-
365
- /* CORRECT — the design system's own expression: theme radius, control radius as the fallback: */
366
- .kpi-card { border-radius: var(--card-corner-radius, calc(var(--control-corner-radius) * 1px)); }
367
-
368
- /* BEST — if the element IS a <Card>, say nothing and let it paint its own corners. */
369
- \`\`\`
370
-
371
- **Square controls, rounded surfaces — that is the themes' intent, not an oversight.** The design
372
- system's own default control radius is \`4\`, yet corporate-light, citi-bank and sunset all set
373
- \`style.borderRadius\` to \`0\` *and* define a non-zero \`--card-corner-radius\` (\`10px\`, \`10px\`, \`2px\`).
374
- So "the buttons look square" is the theme working as designed. **"Make the buttons rounded" is
375
- therefore a request to DEVIATE from the theme, and the sanctioned way to do that is to SET the
376
- token on a wrapper you own — \`.my-page { --control-corner-radius: 6; }\`, unitless** (see "SETTING a
377
- design token" below). Never hand-write \`border-radius\` onto the control itself.
378
-
379
- #### Shadows are tokens too — and the elevation tokens can be MISSING
380
-
381
- \`\`\`css
382
- /* WRONG — hand-rolled, so it ignores the theme entirely: */
383
- .kpi-card:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); }
384
-
385
- /* CORRECT — the theme's elevation, WITH the fallback that keeps it working under every theme: */
386
- .kpi-card:hover { box-shadow: var(--elevation-medium, 0 4px 8px rgba(0,0,0,0.15)); }
387
- \`\`\`
388
-
389
- Unlike \`--card-*\`, the \`--elevation-*\` tokens have **no component fallback anywhere** — they exist
390
- only if the theme defines them, and \`rapid-dark\` defines **neither** \`--elevation-low\` nor
391
- \`--elevation-medium\`. A bare \`box-shadow: var(--elevation-medium)\` therefore resolves to nothing
392
- under that theme and you get no shadow at all, silently — no error, no warning, just a flat card
393
- where you asked for a lift. **Always write the two-argument form**, so the theme wins where it has
394
- an opinion and you still get an elevation where it does not:
395
-
396
- - \`var(--elevation-low, 0 2px 4px rgba(0,0,0,0.1))\`
397
- - \`var(--elevation-medium, 0 4px 8px rgba(0,0,0,0.15))\`
398
-
399
- Those fallback values are the ones the themes that DO define the tokens ship, so the two paths look
400
- identical. A colour literal inside a \`var()\` fallback is not a hardcoded colour and is not linted
401
- as one — it is a theme-aware default.
402
-
403
- #### SETTING a design token (the supported way to restyle)
404
-
405
- A design token is an ordinary inherited CSS custom property, so you can **set** it on any wrapper
406
- and every design-system component inside that subtree picks it up — through the shadow boundary,
407
- because custom properties inherit. This is how you restyle without ever touching a component's
408
- internals:
409
-
410
- \`\`\`css
411
- /* Everything inside .my-page: rounder cards, a visible elevation, tighter controls. */
412
- .my-page {
413
- --card-corner-radius: 14px; /* a LENGTH — px is correct here */
414
- --card-box-shadow: var(--elevation-medium, 0 4px 8px rgba(0,0,0,0.15));
415
- --card-border: calc(var(--stroke-width) * 1px) solid var(--neutral-stroke-divider-rest);
416
- --control-corner-radius: 6; /* UNITLESS — no px (see below) */
417
- }
418
- \`\`\`
419
-
420
- **Unitless vs length — getting this backwards fails silently.** \`--control-corner-radius\`,
421
- \`--stroke-width\`, \`--design-unit\`, \`--density\` and \`--base-height-multiplier\` are unitless
422
- NUMBERS; components multiply them (\`calc(var(--control-corner-radius) * 1px)\`). Writing
423
- \`--control-corner-radius: 6px\` makes that \`calc(6px * 1px)\`, which is invalid, so the browser
424
- throws the declaration away and the corner silently drops to \`0\` — no console error, no visible
425
- clue. \`--card-corner-radius\`, \`--card-border\`, \`--card-box-shadow\` and the \`--elevation-*\`
426
- tokens are the opposite: they are consumed verbatim, so they need real units.
427
-
428
- Standard spacing scale:
429
- \`\`\`css
430
- calc(var(--design-unit) * 1px) /* = 4px — tight */
431
- calc(var(--design-unit) * 2px) /* = 8px — small */
432
- calc(var(--design-unit) * 3px) /* = 12px — medium-small */
433
- calc(var(--design-unit) * 4px) /* = 16px — medium */
434
- calc(var(--design-unit) * 6px) /* = 24px — large */
435
- calc(var(--design-unit) * 8px) /* = 32px — x-large */
436
- \`\`\`
437
-
438
- ---
439
-
440
- ### Colour tokens
441
-
442
- **Fills / Backgrounds**
443
- \`\`\`css
444
- var(--neutral-fill-rest) /* default neutral fill */
445
- var(--neutral-fill-hover) /* hover state fill */
446
- var(--neutral-fill-active) /* active/pressed fill */
447
- var(--neutral-fill-input-rest) /* input field background */
448
- var(--neutral-fill-layer-rest) /* card/panel inner background */
449
- var(--neutral-fill-stealth-rest) /* ghost/transparent fill */
450
- var(--neutral-fill-stealth-hover) /* ghost hover */
451
- var(--neutral-fill-stealth-active) /* ghost active — used by toolbar buttons */
452
- var(--accent-fill-rest) /* primary accent fill */
453
- var(--accent-fill-hover) /* accent hover */
454
- var(--fill-color) /* overall page/app background */
455
- \`\`\`
456
-
457
- **Layers / Elevation (use for container backgrounds)**
458
- \`\`\`css
459
- var(--neutral-layer-1) /* highest elevation surface */
460
- var(--neutral-layer-2) /* raised cards */
461
- var(--neutral-layer-3) /* default elevation */
462
- var(--neutral-layer-4) /* deepest surface */
463
- var(--neutral-layer-card-container) /* card container backgrounds */
464
- var(--neutral-layer-floating) /* modals, popovers */
465
- \`\`\`
466
-
467
- **Text / Foreground**
468
- \`\`\`css
469
- var(--neutral-foreground-rest) /* primary body text */
470
- var(--neutral-foreground-hint) /* secondary / hint / muted text */
471
- var(--accent-foreground-rest) /* accent-coloured text */
472
- var(--foreground-on-accent-rest) /* text on top of accent background */
473
- \`\`\`
474
-
475
- **Stroke / Border**
476
- \`\`\`css
477
- var(--neutral-stroke-rest) /* standard border */
478
- var(--neutral-stroke-hover) /* border on hover */
479
- var(--neutral-stroke-active) /* border on press */
480
- var(--neutral-stroke-divider-rest) /* divider lines */
481
- \`\`\`
482
-
483
- **Semantic / Status (verified in custom.ts + color.hex.ts)**
484
- \`\`\`css
485
- var(--error-color) /* #F9644D — validation failure, error state */
486
- var(--success-color) /* #7ACC79 — success state */
487
- var(--warning-color) /* #FFB660 — warning state */
488
- var(--info-color) /* #11C9FC — informational */
489
- var(--serious-notify-color) /* #F9644D — serious notification */
490
- var(--buy-color) /* #7ACC79 — buy / bid side */
491
- var(--sell-color) /* #F14376 — sell / ask side */
492
- \`\`\`
493
-
494
- **Tile and page stylesheets are GLOBAL.** Only \`*.module.css\` is scoped, and the scaffold uses that
495
- for \`DefaultLayout\` alone; every \`<Tile>Component.css\` you write is imported for side effects and
496
- its selectors land in the document, with components rendering in the light DOM. So two tiles that
497
- both declare \`.tile-title\` do not each get their own — whichever imports last wins, for BOTH.
498
- MEASURED: one buildout declared a bold base-size \`.tile-title\` in step 8 and an 11px dim uppercased
499
- one in step 12; both tiles share a screen, so the earlier tile's labels silently changed two steps
500
- after it was finished. Namespace every selector under the tile's own root class
501
- (\`.trading-overview .tile-title\`) or name it after the tile (\`.trading-overview__title\`), and make
502
- that root class distinctive — the tile's name, never \`panel\`, \`card\` or \`container\`.
503
-
504
- **These nine are FROZEN swatches, not mode-aware recipes.** They hold one constant value in BOTH
505
- themes — the light and dark blocks of \`default.theme.json\` redefine \`--neutral-layer-*\` but never
506
- these. They are tuned for a dark ground, so as TEXT on the light theme's white surfaces they wash
507
- out. MEASURED contrast against \`#ffffff\`: \`--warning-color\` 1.73:1, \`--success-color\`/\`--buy-color\`
508
- 1.96:1, \`--error-color\` 3.02:1, \`--sell-color\` 3.62:1 — all under the 4.5:1 AA floor, while on the
509
- dark ground they run 4.0–8.4:1. A preview opened in dark mode looks perfect and the same screen is
510
- barely readable in light.
511
-
512
- So: use a frozen swatch as a FILL or a tint, never as the foreground on a \`--neutral-layer-*\`
513
- surface. For text, \`success\`, \`error\`, \`warning\`, \`secondary\` and \`tertiary\` each have a DERIVED,
514
- mode-aware family that is computed against the live surface and does track the toggle:
515
- \`--{name}-foreground-rest\` (legible text on the current surface), \`--{name}-fill-rest\` (the fill),
516
- and \`--foreground-on-{name}-rest\` (text ON that fill). **\`buy\`, \`sell\`, \`info\` and \`serious-notify\`
517
- have NO derived family** — there is no \`--buy-foreground-rest\`; for side colouring prefer a tinted
518
- pill (fill + \`--foreground-on-…\`) over coloured text, or accept the swatch only where the surface
519
- is known-dark.
520
-
521
- **Text on a semantic fill takes that fill's OWN foreground token.** \`--foreground-on-accent-rest\`
522
- is computed against the ACCENT fill, which is dark blue, so it resolves to WHITE in both themes —
523
- and white on these pastel fills fails AA everywhere: 1.96:1 on \`--buy-color\`/\`--success-color\`
524
- (black scores 10.74), 1.73:1 on \`--warning-color\` (black 12.11), 3.02:1 on \`--error-color\`,
525
- 3.62:1 on \`--sell-color\`. Use \`--foreground-on-success-rest\` / \`-error-\` / \`-warning-\`, which the
526
- platform computes against that fill and which resolve to black on all four. \`--buy-color\` is the
527
- same hex as \`--success-color\`, and the error foreground resolves correctly on the sell fill, so
528
- those two map onto the success/error pair. Keep \`--foreground-on-accent-rest\` for text on an
529
- ACCENT fill, which is what it is for.
530
-
531
- Financial-markets example — verified token names from \`custom.ts\` and the semantic palettes:
532
- \`\`\`css
533
- /* TEXT — the derived family, so it stays legible when the theme flips */
534
- .axes-grid .pnl-positive { color: var(--success-foreground-rest, #7ACC79); } /* gains */
535
- .axes-grid .pnl-negative { color: var(--error-foreground-rest, #F9644D); } /* losses */
536
-
537
- /* FILL + the foreground derived from THAT fill — never the accent's.
538
- Namespaced under the tile's root class, because this stylesheet is global. */
539
- .axes-grid .side-buy { background: var(--buy-color); color: var(--foreground-on-success-rest, #14210f); }
540
- .axes-grid .side-sell { background: var(--sell-color); color: var(--foreground-on-error-rest, #2b0d0d); }
541
-
542
- /* A tint is also fine — the swatch is the FILL here, not the text */
543
- .axes-grid .side-buy-subtle { background: color-mix(in srgb, var(--buy-color) 15%, transparent); }
544
- \`\`\`
545
-
546
- **A token you invent is a hardcoded colour wearing a \`var()\`.** \`var(--x, fallback)\` falls back
547
- SILENTLY when \`--x\` does not exist — nothing errors, nothing warns, and the fallback is simply what
548
- renders. So an invented name is not "token-driven with a safety net"; it is the literal, permanently,
549
- and it will never follow the theme.
550
-
551
- MEASURED: asked for tinted bid/ask pills, the agent wrote
552
- \`background-color: var(--buy-color-bg, rgba(34, 197, 94, 0.15))\`. \`--buy-color\` is real
553
- (\`rapid-design-system/_config/tokens/custom.ts\` registers it via \`create('buy-color')\`);
554
- **\`--buy-color-bg\` is not defined anywhere**, so every one of those pills is exactly the
555
- hardcoded rgba, in every theme.
556
-
557
- The custom tokens that actually exist are only these nine — \`--buy-color\`, \`--sell-color\`,
558
- \`--success-color\`, \`--error-color\`, \`--warning-color\`, \`--info-color\`,
559
- \`--serious-notify-color\`, \`--secondary-color\`, \`--tertiary-color\` — plus the FAST families
560
- (\`--neutral-*\`, \`--accent-*\`, \`--type-ramp-*\`, \`--design-unit\`, \`--stroke-width\`) and
561
- whatever the theme adds under \`customTokens\` (\`--card-corner-radius\`, \`--card-border\`,
562
- \`--card-box-shadow\`, \`--elevation-low\`, \`--elevation-medium\`), and — for \`success\`, \`error\`,
563
- \`warning\`, \`secondary\` and \`tertiary\` ONLY — the derived semantic palettes
564
- (\`--{name}-fill-rest\`, \`--{name}-foreground-rest\`, \`--foreground-on-{name}-rest\`, plus their
565
- \`-hover\`/\`-active\`/\`-focus\` steps).
566
-
567
- **Do not append any other suffix to a \`*-color\` token.** \`--success-color-subtle\`,
568
- \`--error-color-bg\`, \`--buy-color-light\` and \`--warning-color-dark\` do not exist, and neither does
569
- \`--buy-foreground-rest\` (buy/sell/info/serious-notify have no derived palette). An invented name is
570
- especially dangerous written as \`var(--success-color-subtle, rgba(16,124,65,0.15))\`, because it
571
- LOOKS tokenised and renders correctly — the name never resolves, so the fallback is not a fallback
572
- at all but the permanent value, frozen off-theme forever. MEASURED: 14 such declarations across 5
573
- files in one buildout, covering the background of every Side and Status pill in the app.
574
-
575
- For a TINT of a semantic colour, derive it from the real token instead of inventing a name:
576
- \`\`\`css
577
- .bid-pill { background-color: color-mix(in srgb, var(--buy-color) 15%, transparent); color: var(--buy-color); }
578
- \`\`\`
579
- If you need a plain surface behind the pill rather than a tint, use a real neutral
580
- (\`var(--neutral-fill-rest)\`) — but then let the TEXT carry the meaning, because that surface is
581
- grey and will not read as buy or sell.
582
-
583
- ---
584
-
585
- ### Typography tokens
586
-
587
- \`\`\`css
588
- font-family: var(--body-font);
589
-
590
- /* Type ramp (smallest → largest) */
591
- font-size: var(--type-ramp-minus-2-font-size); /* 12px */
592
- font-size: var(--type-ramp-minus-1-font-size); /* 13px */
593
- font-size: var(--type-ramp-base-font-size); /* 14px — default body */
594
- font-size: var(--type-ramp-plus-1-font-size); /* 15px */
595
- font-size: var(--type-ramp-plus-2-font-size); /* 16px */
596
- font-size: var(--type-ramp-plus-3-font-size); /* 17px */
597
- font-size: var(--type-ramp-plus-4-font-size); /* 18px */
598
- font-size: var(--type-ramp-plus-5-font-size); /* 19px */
599
- font-size: var(--type-ramp-plus-6-font-size); /* 20px */
600
-
601
- /* Matching line heights */
602
- line-height: var(--type-ramp-base-line-height); /* 20px */
603
- \`\`\`
604
-
605
- **Display figure — focal KPI/stat value ONLY.** The ramp tops out at plus-6, too small for
606
- a tile's one hero number. Scale the top token instead of reaching for px:
607
-
608
- \`\`\`css
609
- font-size: calc(var(--type-ramp-plus-6-font-size) * 1.5);
610
- line-height: 1.15;
611
- font-variant-numeric: tabular-nums; /* digits stop jittering as values tick */
612
- \`\`\`
613
-
614
- One per tile; labels stay on the ramp (\`--type-ramp-minus-1-font-size\` + \`--neutral-foreground-hint\`).
615
- Does NOT license px sizes — DP-5 still applies.
616
-
617
- ---
618
-
619
- ### Theming (dark/light toggle)
620
-
621
- The theme declares named modes (\`light\`, \`dark\`). The \`id\`, \`defaultMode\` and token values
622
- vary with the theme the app was generated with (e.g. a \`corporate-light\` app boots light with its
623
- own accent and customTokens) — read the app's actual \`src/styles/default.theme.json\` rather than
624
- assuming the example above. Switching dark/light is a MODE switch via the modal-theme API — never
625
- set luminance values directly:
626
-
627
- \`\`\`tsx
628
- import { applyMode, nextMode } from '@genesislcap/rapid-design-system';
629
- import { activeTheme } from '../../styles/active-theme';
630
-
631
- // inside the component that owns the provider ref + current mode (see layout wiring above):
632
- const onLuminanceToggle = (): void => {
633
- themeModeRef.current = nextMode(activeTheme, themeModeRef.current);
634
- applyMode(providerRef.current, activeTheme, themeModeRef.current);
635
- };
636
- \`\`\`
637
-
638
- \`applyMode\` swaps a \`theme-<mode>\` class on the provider, re-applies that mode's
639
- \`design_tokens\`, keeps the legacy \`.light\` class on \`document.body\`/provider in sync, and
640
- remembers the choice in \`localStorage\` per theme \`id\` (\`resolveInitialMode\` restores it on
641
- reload). The header toggle is gated by \`modeToggleEnabled\` from \`active-theme.ts\` — a
642
- single-mode theme (or \`"showModeToggle": false\`) hides it automatically.
643
-
644
- ---
645
-
646
- ### Custom tokens (app-specific CSS variables) — READ-ONLY, described so you can READ the theme
647
-
648
- > **You cannot author this.** \`default.theme.json\` is regenerated from project config, so its key
649
- > resolves to nothing (see DP-12): the write buffers, then the service skips it. This section is here
650
- > so that when you OPEN the app's theme and find a \`customTokens\` block you know what it means and
651
- > which \`var(--…)\` names it makes available to the CSS you write. To introduce a new variable of
652
- > your own, declare it on a wrapper in a \`.css\` file you own — \`.my-page { --spacing-panel: 12px; }\`
653
- > — which inherits exactly the same way.
654
-
655
- A theme MAY carry a \`customTokens\` key — under \`shared\` (mode-invariant) or under a specific mode.
656
- It is a **FLAT** map of CSS custom-property names to string values, compiled into the injected
657
- theme stylesheet:
658
-
659
- \`\`\`json
660
- {
661
- "shared": {
662
- "design_tokens": { "...": "..." },
663
- "customTokens": {
664
- "--spacing-panel": "12px",
665
- "--grid-header-height": "40px"
666
- }
667
- },
668
- "modes": {
669
- "light": { "customTokens": { "--card-border": "2px solid #eaeff4" } },
670
- "dark": { "customTokens": { "--card-border": "1px solid #2f3c4c" } }
671
- }
672
- }
673
- \`\`\`
674
-
675
- Keys in such a block start with \`--\` and values are plain CSS strings. Nested \`{ "$value" }\`
676
- objects are the LEGACY format — in the modal file they compile to invalid CSS and are silently
677
- dropped (see DP-8), which is worth knowing when a theme token you expected does not resolve.
678
- Reading them from your CSS is normal: \`padding: var(--spacing-panel);\`.
679
-
680
- ---
681
-
682
- ### Component overrides (scoped CSS rules in the theme) — READ-ONLY, for recognition only
683
-
684
- > **You cannot author this either**, for the same reason. It is documented so that when a
685
- > design-system component in the running app looks different from its stock appearance, you can
686
- > open the theme, find the \`componentOverrides\` rule responsible, and stop hunting for a
687
- > stylesheet that does not exist. **Do not propose adding one.** The equivalent you CAN reach is a
688
- > token set on a wrapper you own — \`.my-page { --card-border: …; }\` — which inherits through the
689
- > shadow boundary and needs no \`::part()\`.
690
-
691
- \`componentOverrides\` maps a CSS selector (host tag, class, or \`::part()\`) to a declarations
692
- object, compiled into the theme stylesheet. Values in a well-formed theme reference tokens via
693
- \`var(--…)\` rather than hard-coded hex:
694
-
695
- \`\`\`json
696
- {
697
- "shared": {
698
- "componentOverrides": {
699
- "rapid-button": { "border-radius": "10px" },
700
- "rapid-dialog::part(dialog)": { "border": "var(--card-border)" }
701
- }
702
- }
703
- }
704
- \`\`\`
705
-
706
- The key is \`componentOverrides\` — a \`"parts"\` key is silently ignored (see DP-9), so a theme that
707
- uses \`"parts"\` has no effect at all. A rule sits under a mode only when its declarations differ
708
- between modes. \`::part()\` reaches one shadow boundary from where the theme sheet is adopted.
709
-
710
- ---
711
-
712
- ### LAYERING — z-index, stacking contexts, and popups that hide behind neighbours
713
-
714
- Every Genesis input that opens a popup — \`Select\`, \`Multiselect\`, \`CategorizedMultiselect\`,
715
- \`Combobox\`, \`DatePicker\`, \`DropdownMenu\`, \`Filters\` — renders that popup **inside its own shadow
716
- root** as an absolutely-positioned div. None of them use a portal or \`anchored-region\`, so the popup
717
- cannot escape the page box it sits in. Two different things then break it, and they need different
718
- fixes:
719
-
720
- | Symptom | Failure mode | Fix |
721
- |---|---|---|
722
- | Popup is fully laid out but a **neighbouring element paints over it** (and its area is unclickable) | **Stacking** | z-index on the popup's container — this section |
723
- | Popup is **cut off at a container's edge**, the hidden part simply absent | **Clipping** (\`overflow: hidden\`, \`contain: paint/content\`) | \`overflow: visible; contain: none\` on the clipping ancestor — see \`fui-global-filters\` |
724
-
725
- Diagnose before fixing: **z-index never fixes clipping, and \`overflow\` never fixes stacking.**
726
-
727
- #### Why the component's own z-index does not save you
728
-
729
- \`DatePicker\`'s calendar declares \`z-index: 999\`; \`Select\`'s listbox declares \`z-index: 1\`. Those
730
- numbers are **not global**. A z-index is only resolved against the element's nearest ancestor
731
- **stacking context**, and for a shadow-DOM popup that ancestor lives in *your* page CSS. If your
732
- container is a stacking context with \`z-index: 10\`, then the whole subtree — calendar included —
733
- paints as "10" relative to that container's siblings. The internal 999 only orders things *within*
734
- the container. So the popup's layering is decided by page CSS you write, never by the component.
735
-
736
- #### What silently creates a stacking context
737
-
738
- \`position: sticky\` and \`position: fixed\` create one **always — even with \`z-index: auto\`**. That is
739
- the usual surprise. Also: \`position: relative/absolute\` + any \`z-index\` other than \`auto\`; a flex or
740
- grid **item** with a \`z-index\` (even \`position: static\`); \`opacity\` < 1; \`transform\`, \`filter\`,
741
- \`perspective\`, \`clip-path\`, \`mask\`, \`backdrop-filter\` other than \`none\`; \`isolation: isolate\`;
742
- \`contain: layout | paint | strict | content\`; \`container-type\` other than \`normal\`; \`will-change\`
743
- naming any of those.
744
-
745
- #### The app's z-index ladder — pick values that respect it
746
-
747
- Verified from the installed packages and the generated app shell. Page CSS competes **directly**
748
- with these, because the route container (\`.content\` in \`DefaultLayout.module.css\`) is
749
- \`position: absolute; z-index: auto\` — not a stacking context, so it does not sandbox your values:
750
-
751
- | Layer | z-index | Source |
752
- |---|---|---|
753
- | \`Modal\` (native \`showModal()\`) | **top layer** — above every row here | \`foundation-ui/modal/modal.ts\` — no z-index involved |
754
- | Flyout panel / its backdrop | 2001 / 2000 | \`foundation-ui/flyout/flyout.styles\` |
755
- | \`Dialog\` (native non-modal \`show()\`) | **1001** — clears the header and tiles; loses to Flyout | \`foundation-ui/dialog/dialog.styles\` \`--dialog-z-index\` (default since FUI 15.7.2); see \`fui-dialogs\` DP-6 |
756
- | \`foundation-header\` (whole bar, incl. its nav submenus) | 999 | generated \`layouts/default/DefaultLayout.module.css\` |
757
- | FlexLayout **drag** chrome (overlay, splitter drag, drop outlines) | 1000 | \`flexlayout-react/style/*.css\` — only live during a tab drag |
758
- | \`Multiselect\` / \`DatePicker\` / \`CategorizedMultiselect\` popups | 1000 / 999 | \`foundation-ui\` — scoped to their container, see above |
759
- | FlexLayout tab stamps | 100 | \`flexlayout-react/style/*.css\` |
760
- | \`actions-menu\` | 100 | \`foundation-ui\` |
761
- | FlexLayout tab overlay / splitter | 20 / 10 | \`flexlayout-react/style/*.css\` |
762
- | \`Select\` listbox, \`DropdownMenu\` | 1 | \`foundation-ui\` |
763
-
764
- **The safe band for page-shell chrome is \`100 < z-index < 999\`** — above FlexLayout's static
765
- chrome, below the header and the dialog/flyout layer. **Use \`z-index: 200\`.** Never go \`>= 999\`:
766
- that puts a page strip over the app header's own menus. (FlexLayout's 1000 drag chrome is
767
- irrelevant — no popup is open while the user drags a tab.)
768
-
769
- #### THE RULE for a page shell
770
-
771
- In a page shell (the flex column above/around \`<Layout>\`), **exactly one** element carries a
772
- z-index: the container holding the popup-opening inputs. Everything else carries none.
773
-
774
- \`\`\`css
775
- /* CORRECT — filter/toolbar row owns the only z-index in the shell */
776
- .my-page {
777
- display: flex;
778
- flex-direction: column;
779
- height: calc(100vh - 48px);
780
- }
781
-
782
- .my-page-filters { /* holds Select / DatePicker / Multiselect */
783
- position: relative; /* needed for z-index to apply */
784
- z-index: 200; /* clears the KPI strip AND the FlexLayout tiles below */
785
- display: flex;
786
- gap: calc(var(--design-unit) * 4px);
787
- padding: calc(var(--design-unit) * 3px) calc(var(--design-unit) * 4px);
788
- flex-shrink: 0;
789
- }
790
-
791
- .my-page-kpi-strip { /* NO position, NO z-index */
792
- display: flex;
793
- gap: calc(var(--design-unit) * 4px);
794
- padding: calc(var(--design-unit) * 3px) calc(var(--design-unit) * 4px);
795
- flex-shrink: 0;
796
- }
797
-
798
- .my-page-layout-container { /* position: relative is required by FlexLayout; NO z-index */
799
- flex: 1;
800
- position: relative;
801
- min-height: 0;
802
- }
803
- \`\`\`
804
-
805
- Three traps this avoids:
806
-
807
- 1. **Never \`position: sticky\` on a page-shell strip.** In a generated page shell nothing scrolls —
808
- \`.default-layout\` and \`body\` are \`overflow: hidden\` and the FlexLayout container absorbs the
809
- remaining height — so \`sticky\` is a **no-op that still creates a stacking context**, trapping
810
- every popup in the strip. Only use \`sticky\` when there is a real scroll container.
811
- 2. **Never give two sibling strips the same z-index.** Equal z-index is resolved by DOM order, so
812
- the *later* sibling (typically the KPI strip, rendered under the filter row) paints over the
813
- earlier one's popups.
814
- 3. **Removing the z-index from everything is NOT the fix.** With the filter row unpositioned, its
815
- popups drop below the FlexLayout container (\`position: relative\`) and the tiles paint over them
816
- instead. The filter row must be positioned *and* out-rank its later siblings.
817
-
818
- #### Popups INSIDE a FlexLayout tile — different problem, do not reach for z-index
819
-
820
- \`.flexlayout__tab\` is \`overflow: hidden\`, and there is no stacking context between tile content and
821
- the root. So inside a tile the failure is **clipping**, not stacking: a popup taller than the space
822
- left below its field is simply cut off at the tile edge, and no z-index changes that. Options, best
823
- first: place the popup-opening field at the **top** of the tile so its popup opens into tile space;
824
- keep the option list short; or move the filter into the page shell above \`<Layout>\` and apply the
825
- rule above. See \`fui-global-filters\` for the \`overflow: visible; contain: none\` escape when the
826
- clipping ancestor is a card you control.
827
-
828
- ---
829
-
830
- ### What is safe to add in custom CSS
831
-
832
- - Layout: \`display\`, \`flex\`, \`grid\`, \`gap\`, \`padding\`, \`margin\`, \`width\`, \`height\`, \`min-height\`
833
- - **\`min-height: 0\` — required, not optional, on any flex/grid item that wraps a \`height: 100%\`
834
- child** (a grid, chart, \`EntityManagement\`, \`Layout\`). A flex item defaults to
835
- \`min-height: auto\` and will NOT shrink below its content, so the wrapper keeps the child's
836
- intrinsic height and the child either collapses to nothing or overflows its parent. The moment
837
- you add \`height: 100%\` to something inside a flex column, its wrapper needs \`min-height: 0\`.
838
- This is the single most common way a grid disappears — see "Toolbar above a grid" below.
839
- - Positioning — but see LAYERING above before adding \`position\` or \`z-index\` to a container that
840
- holds a \`Select\` / \`DatePicker\` / \`Multiselect\`, and never \`position: sticky\` without a real
841
- scroll container
842
- - \`border-radius\` on custom (non-design-system) wrapper elements
843
- - \`border: calc(var(--stroke-width) * 1px) solid var(--neutral-stroke-rest)\` on custom wrappers
844
- - \`color\` and font properties using token values above
845
- - Animation / transition on custom elements
846
- - \`background-color\` on your own \`<div>\` containers, using tokens
847
-
848
- ### What NOT to add unless explicitly requested
849
-
850
- | Property | On | Reason |
851
- |---|---|---|
852
- | \`background-color\` | \`rapid-card\`, design-system components | Already set by own tokens — overriding breaks theming |
853
- | \`box-shadow\` | \`rapid-card\` | Component already reads \`var(--card-box-shadow, none)\` — a hand-rolled shadow discards the theme's elevation |
854
- | \`border\` | \`rapid-card\`, \`rapid-dialog\`, FlexLayout items | Component already reads \`var(--card-border, …)\` — the theme's \`2px solid\` becomes your \`1px\` |
855
- | \`border-radius: calc(var(--control-corner-radius) * 1px)\` | any card/panel/tile container | That is the CONTROL radius (\`0\` in the default theme) — use \`var(--card-corner-radius, calc(var(--control-corner-radius) * 1px))\` |
856
- | Hardcoded hex / rgb | Anywhere | Breaks dark/light mode switching — always use tokens |
857
- | \`font-size\` in px | Anywhere | Breaks scaling — use type-ramp tokens |
858
-
859
- ---
860
-
861
- ### Toolbar above a grid
862
-
863
- "Add a button above the grid" is the single most common request against an \`<EntityManagement>\`
864
- grid, and treating it as a styling problem is the mistake. \`EntityManagement\` accepts a
865
- \`customActions\` prop; an entry with \`position: CrudMenuPosition.Top\` renders as a themed toolbar
866
- button above the rows natively — no wrapper \`<div>\`, no \`.toolbar\` class, no alignment CSS and no
867
- \`minHeight: 0\` collapse to avoid:
868
-
869
- \`\`\`tsx
870
- import { CrudMenuPosition, type CustomAction } from '@genesislcap/foundation-entity-management';
871
-
872
- const customActions: CustomAction[] = [{
873
- name: 'Add Trade',
874
- position: CrudMenuPosition.Top, // omit it and you get a PER-ROW button, not a toolbar
875
- requiresSelection: false,
876
- appearance: 'primary',
877
- action: { type: 'callback', callback: onAdd },
878
- }];
879
-
880
- <EntityManagement resourceName="ALL_TRADES" columns={columnDefs} customActions={customActions}
881
- style={{ height: '100%' }} />
882
- \`\`\`
883
-
884
- See \`fui-entity-management\` → "A button above the grid" for the full rule and the one-line test.
885
-
886
- The recipe below is for a **hand-built grid** (RapidGridPro/ag-grid) that has no native toolbar
887
- slot, or for a strip that is not a grid action at all. Do not reach for it above an
888
- \`EntityManagement\`.
889
-
890
- #### Toolbar above a hand-built grid (RapidGridPro / ag-grid)
891
-
892
- It fails in three ways at once if you improvise: the grid disappears, the button is clamped to the
893
- left edge, and it has no breathing room. One snippet fixes all three. Copy it whole.
894
-
895
- \`\`\`tsx
896
- // The wrapper OWNS the height chain. The strip takes its natural height; the grid wrapper takes
897
- // the rest AND is allowed to shrink (minHeight: 0) — without that the grid collapses or overflows.
898
- <div className="trades-panel">
899
- <div className="trades-panel__toolbar">
900
- <Button appearance="primary" onClick={onAdd}>Add Trade</Button>
901
- </div>
902
- <div className="trades-panel__grid">
903
- <RapidGridPro rowData={rows} gridOptions={{ columnDefs }} style={{ height: '100%' }} />
904
- </div>
905
- </div>
906
- \`\`\`
907
-
908
- \`\`\`css
909
- .trades-panel {
910
- display: flex;
911
- flex-direction: column;
912
- height: 100%;
913
- }
914
-
915
- /* Placement + spacing. flex-end right-aligns the actions; use flex-start for a left-aligned
916
- strip and space-between when a title sits opposite the buttons. */
917
- .trades-panel__toolbar {
918
- flex: 0 0 auto; /* natural height — never stretches */
919
- display: flex;
920
- align-items: center;
921
- justify-content: flex-end;
922
- gap: calc(var(--design-unit) * 2px); /* between the buttons */
923
- padding: calc(var(--design-unit) * 2px) calc(var(--design-unit) * 3px); /* off the edges */
924
- }
925
-
926
- /* The collapse rule. flex: 1 hands it the remaining space; min-height: 0 lets it USE it. */
927
- .trades-panel__grid {
928
- flex: 1;
929
- min-height: 0;
930
- }
931
- \`\`\`
932
-
933
- Three things to keep:
934
-
935
- 1. **\`min-height: 0\` on the grid wrapper.** A flex item's default \`min-height: auto\` refuses to
936
- shrink below its content, so a \`height: 100%\` grid inside it collapses to nothing (or pushes the
937
- toolbar off-screen). This is the failure mode — do not omit it because the toolbar "looks fine".
938
- 2. **\`justify-content\` on the strip, not \`margin-left: auto\` on the button.** A bare
939
- \`<div>\` wrapping buttons is \`display: block\`, so the buttons sit flush left with no gap. Make
940
- the strip a flex row and state the alignment.
941
- 3. **\`padding\` and \`gap\` in \`--design-unit\` multiples**, never bare px — that is what makes the
942
- strip match the spacing of every other surface in the app.
943
-
944
- **Use a plain flex \`<div>\` for this, not \`<Toolbar>\`** — and know why, because the usual
945
- explanation is wrong. \`Toolbar\`'s \`:host\` is \`display: inline-flex\`, but a flex ITEM is
946
- blockified, so as a child of your column it *does* span the row (measured: host width 600 in a
947
- 600 wide panel). The part that bites is one level in: its internal
948
- \`.positioning-region\` is \`inline-flex\` with a hardcoded \`justify-content: flex-start\`, so the
949
- BUTTONS shrink-wrap to the left inside a full-width host — which is exactly the
950
- "clamped to the left border" look. One outer-tree rule (\`justify-content: flex-end\` on the host)
951
- does fix it, so \`Toolbar\` is usable; a plain \`<div>\` just needs no such rule, and \`Toolbar\`'s real
952
- job is a widget with roving focus rather than a right-aligned action strip.
953
-
954
- Inside a FlexLayout tile the same recipe applies with inline styles — see \`fui-flexlayout\` →
955
- "Tile sizing" and DP-3.
956
-
957
- ---
958
-
959
- ### KEY RULES
960
-
961
- 1. **\`--design-unit\` is unitless — ALWAYS write \`calc(var(--design-unit) * Npx)\`**
962
- 2. **\`--control-corner-radius\` and \`--stroke-width\`** are also unitless — write \`calc(var(--control-corner-radius) * 1px)\`
963
- 3. Use semantic color tokens, never hardcoded hex values
964
- 4. Do not override background/shadow on design-system components
965
- 5. The theme is \`src/styles/default.theme.json\` (modal format), consumed via \`src/styles/active-theme.ts\` (\`activeTheme\` / \`modeToggleEnabled\`). **Write neither — \`default.theme.json\`'s key resolves to nothing so the write is skipped, and hardcoding a theme in \`active-theme.ts\` cuts the theme picker out of the app.** To restyle, SET the tokens from a page/component \`.css\` file you own (\`.home-page { --card-corner-radius: 14px; }\`); never create \`design-tokens.json\`
966
- 5b. Container chrome is its OWN token family — \`--card-corner-radius\`, \`--card-border\`, \`--card-box-shadow\`, \`--elevation-low\`/\`--elevation-medium\`. Never style a card with \`calc(var(--control-corner-radius) * 1px)\`: that is the CONTROL radius, it is \`0\` in the default theme, and an outer-tree class beats a component's \`:host\`
967
- 6. Theming runtime imports come from \`@genesislcap/rapid-design-system\`: \`injectThemeStyles\`, \`applyMode\`, \`resolveInitialMode\`, \`nextMode\`, \`isModeToggleEnabled\` — never \`configureDesignSystem\` / \`baseLayerLuminance\` / \`StandardLuminance\`
968
- 7. When READING a theme file, \`customTokens\` is a FLAT \`"--var": "value"\` map and component rules live under \`componentOverrides\` (a \`"parts"\` key is inert). **You never write either** — the theme file is read-only to you; the reachable equivalent is a token set on a wrapper in a \`.css\` file you own
969
- 7a2. **Radius follows the element's ROLE, and there are three families — do not mix them.** A SURFACE
970
- (card, panel, tile, dialog) uses \`var(--card-corner-radius, calc(var(--control-corner-radius) * 1px))\`.
971
- A CONTROL (button, input, select) uses \`calc(var(--control-corner-radius) * 1px)\`, or nothing at all,
972
- letting the component paint its own. A PILL (status pill, badge, chip, segmented toggle) is not a theme
973
- opinion at all — its roundness is GEOMETRY, so it takes a shape constant: \`border-radius: 999px\`. The
974
- platform's own \`status-pill.styles.js\` hardcodes \`30px\` for exactly this reason. Putting
975
- \`--card-corner-radius\` on a pill makes it round only by accident (10px under corporate-light) and
976
- square under \`sunset\`, which sets 2px; picking a magic \`4px\` makes it a flat block in every theme.
977
-
978
- 7b. Rounded vs square CONTROLS: control radius is \`style.borderRadius\` in the theme, surfaced as \`--control-corner-radius\` (unitless — the components write \`calc(var(--control-corner-radius) * 1px)\`). It is NOT uniform across the shipped themes, so never assume a value: \`corporate-light\` and \`citi-bank\` set \`0\` with \`--card-corner-radius: 10px\` (square controls, rounded surfaces — deliberate); \`sunset\` sets \`0\` but only \`2px\` on cards, so surfaces are near-square there too; \`rapid-dark\` sets \`4\`; \`authorization\` sets neither and inherits the framework default of \`4\`. Rounding the controls is therefore a deliberate deviation under the default theme and a no-op under others. Do it by SETTING the token on a wrapper — \`.my-page { --control-corner-radius: 6; }\`, unitless — never by writing \`border-radius\` onto the control, which only hits the host and leaves the inner \`.control\` square
979
- 7c. \`--elevation-low\`/\`--elevation-medium\` have NO component fallback and \`rapid-dark\` defines neither — always write \`var(--elevation-medium, 0 4px 8px rgba(0,0,0,0.15))\`, or the shadow silently disappears under that theme
980
- 8. **Layering**: in a page shell exactly ONE element gets a z-index — the container holding
981
- \`Select\` / \`DatePicker\` / \`Multiselect\` — and it is \`position: relative; z-index: 200\`. No
982
- \`position: sticky\` unless something actually scrolls; no z-index on KPI strips, header rows, or
983
- the FlexLayout container. A component's own popup z-index cannot escape your container
984
-
985
- ### Proportional bars in a cell (depth ladders, volume, allocation, utilisation)
986
-
987
- **The design wins.** If a brief specifies the treatment — "bid size in a green pill", "plain text,
988
- no colour" — build that and ignore this section; it describes what to reach for when nothing was
989
- specified, not a house style that overrides a spec.
990
-
991
- With that said: a magnitude that only ever appears as a NUMBER reads as a spreadsheet. When the
992
- design does NOT dictate the treatment and a column carries a size, a volume, a fill or a share,
993
- draw it: a bar whose width is that row's value over the visible maximum. This is the difference between an order-book ladder that looks like a trading screen and
994
- one that looks like a table of numbers, and it is the same primitive behind volume-by-venue,
995
- allocation, utilisation and fill-progress columns — build it once, reuse the shape.
996
-
997
- The whole pattern is one absolutely-positioned bar behind right-aligned text:
998
-
999
- \`\`\`tsx
1000
- // \`max\` is the largest value CURRENTLY VISIBLE, computed once per render — not a constant, or
1001
- // every bar saturates the moment one outlier arrives.
1002
- const DepthBar = ({ value, max, side }: { value: number; max: number; side: 'bid' | 'ask' }) => (
1003
- <div style={{ position: 'relative', height: '100%', display: 'flex', alignItems: 'center',
1004
- justifyContent: side === 'bid' ? 'flex-end' : 'flex-start' }}>
1005
- <div
1006
- aria-hidden
1007
- style={{
1008
- position: 'absolute', top: 2, bottom: 2, [side === 'bid' ? 'right' : 'left']: 0,
1009
- width: \`\${max > 0 ? Math.min(100, (value / max) * 100) : 0}%\`,
1010
- // A TINT of the semantic token, so it reads as depth rather than as a filled cell.
1011
- background: \`color-mix(in srgb, var(\${side === 'bid' ? '--buy-color' : '--sell-color'}) 22%, transparent)\`,
1012
- borderRadius: '2px',
1013
- }}
1014
- />
1015
- <span style={{ position: 'relative', fontVariantNumeric: 'tabular-nums' }}>{format(value)}</span>
1016
- </div>
1017
- );
1018
- \`\`\`
1019
-
1020
- Four things that make it read correctly, and are the reusable part:
1021
-
1022
- - **Mirror the axes.** In a ladder the bid bar grows RIGHT-to-left and the ask bar LEFT-to-right, so
1023
- the two sides meet at the price column. One \`side\` prop flips both \`justifyContent\` and the
1024
- anchored edge; do not write two components.
1025
- - **\`tabular-nums\` on every numeric span.** Proportional digits make a column of prices visibly
1026
- ragged, which is most of why a generated grid looks unfinished next to a design.
1027
- - **Tint, do not fill.** A bar at full saturation competes with the text on top of it.
1028
- \`color-mix(in srgb, var(--token) 22%, transparent)\` keeps the semantic colour and stays readable
1029
- in both themes — and never invent a \`--x-bg\` token for this, because no such token exists.
1030
- - **Empty levels stay visible.** A ladder with gaps should render the price greyed
1031
- (\`var(--neutral-foreground-hint)\`) rather than omitting the row, or the ladder's spacing lies
1032
- about the book.
1033
-
1034
- In a \`<table>\` ladder this is just the component above. Inside a GRID cell it must be wrapped —
1035
- \`createGridProCellRenderer(DepthBar)\` — and remember the cell renders in grid-pro's shadow root, so
1036
- the inline styles above are load-bearing: a class from your \`.css\` would not reach it.
1037
-
1038
- ---
1039
-
1040
- ### DANGEROUS PATTERNS
1041
-
1042
- #### DP-1: Hardcoded colors — breaks dark/light theming
1043
-
1044
- \`\`\`css
1045
- /* WRONG: */
1046
- color: #333333;
1047
- background-color: #ffffff;
1048
- border-color: rgba(0,0,0,0.2);
1049
-
1050
- /* CORRECT: */
1051
- color: var(--neutral-foreground-rest);
1052
- background-color: var(--neutral-layer-1);
1053
- border-color: var(--neutral-stroke-rest);
1054
- \`\`\`
1055
-
1056
- #### DP-2: \`calc(var(--design-unit) * N)\` without \`px\` — unitless result
1057
-
1058
- \`\`\`css
1059
- /* WRONG — unitless result, browser ignores it: */
1060
- padding: calc(var(--design-unit) * 2); /* = 8 — invalid CSS length */
1061
- gap: var(--design-unit); /* = 4 — invalid CSS length */
1062
-
1063
- /* CORRECT: */
1064
- padding: calc(var(--design-unit) * 2px); /* = 8px */
1065
- gap: calc(var(--design-unit) * 2px); /* = 8px */
1066
- \`\`\`
1067
-
1068
- #### DP-3: Using \`--control-corner-radius\` bare — also unitless
1069
-
1070
- \`\`\`css
1071
- /* WRONG — unitless, does nothing: */
1072
- border-radius: var(--control-corner-radius);
1073
-
1074
- /* CORRECT: */
1075
- border-radius: calc(var(--control-corner-radius) * 1px);
1076
- \`\`\`
1077
-
1078
- #### DP-4: Overriding background/border/shadow on design-system components
1079
-
1080
- The trap is that this does not need a \`rapid-card { … }\` selector to happen. A class you put on a
1081
- Genesis component does it too: \`<Card className="kpi-card">\` plus \`.kpi-card { … }\` in the page's
1082
- stylesheet. That class lives in the OUTER tree, and outer-tree declarations beat the component's own
1083
- \`:host\` rule in the shadow cascade **regardless of specificity** — so your line always wins, and the
1084
- theme's card chrome is discarded.
1085
-
1086
- \`\`\`css
1087
- /* WRONG — whether written as a tag selector… */
1088
- rapid-card { background-color: white; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
1089
-
1090
- /* …or, far more commonly, as a class on <Card className="kpi-card">: */
1091
- .kpi-card {
1092
- border-radius: calc(var(--control-corner-radius) * 1px); /* squares a 10px card */
1093
- border: calc(var(--stroke-width) * 1px) solid var(--neutral-stroke-divider-rest); /* 1px over the theme's 2px */
1094
- background-color: var(--neutral-layer-card-container); /* redundant; the card sets it */
1095
- }
1096
- .kpi-card:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); } /* --elevation-medium exists */
1097
-
1098
- /* CORRECT — the class carries LAYOUT only; the component keeps its themed chrome: */
1099
- .kpi-card {
1100
- display: flex;
1101
- flex-direction: column;
1102
- gap: calc(var(--design-unit) * 2px);
1103
- padding: calc(var(--design-unit) * 4px);
1104
- }
1105
- .kpi-card:hover { box-shadow: var(--elevation-medium, 0 4px 8px rgba(0,0,0,0.15)); }
1106
-
1107
- /* CORRECT — and if you genuinely want different chrome, SET the token, don't set the property: */
1108
- .kpi-strip { --card-corner-radius: 14px; --card-box-shadow: var(--elevation-low, 0 2px 4px rgba(0,0,0,0.1)); }
1109
- \`\`\`
1110
-
1111
- #### DP-5: Hardcoded font sizes
1112
-
1113
- \`\`\`css
1114
- /* WRONG: */
1115
- font-size: 14px;
1116
- font-size: 12px;
1117
-
1118
- /* CORRECT: */
1119
- font-size: var(--type-ramp-base-font-size);
1120
- font-size: var(--type-ramp-minus-2-font-size);
1121
- \`\`\`
1122
-
1123
- One sanctioned exception: the display-figure recipe under Typography tokens — a \`calc()\` on the
1124
- top ramp token for a focal KPI value, never a px literal.
1125
-
1126
- #### DP-6: Legacy luminance flipping — baseLayerLuminance / StandardLuminance
1127
-
1128
- \`\`\`ts
1129
- /* WRONG — legacy API: bypasses the modal theme (no theme-<mode> class swap, no mode memory): */
1130
- import { baseLayerLuminance, StandardLuminance } from '@microsoft/fast-components';
1131
- baseLayerLuminance.setValueFor(providerRef.current, StandardLuminance.LightMode);
1132
-
1133
- /* CORRECT — switch MODES via the modal-theme API: */
1134
- import { applyMode, nextMode } from '@genesislcap/rapid-design-system';
1135
- import { activeTheme } from '../../styles/active-theme';
1136
- themeModeRef.current = nextMode(activeTheme, themeModeRef.current);
1137
- applyMode(providerRef.current, activeTheme, themeModeRef.current);
1138
- \`\`\`
1139
-
1140
- #### DP-7: Legacy configureDesignSystem bootstrap
1141
-
1142
- \`\`\`ts
1143
- /* WRONG — legacy API from @genesislcap/foundation-ui reading a design-tokens.json: */
1144
- import { configureDesignSystem } from '@genesislcap/foundation-ui';
1145
- import * as designTokens from './styles/design-tokens.json';
1146
- configureDesignSystem(providerRef.current, designTokens);
1147
-
1148
- /* CORRECT — inject the modal theme once, then apply the active mode: */
1149
- import { applyMode, injectThemeStyles, resolveInitialMode } from '@genesislcap/rapid-design-system';
1150
- import { activeTheme } from '../../styles/active-theme';
1151
- injectThemeStyles(providerRef.current, activeTheme);
1152
- applyMode(providerRef.current, activeTheme, resolveInitialMode(activeTheme));
1153
- \`\`\`
1154
-
1155
- #### DP-8: Nested customTokens objects — legacy shape, silently ignored
1156
-
1157
- \`\`\`jsonc
1158
- /* WRONG — nested {"$value"} tree (legacy design-tokens.json shape): */
1159
- { "customTokens": { "grid": { "header": { "height": { "$value": "40px" } } } } }
1160
-
1161
- /* CORRECT — flat "--var": "value" map: */
1162
- { "customTokens": { "--grid-header-height": "40px" } }
1163
- \`\`\`
1164
-
1165
- #### DP-9: "parts" key instead of componentOverrides
1166
-
1167
- \`\`\`jsonc
1168
- /* WRONG — "parts" is the old name; the theme compiler ignores it silently: */
1169
- { "shared": { "parts": { "rapid-button": { "border-radius": "10px" } } } }
1170
-
1171
- /* CORRECT: */
1172
- { "shared": { "componentOverrides": { "rapid-button": { "border-radius": "10px" } } } }
1173
- \`\`\`
1174
-
1175
- #### DP-10: Creating or editing design-tokens.json
1176
-
1177
- \`\`\`ts
1178
- /* WRONG — the legacy token file no longer exists in generated apps: */
1179
- import * as designTokens from './styles/design-tokens.json';
1180
-
1181
- /* CORRECT — the theme is src/styles/default.theme.json, consumed via active-theme.ts: */
1182
- import { activeTheme, modeToggleEnabled } from './styles/active-theme';
1183
- \`\`\`
1184
-
1185
- #### DP-11: Sticky page-shell strips — the Select/DatePicker popup paints behind the next strip
1186
-
1187
- \`\`\`css
1188
- /* WRONG — two sibling strips, both sticky, both z-index: 10. \`sticky\` creates a stacking
1189
- context even though NOTHING on this page scrolls, so the DatePicker's internal z-index: 999
1190
- is trapped at "10"; the KPI strip is also "10" and comes later in the DOM, so it wins.
1191
- Result: the calendar's month header and the first Select options are covered AND unclickable. */
1192
- .page-filters { position: sticky; top: 0; z-index: 10; }
1193
- .page-kpi-strip { position: sticky; top: 0; z-index: 10; }
1194
-
1195
- /* ALSO WRONG — dropping both leaves the popups below the FlexLayout container
1196
- (which is position: relative), so the tiles paint over them instead: */
1197
- .page-filters { }
1198
- .page-kpi-strip { }
1199
-
1200
- /* CORRECT — the filter row is the only layered element, and out-ranks every later sibling: */
1201
- .page-filters { position: relative; z-index: 200; }
1202
- .page-kpi-strip { } /* no position, no z-index */
1203
- \`\`\`
1204
-
1205
- Emit each container rule in exactly ONE stylesheet. Duplicating \`.page-kpi-strip\` in both the page
1206
- CSS and the component's own CSS means a later-loaded copy silently overrides the fix.
1207
-
1208
- #### DP-12: Restyling the app from \`src/styles/\` — either discarded or permanent
1209
-
1210
- \`styles/default.theme.json\` is regenerated from the project's theme config, so its key resolves to
1211
- nothing and the preview service skips it at flush. The call reports \`status: "buffered"\`, the file
1212
- shows in the diff, the theme is untouched, and the app looks exactly as before. \`styles/styles.css\`
1213
- is the opposite trap: that write DOES land, and pins the app's fonts against the theme for good.
1214
-
1215
- \`\`\`css
1216
- /* WRONG — vfs_write("styles/default.theme.json", …): buffered, then skipped. Nothing changes. */
1217
-
1218
- /* CORRECT — set the tokens from a stylesheet you own, on the page's outer wrapper: */
1219
- .home-page {
1220
- --card-corner-radius: 14px; /* length token — px required */
1221
- --card-border: 2px solid var(--neutral-stroke-divider-rest);
1222
- --card-box-shadow: var(--elevation-low, 0 2px 4px rgba(0,0,0,0.1));
1223
- --control-corner-radius: 6; /* unitless token — px would silently zero it */
1224
- }
1225
- \`\`\`
1226
-
1227
- They inherit through shadow boundaries, so every design-system component inside \`.home-page\`
1228
- follows without a single \`::part()\` or component override.
1229
- `.trim();