rift-ds 1.41.0 → 1.43.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 (212) hide show
  1. package/README.md +2 -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/useFocusScope.d.ts +3 -1
  11. package/behaviors/useFocusScope.js +4 -6
  12. package/bin/rift-ds.mjs +2 -0
  13. package/bin/templates/app/components/rift/ColorModeScript.tsx +3 -1
  14. package/bin/templates/app/components/rift/RiftRoot.tsx +40 -1
  15. package/bin/templates/blocks/app/dashboard/page.module.css +2 -2
  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/notifications/Inbox.tsx +13 -45
  19. package/bin/templates/blocks/app/notifications/page.module.css +5 -0
  20. package/bin/templates/blocks/app/planner/page.tsx +2 -2
  21. package/bin/templates/blocks/app/pricing/page.module.css +15 -1
  22. package/bin/templates/blocks/app/pricing/page.tsx +8 -1
  23. package/bin/templates/blocks/app/settings/Settings.tsx +4 -4
  24. package/bin/templates/blocks/app/sign-in/page.tsx +10 -2
  25. package/bin/templates/blocks/app/sign-up/page.module.css +83 -0
  26. package/bin/templates/blocks/app/sign-up/page.tsx +126 -0
  27. package/bin/templates/blocks/app/starter/page.tsx +1 -1
  28. package/bin/templates/blocks/components/blocks/AppShell.module.css +0 -10
  29. package/bin/templates/blocks/components/blocks/AppShell.tsx +51 -132
  30. package/bin/templates/blocks/components/blocks/DocsShell.tsx +5 -1
  31. package/bin/templates/blocks/components/blocks/notifications.ts +77 -0
  32. package/bin/templates/blocks/registry.json +49 -6
  33. package/chat/ChatWidget.js +2 -1
  34. package/components/AgentPlan/AgentPlan.css +1 -1
  35. package/components/AlertDialog/AlertDialog.css +14 -0
  36. package/components/AlertDialog/AlertDialog.d.ts +35 -3
  37. package/components/AlertDialog/AlertDialog.js +16 -5
  38. package/components/AppLayout/AppLayout.css +6 -0
  39. package/components/AppLayout/AppLayout.d.ts +4 -0
  40. package/components/AppLayout/AppLayout.js +5 -1
  41. package/components/AppSidebar/AppSidebar.css +17 -2
  42. package/components/AppSidebar/AppSidebar.js +9 -2
  43. package/components/AppToolbar/AppToolbar.d.ts +5 -2
  44. package/components/AppToolbar/AppToolbar.js +3 -1
  45. package/components/Attachment/AttachmentGroup.js +2 -1
  46. package/components/Attachment/AttachmentTile.js +2 -1
  47. package/components/Badge/Badge.css +6 -0
  48. package/components/Breadcrumb/Breadcrumb.css +4 -1
  49. package/components/Button/Button.css +20 -1
  50. package/components/Button/Button.js +6 -1
  51. package/components/Card/Card.css +11 -0
  52. package/components/Card/Card.d.ts +9 -3
  53. package/components/Card/Card.js +21 -2
  54. package/components/Chart/AreaChart.d.ts +7 -0
  55. package/components/Chart/AreaChart.js +57 -45
  56. package/components/Chart/BarChart.d.ts +7 -0
  57. package/components/Chart/BarChart.js +52 -46
  58. package/components/Chart/Chart.css +134 -1
  59. package/components/Chart/ChartSkeleton.d.ts +32 -0
  60. package/components/Chart/ChartSkeleton.js +149 -0
  61. package/components/Chart/ComboChart.d.ts +7 -0
  62. package/components/Chart/ComboChart.js +80 -74
  63. package/components/Chart/LineChart.d.ts +17 -3
  64. package/components/Chart/LineChart.js +67 -39
  65. package/components/Chart/PieChart.d.ts +7 -0
  66. package/components/Chart/PieChart.js +41 -34
  67. package/components/Chart/RadarChart.d.ts +7 -0
  68. package/components/Chart/RadarChart.js +39 -32
  69. package/components/Chart/RadialChart.d.ts +7 -0
  70. package/components/Chart/RadialChart.js +5 -1
  71. package/components/Chart/ScatterChart.d.ts +7 -0
  72. package/components/Chart/ScatterChart.js +52 -40
  73. package/components/Chart/StackedBarChart.d.ts +10 -1
  74. package/components/Chart/StackedBarChart.js +57 -43
  75. package/components/Chart/Treemap.d.ts +7 -0
  76. package/components/Chart/Treemap.js +17 -11
  77. package/components/ChatMessage/ChatMessage.css +6 -0
  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 +34 -4
  87. package/components/DataTable/DataTable.d.ts +16 -2
  88. package/components/DataTable/DataTable.js +8 -2
  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/Dropdown/Dropdown.css +3 -1
  109. package/components/Dropdown/Dropdown.js +8 -0
  110. package/components/EmptyState/EmptyState.css +8 -1
  111. package/components/EventCalendar/EventCalendar.css +12 -0
  112. package/components/Field/Field.css +2 -2
  113. package/components/FileInput/FileInput.css +1 -1
  114. package/components/FilterBar/FilterBar.d.ts +6 -1
  115. package/components/FunnelChart/FunnelChart.d.ts +7 -0
  116. package/components/FunnelChart/FunnelChart.js +44 -30
  117. package/components/GanttChart/GanttChart.css +10 -0
  118. package/components/GanttChart/GanttChart.d.ts +4 -0
  119. package/components/GanttChart/GanttChart.js +66 -33
  120. package/components/Gauge/Gauge.css +23 -0
  121. package/components/Gauge/Gauge.d.ts +4 -0
  122. package/components/Gauge/Gauge.js +14 -8
  123. package/components/ImageCompare/ImageCompare.js +2 -1
  124. package/components/Input/Input.css +15 -1
  125. package/components/Inspector/Inspector.css +4 -1
  126. package/components/List/List.css +1 -1
  127. package/components/NotificationCenter/NotificationCenter.css +152 -27
  128. package/components/NotificationCenter/NotificationCenter.d.ts +71 -8
  129. package/components/NotificationCenter/NotificationCenter.js +120 -13
  130. package/components/NumberInput/NumberInput.css +2 -0
  131. package/components/PageHeader/PageHeader.css +12 -4
  132. package/components/Panel/Panel.d.ts +1 -1
  133. package/components/Popover/Popover.css +3 -0
  134. package/components/Popover/Popover.d.ts +1 -1
  135. package/components/Popover/Popover.js +9 -1
  136. package/components/Prose/Prose.css +1 -1
  137. package/components/QuestionCard/QuestionCard.css +7 -4
  138. package/components/RadioButton/RadioButton.css +1 -1
  139. package/components/RadioButton/RadioButton.d.ts +4 -2
  140. package/components/RadioButton/RadioButton.js +5 -2
  141. package/components/ResourceTimeline/ResourceTimeline.css +12 -0
  142. package/components/ResourceTimeline/ResourceTimeline.d.ts +5 -1
  143. package/components/ResourceTimeline/ResourceTimeline.js +94 -52
  144. package/components/RichDropdown/RichDropdown.css +3 -1
  145. package/components/SegmentedControl/SegmentedControl.css +5 -0
  146. package/components/SelectionCard/SelectionCard.css +29 -0
  147. package/components/SelectionCard/SelectionCard.d.ts +7 -0
  148. package/components/SelectionCard/SelectionCard.js +25 -2
  149. package/components/Sparkline/Sparkline.css +20 -0
  150. package/components/Sparkline/Sparkline.d.ts +4 -0
  151. package/components/Sparkline/Sparkline.js +14 -8
  152. package/components/Stat/Stat.css +39 -0
  153. package/components/Stat/Stat.d.ts +23 -2
  154. package/components/Stat/Stat.js +21 -6
  155. package/components/Table/Table.css +106 -16
  156. package/components/Table/Table.d.ts +4 -0
  157. package/components/Table/Table.js +43 -28
  158. package/components/Textarea/Textarea.css +4 -2
  159. package/components/ThemeToggle/colorMode.d.ts +13 -5
  160. package/components/ThemeToggle/colorMode.js +4 -2
  161. package/components/ThreadHistory/ThreadHistory.css +11 -0
  162. package/components/ThreadHistory/ThreadHistory.d.ts +5 -1
  163. package/components/ThreadHistory/ThreadHistory.js +6 -1
  164. package/components/ThreadPanel/ThreadPanel.d.ts +4 -0
  165. package/components/ThreadPanel/ThreadPanel.js +5 -1
  166. package/components/TimePicker/TimePicker.css +3 -1
  167. package/components/TimePicker/TimePicker.d.ts +4 -2
  168. package/components/TimePicker/TimePicker.js +11 -3
  169. package/components/Timeline/Timeline.css +15 -0
  170. package/components/Timeline/Timeline.d.ts +8 -0
  171. package/components/Timeline/Timeline.js +21 -0
  172. package/components/Toast/Toast.css +16 -0
  173. package/components/Toast/Toast.d.ts +7 -2
  174. package/components/ToggleGroup/ToggleGroup.css +28 -2
  175. package/components/ToggleSwitch/ToggleSwitch.css +1 -1
  176. package/components/Toolbar/Toolbar.d.ts +6 -1
  177. package/components/Tooltip/Tooltip.d.ts +9 -0
  178. package/components/Tooltip/Tooltip.js +34 -8
  179. package/components/TreeView/TreeView.css +12 -0
  180. package/components/TreeView/TreeView.d.ts +4 -0
  181. package/components/TreeView/TreeView.js +20 -0
  182. package/components/UsageCard/UsageCard.css +11 -0
  183. package/components/UsageCard/UsageCard.d.ts +4 -0
  184. package/components/UsageCard/UsageCard.js +25 -16
  185. package/components/Widget/Widget.css +7 -0
  186. package/components/Widget/Widget.d.ts +4 -0
  187. package/components/Widget/Widget.js +14 -2
  188. package/components/Wizard/Wizard.d.ts +8 -3
  189. package/components/Wizard/Wizard.js +4 -1
  190. package/components/registry.json +15 -6
  191. package/components/registry.json.d.ts +15 -6
  192. package/components/registry.json.js +1 -1
  193. package/package.json +7 -2
  194. package/tokens/presets/contrast.css +4 -4
  195. package/tokens/presets/coral.css +3 -4
  196. package/tokens/presets/forest.css +16 -4
  197. package/tokens/presets/gold.css +4 -3
  198. package/tokens/presets/marquee.css +2 -3
  199. package/tokens/presets/mono.css +28 -28
  200. package/tokens/presets/pink.css +5 -4
  201. package/tokens/presets/terminal.css +4 -3
  202. package/tokens/presets/violet.css +3 -4
  203. package/tokens/presets/warm.css +16 -4
  204. package/tokens/presets/zest.css +11 -13
  205. package/tokens/registry.json +1 -0
  206. package/tokens/registry.json.d.ts +1 -0
  207. package/tokens/registry.json.js +1 -1
  208. package/tokens/tokens-dark.css +4 -0
  209. package/tokens/tokens-light.css +4 -0
  210. package/tokens/values.d.ts +24 -4
  211. package/tokens/values.js +25 -6
  212. package/tokens/values.json.js +1 -1
@@ -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
+ }
@@ -0,0 +1,126 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * The sign-up block: the sign-in block's card with a name, an email and a
5
+ * new password, an agreement to the terms and a single sign-on route. It
6
+ * checks the fields in the browser and goes no further; connect `signUp`
7
+ * to your auth provider. It links back to the sign-in block's page, which
8
+ * `init block sign-up` writes beside it.
9
+ */
10
+
11
+ import { useState, type FormEvent } from 'react';
12
+ import { Button } from 'rift-ds/components/Button/Button';
13
+ import { Checkbox } from 'rift-ds/components/Checkbox/Checkbox';
14
+ import { Divider } from 'rift-ds/components/Divider/Divider';
15
+ import { Input } from 'rift-ds/components/Input/Input';
16
+ import styles from './page.module.css';
17
+
18
+ const PRODUCT_NAME = 'Acme';
19
+ const EMAIL_SHAPE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
20
+ /** The shortest password the form takes. Match your auth provider's rule. */
21
+ const PASSWORD_MIN = 8;
22
+
23
+ /**
24
+ * Where "Sign in" goes: the sign-in block's page. Relative, so it resolves
25
+ * beside this page (`sign-in` from /sign-up is /sign-in). Make it absolute
26
+ * ('/sign-in') if your pages nest.
27
+ */
28
+ const SIGN_IN_ROUTE = 'sign-in';
29
+
30
+ export default function SignUpPage() {
31
+ const [name, setName] = useState('');
32
+ const [email, setEmail] = useState('');
33
+ const [password, setPassword] = useState('');
34
+ const [agreed, setAgreed] = useState(false);
35
+ const [nameError, setNameError] = useState<string>();
36
+ const [emailError, setEmailError] = useState<string>();
37
+ const [passwordError, setPasswordError] = useState<string>();
38
+ const [agreedError, setAgreedError] = useState<string>();
39
+
40
+ const signUp = () => {
41
+ const nextNameError = name.trim() ? undefined : 'Enter your name.';
42
+ const nextEmailError = EMAIL_SHAPE.test(email.trim()) ? undefined : 'Enter an email we can reach you at.';
43
+ const nextPasswordError =
44
+ password.length >= PASSWORD_MIN ? undefined : `Use at least ${PASSWORD_MIN} characters.`;
45
+ const nextAgreedError = agreed ? undefined : 'Agree to the terms to continue.';
46
+ setNameError(nextNameError);
47
+ setEmailError(nextEmailError);
48
+ setPasswordError(nextPasswordError);
49
+ setAgreedError(nextAgreedError);
50
+ if (nextNameError || nextEmailError || nextPasswordError || nextAgreedError) return;
51
+ // Hand { name, email, password } to your auth provider here.
52
+ };
53
+
54
+ /* The Create account button is the form's submit button, so a click and
55
+ Enter in a field both arrive here. */
56
+ const handleSubmit = (event: FormEvent<HTMLFormElement>) => {
57
+ event.preventDefault();
58
+ signUp();
59
+ };
60
+
61
+ return (
62
+ <div className={styles.page}>
63
+ <main className={styles.card}>
64
+ <div className={styles.intro}>
65
+ <span className={styles.product}>{PRODUCT_NAME}</span>
66
+ <h1 className={styles.title}>Create your account</h1>
67
+ <p className={styles.subhead}>Free for your first five people. No card needed.</p>
68
+ </div>
69
+
70
+ <form className={styles.form} onSubmit={handleSubmit} noValidate>
71
+ <Input
72
+ label="Name"
73
+ name="name"
74
+ autoComplete="name"
75
+ value={name}
76
+ onValueChange={setName}
77
+ error={Boolean(nameError)}
78
+ helperText={nameError}
79
+ />
80
+ <Input
81
+ label="Work email"
82
+ type="email"
83
+ name="email"
84
+ autoComplete="email"
85
+ value={email}
86
+ onValueChange={setEmail}
87
+ error={Boolean(emailError)}
88
+ helperText={emailError}
89
+ />
90
+ <Input
91
+ label="Password"
92
+ type="password"
93
+ name="password"
94
+ autoComplete="new-password"
95
+ value={password}
96
+ onValueChange={setPassword}
97
+ error={Boolean(passwordError)}
98
+ helperText={passwordError ?? `At least ${PASSWORD_MIN} characters.`}
99
+ />
100
+ <Checkbox
101
+ label="I agree to the terms and the privacy policy"
102
+ checked={agreed}
103
+ onCheckedChange={setAgreed}
104
+ error={Boolean(agreedError)}
105
+ helperText={agreedError}
106
+ />
107
+ <Button type="submit" variant="primary" label="Create account" className={styles.full} />
108
+ </form>
109
+
110
+ <Divider label="or" labelPosition="center" spacing="none" />
111
+
112
+ <Button
113
+ variant="secondary"
114
+ tone="neutral"
115
+ label="Continue with single sign-on"
116
+ iconLeft="key"
117
+ className={styles.full}
118
+ />
119
+
120
+ <p className={styles.footer}>
121
+ Have an account? <Button variant="tertiary" size="compact" label="Sign in" href={SIGN_IN_ROUTE} />
122
+ </p>
123
+ </main>
124
+ </div>
125
+ );
126
+ }
@@ -18,7 +18,7 @@ export default function StarterPage() {
18
18
  title="Home"
19
19
  actions={<Button variant="primary" size="compact" label="New project" iconLeft="add" />}
20
20
  >
21
- <Panel className={styles.empty}>
21
+ <Panel bordered className={styles.empty}>
22
22
  <EmptyState
23
23
  icon="dashboard_customize"
24
24
  title="Your page starts here"
@@ -11,13 +11,3 @@
11
11
  .shell[data-width='narrow'] {
12
12
  --ds-shell-contained-width: 960px; /* a slim centred column */
13
13
  }
14
-
15
- /* A theme's swatch in the Appearance rows: its action colour in a dot the
16
- size of the icons beside it. */
17
- .swatch {
18
- display: inline-block;
19
- width: var(--icon-size-500);
20
- height: var(--icon-size-500);
21
- border-radius: var(--radius-pill);
22
- border: var(--border-025) solid var(--color-bg-container-border);
23
- }
@@ -3,8 +3,8 @@
3
3
  /**
4
4
  * The app shell every rift-ds app block page sits in, composed from the
5
5
  * library's own shell pieces: AppLayout (its AppSidebar in one of the three
6
- * app shell modes, SHELL_LAYOUT below, the default the sidebar's Appearance
7
- * rows start from), an AppToolbar in AppLayout's toolbar slot (the search,
6
+ * app shell modes, SHELL_LAYOUT below, at the width CONTENT_WIDTH sets), an
7
+ * AppToolbar in AppLayout's toolbar slot (the search,
8
8
  * the notifications, help, settings and the AI entry), and a PageHeader
9
9
  * (breadcrumb, title, actions) over the page. This file is yours: rename the
10
10
  * product, change the navigation, and grow it with your app.
@@ -14,11 +14,11 @@
14
14
  * scrolls, moves the page over while the sidebar's panel is open, sets the
15
15
  * content in a raised surface in the inset mode, and on a phone turns the
16
16
  * sidebar into a drawer behind its menu button. The toolbar folds itself by
17
- * its own width: the AI entry to its icon, then the search, then the icon
18
- * controls after the first into a More menu.
17
+ * its own width: the AI entry to its icon, then the search. Help stays in the
18
+ * bar, since a More menu would hold it alone.
19
19
  */
20
20
 
21
- import { useState, useSyncExternalStore, type ReactNode } from 'react';
21
+ import type { ReactNode } from 'react';
22
22
  import { AppLayout } from 'rift-ds/components/AppLayout/AppLayout';
23
23
  import type { AppSidebarLayout, AppSidebarProfile, AppSidebarSection } from 'rift-ds/components/AppSidebar/AppSidebar';
24
24
  import { AppToolbar } from 'rift-ds/components/AppToolbar/AppToolbar';
@@ -26,10 +26,8 @@ import type { BreadcrumbItem } from 'rift-ds/components/Breadcrumb/Breadcrumb';
26
26
  import { NotificationCenter, NotificationItem } from 'rift-ds/components/NotificationCenter/NotificationCenter';
27
27
  import { PageHeader } from 'rift-ds/components/PageHeader/PageHeader';
28
28
  import { useColorMode } from 'rift-ds/components/ThemeToggle/useColorMode';
29
- import { BREAKPOINT_MOBILE_PX, mediaBelow } from 'rift-ds/tokens/breakpoints';
30
- import { SHIPPED_THEMES, shippedThemeOptions } from 'rift-ds/tokens/values';
31
- // Every shipped theme, so a Theme pick applies; keep only yours once you choose.
32
- import 'rift-ds/tokens/presets/presets.css';
29
+ import { useLinkComponent } from 'rift-ds/behaviors/LinkProvider';
30
+ import { useNotifications } from './notifications';
33
31
  import styles from './AppShell.module.css';
34
32
 
35
33
  /**
@@ -38,55 +36,19 @@ import styles from './AppShell.module.css';
38
36
  * hairline, the content crisp beside it; `floating` lifts the sidebar into a
39
37
  * card on the shell colour off the edges, the content crisp on the app
40
38
  * surface; `inset` runs it flush and sets the content in a
41
- * raised surface held off the other edges, scrolling inside itself.
39
+ * raised surface held off the other edges, scrolling inside itself. Pick
40
+ * one here: the shell carries no layout picker, since a product ships one
41
+ * shell, not a choice of three.
42
42
  */
43
43
  const SHELL_LAYOUT: AppSidebarLayout = 'floating';
44
44
 
45
- /** The sidebar's Appearance rows: what each choice is called and shows. */
45
+ /** The sidebar's Mode row: what each choice is called and shows. */
46
46
  const MODES = [
47
47
  { value: 'system', label: 'System', icon: 'routine', description: 'Follows your device' },
48
48
  { value: 'light', label: 'Light', icon: 'light_mode', description: 'Light surfaces, dark text' },
49
49
  { value: 'dark', label: 'Dark', icon: 'dark_mode', description: 'Dark surfaces, light text' },
50
50
  ] as const;
51
51
 
52
- const LAYOUTS: { value: AppSidebarLayout; label: string; icon: string; description: string }[] = [
53
- { value: 'flush', label: 'Flush', icon: 'vertical_split', description: 'Edge to edge behind a hairline' },
54
- { value: 'floating', label: 'Floating', icon: 'view_sidebar', description: 'The sidebar as a card beside the page' },
55
- { value: 'inset', label: 'Inset', icon: 'space_dashboard', description: 'The page in a raised surface' },
56
- ];
57
-
58
- const WIDTHS: { value: ContentWidth; label: string; icon: string; description: string }[] = [
59
- { value: 'narrow', label: 'Narrow', icon: 'width_normal', description: 'A slim centred column' },
60
- { value: 'contained', label: 'Contained', icon: 'width_wide', description: 'Centred at a comfortable width' },
61
- { value: 'full', label: 'Full width', icon: 'width_full', description: 'The whole column, edge to edge' },
62
- ];
63
-
64
- /**
65
- * The theme is the `data-brand` attribute on <html> (none for the base
66
- * look). Watched, so a pick made anywhere shows here; store it where you
67
- * keep the reader's other preferences to make it last.
68
- */
69
- const subscribeRoot = (callback: () => void) => {
70
- const observer = new MutationObserver(callback);
71
- observer.observe(document.documentElement, { attributes: true, attributeFilter: ['data-brand', 'data-theme'] });
72
- return () => observer.disconnect();
73
- };
74
- const readBrand = () => document.documentElement.getAttribute('data-brand');
75
- const readDark = () => document.documentElement.getAttribute('data-theme') === 'dark';
76
- const applyBrand = (brand: string | null) => {
77
- if (brand) document.documentElement.setAttribute('data-brand', brand);
78
- else document.documentElement.removeAttribute('data-brand');
79
- };
80
-
81
- /** Below the mobile step every mode gives way to the plain page, so Layout and Width leave the sidebar. */
82
- const PHONE_QUERY = mediaBelow(BREAKPOINT_MOBILE_PX);
83
- const subscribePhone = (callback: () => void) => {
84
- const query = window.matchMedia(PHONE_QUERY);
85
- query.addEventListener('change', callback);
86
- return () => query.removeEventListener('change', callback);
87
- };
88
- const readPhone = () => window.matchMedia(PHONE_QUERY).matches;
89
-
90
52
  /** How wide the page runs, apart from the mode. */
91
53
  type ContentWidth = 'narrow' | 'contained' | 'full';
92
54
 
@@ -94,12 +56,12 @@ type ContentWidth = 'narrow' | 'contained' | 'full';
94
56
  * How wide the page runs, apart from the mode: `narrow` centres a slim
95
57
  * column (960px), `contained` centres the content column (1440px), both set
96
58
  * in AppShell.module.css, and `full` runs it the whole width the mode
97
- * leaves. Any mode takes any of them.
59
+ * leaves. Any mode takes any of them. Set it here, as with the mode.
98
60
  */
99
61
  const CONTENT_WIDTH: ContentWidth = 'contained';
100
62
 
101
- /** The product's name, shown beside the logo in the sidebar. */
102
- const PRODUCT_NAME = 'Acme';
63
+ /** The product's name: beside the logo in the sidebar, and wherever a page names it (import it there). */
64
+ export const PRODUCT_NAME = 'Acme';
103
65
 
104
66
  /** The sidebar's navigation. Give an item an `href` (`'/dashboard'`) to make it a link. */
105
67
  const NAV_SECTIONS: AppSidebarSection[] = [
@@ -134,6 +96,12 @@ export const SETTINGS_SECTIONS = [
134
96
  { id: 'security', label: 'Security', group: 'Account', description: 'How you sign in, and where you are signed in now.' },
135
97
  ] as const;
136
98
 
99
+ /** Moves the page to a settings section's hash and tells whoever follows it. */
100
+ function openSection(id: string) {
101
+ window.history.pushState(null, '', `#${id}`);
102
+ window.dispatchEvent(new HashChangeEvent('hashchange'));
103
+ }
104
+
137
105
  /** The navigation, with the settings sections linked from wherever the reader is. */
138
106
  function navFor(activeKey: string): AppSidebarSection[] {
139
107
  // On the settings page a section is a jump within it; anywhere else it
@@ -152,8 +120,8 @@ function navFor(activeKey: string): AppSidebarSection[] {
152
120
  href: `${base}#${entry.id}`,
153
121
  // A router's link (Next.js's) moves a hash without the
154
122
  // hashchange event the settings page follows, so on that page
155
- // the link sets the hash itself.
156
- ...(base === '' ? { onClick: () => window.location.assign(`#${entry.id}`) } : {}),
123
+ // the link moves the hash and says so itself.
124
+ ...(base === '' ? { onClick: () => openSection(entry.id) } : {}),
157
125
  })),
158
126
  }
159
127
  : item,
@@ -163,22 +131,16 @@ function navFor(activeKey: string): AppSidebarSection[] {
163
131
 
164
132
  /**
165
133
  * Where the toolbar's links go: the notifications and settings blocks'
166
- * pages. Relative, so they resolve beside the page they are on: every block
134
+ * pages, which every block that writes this shell writes too, so both
135
+ * resolve from the first one you add. Relative, so they resolve beside the page they are on: every block
167
136
  * is a top-level route in your app (`notifications` from /dashboard is
168
137
  * /notifications), and the rift-ds docs preview finds its own copies the
169
138
  * same way. Make them absolute ('/notifications') if your pages nest.
170
139
  */
171
140
  const ROUTES = { notifications: 'notifications', settings: 'settings' };
172
141
 
173
- /**
174
- * The bell's latest notifications. Read your own; See all opens the
175
- * notifications block's page at /notifications.
176
- */
177
- const LATEST = [
178
- { id: 'payment', icon: 'payments', title: 'Payment received', text: 'Northwind Supply paid invoice 1042.', time: '2m' },
179
- { id: 'approval', icon: 'approval', title: 'Approval needed', text: 'Jordan Reyes asked to spend $1,632.42.', time: '1h' },
180
- { id: 'statement', icon: 'description', title: 'Statement ready', text: 'Your October statement is ready.', time: 'Mon' },
181
- ];
142
+ /** How many of the newest notifications the bell's panel lists. */
143
+ const BELL_ROWS = 3;
182
144
 
183
145
  const PROFILE: AppSidebarProfile = {
184
146
  name: 'Alex Morgan',
@@ -203,41 +165,24 @@ export interface AppShellProps {
203
165
  }
204
166
 
205
167
  export function AppShell({ activeKey, activeSubKey, breadcrumb, title, description, actions, children }: AppShellProps) {
206
- const [layout, setLayout] = useState<AppSidebarLayout>(SHELL_LAYOUT);
207
- const [width, setWidth] = useState<ContentWidth>(CONTENT_WIDTH);
208
168
  const [mode, setMode] = useColorMode();
209
- const phone = useSyncExternalStore(subscribePhone, readPhone, () => false);
210
- const brand = useSyncExternalStore(subscribeRoot, readBrand, () => null);
211
- const dark = useSyncExternalStore(subscribeRoot, readDark, () => false);
212
- const [unread, setUnread] = useState<string[]>(['payment', 'approval']);
169
+ const notifications = useNotifications();
170
+ const { unread } = notifications;
171
+ // PageHeader renders on the server too, so it takes its link as a prop
172
+ // rather than reading the provider: hand it the app's router link here,
173
+ // or every breadcrumb click reloads the page.
174
+ const linkComponent = useLinkComponent();
213
175
 
214
- // The sidebar's Appearance section: each row shows its current choice and
215
- // opens the choices in the sidebar's panel, where a pick applies at once.
216
- // Theme and Mode are the reader's (Mode is stored, like ThemeToggle's);
217
- // Layout and Width are for trying the shell out, so pick yours and drop
218
- // them.
176
+ // The reader's one appearance choice: the colour mode, stored like
177
+ // ThemeToggle's. The row shows the current choice and opens the three in
178
+ // the sidebar's panel, where a pick applies at once. The theme, the shell
179
+ // mode and the width are the product's decisions, made in code (the theme
180
+ // in the root layout, the other two above), so the shell offers no picker
181
+ // for them.
219
182
  const modeNow = MODES.find((option) => option.value === mode) ?? MODES[0];
220
- const themes = shippedThemeOptions(dark ? 'dark' : 'light');
221
- const themeNow = SHIPPED_THEMES.find((theme) => theme.brand === brand) ?? SHIPPED_THEMES[0];
222
- const swatch = (color?: string) => <span className={styles.swatch} style={{ backgroundColor: color }} />;
223
- const layoutNow = LAYOUTS.find((option) => option.value === layout) ?? LAYOUTS[0];
224
- const widthNow = WIDTHS.find((option) => option.value === width) ?? WIDTHS[0];
225
183
  const appearance: AppSidebarSection = {
226
184
  category: 'Appearance',
227
185
  items: [
228
- {
229
- key: 'appearance-theme',
230
- label: 'Theme',
231
- icon: swatch(themes.find((theme) => theme.value === themeNow.id)?.color),
232
- value: themeNow.label,
233
- children: SHIPPED_THEMES.map((theme) => ({
234
- key: `theme-${theme.id}`,
235
- label: theme.label,
236
- icon: swatch(themes.find((option) => option.value === theme.id)?.color),
237
- selected: theme.id === themeNow.id,
238
- onClick: () => applyBrand(theme.brand),
239
- })),
240
- },
241
186
  {
242
187
  key: 'appearance-mode',
243
188
  label: 'Mode',
@@ -252,38 +197,6 @@ export function AppShell({ activeKey, activeSubKey, breadcrumb, title, descripti
252
197
  onClick: () => setMode(option.value),
253
198
  })),
254
199
  },
255
- ...(phone
256
- ? []
257
- : [
258
- {
259
- key: 'appearance-layout',
260
- label: 'Layout',
261
- icon: layoutNow.icon,
262
- value: layoutNow.label,
263
- children: LAYOUTS.map((option) => ({
264
- key: `layout-${option.value}`,
265
- label: option.label,
266
- description: option.description,
267
- icon: option.icon,
268
- selected: option.value === layout,
269
- onClick: () => setLayout(option.value),
270
- })),
271
- },
272
- {
273
- key: 'appearance-width',
274
- label: 'Width',
275
- icon: widthNow.icon,
276
- value: widthNow.label,
277
- children: WIDTHS.map((option) => ({
278
- key: `width-${option.value}`,
279
- label: option.label,
280
- description: option.description,
281
- icon: option.icon,
282
- selected: option.value === width,
283
- onClick: () => setWidth(option.value),
284
- })),
285
- },
286
- ]),
287
200
  ],
288
201
  };
289
202
 
@@ -296,11 +209,11 @@ export function AppShell({ activeKey, activeSubKey, breadcrumb, title, descripti
296
209
  activeKey={activeKey}
297
210
  activeSubKey={activeSubKey}
298
211
  logoText={PRODUCT_NAME}
299
- layout={layout}
212
+ layout={SHELL_LAYOUT}
300
213
  // AppLayout's width axis is contained or full; narrow is a contained
301
214
  // column held slimmer, through data-width and AppShell.module.css.
302
- width={width === 'full' ? 'full' : 'contained'}
303
- data-width={width}
215
+ width={CONTENT_WIDTH === 'full' ? 'full' : 'contained'}
216
+ data-width={CONTENT_WIDTH}
304
217
  toolbar={
305
218
  <AppToolbar
306
219
  onSearch={() => {}}
@@ -313,17 +226,17 @@ export function AppShell({ activeKey, activeSubKey, breadcrumb, title, descripti
313
226
  panel: (
314
227
  <NotificationCenter
315
228
  unreadCount={unread.length}
316
- onMarkAllRead={() => setUnread([])}
229
+ onMarkAllRead={notifications.readAll}
317
230
  seeAllHref={ROUTES.notifications}
318
231
  >
319
- {LATEST.map((item) => (
232
+ {notifications.items.slice(0, BELL_ROWS).map((item) => (
320
233
  <NotificationItem
321
234
  key={item.id}
322
235
  media={item.icon}
323
236
  title={item.title}
324
237
  time={item.time}
325
238
  unread={unread.includes(item.id)}
326
- onSelect={() => setUnread((ids) => ids.filter((id) => id !== item.id))}
239
+ onSelect={() => notifications.read(item.id)}
327
240
  >
328
241
  {item.text}
329
242
  </NotificationItem>
@@ -338,7 +251,13 @@ export function AppShell({ activeKey, activeSubKey, breadcrumb, title, descripti
338
251
  />
339
252
  }
340
253
  >
341
- <PageHeader breadcrumb={breadcrumb} title={title} description={description} actions={actions} />
254
+ <PageHeader
255
+ breadcrumb={breadcrumb}
256
+ title={title}
257
+ description={description}
258
+ actions={actions}
259
+ linkComponent={linkComponent}
260
+ />
342
261
  {children}
343
262
  </AppLayout>
344
263
  );
@@ -20,6 +20,7 @@
20
20
  */
21
21
 
22
22
  import type { ReactNode } from 'react';
23
+ import { useLinkComponent } from 'rift-ds/behaviors/LinkProvider';
23
24
  import { AnchorNav } from 'rift-ds/components/AnchorNav/AnchorNav';
24
25
  import { BackToTop } from 'rift-ds/components/BackToTop/BackToTop';
25
26
  import { Breadcrumb, type BreadcrumbItem } from 'rift-ds/components/Breadcrumb/Breadcrumb';
@@ -123,6 +124,9 @@ export interface DocsShellProps {
123
124
  }
124
125
 
125
126
  export function DocsShell({ currentHref, breadcrumb, children }: DocsShellProps) {
127
+ // Breadcrumb renders on the server too, so it takes its link as a prop:
128
+ // hand it the app's router link, or a crumb reloads the page.
129
+ const linkComponent = useLinkComponent();
126
130
  return (
127
131
  <SiteLayout
128
132
  width={PAGE_WIDTH}
@@ -171,7 +175,7 @@ export function DocsShell({ currentHref, breadcrumb, children }: DocsShellProps)
171
175
  />
172
176
  }
173
177
  >
174
- <Breadcrumb items={breadcrumb} />
178
+ <Breadcrumb items={breadcrumb} linkComponent={linkComponent} />
175
179
  <div className={styles.article}>{children}</div>
176
180
  <BackToTop focusTarget="docs-article" />
177
181
  </SiteLayout>
@@ -0,0 +1,77 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * The one record of the app's notifications and which are unread. The bell
5
+ * in the shell's toolbar (AppShell.tsx) and the notifications block's page
6
+ * (app/notifications/Inbox.tsx) both read it, so a count is the same
7
+ * wherever it shows and "Mark all as read" on the page clears the bell. It
8
+ * lives in memory for the visit. This file is yours: swap it for your own
9
+ * notifications and your server's read state, behind the same
10
+ * `useNotifications`.
11
+ */
12
+
13
+ import { useSyncExternalStore } from 'react';
14
+
15
+ /** One notification, as the bell and the notifications page both show it. */
16
+ export interface AppNotification {
17
+ id: string;
18
+ /** Which day group the row sits under on the notifications page. */
19
+ group: 'Today' | 'This week' | 'Earlier';
20
+ category: 'payments' | 'cards' | 'team' | 'approvals';
21
+ icon: string;
22
+ title: string;
23
+ text: string;
24
+ /** When it happened, already written for the reader. */
25
+ time: string;
26
+ }
27
+
28
+ const NOTIFICATIONS: AppNotification[] = [
29
+ { id: 'n1', group: 'Today', category: 'payments', icon: 'payments', title: 'Payment received', text: 'Northwind Supply paid invoice 1042 for $4,180.00.', time: '2m' },
30
+ { id: 'n2', group: 'Today', category: 'approvals', icon: 'approval', title: 'Approval needed', text: 'Jordan Reyes asked to spend $1,632.42 from the Software budget.', time: '1h' },
31
+ { id: 'n3', group: 'Today', category: 'cards', icon: 'credit_card_off', title: 'Card frozen', text: 'The card ending in 7781 is frozen until you unfreeze it.', time: '3h' },
32
+ { id: 'n4', group: 'This week', category: 'team', icon: 'person_add', title: 'Invite accepted', text: 'Sam Patel joined the workspace as an admin.', time: 'Tue' },
33
+ { id: 'n5', group: 'This week', category: 'payments', icon: 'schedule', title: 'Payment scheduled', text: '$5,000.00 to Bright Studio goes out on Friday.', time: 'Mon' },
34
+ { id: 'n6', group: 'This week', category: 'approvals', icon: 'receipt_long', title: 'Receipt missing', text: 'Add a receipt for $375.87 at Harbor Bistro.', time: 'Mon' },
35
+ { id: 'n7', group: 'Earlier', category: 'cards', icon: 'credit_card', title: 'New card requested', text: 'Lee Chen asked for a card with a $5,000 limit.', time: 'Nov 18' },
36
+ { id: 'n8', group: 'Earlier', category: 'team', icon: 'shield_person', title: 'Two admins required', text: 'Sensitive changes now need a second admin to approve.', time: 'Nov 14' },
37
+ { id: 'n9', group: 'Earlier', category: 'payments', icon: 'description', title: 'Statement ready', text: 'Your October statement is ready to download.', time: 'Nov 1' },
38
+ ];
39
+
40
+ // The record itself, held in memory for the visit.
41
+ let inbox: { items: AppNotification[]; unread: string[] } = {
42
+ items: NOTIFICATIONS,
43
+ unread: ['n1', 'n2', 'n3', 'n4'],
44
+ };
45
+ const inboxListeners = new Set<() => void>();
46
+ const subscribeInbox = (listener: () => void) => {
47
+ inboxListeners.add(listener);
48
+ return () => {
49
+ inboxListeners.delete(listener);
50
+ };
51
+ };
52
+ const readInbox = () => inbox;
53
+ function writeInbox(next: typeof inbox) {
54
+ inbox = next;
55
+ inboxListeners.forEach((listener) => listener());
56
+ }
57
+
58
+ /** The notifications, which are unread, and the four things a reader does to them. */
59
+ export function useNotifications() {
60
+ const { items, unread } = useSyncExternalStore(subscribeInbox, readInbox, readInbox);
61
+ return {
62
+ items,
63
+ unread,
64
+ /** Marks one as read. */
65
+ read: (id: string) => writeInbox({ items: inbox.items, unread: inbox.unread.filter((other) => other !== id) }),
66
+ /** Marks every one as read. */
67
+ readAll: () => writeInbox({ items: inbox.items, unread: [] }),
68
+ /** Clears one from the list. */
69
+ dismiss: (id: string) =>
70
+ writeInbox({
71
+ items: inbox.items.filter((item) => item.id !== id),
72
+ unread: inbox.unread.filter((other) => other !== id),
73
+ }),
74
+ /** Clears the whole list. */
75
+ clear: () => writeInbox({ items: [], unread: [] }),
76
+ };
77
+ }