rift-ds 1.40.0 → 1.42.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 (218) hide show
  1. package/README.md +6 -2
  2. package/behaviors/LoadingImage.d.ts +2 -0
  3. package/behaviors/LoadingImage.js +34 -0
  4. package/behaviors/ScrollRegion.js +15 -2
  5. package/behaviors/VisuallyHidden.d.ts +30 -0
  6. package/behaviors/VisuallyHidden.js +17 -0
  7. package/behaviors/loading-image.css +30 -0
  8. package/behaviors/quietFocus.d.ts +4 -0
  9. package/behaviors/quietFocus.js +14 -0
  10. package/behaviors/shell.css +9 -11
  11. package/behaviors/useFocusScope.d.ts +3 -1
  12. package/behaviors/useFocusScope.js +4 -6
  13. package/bin/rift-ds.mjs +1 -0
  14. package/bin/templates/app/components/rift/ColorModeScript.tsx +3 -1
  15. package/bin/templates/app/components/rift/RiftRoot.tsx +40 -1
  16. package/bin/templates/blocks/app/dashboard/page.tsx +7 -5
  17. package/bin/templates/blocks/app/landing/page.tsx +1 -1
  18. package/bin/templates/blocks/app/pricing/page.module.css +15 -1
  19. package/bin/templates/blocks/app/pricing/page.tsx +8 -1
  20. package/bin/templates/blocks/app/sign-in/page.tsx +10 -2
  21. package/bin/templates/blocks/app/sign-up/page.module.css +83 -0
  22. package/bin/templates/blocks/app/sign-up/page.tsx +126 -0
  23. package/bin/templates/blocks/app/starter/page.tsx +1 -1
  24. package/bin/templates/blocks/components/blocks/AppShell.module.css +0 -10
  25. package/bin/templates/blocks/components/blocks/AppShell.tsx +41 -116
  26. package/bin/templates/blocks/components/blocks/DocsShell.tsx +5 -1
  27. package/bin/templates/blocks/registry.json +44 -6
  28. package/chat/ChatLauncher.d.ts +2 -2
  29. package/chat/ChatWidget.css +7 -7
  30. package/chat/ChatWidget.d.ts +1 -1
  31. package/components/AgentPlan/AgentPlan.css +1 -1
  32. package/components/AlertDialog/AlertDialog.css +14 -0
  33. package/components/AlertDialog/AlertDialog.d.ts +35 -3
  34. package/components/AlertDialog/AlertDialog.js +16 -5
  35. package/components/AppLayout/AppLayout.css +1 -1
  36. package/components/AppLayout/AppLayout.d.ts +2 -2
  37. package/components/AppSidebar/AppSidebar.css +25 -17
  38. package/components/AppSidebar/AppSidebar.d.ts +4 -4
  39. package/components/AppSidebar/AppSidebar.js +14 -5
  40. package/components/Attachment/AttachmentGroup.js +2 -1
  41. package/components/Attachment/AttachmentTile.js +2 -1
  42. package/components/Avatar/Avatar.css +18 -5
  43. package/components/Avatar/Avatar.d.ts +2 -0
  44. package/components/Avatar/Avatar.js +2 -1
  45. package/components/AvatarGroup/AvatarGroup.css +8 -1
  46. package/components/AvatarGroup/AvatarGroup.d.ts +6 -0
  47. package/components/AvatarGroup/AvatarGroup.js +2 -2
  48. package/components/Badge/Badge.css +6 -0
  49. package/components/Breadcrumb/Breadcrumb.css +4 -1
  50. package/components/Button/Button.css +20 -1
  51. package/components/Button/Button.js +6 -1
  52. package/components/Card/Card.css +11 -0
  53. package/components/Card/Card.d.ts +9 -3
  54. package/components/Card/Card.js +21 -2
  55. package/components/Chart/AreaChart.d.ts +7 -0
  56. package/components/Chart/AreaChart.js +51 -45
  57. package/components/Chart/BarChart.d.ts +7 -0
  58. package/components/Chart/BarChart.js +52 -46
  59. package/components/Chart/Chart.css +122 -1
  60. package/components/Chart/ChartSkeleton.d.ts +32 -0
  61. package/components/Chart/ChartSkeleton.js +149 -0
  62. package/components/Chart/ComboChart.d.ts +7 -0
  63. package/components/Chart/ComboChart.js +80 -74
  64. package/components/Chart/LineChart.d.ts +17 -3
  65. package/components/Chart/LineChart.js +61 -39
  66. package/components/Chart/PieChart.d.ts +7 -0
  67. package/components/Chart/PieChart.js +41 -34
  68. package/components/Chart/RadarChart.d.ts +7 -0
  69. package/components/Chart/RadarChart.js +38 -32
  70. package/components/Chart/RadialChart.d.ts +7 -0
  71. package/components/Chart/RadialChart.js +5 -1
  72. package/components/Chart/ScatterChart.d.ts +7 -0
  73. package/components/Chart/ScatterChart.js +46 -40
  74. package/components/Chart/StackedBarChart.d.ts +10 -1
  75. package/components/Chart/StackedBarChart.js +51 -43
  76. package/components/Chart/Treemap.d.ts +7 -0
  77. package/components/Chart/Treemap.js +17 -11
  78. package/components/Checkbox/Checkbox.css +25 -1
  79. package/components/Checkbox/Checkbox.d.ts +8 -4
  80. package/components/Checkbox/Checkbox.js +17 -8
  81. package/components/Chip/Chip.css +5 -3
  82. package/components/ContactCard/ContactCard.css +4 -3
  83. package/components/ContributionGraph/ContributionGraph.css +20 -0
  84. package/components/ContributionGraph/ContributionGraph.d.ts +4 -0
  85. package/components/ContributionGraph/ContributionGraph.js +11 -6
  86. package/components/DataTable/DataTable.css +91 -4
  87. package/components/DataTable/DataTable.d.ts +42 -4
  88. package/components/DataTable/DataTable.js +121 -90
  89. package/components/DateInput/DateInput.css +3 -1
  90. package/components/DatePicker/DatePicker.css +16 -0
  91. package/components/DatePicker/DatePicker.d.ts +13 -0
  92. package/components/DatePicker/DatePicker.js +21 -27
  93. package/components/DatePicker/MonthGrid.d.ts +2 -2
  94. package/components/DatePicker/MonthGrid.js +1 -1
  95. package/components/DatePicker/today.d.ts +15 -0
  96. package/components/DatePicker/today.js +17 -0
  97. package/components/DateRangePicker/DateRangePicker.d.ts +14 -1
  98. package/components/DateRangePicker/DateRangePicker.js +18 -7
  99. package/components/DescriptionList/DescriptionList.css +11 -0
  100. package/components/DescriptionList/DescriptionList.d.ts +5 -1
  101. package/components/DescriptionList/DescriptionList.js +21 -6
  102. package/components/Dialog/Dialog.css +9 -0
  103. package/components/Dialog/Dialog.d.ts +9 -0
  104. package/components/Dialog/Dialog.js +32 -19
  105. package/components/DocumentChip/DocumentChip.css +1 -1
  106. package/components/Drawer/Drawer.d.ts +9 -0
  107. package/components/Drawer/Drawer.js +8 -0
  108. package/components/DrillMenu/DrillMenu.d.ts +2 -1
  109. package/components/DrillMenu/DrillMenu.js +14 -3
  110. package/components/Dropdown/Dropdown.css +3 -1
  111. package/components/EmptyState/EmptyState.css +8 -1
  112. package/components/EntitySwitcher/EntitySwitcher.css +2 -1
  113. package/components/Field/Field.css +2 -2
  114. package/components/FileInput/FileInput.css +1 -1
  115. package/components/FilterBar/FilterBar.d.ts +6 -1
  116. package/components/FunnelChart/FunnelChart.d.ts +7 -0
  117. package/components/FunnelChart/FunnelChart.js +44 -30
  118. package/components/GanttChart/GanttChart.css +10 -0
  119. package/components/GanttChart/GanttChart.d.ts +4 -0
  120. package/components/GanttChart/GanttChart.js +66 -33
  121. package/components/Gauge/Gauge.css +23 -0
  122. package/components/Gauge/Gauge.d.ts +4 -0
  123. package/components/Gauge/Gauge.js +14 -8
  124. package/components/Icon/Icon.css +6 -1
  125. package/components/Icon/Icon.d.ts +3 -1
  126. package/components/Icon/Icon.js +2 -0
  127. package/components/ImageCompare/ImageCompare.js +2 -1
  128. package/components/Input/Input.css +3 -1
  129. package/components/List/List.css +1 -1
  130. package/components/NotificationCenter/NotificationCenter.css +16 -0
  131. package/components/NotificationCenter/NotificationCenter.d.ts +4 -0
  132. package/components/NotificationCenter/NotificationCenter.js +23 -1
  133. package/components/NumberInput/NumberInput.css +2 -0
  134. package/components/PageHeader/PageHeader.css +12 -4
  135. package/components/Panel/Panel.d.ts +1 -1
  136. package/components/PixelAvatar/PixelAvatar.css +7 -1
  137. package/components/PixelAvatar/PixelAvatar.d.ts +2 -0
  138. package/components/PixelAvatar/PixelAvatar.js +2 -1
  139. package/components/Prose/Prose.css +1 -1
  140. package/components/RadioButton/RadioButton.css +1 -1
  141. package/components/RadioButton/RadioButton.d.ts +4 -2
  142. package/components/RadioButton/RadioButton.js +5 -2
  143. package/components/ResourceTimeline/ResourceTimeline.css +12 -0
  144. package/components/ResourceTimeline/ResourceTimeline.d.ts +5 -1
  145. package/components/ResourceTimeline/ResourceTimeline.js +94 -52
  146. package/components/RichDropdown/RichDropdown.css +3 -1
  147. package/components/SelectionCard/SelectionCard.css +29 -0
  148. package/components/SelectionCard/SelectionCard.d.ts +7 -0
  149. package/components/SelectionCard/SelectionCard.js +25 -2
  150. package/components/ShaderField/useShaderField.js +2 -2
  151. package/components/ShaderScene/ShaderScene.js +2 -2
  152. package/components/SiteHeader/SiteHeader.css +0 -9
  153. package/components/SourceChip/SourceChip.css +2 -1
  154. package/components/Sparkline/Sparkline.css +20 -0
  155. package/components/Sparkline/Sparkline.d.ts +4 -0
  156. package/components/Sparkline/Sparkline.js +14 -8
  157. package/components/Stat/Stat.css +31 -0
  158. package/components/Stat/Stat.d.ts +23 -2
  159. package/components/Stat/Stat.js +21 -6
  160. package/components/SubNavPanel/SubNavPanel.css +10 -9
  161. package/components/Table/Table.css +409 -14
  162. package/components/Table/Table.d.ts +32 -2
  163. package/components/Table/Table.js +66 -34
  164. package/components/Textarea/Textarea.css +4 -2
  165. package/components/ThemeToggle/colorMode.d.ts +10 -2
  166. package/components/ThemeToggle/colorMode.js +4 -2
  167. package/components/ThreadHistory/ThreadHistory.css +11 -0
  168. package/components/ThreadHistory/ThreadHistory.d.ts +5 -1
  169. package/components/ThreadHistory/ThreadHistory.js +6 -1
  170. package/components/ThreadPanel/ThreadPanel.d.ts +4 -0
  171. package/components/ThreadPanel/ThreadPanel.js +5 -1
  172. package/components/TimePicker/TimePicker.css +3 -1
  173. package/components/TimePicker/TimePicker.d.ts +4 -2
  174. package/components/TimePicker/TimePicker.js +11 -3
  175. package/components/Timeline/Timeline.css +15 -0
  176. package/components/Timeline/Timeline.d.ts +8 -0
  177. package/components/Timeline/Timeline.js +21 -0
  178. package/components/Toast/Toast.css +16 -0
  179. package/components/Toast/Toast.d.ts +7 -2
  180. package/components/ToggleGroup/ToggleGroup.css +28 -2
  181. package/components/ToggleSwitch/ToggleSwitch.css +1 -1
  182. package/components/Tooltip/Tooltip.d.ts +9 -0
  183. package/components/Tooltip/Tooltip.js +34 -8
  184. package/components/TreeView/TreeView.css +12 -0
  185. package/components/TreeView/TreeView.d.ts +4 -0
  186. package/components/TreeView/TreeView.js +20 -0
  187. package/components/UsageCard/UsageCard.css +11 -0
  188. package/components/UsageCard/UsageCard.d.ts +4 -0
  189. package/components/UsageCard/UsageCard.js +25 -16
  190. package/components/Widget/Widget.css +7 -0
  191. package/components/Widget/Widget.d.ts +4 -0
  192. package/components/Widget/Widget.js +14 -2
  193. package/components/registry.json +5 -2
  194. package/components/registry.json.d.ts +5 -2
  195. package/components/registry.json.js +1 -1
  196. package/package.json +9 -3
  197. package/tokens/motion.d.ts +2 -0
  198. package/tokens/motion.js +2 -0
  199. package/tokens/presets/contrast.css +36 -3
  200. package/tokens/presets/coral.css +39 -3
  201. package/tokens/presets/forest.css +55 -3
  202. package/tokens/presets/gold.css +39 -4
  203. package/tokens/presets/marquee.css +42 -4
  204. package/tokens/presets/mono.css +107 -29
  205. package/tokens/presets/pink.css +41 -3
  206. package/tokens/presets/plum.css +41 -1
  207. package/tokens/presets/terminal.css +40 -4
  208. package/tokens/presets/violet.css +42 -3
  209. package/tokens/presets/warm.css +49 -5
  210. package/tokens/presets/zest.css +47 -3
  211. package/tokens/registry.json +2 -0
  212. package/tokens/registry.json.d.ts +2 -0
  213. package/tokens/registry.json.js +1 -1
  214. package/tokens/tokens-dark.css +5 -0
  215. package/tokens/tokens-light.css +9 -0
  216. package/tokens/values.d.ts +14 -1
  217. package/tokens/values.js +14 -1
  218. package/tokens/values.json.js +1 -1
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <!-- banner:start -->
2
- <a href="https://rift-ds.com"><img src="https://raw.githubusercontent.com/robritacca-dotcom/rift-ds/main/.github/readme-banner.jpg" alt="Rift DS, the AI-ready React design system" width="100%"></a>
2
+ <a href="https://rift-ds.com"><img src="https://raw.githubusercontent.com/robritacca-dotcom/rift-ds/main/.github/readme-banner.jpg" alt="Rift DS, the open-source, AI-native design system" width="100%"></a>
3
3
  <!-- banner:end -->
4
4
 
5
5
  # Rift DS
@@ -153,4 +153,8 @@ Designed and built by [Robert Ritacca](https://robertritacca.com).
153
153
 
154
154
  ## License
155
155
 
156
- MIT, the whole repository: components, tokens, scripts, the website, and the docs. Use it in anything. See [`LICENSE`](LICENSE) for the full terms.
156
+ The package is MIT: the components, the tokens, the chat widget, the command-line tool and everything else published to npm as `rift-ds`, with the scripts that build them. Use it in anything. See [`LICENSE`](LICENSE) for the full terms.
157
+
158
+ The website is not. Its code, pages, writing and design are all rights reserved, apart from the files it publishes for use with the package, which are MIT too. See [`website/LICENSE`](website/LICENSE).
159
+
160
+ The Rift DS name, the logo, the mark and the brand's other assets are not licensed under either. A fork or a product built on the package needs its own name and logo. See [`TRADEMARKS.md`](TRADEMARKS.md).
@@ -0,0 +1,2 @@
1
+ import { ComponentPropsWithoutRef } from 'react';
2
+ export declare function LoadingImage({ className, src, onLoad, onError, ...rest }: ComponentPropsWithoutRef<'img'>): import("react").JSX.Element;
@@ -0,0 +1,34 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useState, useCallback } from "react";
4
+ import "./loading-image.css";
5
+ function LoadingImage({ className, src, onLoad, onError, ...rest }) {
6
+ const [settledSrc, setSettledSrc] = useState(void 0);
7
+ const attach = useCallback(
8
+ (node) => {
9
+ if (node?.complete) setSettledSrc(src);
10
+ },
11
+ [src]
12
+ );
13
+ const classes = [settledSrc === src ? "" : "ds-image--loading", className].filter(Boolean).join(" ");
14
+ return /* @__PURE__ */ jsx(
15
+ "img",
16
+ {
17
+ ...rest,
18
+ ref: attach,
19
+ src,
20
+ className: classes || void 0,
21
+ onLoad: (event) => {
22
+ setSettledSrc(src);
23
+ onLoad?.(event);
24
+ },
25
+ onError: (event) => {
26
+ setSettledSrc(src);
27
+ onError?.(event);
28
+ }
29
+ }
30
+ );
31
+ }
32
+ export {
33
+ LoadingImage
34
+ };
@@ -26,12 +26,25 @@ function ScrollRegion({
26
26
  if (!caption.id) caption.id = captionId;
27
27
  setLabelledBy(caption.id);
28
28
  }
29
- const measure = () => setOverflows(node.scrollWidth > node.clientWidth + 1);
29
+ const mark = () => {
30
+ const hidden = node.scrollWidth - node.clientWidth;
31
+ const from = Math.abs(node.scrollLeft);
32
+ node.toggleAttribute("data-scroll-start", hidden > 1 && from > 1);
33
+ node.toggleAttribute("data-scroll-end", hidden > 1 && from < hidden - 1);
34
+ };
35
+ const measure = () => {
36
+ setOverflows(node.scrollWidth > node.clientWidth + 1);
37
+ mark();
38
+ };
30
39
  measure();
31
40
  const observer = new ResizeObserver(measure);
32
41
  observer.observe(node);
33
42
  if (node.firstElementChild) observer.observe(node.firstElementChild);
34
- return () => observer.disconnect();
43
+ node.addEventListener("scroll", mark, { passive: true });
44
+ return () => {
45
+ observer.disconnect();
46
+ node.removeEventListener("scroll", mark);
47
+ };
35
48
  }, [captionId]);
36
49
  return /* @__PURE__ */ jsx(
37
50
  "div",
@@ -0,0 +1,30 @@
1
+ import { default as React } from 'react';
2
+ /**
3
+ * VisuallyHidden
4
+ *
5
+ * Text that is read but not seen: a status for a live region, a spoken
6
+ * name beside an icon, a column's heading that sighted readers get from
7
+ * the layout. It renders its children in the library's one visually-hidden
8
+ * recipe (`ds-visually-hidden`, in visually-hidden.css), the same class
9
+ * every component uses, so an app never writes the clip recipe a second
10
+ * time.
11
+ *
12
+ * Presentational, so it renders from a Server Component. It is not for a
13
+ * native input that must stay focusable while hidden; that keeps its own
14
+ * rule (see FileInput).
15
+ */
16
+ /** Props owned by VisuallyHidden itself; everything else falls through to the element. */
17
+ type VisuallyHiddenOwnProps = {
18
+ /** The element to render: a `span` inside a line of text (the default), a `div` around blocks. */
19
+ as?: 'span' | 'div';
20
+ /** The text a screen reader announces and the page does not show. */
21
+ children?: React.ReactNode;
22
+ /** Additional CSS classes */
23
+ className?: string;
24
+ /** A ref to the rendered element. */
25
+ ref?: React.Ref<HTMLElement>;
26
+ };
27
+ export interface VisuallyHiddenProps extends VisuallyHiddenOwnProps, Omit<React.ComponentPropsWithoutRef<'span'>, keyof VisuallyHiddenOwnProps> {
28
+ }
29
+ export declare function VisuallyHidden({ as: Element, className, children, ref, ...rest }: VisuallyHiddenProps): React.JSX.Element;
30
+ export {};
@@ -0,0 +1,17 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import "react";
3
+ import "./visually-hidden.css";
4
+ function VisuallyHidden({ as: Element = "span", className = "", children, ref, ...rest }) {
5
+ return /* @__PURE__ */ jsx(
6
+ Element,
7
+ {
8
+ ...rest,
9
+ ref,
10
+ className: ["ds-visually-hidden", className].filter(Boolean).join(" "),
11
+ children
12
+ }
13
+ );
14
+ }
15
+ export {
16
+ VisuallyHidden
17
+ };
@@ -0,0 +1,30 @@
1
+ /* ============================================
2
+ LOADING IMAGE
3
+ The one placeholder for a picture that is
4
+ still downloading: the Skeleton fill in the
5
+ image's own box, pulsing, until the file has
6
+ loaded (LoadingImage.tsx sets and clears the
7
+ class). Behind `scripting: enabled`, because
8
+ only a script can clear it.
9
+ ============================================ */
10
+
11
+ @layer rift.tokens, rift.preset, rift.components;
12
+
13
+ @layer rift.components {
14
+
15
+ @media (scripting: enabled) {
16
+ .ds-image--loading {
17
+ background-color: var(--color-bg-container-secondary);
18
+ /* ds-allow(motion): the pulse needs a symmetric in-out curve and no
19
+ --motion-ease-* token provides one; the duration is tokenized. */
20
+ animation: ds-image-pulse var(--motion-duration-loop-shimmer) ease-in-out infinite alternate;
21
+ }
22
+ }
23
+
24
+ @keyframes ds-image-pulse {
25
+ to {
26
+ opacity: 0.5;
27
+ }
28
+ }
29
+
30
+ } /* @layer rift.components */
@@ -0,0 +1,4 @@
1
+ /** Focus `element` on a script's behalf: a hint that opens on focus stays closed for it. */
2
+ export declare function focusQuietly(element: HTMLElement, options?: FocusOptions): void;
3
+ /** Whether `element` holds focus a script gave it through `focusQuietly`. */
4
+ export declare const isQuietFocus: (element: Element | null) => boolean;
@@ -0,0 +1,14 @@
1
+ const quiet = /* @__PURE__ */ new WeakSet();
2
+ function focusQuietly(element, options) {
3
+ if (document.activeElement !== element) {
4
+ quiet.add(element);
5
+ element.addEventListener("blur", () => quiet.delete(element), { once: true });
6
+ }
7
+ element.focus(options);
8
+ if (document.activeElement !== element) quiet.delete(element);
9
+ }
10
+ const isQuietFocus = (element) => element !== null && quiet.has(element);
11
+ export {
12
+ focusQuietly,
13
+ isQuietFocus
14
+ };
@@ -28,10 +28,10 @@
28
28
  something, so it is the chat's alone: an
29
29
  app layout or a template is always the
30
30
  floor of its page and stays solid.
31
- - floating: the rail is a glass card held off
32
- the edges by the float gap, hairline and
33
- floating shadow; the content sits on the
34
- page.
31
+ - floating: the rail is a card on the shell
32
+ colour held off the edges by the float gap,
33
+ hairline and floating shadow; the content
34
+ is crisp on the app surface around it.
35
35
  - inset: the rail runs flush on the shell
36
36
  plane and the content is a raised surface,
37
37
  hairline and floating shadow, held off the
@@ -58,12 +58,10 @@
58
58
  --ds-shell-gap: var(--ds-shell-inset, 10px);
59
59
  --ds-shell-float-gap: var(--ds-sidebar-float-inset, 20px);
60
60
 
61
- /* The raised edge and the glass card, shared by floating and inset. */
61
+ /* The raised edge, shared by floating and inset. */
62
62
  --ds-shell-radius: var(--radius-600);
63
- --ds-shell-edge-border: var(--color-bg-container-border);
63
+ --ds-shell-edge-border: var(--color-bg-app-shell-border);
64
64
  --ds-shell-edge-shadow: var(--shadow-floating);
65
- --ds-shell-glass: var(--color-bg-glass);
66
- --ds-shell-glass-blur: blur(24px);
67
65
  }
68
66
 
69
67
  :where([data-ds-shell='flush']) {
@@ -88,9 +86,9 @@
88
86
  }
89
87
 
90
88
  :where([data-ds-shell='floating']) {
91
- --ds-shell-plane: var(--color-bg-page-primary);
92
- --ds-shell-surface: var(--color-bg-page-primary);
93
- --ds-shell-rail-bg: var(--ds-shell-glass);
89
+ --ds-shell-plane: var(--color-bg-app-surface);
90
+ --ds-shell-surface: var(--color-bg-app-surface);
91
+ --ds-shell-rail-bg: var(--color-bg-app-shell);
94
92
  --ds-shell-rail-divider: transparent;
95
93
  --ds-shell-surface-border: transparent;
96
94
  --ds-shell-surface-shadow: none;
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Focus containment for modal overlays: initial focus, Tab wrapping, focus
3
- * restore, and background isolation.
3
+ * restore, and background isolation. The initial focus and the restore are
4
+ * moved quietly (src/behaviors/quietFocus.ts), so a Tooltip on the control
5
+ * that receives them does not open.
4
6
  *
5
7
  * Restore is guarded twice. The element that opened a dialog can be gone by
6
8
  * the time it closes (a row the dialog itself deleted), and it can still be in
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { useRef, useEffect } from "react";
3
3
  import { getInitialFocus, getFocusable } from "./focusable.js";
4
+ import { focusQuietly } from "./quietFocus.js";
4
5
  const inertScopes = [];
5
6
  const inerted = /* @__PURE__ */ new Set();
6
7
  const applyInert = () => {
@@ -48,7 +49,7 @@ function useFocusScope(ref, options) {
48
49
  let focusAttempts = 0;
49
50
  const tryInitialFocus = () => {
50
51
  const initial = optionsRef.current.initialFocus?.() ?? getInitialFocus(panel) ?? panel;
51
- initial.focus();
52
+ focusQuietly(initial);
52
53
  if (document.activeElement === initial) return;
53
54
  focusAttempts += 1;
54
55
  if (focusAttempts < 5) focusRaf = requestAnimationFrame(tryInitialFocus);
@@ -84,11 +85,8 @@ function useFocusScope(ref, options) {
84
85
  }
85
86
  const restore = optionsRef.current.restoreFocus;
86
87
  const chosen = typeof restore === "function" ? restore() : null;
87
- if (chosen) {
88
- chosen.focus();
89
- } else if (restore !== false && previousFocus) {
90
- restoreTarget(previousFocus)?.focus();
91
- }
88
+ const back = chosen ?? (restore !== false && previousFocus ? restoreTarget(previousFocus) : null);
89
+ if (back) focusQuietly(back);
92
90
  };
93
91
  }, [active, ref]);
94
92
  }
package/bin/rift-ds.mjs CHANGED
@@ -312,6 +312,7 @@ function initApp({ app, dryRun }) {
312
312
  console.log(`\nPick a shipped theme before the first screen: the base theme is a neutral starting point, not a look.`);
313
313
  console.log(`Import ${PACKAGE_NAME}/tokens/presets/<id>.css after tokens.css and set data-brand="<id>" on <html>.`);
314
314
  console.log(`Compare them at ${SITE_ORIGIN}/playground.`);
315
+ console.log(`A project with a theme.css from the playground already has its look: skip this, and follow that file's own steps for the font.`);
315
316
  console.log(`\nThen add a first page: npx ${PACKAGE_NAME} init block dashboard (no name lists them).`);
316
317
  console.log(`Setup and theming: ${SITE_ORIGIN}/docs/get-started`);
317
318
  }
@@ -7,7 +7,9 @@ import { colorModeScript, type ColorModeScriptOptions } from 'rift-ds/components
7
7
  *
8
8
  * If your app lets the visitor pick a theme, store the preset id under a key
9
9
  * of your own and pass it as `brandStorageKey`: the script then applies that
10
- * theme before first paint too.
10
+ * theme before first paint too. For a dark-first app pass
11
+ * `defaultMode="dark"` here and to RiftRoot: a first-time visitor then opens
12
+ * in dark, and their own choice still wins.
11
13
  */
12
14
  export function ColorModeScript(options: ColorModeScriptOptions) {
13
15
  return <script dangerouslySetInnerHTML={{ __html: colorModeScript(options) }} />;
@@ -1,13 +1,52 @@
1
1
  'use client';
2
2
 
3
+ import { useEffect } from 'react';
3
4
  import Link from 'next/link';
4
5
  import { LinkProvider } from 'rift-ds/behaviors/LinkProvider';
6
+ import {
7
+ DEFAULT_COLOR_MODE_STORAGE_KEY,
8
+ isColorModeSetting,
9
+ type ColorModeSetting,
10
+ } from 'rift-ds/components/ThemeToggle/colorMode';
11
+
12
+ export interface RiftRootProps {
13
+ children: React.ReactNode;
14
+ /** The key the colour mode is stored under. Pass the one ColorModeScript takes, if you changed it. */
15
+ storageKey?: string;
16
+ /** The mode a first-time visitor opens in. Pass the one ColorModeScript takes, if you set it. */
17
+ defaultMode?: ColorModeSetting;
18
+ }
5
19
 
6
20
  /**
7
21
  * The app's root for rift-ds: hands Next's Link to every rift-ds component
8
22
  * that renders a link, so they navigate through the router instead of
9
23
  * reloading the page. Wrap your root layout's body content in it.
24
+ *
25
+ * It also puts the colour mode back where the head's script never ran. On a
26
+ * page Next renders in the browser alone (the shell it serves for a dynamic
27
+ * notFound() or a thrown error), <html> arrives with no data-theme, so a
28
+ * dark-mode visitor would see a light page. When the attribute is missing
29
+ * on mount, the stored choice is applied again, as ColorModeScript does.
10
30
  */
11
- export function RiftRoot({ children }: { children: React.ReactNode }) {
31
+ export function RiftRoot({
32
+ children,
33
+ storageKey = DEFAULT_COLOR_MODE_STORAGE_KEY,
34
+ defaultMode = 'system',
35
+ }: RiftRootProps) {
36
+ useEffect(() => {
37
+ const root = document.documentElement;
38
+ if (root.hasAttribute('data-theme')) return;
39
+ let saved: string | null = null;
40
+ try {
41
+ saved = localStorage.getItem(storageKey);
42
+ } catch {
43
+ // Storage unavailable: fall through to the default mode.
44
+ }
45
+ const setting = isColorModeSetting(saved) ? saved : defaultMode;
46
+ const dark = setting === 'system' ? window.matchMedia('(prefers-color-scheme: dark)').matches : setting === 'dark';
47
+ root.setAttribute('data-theme-setting', setting);
48
+ root.setAttribute('data-theme', dark ? 'dark' : 'light');
49
+ }, [storageKey, defaultMode]);
50
+
12
51
  return <LinkProvider linkComponent={Link}>{children}</LinkProvider>;
13
52
  }
@@ -23,7 +23,8 @@ const STATS = [
23
23
  { label: 'Open tasks', value: '128', delta: '+12', trend: 'up' },
24
24
  { label: 'Due this week', value: '24', delta: '-3', trend: 'down' },
25
25
  { label: 'Completed', value: '342', delta: '+18%', trend: 'up' },
26
- { label: 'Avg. cycle time', value: '3.2d', delta: '-0.4d', trend: 'up' },
26
+ // Lower is better here: the arrow says which way it went, the colour that it is good news.
27
+ { label: 'Avg. cycle time', value: '3.2d', delta: '-0.4d', trend: 'down', sentiment: 'positive' },
27
28
  ] as const;
28
29
 
29
30
  const PROGRESS = [
@@ -79,20 +80,21 @@ export default function DashboardPage() {
79
80
  >
80
81
  <div className={styles.stats}>
81
82
  {STATS.map((stat) => (
82
- <Panel key={stat.label}>
83
+ <Panel key={stat.label} bordered>
83
84
  <Stat
84
85
  label={stat.label}
85
86
  value={stat.value}
86
87
  delta={stat.delta}
87
88
  trend={stat.trend}
88
- deltaPlacement="auto"
89
+ sentiment={'sentiment' in stat ? stat.sentiment : undefined}
90
+ deltaPlacement="inline"
89
91
  />
90
92
  </Panel>
91
93
  ))}
92
94
  </div>
93
95
 
94
96
  <div className={styles.panels}>
95
- <Panel>
97
+ <Panel bordered>
96
98
  <h2 className={styles.panelTitle}>Progress by project</h2>
97
99
  <ul className={styles.list}>
98
100
  {PROGRESS.map((row) => (
@@ -107,7 +109,7 @@ export default function DashboardPage() {
107
109
  </ul>
108
110
  </Panel>
109
111
 
110
- <Panel>
112
+ <Panel bordered>
111
113
  <h2 className={styles.panelTitle}>Recent activity</h2>
112
114
  <ul className={styles.list}>
113
115
  {ACTIVITY.map((row) => (
@@ -97,7 +97,7 @@ export default function LandingPage() {
97
97
  <Grid minColumnWidth="280px" gap="500" as="ul" className={styles.plainList}>
98
98
  {FEATURES.map((feature) => (
99
99
  <li key={feature.title}>
100
- <Panel className={styles.feature}>
100
+ <Panel bordered className={styles.feature}>
101
101
  <Icon name={feature.icon} size="800" tile />
102
102
  <Heading level={3}>{feature.title}</Heading>
103
103
  <Text tone="neutral">{feature.body}</Text>
@@ -1,4 +1,4 @@
1
- /* The pricing page's own layout is two rules. The plans' grid, the cards
1
+ /* The pricing page's own layout is a few rules. The plans' grid, the cards
2
2
  and the table come from the components. */
3
3
 
4
4
  /* A plan's button runs the width of its card. */
@@ -13,3 +13,17 @@
13
13
  display: inline-flex;
14
14
  margin-block: calc(-1 * (var(--padding-050) + var(--border-025)));
15
15
  }
16
+
17
+ /* The compare table's "included" mark is the feature lists' tick: List's
18
+ check marker, at its size and in the positive icon colour. */
19
+ .included {
20
+ display: inline-flex;
21
+ color: var(--color-status-positive-icon);
22
+ }
23
+
24
+ .tick {
25
+ inline-size: var(--icon-size-500);
26
+ block-size: var(--icon-size-500);
27
+ padding: var(--padding-050);
28
+ box-sizing: border-box;
29
+ }
@@ -11,6 +11,7 @@
11
11
  import { useState } from 'react';
12
12
  import { Badge } from 'rift-ds/components/Badge/Badge';
13
13
  import { Button } from 'rift-ds/components/Button/Button';
14
+ import { CheckIcon } from 'rift-ds/components/Checkbox/Checkbox';
14
15
  import { Grid } from 'rift-ds/components/Grid/Grid';
15
16
  import { Heading } from 'rift-ds/components/Heading/Heading';
16
17
  import { Icon } from 'rift-ds/components/Icon/Icon';
@@ -70,7 +71,13 @@ const PLANS: Plan[] = [
70
71
  },
71
72
  ];
72
73
 
73
- const yes = <Icon name="check" size="500" label="Included" />;
74
+ /* "Included" is drawn one way on the page: the tick a plan's feature list
75
+ wears in its card, at the same size and in the same colour. */
76
+ const yes = (
77
+ <span className={styles.included} role="img" aria-label="Included">
78
+ <CheckIcon className={styles.tick} />
79
+ </span>
80
+ );
74
81
  const no = <Icon name="remove" size="500" tone="neutral" label="Not included" />;
75
82
 
76
83
  const COMPARE_COLUMNS: TableColumn[] = [
@@ -3,7 +3,8 @@
3
3
  /**
4
4
  * The sign-in block: a centred card with email and password, a remember-me
5
5
  * choice and a single sign-on route. It checks the fields in the browser
6
- * and goes no further; connect `signIn` to your auth provider.
6
+ * and goes no further; connect `signIn` to your auth provider. It links to
7
+ * the sign-up block's page, which `init block sign-in` writes beside it.
7
8
  */
8
9
 
9
10
  import { useState, type FormEvent } from 'react';
@@ -16,6 +17,13 @@ import styles from './page.module.css';
16
17
  const PRODUCT_NAME = 'Acme';
17
18
  const EMAIL_SHAPE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
18
19
 
20
+ /**
21
+ * Where "Create an account" goes: the sign-up block's page. Relative, so it
22
+ * resolves beside this page (`sign-up` from /sign-in is /sign-up). Make it
23
+ * absolute ('/sign-up') if your pages nest.
24
+ */
25
+ const SIGN_UP_ROUTE = 'sign-up';
26
+
19
27
  export default function SignInPage() {
20
28
  const [email, setEmail] = useState('');
21
29
  const [password, setPassword] = useState('');
@@ -87,7 +95,7 @@ export default function SignInPage() {
87
95
  />
88
96
 
89
97
  <p className={styles.footer}>
90
- New here? <Button variant="tertiary" size="compact" label="Create an account" href="#" />
98
+ New here? <Button variant="tertiary" size="compact" label="Create an account" href={SIGN_UP_ROUTE} />
91
99
  </p>
92
100
  </main>
93
101
  </div>
@@ -0,0 +1,83 @@
1
+ /* The sign-in block's card, so the two pages read as one flow: centred at
2
+ every width, 400px wide on a desktop, the full width less the gutter on
3
+ a phone, where it drops its fill and sits straight on the page. */
4
+
5
+ .page {
6
+ min-height: 100dvh;
7
+ display: grid;
8
+ place-items: center;
9
+ padding: var(--padding-1000) var(--padding-500);
10
+ background-color: var(--color-bg-page-primary);
11
+ }
12
+
13
+ .card {
14
+ width: 100%;
15
+ max-width: 400px;
16
+ display: flex;
17
+ flex-direction: column;
18
+ gap: var(--gap-500);
19
+ padding: var(--padding-1000);
20
+ border-radius: var(--radius-600);
21
+ background-color: var(--color-bg-container-primary);
22
+ }
23
+
24
+ .intro {
25
+ display: flex;
26
+ flex-direction: column;
27
+ gap: var(--gap-200);
28
+ }
29
+
30
+ .product {
31
+ font-family: var(--font-title-body-family);
32
+ font-size: var(--font-title-body-size);
33
+ font-weight: var(--font-title-body-weight);
34
+ line-height: var(--font-title-body-line-height);
35
+ color: var(--color-text-primary);
36
+ }
37
+
38
+ .title {
39
+ margin: 0;
40
+ font-family: var(--font-heading-2-family);
41
+ font-size: var(--font-heading-2-size);
42
+ font-weight: var(--font-heading-2-weight);
43
+ line-height: var(--font-heading-2-line-height);
44
+ letter-spacing: var(--font-heading-2-letter-spacing);
45
+ color: var(--color-text-primary);
46
+ }
47
+
48
+ .subhead,
49
+ .footer {
50
+ margin: 0;
51
+ font-size: var(--font-paragraph-sm-size);
52
+ line-height: var(--font-paragraph-sm-line-height);
53
+ color: var(--color-text-secondary);
54
+ }
55
+
56
+ .form {
57
+ display: flex;
58
+ flex-direction: column;
59
+ gap: var(--gap-400);
60
+ }
61
+
62
+ .full {
63
+ width: 100%;
64
+ }
65
+
66
+ .footer {
67
+ display: flex;
68
+ align-items: center;
69
+ justify-content: center;
70
+ gap: var(--gap-100);
71
+ }
72
+
73
+ @media (max-width: 600px) {
74
+ .page {
75
+ place-items: start center;
76
+ padding: var(--padding-1000) var(--padding-400);
77
+ }
78
+
79
+ .card {
80
+ padding: 0;
81
+ background-color: transparent;
82
+ }
83
+ }