rift-ds 1.32.0 → 1.34.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 (124) hide show
  1. package/README.md +4 -4
  2. package/behaviors/chat-card.css +11 -6
  3. package/behaviors/clipboard.d.ts +7 -0
  4. package/behaviors/clipboard.js +35 -0
  5. package/behaviors/headingSlug.d.ts +8 -0
  6. package/behaviors/headingSlug.js +4 -0
  7. package/behaviors/shell.css +64 -0
  8. package/behaviors/syncedChoice.d.ts +2 -0
  9. package/behaviors/syncedChoice.js +48 -0
  10. package/behaviors/useLayer.d.ts +15 -2
  11. package/behaviors/useLayer.js +3 -2
  12. package/bin/templates/blocks/app/guide/PageFeedback.tsx +55 -0
  13. package/bin/templates/blocks/app/guide/page.module.css +94 -0
  14. package/bin/templates/blocks/app/guide/page.tsx +168 -0
  15. package/bin/templates/blocks/components/blocks/AppShell.module.css +3 -1
  16. package/bin/templates/blocks/components/blocks/AppShell.tsx +8 -0
  17. package/bin/templates/blocks/components/blocks/DocsShell.module.css +18 -0
  18. package/bin/templates/blocks/components/blocks/DocsShell.tsx +179 -0
  19. package/bin/templates/blocks/registry.json +13 -0
  20. package/chat/AssistantTurn.d.ts +2 -0
  21. package/chat/AssistantTurn.js +18 -7
  22. package/chat/ChatProvider.js +14 -0
  23. package/chat/ChatWidget.css +10 -0
  24. package/chat/ChatWidget.d.ts +7 -3
  25. package/chat/ChatWidget.js +6 -3
  26. package/chat/agentState.d.ts +2 -1
  27. package/chat/agentState.js +4 -1
  28. package/chat/awaiting.d.ts +19 -0
  29. package/chat/awaiting.js +21 -0
  30. package/chat/context.d.ts +4 -0
  31. package/chat/index.d.ts +1 -0
  32. package/chat/index.js +3 -1
  33. package/chat/server.d.ts +8 -3
  34. package/chat/server.js +1 -1
  35. package/code/highlight.d.ts +4 -0
  36. package/code/highlight.js +34 -0
  37. package/code/index.d.ts +16 -0
  38. package/code/index.js +23 -0
  39. package/components/ActionCard/ActionCard.css +3 -3
  40. package/components/AgentStatus/AgentStatus.css +114 -22
  41. package/components/AgentStatus/AgentStatus.d.ts +10 -7
  42. package/components/AgentStatus/AgentStatus.js +10 -0
  43. package/components/AiButton/AiButton.d.ts +3 -3
  44. package/components/AnchorNav/AnchorNav.d.ts +29 -3
  45. package/components/AnchorNav/AnchorNav.js +69 -5
  46. package/components/AppLayout/AppLayout.css +8 -4
  47. package/components/AppLayout/AppLayout.d.ts +13 -3
  48. package/components/AppLayout/AppLayout.js +2 -0
  49. package/components/ArtifactPanel/ArtifactPanel.css +46 -0
  50. package/components/ArtifactPanel/ArtifactPanel.d.ts +14 -4
  51. package/components/ArtifactPanel/ArtifactPanel.js +8 -5
  52. package/components/BackToTop/BackToTop.css +28 -0
  53. package/components/BackToTop/BackToTop.d.ts +28 -0
  54. package/components/BackToTop/BackToTop.js +47 -0
  55. package/components/BentoTile/BentoTile.css +3 -0
  56. package/components/CodeBlock/CodeBlock.css +63 -24
  57. package/components/CodeBlock/CodeBlock.d.ts +62 -6
  58. package/components/CodeBlock/CodeBlock.js +90 -48
  59. package/components/Composer/Composer.css +14 -9
  60. package/components/Composer/Composer.d.ts +10 -8
  61. package/components/Composer/Composer.js +2 -1
  62. package/components/CopyButton/CopyButton.d.ts +42 -0
  63. package/components/CopyButton/CopyButton.js +72 -0
  64. package/components/DescriptionList/DescriptionListCopy.d.ts +2 -2
  65. package/components/DescriptionList/DescriptionListCopy.js +7 -35
  66. package/components/Figure/Figure.css +26 -0
  67. package/components/Figure/Figure.d.ts +10 -1
  68. package/components/Figure/Figure.js +15 -3
  69. package/components/Heading/Heading.css +43 -0
  70. package/components/Heading/Heading.d.ts +14 -3
  71. package/components/Heading/Heading.js +22 -4
  72. package/components/HoverCard/HoverCard.js +1 -0
  73. package/components/Link/Link.css +38 -0
  74. package/components/Link/Link.d.ts +3 -3
  75. package/components/Link/Link.js +1 -1
  76. package/components/Menubar/Menubar.css +82 -0
  77. package/components/Menubar/Menubar.d.ts +40 -0
  78. package/components/Menubar/Menubar.js +97 -0
  79. package/components/MessageCard/MessageCard.css +1 -1
  80. package/components/NavList/NavList.css +197 -0
  81. package/components/NavList/NavList.d.ts +54 -6
  82. package/components/NavList/NavList.js +136 -8
  83. package/components/Pagination/Pagination.css +80 -0
  84. package/components/Pagination/Pagination.d.ts +29 -3
  85. package/components/Pagination/Pagination.js +49 -5
  86. package/components/Rating/Rating.css +26 -0
  87. package/components/Rating/Rating.d.ts +18 -5
  88. package/components/Rating/Rating.js +16 -7
  89. package/components/SectionTitle/SectionTitle.css +36 -0
  90. package/components/SectionTitle/SectionTitle.d.ts +10 -1
  91. package/components/SectionTitle/SectionTitle.js +7 -2
  92. package/components/ShaderScene/ShaderScene.d.ts +2 -1
  93. package/components/ShaderScene/ShaderScene.js +20 -2
  94. package/components/SiteFooter/SiteFooter.css +157 -0
  95. package/components/SiteFooter/SiteFooter.d.ts +53 -0
  96. package/components/SiteFooter/SiteFooter.js +61 -0
  97. package/components/SiteHeader/SiteHeader.css +106 -4
  98. package/components/SiteHeader/SiteHeader.d.ts +25 -2
  99. package/components/SiteHeader/SiteHeader.js +46 -8
  100. package/components/SiteLayout/SiteLayout.css +361 -0
  101. package/components/SiteLayout/SiteLayout.d.ts +103 -0
  102. package/components/SiteLayout/SiteLayout.js +68 -0
  103. package/components/SourceTrail/SourceTrail.css +1 -1
  104. package/components/Table/Table.css +14 -0
  105. package/components/Table/Table.d.ts +2 -0
  106. package/components/Table/Table.js +1 -1
  107. package/components/ToolCall/ToolCall.css +2 -2
  108. package/components/Tooltip/Tooltip.js +1 -0
  109. package/components/UsageCard/UsageCard.css +4 -3
  110. package/components/keyboard-patterns.json.d.ts +57 -0
  111. package/components/keyboard-patterns.json.js +1 -1
  112. package/components/registry.json +89 -19
  113. package/components/registry.json.d.ts +89 -19
  114. package/components/registry.json.js +1 -1
  115. package/index.d.ts +5 -0
  116. package/index.js +14 -1
  117. package/package.json +14 -2
  118. package/tokens/breakpoints.js +3 -3
  119. package/tokens/registry.json +5 -0
  120. package/tokens/registry.json.d.ts +5 -0
  121. package/tokens/registry.json.js +1 -1
  122. package/tokens/tokens-dark.css +12 -0
  123. package/tokens/tokens-light.css +12 -0
  124. package/tokens/values.json.js +1 -1
package/README.md CHANGED
@@ -13,7 +13,7 @@ An open source React design system built for AI products and coding agents: comp
13
13
 
14
14
  ## Why Rift DS
15
15
 
16
- - **<!-- component-count -->189<!-- /component-count --> components.** Buttons, forms and tables through to charts, navigation and overlays, each typed and documented with live examples. Every one forwards a ref and your own attributes to its element, state you can own works controlled or uncontrolled (a modal opens when your app says so, by design), and every word a component writes has a prop you can localise. The build checks the first two on every component, and the words wherever they sit in markup. React and React DOM are the only required peer dependencies.
16
+ - **<!-- component-count -->194<!-- /component-count --> components.** Buttons, forms and tables through to charts, navigation and overlays, each typed and documented with live examples. Every one forwards a ref and your own attributes to its element, state you can own works controlled or uncontrolled (a modal opens when your app says so, by design), and every word a component writes has a prop you can localise. The build checks the first two on every component, and the words wherever they sit in markup. React and React DOM are the only required peer dependencies.
17
17
  - **A matching <!-- figma-kit-link -->[Figma kit](https://www.figma.com/community/file/1701820123445795117)<!-- /figma-kit-link -->.** Every component has a page in it, with a sticker sheet of its states, built on variables named after the same tokens. Duplicate it from the Figma Community to design with the same system.
18
18
  - **AI patterns, the whole chat and templates, ready to use.** Composer, streaming chat thread, tool calls, reasoning and thread panel are in the box, the complete AI chat ships assembled as one widget that one command scaffolds, and the docs site has complete template screens built from them.
19
19
  - **Fully themeable.** The shipped themes are complete looks to start from, each in light and dark. One `data-brand` attribute applies a theme, and a few CSS overrides make your own.
@@ -44,7 +44,7 @@ import 'rift-ds/tokens/base.css'; // the reset and page every component is tuned
44
44
  import { Button, Card, Badge } from 'rift-ds';
45
45
  ```
46
46
 
47
- React 19+ is a peer dependency. The package's own runtime dependencies, TanStack Table and TanStack Virtual (the headless engine under `DataTable` and the windowing behind its long tables), install with it. The package is ESM-only and resolved via `exports` subpaths: use a bundler that handles CSS and font imports from `node_modules` (Vite, Next.js, webpack) and set TypeScript's `moduleResolution` to `"bundler"` or `"nodenext"`. The Recharts-backed charts live behind `rift-ds/charts`, so the optional `recharts` peer dependency is only needed if you use them. The chat widget's subpaths bring their own optional peers (`react-markdown` and `remark-gfm` for the panel, `@anthropic-ai/sdk` for the server handlers, `@upstash/ratelimit` and `@upstash/redis` for the guardrails), needed only if you use them. Prefer owning the source? Pull single components through the shadcn CLI (`npx shadcn@latest add https://rift-ds.com/r/button.json`, with details in the [get-started guide](https://rift-ds.com/docs/get-started)), or clone this repo and build on it directly; all of it is MIT.
47
+ React 19+ is a peer dependency. The package's own runtime dependencies, TanStack Table and TanStack Virtual (the headless engine under `DataTable` and the windowing behind its long tables), install with it. The package is ESM-only and resolved via `exports` subpaths: use a bundler that handles CSS and font imports from `node_modules` (Vite, Next.js, webpack) and set TypeScript's `moduleResolution` to `"bundler"` or `"nodenext"`. The Recharts-backed charts live behind `rift-ds/charts`, so the optional `recharts` peer dependency is only needed if you use them. The chat widget's subpaths bring their own optional peers (`react-markdown` and `remark-gfm` for the panel, `@anthropic-ai/sdk` for the server handlers, `@upstash/ratelimit` and `@upstash/redis` for the guardrails), needed only if you use them. Code highlighting is the same: `rift-ds/code/highlight` needs the optional `shiki` peer, while `rift-ds/code`'s `packageManagerTabs` needs nothing. Prefer owning the source? Pull single components through the shadcn CLI (`npx shadcn@latest add https://rift-ds.com/r/button.json`, with details in the [get-started guide](https://rift-ds.com/docs/get-started)), or clone this repo and build on it directly; all of it is MIT.
48
48
 
49
49
  ## The chat widget
50
50
 
@@ -112,13 +112,13 @@ import 'rift-ds/tokens/presets/presets.css';
112
112
 
113
113
  ## Components
114
114
 
115
- <!-- component-count -->189<!-- /component-count --> components, including a chat set for AI products (Chat thread, Composer, Tool call, Reasoning, Thread panel) and Shader field, a WebGL2 ambient background whose light sources read your colour tokens at runtime, so it re-themes with everything else. Details and live examples are on the [docs site](https://rift-ds.com/components).
115
+ <!-- component-count -->194<!-- /component-count --> components, including a chat set for AI products (Chat thread, Composer, Tool call, Reasoning, Thread panel) and Shader field, a WebGL2 ambient background whose light sources read your colour tokens at runtime, so it re-themes with everything else. Details and live examples are on the [docs site](https://rift-ds.com/components).
116
116
 
117
117
  <details>
118
118
  <summary>The full list</summary>
119
119
 
120
120
  <!-- component-list:start -->
121
- Accordion · Action card · Action readout · Agent plan · Agent rail · Agent status · AI button · Alert · Alert dialog · Anchor nav · Animated number · App layout · App sidebar · Area chart · Artifact card · Artifact panel · Attachment drop zone · Attachment group · Attachment tile · Attachment viewer · Avatar · Avatar group · Badge · Banner · Bar chart · Bento tile · Bento tile art · Bottom nav · Breadcrumb · Button · Button group · Card · Card stack · Carousel · Chat header · Chat marker · Chat message · Chat thread · Checkbox · Checklist · Chip · Code block · Code diff · Colour picker · Combo chart · Combobox · Command palette · Command palette trigger · Composer · Contact card · Context menu · Contribution graph · Currency input · Data table · Date input · Date picker · Date range picker · Deadline · Decision row · Description list · Dialog · Divider · Document chip · Document viewer · Drawer · Dropdown · Dropdown menu · Empty state · Entity card · Entity switcher · Error summary · Event calendar · Field · Figure · File input · File row · Filter bar · Form section · Funnel chart · Gantt chart · Gauge · Globe · Grid · Heading · Hover card · Icon · Icon button · Image compare · Input · Inspector colour picker · Inspector dropdown · Inspector input · Inspector section · Inspector segments · Inspector slider · Inspector toggle switch · Instructions · Interrupt card · Kbd · Legend tile · Lightbox · Line chart · Link · Link list · List · Map callout · Map legend · Masked input · Mega menu · Mention · Message actions · Message card · Meter · Model picker · Nav · Nav list · Notification centre · Number input · Org chart · Page header · Pagination · Panel · Pie chart · Pin input · Pixel avatar · Popover · Progress bar · Progressive blur · Prompt suggestions · Prose · Question card · Quote · Radar chart · Radial chart · Radio button · Rating · Reasoning · Resource timeline · Rich dropdown · Scatter chart · Section title · Segmented control · Selection card · Shader field · Shader scene · Sidebar panel · Signature pad · Site header · Skeleton · Slider · Source chip · Source trail · Sparkline · Spinner · Split button · Split pane · Stack · Stacked bar chart · Stat · Status dot · Stepper · Streaming text · Swatch · Table · Table toolbar · Tabs · Tag input · Text · Textarea · Theme picker · Theme toggle · Thread panel · Thread tabs · Time picker · Timeline · Toast · Toggle group · Toggle switch · Tool call · Toolbar · Tooltip · Top app bar · Tree view · Treemap · Usage card · Waveform · Widget · Wizard · World map
121
+ Accordion · Action card · Action readout · Agent plan · Agent rail · Agent status · AI button · Alert · Alert dialog · Anchor nav · Animated number · App layout · App sidebar · Area chart · Artifact card · Artifact panel · Attachment drop zone · Attachment group · Attachment tile · Attachment viewer · Avatar · Avatar group · Back to top · Badge · Banner · Bar chart · Bento tile · Bento tile art · Bottom nav · Breadcrumb · Button · Button group · Card · Card stack · Carousel · Chat header · Chat marker · Chat message · Chat thread · Checkbox · Checklist · Chip · Code block · Code diff · Colour picker · Combo chart · Combobox · Command palette · Command palette trigger · Composer · Contact card · Context menu · Contribution graph · Copy button · Currency input · Data table · Date input · Date picker · Date range picker · Deadline · Decision row · Description list · Dialog · Divider · Document chip · Document viewer · Drawer · Dropdown · Dropdown menu · Empty state · Entity card · Entity switcher · Error summary · Event calendar · Field · Figure · File input · File row · Filter bar · Form section · Funnel chart · Gantt chart · Gauge · Globe · Grid · Heading · Hover card · Icon · Icon button · Image compare · Input · Inspector colour picker · Inspector dropdown · Inspector input · Inspector section · Inspector segments · Inspector slider · Inspector toggle switch · Instructions · Interrupt card · Kbd · Legend tile · Lightbox · Line chart · Link · Link list · List · Map callout · Map legend · Masked input · Mega menu · Mention · Menu bar · Message actions · Message card · Meter · Model picker · Nav · Nav list · Notification centre · Number input · Org chart · Page header · Pagination · Panel · Pie chart · Pin input · Pixel avatar · Popover · Progress bar · Progressive blur · Prompt suggestions · Prose · Question card · Quote · Radar chart · Radial chart · Radio button · Rating · Reasoning · Resource timeline · Rich dropdown · Scatter chart · Section title · Segmented control · Selection card · Shader field · Shader scene · Sidebar panel · Signature pad · Site footer · Site header · Site layout · Skeleton · Slider · Source chip · Source trail · Sparkline · Spinner · Split button · Split pane · Stack · Stacked bar chart · Stat · Status dot · Stepper · Streaming text · Swatch · Table · Table toolbar · Tabs · Tag input · Text · Textarea · Theme picker · Theme toggle · Thread panel · Thread tabs · Time picker · Timeline · Toast · Toggle group · Toggle switch · Tool call · Toolbar · Tooltip · Top app bar · Tree view · Treemap · Usage card · Waveform · Widget · Wizard · World map
122
122
  <!-- component-list:end -->
123
123
 
124
124
  </details>
@@ -48,15 +48,15 @@
48
48
  /* Insets: every row's first thing stands this far in; stacked cards and
49
49
  opened panels hold their text this far off the top and bottom edges. */
50
50
  --ds-chat-card-inset: var(--padding-500);
51
- --ds-chat-card-edge: var(--padding-300);
51
+ --ds-chat-card-edge: var(--padding-400);
52
52
 
53
53
  /* Rhythm, three steps: a title's subline (a description, detail, meta or
54
54
  subtitle line) sits straight under it, its leading the only space; a
55
55
  body under that (a description under a meta line, a list of facts)
56
56
  stands a text gap off; blocks (text to buttons) a block gap apart. */
57
57
  --ds-chat-card-gap-subline: 0;
58
- --ds-chat-card-gap-text: var(--gap-200);
59
- --ds-chat-card-gap-block: var(--gap-400);
58
+ --ds-chat-card-gap-text: var(--gap-300);
59
+ --ds-chat-card-gap-block: var(--gap-500);
60
60
 
61
61
  /* One-row cards: a compact control and this much above and below, so a
62
62
  label row and a row holding a button are one height. */
@@ -70,12 +70,17 @@
70
70
  /* The fact list: a label beside its value, a line each, as ActionReadout
71
71
  and ActionCard list what a change will do or did. A card sets only where
72
72
  the list sits. */
73
+ /* The list's own margin is cleared at no specificity, so the card's rule
74
+ for where the list sits wins whichever stylesheet loads last. */
75
+ :where(.ds-chat-card-facts) {
76
+ margin: 0;
77
+ }
78
+
73
79
  .ds-chat-card-facts {
74
80
  display: grid;
75
81
  grid-template-columns: max-content minmax(0, 1fr);
76
- column-gap: var(--gap-400);
77
- row-gap: var(--gap-100);
78
- margin: 0;
82
+ column-gap: var(--gap-500);
83
+ row-gap: var(--gap-200);
79
84
  font-family: var(--font-paragraph-sm-family);
80
85
  font-size: var(--font-paragraph-sm-size);
81
86
  font-weight: var(--font-paragraph-sm-weight);
@@ -0,0 +1,7 @@
1
+ /** Put text on the clipboard: the async API, else a selected textarea. */
2
+ export declare function writeClipboard(text: string): void;
3
+ /** A copy action with a short-lived `copied` flag for the confirmation. */
4
+ export declare function useCopied(): {
5
+ copied: boolean;
6
+ copy: (text: string) => void;
7
+ };
@@ -0,0 +1,35 @@
1
+ "use client";
2
+ import { useState, useRef, useEffect, useCallback } from "react";
3
+ import { MOTION_FEEDBACK_RESET_MS } from "../tokens/motion.js";
4
+ function writeClipboard(text) {
5
+ const fallback = () => {
6
+ const focused = document.activeElement instanceof HTMLElement ? document.activeElement : null;
7
+ const textarea = document.createElement("textarea");
8
+ textarea.value = text;
9
+ textarea.setAttribute("readonly", "");
10
+ textarea.className = "ds-visually-hidden";
11
+ document.body.appendChild(textarea);
12
+ textarea.select();
13
+ document.execCommand("copy");
14
+ document.body.removeChild(textarea);
15
+ focused?.focus({ preventScroll: true });
16
+ };
17
+ if (navigator.clipboard?.writeText) navigator.clipboard.writeText(text).catch(fallback);
18
+ else fallback();
19
+ }
20
+ function useCopied() {
21
+ const [copied, setCopied] = useState(false);
22
+ const timer = useRef(void 0);
23
+ useEffect(() => () => window.clearTimeout(timer.current), []);
24
+ const copy = useCallback((text) => {
25
+ writeClipboard(text);
26
+ setCopied(true);
27
+ window.clearTimeout(timer.current);
28
+ timer.current = window.setTimeout(() => setCopied(false), MOTION_FEEDBACK_RESET_MS);
29
+ }, []);
30
+ return { copied, copy };
31
+ }
32
+ export {
33
+ useCopied,
34
+ writeClipboard
35
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * headingSlug: a URL fragment from a heading's text, lower case, words
3
+ * joined by hyphens, accents and punctuation dropped. The one home of the
4
+ * rule, so the ids Heading's and SectionTitle's `anchor` write and the ones
5
+ * AnchorNav's `fromHeadings` gives an unnamed heading always agree.
6
+ * Heading re-exports it for hosts that link to a section by its text.
7
+ */
8
+ export declare const headingSlug: (text: string) => string;
@@ -0,0 +1,4 @@
1
+ const headingSlug = (text) => text.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g, "").replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-+|-+$/g, "");
2
+ export {
3
+ headingSlug
4
+ };
@@ -37,6 +37,10 @@
37
37
  hairline and floating shadow, held off the
38
38
  other edges by the inset gap.
39
39
 
40
+ The page's width is a second axis, apart from
41
+ the mode (WIDTH below): any mode takes a
42
+ contained or a full-width page.
43
+
40
44
  Declared on the marked root, not on :root, so
41
45
  a theme scoped to part of a page reaches it.
42
46
  design.md's "App shells" section owns the
@@ -99,6 +103,66 @@
99
103
  --ds-shell-surface-radius: var(--ds-shell-radius);
100
104
  }
101
105
 
106
+ /* ============================================
107
+ WIDTH
108
+ How wide the page runs, an axis of its own: any
109
+ shell mode, a site layout or a header takes
110
+ data-ds-width="contained" (a centred column with
111
+ a maximum) or "full" (the whole width the host
112
+ gives it, the side gutter aside), so a mode
113
+ never decides it.
114
+
115
+ A host's column reads
116
+ max-width: var(--ds-shell-content-max, var(--ds-shell-contained-width));
117
+ padding-inline: var(--ds-shell-gutter);
118
+ with margin-inline: auto. "full" sets the
119
+ maximum to none; contained resets it to unset
120
+ (so a contained row nests inside a full page),
121
+ and the fallback reads the contained width where
122
+ the column is. A host or a page can set its own
123
+ (--ds-shell-contained-width, 1440px by default,
124
+ and --ds-shell-gutter) on any element down to
125
+ the column itself: the defaults are declared
126
+ only on the outermost width element, so a
127
+ nested one (a header's slot, a footer's row)
128
+ inherits the host's values, never the defaults.
129
+ ============================================ */
130
+
131
+ :where([data-ds-width]:not([data-ds-width] *)) {
132
+ --ds-shell-contained-width: 1440px;
133
+ --ds-shell-gutter: var(--padding-500);
134
+ }
135
+
136
+ :where([data-ds-width='full']) {
137
+ --ds-shell-content-max: none;
138
+ }
139
+
140
+ /* The contained width's steps, a level either side of the default, for a
141
+ host that wants the page narrower or wider without a length of its own:
142
+ data-ds-contained="narrow" (1200px: with a sidebar docked at the edge,
143
+ a 1080px article), "default"
144
+ (1440px) or "wide" (1680px, a dashboard). Declared after the default so
145
+ it wins on the same element, and inherited by every nested width element. */
146
+ :where([data-ds-contained='narrow']) {
147
+ --ds-shell-contained-width: 1200px;
148
+ }
149
+
150
+ :where([data-ds-contained='wide']) {
151
+ --ds-shell-contained-width: 1680px;
152
+ }
153
+
154
+ /* initial makes a custom property guaranteed-invalid, so a reader's
155
+ fallback applies. */
156
+ :where([data-ds-width='contained']) {
157
+ --ds-shell-content-max: initial;
158
+ }
159
+
160
+ @media (max-width: 768px) {
161
+ :where([data-ds-width]:not([data-ds-width] *)) {
162
+ --ds-shell-gutter: var(--padding-400);
163
+ }
164
+ }
165
+
102
166
  /* The blur backdrop, drawn once for any host: a fixed layer behind the
103
167
  host's content rather than a filter on the host itself, which would
104
168
  become the containing block of every fixed descendant (AppSidebar, the
@@ -0,0 +1,2 @@
1
+ /** The shared pick for `key`, and a setter that moves every control sharing it. */
2
+ export declare function useSyncedChoice(key: string | undefined, fallback: string | undefined): [string | undefined, (value: string) => void];
@@ -0,0 +1,48 @@
1
+ "use client";
2
+ import { useCallback, useSyncExternalStore } from "react";
3
+ const PREFIX = "rift-ds:choice:";
4
+ const values = /* @__PURE__ */ new Map();
5
+ const listeners = /* @__PURE__ */ new Map();
6
+ function read(key) {
7
+ if (values.has(key)) return values.get(key);
8
+ try {
9
+ const stored = window.localStorage.getItem(PREFIX + key);
10
+ if (stored !== null) values.set(key, stored);
11
+ return stored ?? void 0;
12
+ } catch {
13
+ return void 0;
14
+ }
15
+ }
16
+ function write(key, value) {
17
+ values.set(key, value);
18
+ try {
19
+ window.localStorage.setItem(PREFIX + key, value);
20
+ } catch {
21
+ }
22
+ listeners.get(key)?.forEach((listener) => listener());
23
+ }
24
+ function useSyncedChoice(key, fallback) {
25
+ const subscribe = useCallback(
26
+ (listener) => {
27
+ if (!key) return () => {
28
+ };
29
+ let set = listeners.get(key);
30
+ if (!set) listeners.set(key, set = /* @__PURE__ */ new Set());
31
+ set.add(listener);
32
+ return () => set.delete(listener);
33
+ },
34
+ [key]
35
+ );
36
+ const value = useSyncExternalStore(
37
+ subscribe,
38
+ () => key ? read(key) ?? fallback : fallback,
39
+ () => fallback
40
+ );
41
+ const setValue = useCallback((next) => {
42
+ if (key) write(key, next);
43
+ }, [key]);
44
+ return [value, setValue];
45
+ }
46
+ export {
47
+ useSyncedChoice
48
+ };
@@ -12,12 +12,16 @@
12
12
  * swallowed when that layer is not Escape-dismissible (a lower layer must
13
13
  * never close through a blocking one). One press, one layer. An Escape a
14
14
  * component has already handled (`event.preventDefault()`, say an input
15
- * clearing its own text) is left alone.
15
+ * clearing its own text) is left alone. A passive layer on top (a
16
+ * tooltip, a hover card) still takes Escape first.
16
17
  * - **An outside press** walks down from the top: every layer the press
17
18
  * lands outside of, and that opts into light dismiss, closes; the walk
18
19
  * stops at the first layer that contains the press or does not
19
20
  * light-dismiss (a modal, which owns its backdrop). So a press on a
20
- * Dialog's body closes the menus open above it and leaves the Dialog.
21
+ * Dialog's body closes the menus open above it and leaves the Dialog. A
22
+ * `passive` layer (a tooltip) is passed through, never a stop, so a press
23
+ * on another menu's trigger closes the open menu even while a tooltip
24
+ * shows over it.
21
25
  * - **Backdrop clicks** stay with the modal that draws the backdrop, but a
22
26
  * press that began while another layer was on top was that layer's press:
23
27
  * `ownsPress()` tells the modal so, and it keeps itself open. Without it, a
@@ -49,6 +53,15 @@ type LayerOptions = {
49
53
  * also to stop the outside-press walk at a layer that contains the press.
50
54
  */
51
55
  getElements?: () => (HTMLElement | null | undefined)[];
56
+ /**
57
+ * A layer that only listens for Escape and never owns a press: a tooltip
58
+ * or a hover card. (Not addEventListener's `passive`.)
59
+ * The outside-press walk passes through it to the layers beneath, and it is
60
+ * never the press owner, so a tooltip showing over an open menu (its own
61
+ * trigger hovered, say) never keeps that menu open or a modal's backdrop
62
+ * from closing it. Escape still reaches it first while it is on top.
63
+ */
64
+ passive?: boolean;
52
65
  };
53
66
  export type LayerHandle = {
54
67
  /**
@@ -16,11 +16,12 @@ const handleKeyDown = (event) => {
16
16
  options.onDismiss?.();
17
17
  };
18
18
  const handlePointerDown = (event) => {
19
- pressOwner = layers[layers.length - 1] ?? null;
19
+ pressOwner = [...layers].reverse().find((layer) => !layer.optionsRef.current.passive) ?? null;
20
20
  const target = event.target instanceof Node ? event.target : null;
21
21
  if (!target) return;
22
22
  for (const layer of [...layers].reverse()) {
23
23
  const options = layer.optionsRef.current;
24
+ if (options.passive) continue;
24
25
  if (!options.dismissOnOutsidePress || contains(layer, target)) break;
25
26
  options.onDismiss?.();
26
27
  }
@@ -60,7 +61,7 @@ function useLayer(options) {
60
61
  const ownsPress = useCallback(() => {
61
62
  const layer = layerRef.current;
62
63
  if (!layer) return false;
63
- return pressOwner ? pressOwner === layer : layers[layers.length - 1] === layer;
64
+ return pressOwner ? pressOwner === layer : [...layers].reverse().find((entry) => !entry.optionsRef.current.passive) === layer;
64
65
  }, []);
65
66
  return { ownsPress };
66
67
  }
@@ -0,0 +1,55 @@
1
+ 'use client';
2
+ /**
3
+ * "Was this page helpful?" at the foot of a docs page: a thumbs Rating, then
4
+ * an optional note once the reader answers. Send the answer to your
5
+ * analytics in `send` below; nothing is sent anywhere as written.
6
+ */
7
+
8
+ import { useState } from 'react';
9
+ import { Button } from 'rift-ds/components/Button/Button';
10
+ import { Rating } from 'rift-ds/components/Rating/Rating';
11
+ import { Textarea } from 'rift-ds/components/Textarea/Textarea';
12
+ import styles from './page.module.css';
13
+
14
+ export function PageFeedback() {
15
+ const [answer, setAnswer] = useState(0);
16
+ const [note, setNote] = useState('');
17
+ const [sent, setSent] = useState(false);
18
+
19
+ // Replace with a call to your analytics or feedback endpoint.
20
+ const send = () => setSent(true);
21
+
22
+ if (sent) {
23
+ return <p className={styles.feedbackThanks}>Thanks for telling us.</p>;
24
+ }
25
+ return (
26
+ <div className={styles.feedback}>
27
+ <div className={styles.feedbackRow}>
28
+ <span id="page-feedback-question" className={styles.feedbackQuestion}>
29
+ Was this page helpful?
30
+ </span>
31
+ <Rating
32
+ variant="thumbs"
33
+ aria-labelledby="page-feedback-question"
34
+ upLabel="Yes"
35
+ downLabel="No"
36
+ value={answer}
37
+ onValueChange={setAnswer}
38
+ />
39
+ </div>
40
+ {answer > 0 && (
41
+ <div className={styles.feedbackNote}>
42
+ <Textarea
43
+ label={answer === 1 ? 'What helped? (optional)' : 'What was missing? (optional)'}
44
+ size="compact"
45
+ value={note}
46
+ onValueChange={setNote}
47
+ />
48
+ <div>
49
+ <Button variant="secondary" size="compact" label="Send" onClick={send} />
50
+ </div>
51
+ </div>
52
+ )}
53
+ </div>
54
+ );
55
+ }
@@ -0,0 +1,94 @@
1
+ /*
2
+ * The docs page's own spacing. Every value is a rift-ds token, except the
3
+ * specimen height, explained where it is set.
4
+ */
5
+
6
+ .intro {
7
+ display: flex;
8
+ flex-direction: column;
9
+ gap: var(--gap-300);
10
+ }
11
+
12
+ .lead {
13
+ margin: 0;
14
+ font-family: var(--font-sub-display-family);
15
+ font-size: var(--font-sub-display-size);
16
+ font-weight: var(--font-sub-display-weight);
17
+ line-height: var(--font-sub-display-line-height);
18
+ color: var(--color-text-secondary);
19
+ }
20
+
21
+ .section {
22
+ display: flex;
23
+ flex-direction: column;
24
+ gap: var(--gap-400);
25
+ padding-block-start: var(--padding-500);
26
+ }
27
+
28
+ .pair {
29
+ display: grid;
30
+ grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
31
+ gap: var(--gap-400);
32
+ }
33
+
34
+ /* A small stage for a Do or Don't specimen: tall enough for one control
35
+ with room around it. */
36
+ .specimen {
37
+ display: flex;
38
+ align-items: center;
39
+ justify-content: center;
40
+ min-height: calc(3 * var(--control-height-default));
41
+ line-height: normal;
42
+ }
43
+
44
+ .pageFooter {
45
+ display: flex;
46
+ flex-direction: column;
47
+ gap: var(--gap-500);
48
+ padding-block-start: var(--padding-1000);
49
+ border-block-start: var(--border-025) solid var(--color-divider);
50
+ }
51
+
52
+ .meta {
53
+ display: flex;
54
+ flex-wrap: wrap;
55
+ align-items: center;
56
+ justify-content: space-between;
57
+ gap: var(--gap-300);
58
+ }
59
+
60
+ .updated {
61
+ font-family: var(--font-caption-family);
62
+ font-size: var(--font-caption-size);
63
+ line-height: var(--font-caption-line-height);
64
+ color: var(--color-text-tertiary);
65
+ }
66
+
67
+ .feedback {
68
+ display: flex;
69
+ flex-direction: column;
70
+ gap: var(--gap-300);
71
+ }
72
+
73
+ .feedbackRow {
74
+ display: flex;
75
+ align-items: center;
76
+ gap: var(--gap-300);
77
+ }
78
+
79
+ .feedbackQuestion,
80
+ .feedbackThanks {
81
+ margin: 0;
82
+ font-family: var(--font-paragraph-sm-family);
83
+ font-size: var(--font-paragraph-sm-size);
84
+ line-height: var(--font-paragraph-sm-line-height);
85
+ color: var(--color-text-secondary);
86
+ }
87
+
88
+ .feedbackNote {
89
+ /* A note field the width of a short sentence, not of the article. */
90
+ display: flex;
91
+ flex-direction: column;
92
+ gap: var(--gap-300);
93
+ max-width: 480px;
94
+ }
@@ -0,0 +1,168 @@
1
+ /**
2
+ * The docs block: one documentation page in the docs shell, showing every
3
+ * piece a docs page needs. Keep the shell, replace this article with
4
+ * yours, and give each page its own `currentHref` and breadcrumb.
5
+ *
6
+ * Code here is monochrome. To colour it, install shiki and pass
7
+ * `lines={await highlight(code, 'tsx')}` (from `rift-ds/code/highlight`)
8
+ * to each CodeBlock, in a Server Component such as this page, so the page
9
+ * ships no highlighter.
10
+ */
11
+
12
+ import { Alert } from 'rift-ds/components/Alert/Alert';
13
+ import { ArtifactPanel } from 'rift-ds/components/ArtifactPanel/ArtifactPanel';
14
+ import { Button } from 'rift-ds/components/Button/Button';
15
+ import { CodeBlock } from 'rift-ds/components/CodeBlock/CodeBlock';
16
+ import { Figure } from 'rift-ds/components/Figure/Figure';
17
+ import { Heading } from 'rift-ds/components/Heading/Heading';
18
+ import { Instructions } from 'rift-ds/components/Instructions/Instructions';
19
+ import { Link } from 'rift-ds/components/Link/Link';
20
+ import { Pagination } from 'rift-ds/components/Pagination/Pagination';
21
+ import { Prose } from 'rift-ds/components/Prose/Prose';
22
+ import { Table } from 'rift-ds/components/Table/Table';
23
+ import { TreeView } from 'rift-ds/components/TreeView/TreeView';
24
+ import { packageManagerTabs } from 'rift-ds/code';
25
+ import { DocsShell } from '../../components/blocks/DocsShell';
26
+ import { PageFeedback } from './PageFeedback';
27
+ import styles from './page.module.css';
28
+
29
+ const USAGE = `import { Button } from 'rift-ds/components/Button/Button';
30
+
31
+ export function SaveBar() {
32
+ return <Button variant="primary">Save changes</Button>;
33
+ }`;
34
+
35
+ export default function GuidePage() {
36
+ return (
37
+ <DocsShell currentHref="#installation" breadcrumb={[{ label: 'Docs', href: '#docs' }, { label: 'Installation' }]}>
38
+ <header className={styles.intro}>
39
+ <Heading level={1} tier="display-2">
40
+ Installation
41
+ </Heading>
42
+ <p className={styles.lead}>
43
+ Add Acme to a React app, set up its theme, and render your first component.
44
+ </p>
45
+ </header>
46
+
47
+ <section className={styles.section}>
48
+ <Heading level={2} anchor>
49
+ Install the package
50
+ </Heading>
51
+ <Prose>
52
+ <p>Install it with the package manager your app uses. Your pick is remembered on every page.</p>
53
+ </Prose>
54
+ <CodeBlock tabs={packageManagerTabs({ install: 'acme-ui' })} syncKey="package-manager" />
55
+ <Alert
56
+ variant="info"
57
+ title="React 19 or later"
58
+ description="Acme relies on React 19's ref as a prop. Upgrade React first if your app is on 18."
59
+ />
60
+ </section>
61
+
62
+ <section className={styles.section}>
63
+ <Heading level={2} anchor>
64
+ Set up the theme
65
+ </Heading>
66
+ <Instructions
67
+ steps={[
68
+ { label: 'Import the stylesheet', description: 'Once, in your root layout, before your own CSS.' },
69
+ { label: 'Load the font', description: 'Through your framework’s font loader, or a link in the head.' },
70
+ { label: 'Set the colour mode', description: 'Render the colour mode script in the head so the first paint is right.' },
71
+ ]}
72
+ />
73
+ <CodeBlock
74
+ tabs={packageManagerTabs({ run: 'acme-ui init' })}
75
+ syncKey="package-manager"
76
+ />
77
+ </section>
78
+
79
+ <section className={styles.section}>
80
+ <Heading level={2} anchor>
81
+ Your first component
82
+ </Heading>
83
+ <ArtifactPanel layout="inline" viewLabel="Button example" code={USAGE} language="tsx">
84
+ <Button variant="primary">Save changes</Button>
85
+ </ArtifactPanel>
86
+ <Heading level={3} anchor>
87
+ Props
88
+ </Heading>
89
+ <Table
90
+ bordered
91
+ size="compact"
92
+ caption="Button props"
93
+ captionHidden
94
+ columns={[
95
+ { key: 'prop', header: 'Prop', mono: true, width: '24%', rowHeader: true },
96
+ { key: 'type', header: 'Type', mono: true, width: '36%' },
97
+ { key: 'description', header: 'Description' },
98
+ ]}
99
+ rows={[
100
+ { id: 'variant', cells: { prop: 'variant', type: "'primary' | 'secondary' | 'tertiary'", description: 'How much the button stands out.' } },
101
+ { id: 'size', cells: { prop: 'size', type: "'default' | 'compact'", description: 'The control height.' } },
102
+ { id: 'disabled', cells: { prop: 'disabled', type: 'boolean', description: 'Holds the button still.' } },
103
+ ]}
104
+ />
105
+ </section>
106
+
107
+ <section className={styles.section}>
108
+ <Heading level={2} anchor>
109
+ Writing labels
110
+ </Heading>
111
+ <div className={styles.pair}>
112
+ <Figure variant="positive" caption="Say what happens when it is pressed.">
113
+ <div className={styles.specimen}>
114
+ <Button variant="primary">Save changes</Button>
115
+ </div>
116
+ </Figure>
117
+ <Figure variant="error" caption="Leave the reader guessing what the button does.">
118
+ <div className={styles.specimen}>
119
+ <Button variant="primary">Click here</Button>
120
+ </div>
121
+ </Figure>
122
+ </div>
123
+ </section>
124
+
125
+ <section className={styles.section}>
126
+ <Heading level={2} anchor>
127
+ Project structure
128
+ </Heading>
129
+ <TreeView
130
+ aria-label="Project files"
131
+ defaultExpandedIds={['app', 'components']}
132
+ nodes={[
133
+ {
134
+ id: 'app',
135
+ label: 'app',
136
+ icon: 'folder',
137
+ children: [
138
+ { id: 'layout', label: 'layout.tsx', icon: 'description' },
139
+ { id: 'page', label: 'page.tsx', icon: 'description' },
140
+ ],
141
+ },
142
+ {
143
+ id: 'components',
144
+ label: 'components',
145
+ icon: 'folder',
146
+ children: [{ id: 'save-bar', label: 'SaveBar.tsx', icon: 'description' }],
147
+ },
148
+ ]}
149
+ />
150
+ </section>
151
+
152
+ <footer className={styles.pageFooter}>
153
+ <div className={styles.meta}>
154
+ <Link variant="standalone" size="compact" href="#edit" iconLeft="edit">
155
+ Edit this page
156
+ </Link>
157
+ <span className={styles.updated}>Last updated 12 Nov 2026</span>
158
+ </div>
159
+ <PageFeedback />
160
+ <Pagination
161
+ variant="adjacent"
162
+ previous={{ href: '#introduction', label: 'Introduction' }}
163
+ next={{ href: '#theming', label: 'Theming' }}
164
+ />
165
+ </footer>
166
+ </DocsShell>
167
+ );
168
+ }
@@ -72,7 +72,9 @@
72
72
  .content {
73
73
  position: relative;
74
74
  width: 100%;
75
- max-width: 1440px;
75
+ /* The shell recipe's width axis (CONTENT_WIDTH in AppShell.tsx): 1440px
76
+ contained, or the whole column when full, in any mode. */
77
+ max-width: var(--ds-shell-content-max, var(--ds-shell-contained-width));
76
78
  min-width: 0;
77
79
  display: flex;
78
80
  flex-direction: column;