rift-ds 1.38.0 → 1.40.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 (88) hide show
  1. package/README.md +3 -3
  2. package/behaviors/shortcuts.js +2 -2
  3. package/behaviors/top-layer.css +28 -0
  4. package/behaviors/useAnchoredPosition.d.ts +12 -9
  5. package/behaviors/useAnchoredPosition.js +3 -0
  6. package/behaviors/useFoldedSections.d.ts +17 -0
  7. package/behaviors/useFoldedSections.js +23 -0
  8. package/behaviors/useLayer.d.ts +9 -0
  9. package/behaviors/useLayer.js +4 -3
  10. package/bin/rift-ds.mjs +3 -0
  11. package/bin/templates/blocks/app/notifications/Inbox.tsx +163 -0
  12. package/bin/templates/blocks/app/notifications/page.module.css +63 -0
  13. package/bin/templates/blocks/app/notifications/page.tsx +13 -0
  14. package/bin/templates/blocks/app/settings/Settings.tsx +483 -0
  15. package/bin/templates/blocks/app/settings/page.module.css +160 -6
  16. package/bin/templates/blocks/app/settings/page.tsx +10 -78
  17. package/bin/templates/blocks/components/blocks/AppShell.module.css +16 -244
  18. package/bin/templates/blocks/components/blocks/AppShell.tsx +274 -84
  19. package/bin/templates/blocks/registry.json +16 -3
  20. package/chat/ChatThreads.d.ts +63 -19
  21. package/chat/ChatThreads.js +119 -32
  22. package/chat/ChatWidget.css +15 -3
  23. package/chat/ChatWidget.d.ts +16 -17
  24. package/chat/ChatWidget.js +40 -7
  25. package/chat/DemoWelcome.d.ts +7 -0
  26. package/chat/DemoWelcome.js +19 -0
  27. package/chat/demo-fixtures.d.ts +1 -1
  28. package/chat/demo-fixtures.js +1 -0
  29. package/chat/rail-seat.d.ts +25 -0
  30. package/chat/rail-seat.js +8 -0
  31. package/chat/registry.json.d.ts +4 -1
  32. package/chat/registry.json.js +1 -1
  33. package/components/AppLayout/AppLayout.css +64 -0
  34. package/components/AppLayout/AppLayout.d.ts +21 -1
  35. package/components/AppLayout/AppLayout.js +9 -2
  36. package/components/AppSidebar/AppSidebar.css +378 -16
  37. package/components/AppSidebar/AppSidebar.d.ts +92 -4
  38. package/components/AppSidebar/AppSidebar.js +321 -155
  39. package/components/AppToolbar/AppToolbar.css +143 -0
  40. package/components/AppToolbar/AppToolbar.d.ts +124 -0
  41. package/components/AppToolbar/AppToolbar.js +119 -0
  42. package/components/ColourSwatch/ColourSwatch.css +49 -0
  43. package/components/ColourSwatch/ColourSwatch.d.ts +9 -1
  44. package/components/ColourSwatch/ColourSwatch.js +12 -1
  45. package/components/CommandPaletteTrigger/CommandPaletteTrigger.css +13 -0
  46. package/components/CommandPaletteTrigger/CommandPaletteTrigger.d.ts +7 -0
  47. package/components/CommandPaletteTrigger/CommandPaletteTrigger.js +2 -0
  48. package/components/Composer/Composer.css +20 -0
  49. package/components/Composer/Composer.d.ts +8 -0
  50. package/components/Composer/Composer.js +2 -0
  51. package/components/DrillMenu/DrillMenu.css +7 -0
  52. package/components/DrillMenu/DrillMenu.d.ts +6 -0
  53. package/components/DrillMenu/DrillMenu.js +2 -1
  54. package/components/NotificationCenter/NotificationCenter.css +145 -99
  55. package/components/NotificationCenter/NotificationCenter.d.ts +58 -4
  56. package/components/NotificationCenter/NotificationCenter.js +71 -63
  57. package/components/PaymentCard/PaymentCard.css +182 -0
  58. package/components/PaymentCard/PaymentCard.d.ts +80 -0
  59. package/components/PaymentCard/PaymentCard.js +80 -0
  60. package/components/PromptSuggestions/PromptSuggestions.css +180 -11
  61. package/components/PromptSuggestions/PromptSuggestions.d.ts +24 -3
  62. package/components/PromptSuggestions/PromptSuggestions.js +35 -9
  63. package/components/RadioButton/RadioButton.d.ts +2 -1
  64. package/components/RadioButton/RadioButton.js +1 -0
  65. package/components/ShaderScene/scenes.js +6 -5
  66. package/components/Stat/Stat.css +19 -19
  67. package/components/SubNavPanel/SubNavPanel.css +21 -0
  68. package/components/SubNavPanel/SubNavPanel.js +19 -2
  69. package/components/ThreadHistory/ThreadHistory.css +519 -0
  70. package/components/ThreadHistory/ThreadHistory.d.ts +90 -0
  71. package/components/ThreadHistory/ThreadHistory.js +344 -0
  72. package/components/ThreadPanel/ThreadPanel.css +90 -306
  73. package/components/ThreadPanel/ThreadPanel.d.ts +16 -0
  74. package/components/ThreadPanel/ThreadPanel.js +67 -241
  75. package/components/registry.json +57 -7
  76. package/components/registry.json.d.ts +57 -7
  77. package/components/registry.json.js +1 -1
  78. package/index.d.ts +3 -0
  79. package/index.js +6 -0
  80. package/package.json +1 -1
  81. package/tokens/presets/contrast.css +36 -19
  82. package/tokens/presets/coral.css +2 -0
  83. package/tokens/presets/forest.css +8 -0
  84. package/tokens/presets/pink.css +2 -0
  85. package/tokens/presets/violet.css +51 -21
  86. package/tokens/presets/zest.css +4 -0
  87. package/tokens/values.json.js +1 -1
  88. package/bin/templates/blocks/app/settings/ProfileForm.tsx +0 -98
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 -->195<!-- /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 -->198<!-- /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.
@@ -113,13 +113,13 @@ import 'rift-ds/tokens/presets/presets.css';
113
113
 
114
114
  ## Components
115
115
 
116
- <!-- component-count -->195<!-- /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
+ <!-- component-count -->198<!-- /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).
117
117
 
118
118
  <details>
119
119
  <summary>The full list</summary>
120
120
 
121
121
  <!-- component-list:start -->
122
- Accordion · Action bar · 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 · Drill menu · 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 · 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 · Side nav · 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 · Sub-nav panel · 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
+ Accordion · Action bar · Action card · Action readout · Agent plan · Agent rail · Agent status · AI button · Alert · Alert dialog · Anchor nav · Animated number · App layout · App sidebar · App toolbar · 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 · Drill menu · 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 · Notification centre · Number input · Org chart · Page header · Pagination · Panel · Payment card · 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 · Side nav · 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 · Sub-nav panel · Swatch · Table · Table toolbar · Tabs · Tag input · Text · Textarea · Theme picker · Theme toggle · Thread history · 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
123
123
  <!-- component-list:end -->
124
124
 
125
125
  </details>
@@ -1,10 +1,10 @@
1
1
  "use client";
2
- import { useRef, useEffect, useSyncExternalStore } from "react";
2
+ import { useSyncExternalStore, useRef, useEffect } from "react";
3
3
  import { MOTION_SHORTCUT_SEQUENCE_MS } from "../tokens/motion.js";
4
4
  import { warnOnce } from "./devWarning.js";
5
5
  import { activeModalPanel } from "./useFocusScope.js";
6
6
  import { hasOpenLayer, openLayerContains } from "./useLayer.js";
7
- import { parseShortcut, detectPlatform, KEY_ALIASES } from "./shortcut-keys.js";
7
+ import { detectPlatform, parseShortcut, KEY_ALIASES } from "./shortcut-keys.js";
8
8
  import { formatShortcut, shortcutAria, shortcutKeys } from "./shortcut-keys.js";
9
9
  const noSubscription = () => () => {
10
10
  };
@@ -0,0 +1,28 @@
1
+ /* ============================================
2
+ TOP LAYER
3
+ An anchored panel (src/behaviors/useAnchoredPosition)
4
+ paints in the browser's top layer while open, as a
5
+ manual popover (src/behaviors/useTopLayer), so no
6
+ ancestor's clip, mask or stacking context can hide
7
+ it: a rail's scroll fade masked a switcher's menu to
8
+ the rail's width. The browser gives a popover its own
9
+ defaults (a border, a padding, Canvas colours, a
10
+ scrolling box); these put back what an unlifted panel
11
+ had, at no specificity (:where), so every component's
12
+ own rule for its panel still wins. useAnchoredPosition
13
+ imports this sheet, so every panel it places has it.
14
+ ============================================ */
15
+
16
+ @layer rift.tokens, rift.preset, rift.components;
17
+
18
+ @layer rift.components {
19
+
20
+ :where([popover][data-side]) {
21
+ overflow: visible;
22
+ padding: 0;
23
+ border: 0;
24
+ background: none;
25
+ color: inherit;
26
+ }
27
+
28
+ } /* @layer rift.components */
@@ -3,15 +3,18 @@
3
3
  * against the control that opened it (menus, listboxes, pickers, popovers,
4
4
  * hover cards, tooltips).
5
5
  *
6
- * The panel stays where it is in the DOM, so it keeps the trigger's stacking
7
- * context (a tooltip excepted, which paints in the top layer through
8
- * src/behaviors/useTopLayer) and any theme scoped above it, but is
9
- * `position: fixed`, placed
10
- * from the anchor's rectangle. A fixed panel is not clipped by an ancestor's
11
- * `overflow`, which is what lets a menu inside a table's scroll wrapper, a
12
- * rail or a card show whole. Portals would escape the same way but would
13
- * leave the theme scope; floating-ui would solve it at the cost of a
14
- * dependency. This is the approach Tooltip proved first.
6
+ * The panel stays where it is in the DOM, so it keeps any theme scoped above
7
+ * it, but is `position: fixed`, placed from the anchor's rectangle, and while
8
+ * open it paints in the browser's top layer (src/behaviors/useTopLayer). A
9
+ * fixed panel alone escapes an ancestor's `overflow`, but not its mask or
10
+ * stacking context: a rail's scroll fade masked a switcher's menu to the
11
+ * rail's width. In the top layer nothing on the page can clip or cover it,
12
+ * which is what lets a menu inside a table's scroll wrapper, a faded rail or
13
+ * a card show whole. src/behaviors/top-layer.css undoes the browser's
14
+ * popover defaults beneath each component's own panel rule. Portals would
15
+ * escape the same way but would leave the theme scope; floating-ui would
16
+ * solve it at the cost of a dependency. This is the approach Tooltip proved
17
+ * first.
15
18
  *
16
19
  * On every placement it:
17
20
  * - puts the panel on the preferred side, flipping to the opposite side when
@@ -1,6 +1,8 @@
1
1
  "use client";
2
2
  import { useRef, useLayoutEffect } from "react";
3
3
  import { isRtl } from "./direction.js";
4
+ import { useTopLayer } from "./useTopLayer.js";
5
+ import "./top-layer.css";
4
6
  function fixedContainingBlock(element) {
5
7
  if (element.matches(":popover-open")) return null;
6
8
  for (let node = element.parentElement; node; node = node.parentElement) {
@@ -33,6 +35,7 @@ function useAnchoredPosition({
33
35
  onPlace,
34
36
  target
35
37
  }) {
38
+ useTopLayer({ open, panelRef, target });
36
39
  const onPlaceRef = useRef(onPlace);
37
40
  useLayoutEffect(() => {
38
41
  onPlaceRef.current = onPlace;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The fold state of a nav's titled sections, for a nav whose sections can
3
+ * fold under their headings (AppSidebar's
4
+ * `collapsibleSections`). Sections open by default, so the state is the
5
+ * list of folded ids: controlled through `collapsed`, or kept here from
6
+ * `defaultCollapsed`, with `onChange` told the whole new list either way.
7
+ * SideNav folds its sections its own way (per section, closed by default),
8
+ * so it keeps its own expanded list.
9
+ */
10
+ export declare function useFoldedSections({ collapsed, defaultCollapsed, onChange, }: {
11
+ collapsed?: string[];
12
+ defaultCollapsed?: string[];
13
+ onChange?: (collapsed: string[]) => void;
14
+ }): {
15
+ isFolded: (id: string) => boolean;
16
+ toggle: (id: string) => void;
17
+ };
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import { useState, useCallback } from "react";
3
+ function useFoldedSections({
4
+ collapsed,
5
+ defaultCollapsed,
6
+ onChange
7
+ }) {
8
+ const [own, setOwn] = useState(() => defaultCollapsed ?? []);
9
+ const current = collapsed ?? own;
10
+ const toggle = useCallback(
11
+ (id) => {
12
+ const next = current.includes(id) ? current.filter((entry) => entry !== id) : [...current, id];
13
+ if (collapsed === void 0) setOwn(next);
14
+ onChange?.(next);
15
+ },
16
+ [current, collapsed, onChange]
17
+ );
18
+ const isFolded = (id) => current.includes(id);
19
+ return { isFolded, toggle };
20
+ }
21
+ export {
22
+ useFoldedSections
23
+ };
@@ -80,6 +80,15 @@ export type LayerHandle = {
80
80
  export declare const openLayerContains: (node: Node) => boolean;
81
81
  /** Whether any layer is open. Escape belongs to the stack while one is, so keyboard shortcuts leave it alone. */
82
82
  export declare const hasOpenLayer: () => boolean;
83
+ /**
84
+ * The stack's Escape: the topmost open layer is dismissed and the key marked
85
+ * handled. Installed on the document while a layer is open; a layer whose
86
+ * keydown would otherwise reach a host first (a drawer inside a chat panel
87
+ * that closes on Escape in its own React handler) calls it from its own
88
+ * keydown, so the stack still decides which layer the key belongs to, and
89
+ * the host sees the key already handled.
90
+ */
91
+ export declare const handleLayerEscape: (event: KeyboardEvent) => void;
83
92
  /**
84
93
  * Register an overlay on the dismissal stack while `open` is true. Options
85
94
  * are read at event time, so a `dismissOnEscape` toggle takes effect without
@@ -6,7 +6,7 @@ let pressOwner = null;
6
6
  const contains = (layer, target) => (layer.optionsRef.current.getElements?.() ?? []).some((el) => el?.contains(target));
7
7
  const openLayerContains = (node) => layers.some((layer) => contains(layer, node));
8
8
  const hasOpenLayer = () => layers.length > 0;
9
- const handleKeyDown = (event) => {
9
+ const handleLayerEscape = (event) => {
10
10
  if (event.key !== "Escape" || event.defaultPrevented) return;
11
11
  const top = layers[layers.length - 1];
12
12
  if (!top) return;
@@ -28,11 +28,11 @@ const handlePointerDown = (event) => {
28
28
  };
29
29
  const syncListeners = () => {
30
30
  if (layers.length > 0 && !listenersInstalled) {
31
- document.addEventListener("keydown", handleKeyDown);
31
+ document.addEventListener("keydown", handleLayerEscape);
32
32
  document.addEventListener("pointerdown", handlePointerDown, true);
33
33
  listenersInstalled = true;
34
34
  } else if (layers.length === 0 && listenersInstalled) {
35
- document.removeEventListener("keydown", handleKeyDown);
35
+ document.removeEventListener("keydown", handleLayerEscape);
36
36
  document.removeEventListener("pointerdown", handlePointerDown, true);
37
37
  listenersInstalled = false;
38
38
  pressOwner = null;
@@ -66,6 +66,7 @@ function useLayer(options) {
66
66
  return { ownsPress };
67
67
  }
68
68
  export {
69
+ handleLayerEscape,
69
70
  hasOpenLayer,
70
71
  openLayerContains,
71
72
  useLayer
package/bin/rift-ds.mjs CHANGED
@@ -309,6 +309,9 @@ function initApp({ app, dryRun }) {
309
309
  }
310
310
  console.log(`\nIf the layout imports a globals.css from create-next-app, drop that import (or empty the file):`);
311
311
  console.log(`its body colours and font would cover the library's.`);
312
+ console.log(`\nPick a shipped theme before the first screen: the base theme is a neutral starting point, not a look.`);
313
+ console.log(`Import ${PACKAGE_NAME}/tokens/presets/<id>.css after tokens.css and set data-brand="<id>" on <html>.`);
314
+ console.log(`Compare them at ${SITE_ORIGIN}/playground.`);
312
315
  console.log(`\nThen add a first page: npx ${PACKAGE_NAME} init block dashboard (no name lists them).`);
313
316
  console.log(`Setup and theming: ${SITE_ORIGIN}/docs/get-started`);
314
317
  }
@@ -0,0 +1,163 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * The notifications block's inbox: the page header's actions, the filters
5
+ * and the list share one record of what is read and what is left, so they
6
+ * hold here together. Swap INBOX for your notifications, `read` for your
7
+ * server's read state, and the `onSelect` of each row for where it should
8
+ * take the reader.
9
+ */
10
+
11
+ import { useState } from 'react';
12
+ import { Button } from 'rift-ds/components/Button/Button';
13
+ import { Dropdown } from 'rift-ds/components/Dropdown/Dropdown';
14
+ import { EmptyState } from 'rift-ds/components/EmptyState/EmptyState';
15
+ import { NotificationItem } from 'rift-ds/components/NotificationCenter/NotificationCenter';
16
+ import { Tabs } from 'rift-ds/components/Tabs/Tabs';
17
+ import { AppShell } from '../../components/blocks/AppShell';
18
+ import styles from './page.module.css';
19
+
20
+ type Category = 'payments' | 'cards' | 'team' | 'approvals';
21
+
22
+ interface Notification {
23
+ id: string;
24
+ /** Which day group the row sits under. */
25
+ group: 'Today' | 'This week' | 'Earlier';
26
+ category: Category;
27
+ icon: string;
28
+ title: string;
29
+ text: string;
30
+ /** When it happened, already written for the reader. */
31
+ time: string;
32
+ }
33
+
34
+ const INBOX: Notification[] = [
35
+ { id: 'n1', group: 'Today', category: 'payments', icon: 'payments', title: 'Payment received', text: 'Northwind Supply paid invoice 1042 for $4,180.00.', time: '2m' },
36
+ { 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' },
37
+ { 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' },
38
+ { id: 'n4', group: 'This week', category: 'team', icon: 'person_add', title: 'Invite accepted', text: 'Sam Patel joined Acme as an admin.', time: 'Tue' },
39
+ { 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' },
40
+ { 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' },
41
+ { 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' },
42
+ { 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' },
43
+ { id: 'n9', group: 'Earlier', category: 'payments', icon: 'description', title: 'Statement ready', text: 'Your October statement is ready to download.', time: 'Nov 1' },
44
+ ];
45
+
46
+ const GROUPS = ['Today', 'This week', 'Earlier'] as const;
47
+
48
+ const CATEGORY_OPTIONS = [
49
+ { value: 'all', label: 'All categories' },
50
+ { value: 'payments', label: 'Payments' },
51
+ { value: 'cards', label: 'Cards' },
52
+ { value: 'team', label: 'Team' },
53
+ { value: 'approvals', label: 'Approvals' },
54
+ ];
55
+
56
+ export function Inbox() {
57
+ const [items, setItems] = useState(INBOX);
58
+ const [unread, setUnread] = useState<string[]>(['n1', 'n2', 'n3', 'n4']);
59
+ const [show, setShow] = useState('all');
60
+ const [category, setCategory] = useState('all');
61
+
62
+ const read = (id: string) => setUnread((ids) => ids.filter((other) => other !== id));
63
+ const dismiss = (id: string) => {
64
+ setItems((list) => list.filter((item) => item.id !== id));
65
+ read(id);
66
+ };
67
+
68
+ const shown = items.filter(
69
+ (item) =>
70
+ (show === 'all' || unread.includes(item.id)) && (category === 'all' || item.category === category),
71
+ );
72
+
73
+ return (
74
+ <AppShell
75
+ activeKey="inbox"
76
+ breadcrumb={[{ label: 'Acme', href: '#' }, { label: 'Notifications' }]}
77
+ title="Notifications"
78
+ actions={
79
+ <>
80
+ <Button
81
+ label="Mark all as read"
82
+ variant="secondary"
83
+ iconLeft="done_all"
84
+ disabled={unread.length === 0}
85
+ onClick={() => setUnread([])}
86
+ />
87
+ <Button
88
+ label="Clear all"
89
+ variant="tertiary"
90
+ tone="destructive"
91
+ disabled={items.length === 0}
92
+ onClick={() => {
93
+ setItems([]);
94
+ setUnread([]);
95
+ }}
96
+ />
97
+ </>
98
+ }
99
+ >
100
+ <div className={styles.column}>
101
+ <div className={styles.filters}>
102
+ <Tabs
103
+ aria-label="Show"
104
+ tabs={[
105
+ { value: 'all', label: 'All', panelId: 'notifications-list' },
106
+ { value: 'unread', label: 'Unread', count: unread.length, panelId: 'notifications-list' },
107
+ ]}
108
+ value={show}
109
+ onValueChange={setShow}
110
+ />
111
+ <Dropdown
112
+ className={styles.category}
113
+ aria-label="Category"
114
+ options={CATEGORY_OPTIONS}
115
+ value={category}
116
+ onValueChange={setCategory}
117
+ />
118
+ </div>
119
+
120
+ <div id="notifications-list" role="tabpanel" aria-label={show === 'all' ? 'All' : 'Unread'} className={styles.groups}>
121
+ {shown.length === 0 ? (
122
+ <EmptyState
123
+ icon="notifications"
124
+ title={items.length === 0 ? 'No notifications' : 'You’re all caught up'}
125
+ description={
126
+ items.length === 0
127
+ ? 'New notifications will collect here as they arrive.'
128
+ : 'Nothing here matches these filters.'
129
+ }
130
+ />
131
+ ) : (
132
+ GROUPS.map((group) => {
133
+ const rows = shown.filter((item) => item.group === group);
134
+ if (rows.length === 0) return null;
135
+ return (
136
+ <section key={group} className={styles.group} aria-labelledby={`group-${group}`}>
137
+ <h2 id={`group-${group}`} className={styles.groupLabel}>
138
+ {group}
139
+ </h2>
140
+ <div className={styles.list}>
141
+ {rows.map((item) => (
142
+ <NotificationItem
143
+ key={item.id}
144
+ media={item.icon}
145
+ title={item.title}
146
+ time={item.time}
147
+ unread={unread.includes(item.id)}
148
+ onSelect={() => read(item.id)}
149
+ onDismiss={() => dismiss(item.id)}
150
+ >
151
+ {item.text}
152
+ </NotificationItem>
153
+ ))}
154
+ </div>
155
+ </section>
156
+ );
157
+ })
158
+ )}
159
+ </div>
160
+ </div>
161
+ </AppShell>
162
+ );
163
+ }
@@ -0,0 +1,63 @@
1
+ /* The notifications column: the filters over the list, across the whole
2
+ content column, with each row's time held to the far edge. Each day's
3
+ rows sit under a quiet label, the rows themselves the notification
4
+ panel's own, so the page and the panel read as one list at two sizes. */
5
+
6
+ .column {
7
+ display: flex;
8
+ flex-direction: column;
9
+ gap: var(--gap-500);
10
+ }
11
+
12
+ .filters {
13
+ display: flex;
14
+ flex-wrap: wrap;
15
+ align-items: center;
16
+ justify-content: space-between;
17
+ gap: var(--gap-300);
18
+ }
19
+
20
+ .groups {
21
+ display: flex;
22
+ flex-direction: column;
23
+ gap: var(--gap-500);
24
+ }
25
+
26
+ .category {
27
+ width: 220px; /* room for the longest category */
28
+ }
29
+
30
+ .group {
31
+ display: flex;
32
+ flex-direction: column;
33
+ gap: var(--gap-100);
34
+ }
35
+
36
+ /* The palette's group label: small, tertiary, inset to the rows' text. */
37
+ .groupLabel {
38
+ margin: 0;
39
+ padding: 0 var(--padding-300);
40
+ color: var(--color-text-tertiary);
41
+ font-family: var(--font-paragraph-sm-emphasis-family);
42
+ font-size: var(--font-paragraph-sm-emphasis-size);
43
+ font-weight: var(--font-paragraph-sm-emphasis-weight);
44
+ line-height: var(--font-paragraph-sm-emphasis-line-height);
45
+ letter-spacing: var(--font-paragraph-sm-emphasis-letter-spacing);
46
+ }
47
+
48
+ .list {
49
+ display: flex;
50
+ flex-direction: column;
51
+ }
52
+
53
+ /* On the page the rows part with a rule, as a long list reads best; the
54
+ panel keeps the palette's unruled rows. */
55
+ .list > :global(.ds-notification-item) + :global(.ds-notification-item) {
56
+ border-top: var(--border-025) solid var(--color-divider);
57
+ }
58
+
59
+ @media (max-width: 480px) {
60
+ .category {
61
+ width: 100%;
62
+ }
63
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The notifications block: the full list a notification panel's See all
3
+ * opens, the same rows the panel shows, laid out as a page. Filter by All or
4
+ * Unread and by category, open a row to read it, clear one with its close
5
+ * button, or read or clear them all from the page header. The notifications
6
+ * are placeholders (Inbox.tsx beside this page holds them); read your own.
7
+ */
8
+
9
+ import { Inbox } from './Inbox';
10
+
11
+ export default function NotificationsPage() {
12
+ return <Inbox />;
13
+ }