oneslash-design-system 2.18.0 → 2.19.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 (118) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +26 -1
  3. package/dist/cases/app-shell/sidebar.d.ts +1 -0
  4. package/dist/cases/app-shell/sidebar.jsx +124 -0
  5. package/dist/cases/app-shell/top-tabs.d.ts +1 -0
  6. package/dist/cases/app-shell/top-tabs.jsx +106 -0
  7. package/dist/cases/app-shell.md +364 -0
  8. package/dist/cases/artifact-card/card.jsx +32 -6
  9. package/dist/cases/artifact-card.md +55 -7
  10. package/dist/cases/error-page/in-shell.jsx +26 -17
  11. package/dist/cases/error-page.md +42 -21
  12. package/dist/cases/master-detail/list-then-page.d.ts +1 -0
  13. package/dist/cases/master-detail/list-then-page.jsx +65 -0
  14. package/dist/cases/master-detail/split.d.ts +1 -0
  15. package/dist/cases/master-detail/split.jsx +49 -0
  16. package/dist/cases/master-detail.md +213 -0
  17. package/dist/cases/mobile-menu/links.d.ts +1 -0
  18. package/dist/cases/mobile-menu/links.jsx +24 -0
  19. package/dist/cases/mobile-menu/sections.d.ts +1 -0
  20. package/dist/cases/mobile-menu/sections.jsx +61 -0
  21. package/dist/cases/mobile-menu.md +170 -0
  22. package/dist/cases/not-found-page/in-shell.jsx +26 -17
  23. package/dist/cases/not-found-page.md +41 -20
  24. package/dist/cases/on-this-page/aside.d.ts +1 -0
  25. package/dist/cases/on-this-page/aside.jsx +39 -0
  26. package/dist/cases/on-this-page.md +80 -0
  27. package/dist/cases/page-header/actions.d.ts +1 -0
  28. package/dist/cases/page-header/actions.jsx +65 -0
  29. package/dist/cases/page-header/sub-page.d.ts +1 -0
  30. package/dist/cases/page-header/sub-page.jsx +37 -0
  31. package/dist/cases/page-header.md +195 -0
  32. package/dist/cases/phone-navigation.md +32 -0
  33. package/dist/cases/route-loading/region.jsx +27 -18
  34. package/dist/cases/route-loading.md +42 -21
  35. package/dist/cases/side-pane/beside.d.ts +1 -0
  36. package/dist/cases/side-pane/beside.jsx +79 -0
  37. package/dist/cases/side-pane/over.d.ts +1 -0
  38. package/dist/cases/side-pane/over.jsx +58 -0
  39. package/dist/cases/side-pane.md +238 -0
  40. package/dist/cases/sidebar-nav/flat.d.ts +1 -0
  41. package/dist/cases/sidebar-nav/flat.jsx +81 -0
  42. package/dist/cases/sidebar-nav/nested.d.ts +1 -0
  43. package/dist/cases/sidebar-nav/nested.jsx +122 -0
  44. package/dist/cases/sidebar-nav.md +261 -0
  45. package/dist/cases/site-footer/columns.d.ts +1 -0
  46. package/dist/cases/site-footer/columns.jsx +51 -0
  47. package/dist/cases/site-footer/simple.d.ts +1 -0
  48. package/dist/cases/site-footer/simple.jsx +24 -0
  49. package/dist/cases/site-footer.md +133 -0
  50. package/dist/cases/site-header/links.d.ts +1 -0
  51. package/dist/cases/site-header/links.jsx +26 -0
  52. package/dist/cases/site-header/sections.d.ts +1 -0
  53. package/dist/cases/site-header/sections.jsx +64 -0
  54. package/dist/cases/site-header.md +183 -0
  55. package/dist/cases/theme-switcher/menu.d.ts +1 -0
  56. package/dist/cases/theme-switcher/menu.jsx +47 -0
  57. package/dist/cases/theme-switcher/segmented.d.ts +1 -0
  58. package/dist/cases/theme-switcher/segmented.jsx +26 -0
  59. package/dist/cases/theme-switcher.md +149 -0
  60. package/dist/cases.json +666 -19
  61. package/dist/components/appShell.d.ts +44 -0
  62. package/dist/components/appShell.jsx +121 -0
  63. package/dist/components/drawer.d.ts +31 -0
  64. package/dist/components/drawer.jsx +121 -0
  65. package/dist/components/heading.d.ts +3 -1
  66. package/dist/components/heading.jsx +2 -2
  67. package/dist/components/link.d.ts +6 -1
  68. package/dist/components/link.jsx +11 -3
  69. package/dist/components/menuItem.d.ts +7 -1
  70. package/dist/components/menuItem.jsx +4 -3
  71. package/dist/components/modal.jsx +12 -23
  72. package/dist/components/onThisPage.d.ts +29 -0
  73. package/dist/components/onThisPage.jsx +151 -0
  74. package/dist/components/pageShell.d.ts +7 -1
  75. package/dist/components/pageShell.jsx +14 -1
  76. package/dist/components/popover.jsx +4 -0
  77. package/dist/components/settingsSection.d.ts +6 -1
  78. package/dist/components/settingsSection.jsx +10 -3
  79. package/dist/components/sidePane.d.ts +32 -0
  80. package/dist/components/sidePane.jsx +128 -0
  81. package/dist/components/siteFooter.d.ts +24 -0
  82. package/dist/components/siteFooter.jsx +48 -0
  83. package/dist/components/siteHeader.d.ts +55 -0
  84. package/dist/components/siteHeader.jsx +125 -0
  85. package/dist/components/titleBar.d.ts +17 -0
  86. package/dist/components/titleBar.jsx +17 -0
  87. package/dist/index.d.ts +7 -0
  88. package/dist/index.js +7 -0
  89. package/dist/internal/overlayStack.d.ts +24 -0
  90. package/dist/internal/overlayStack.js +71 -0
  91. package/dist/internal/resize.d.ts +9 -0
  92. package/dist/internal/resize.js +31 -0
  93. package/dist/internal/scrollSpy.d.ts +24 -0
  94. package/dist/internal/scrollSpy.js +53 -0
  95. package/dist/internal/siteBrand.d.ts +6 -0
  96. package/dist/internal/siteBrand.jsx +11 -0
  97. package/dist/native-mapping.json +43 -1
  98. package/dist/stories/AppShell.stories.d.ts +15 -0
  99. package/dist/stories/AppShell.stories.jsx +137 -0
  100. package/dist/stories/Cases.generated.stories.d.ts +19 -0
  101. package/dist/stories/Cases.generated.stories.jsx +38 -0
  102. package/dist/stories/Drawer.stories.d.ts +10 -0
  103. package/dist/stories/Drawer.stories.jsx +123 -0
  104. package/dist/stories/Link.stories.d.ts +1 -0
  105. package/dist/stories/Link.stories.jsx +8 -0
  106. package/dist/stories/OnThisPage.stories.d.ts +10 -0
  107. package/dist/stories/OnThisPage.stories.jsx +105 -0
  108. package/dist/stories/SettingsSection.stories.d.ts +1 -0
  109. package/dist/stories/SettingsSection.stories.jsx +27 -0
  110. package/dist/stories/SidePane.stories.d.ts +6 -0
  111. package/dist/stories/SidePane.stories.jsx +37 -0
  112. package/dist/stories/SiteFooter.stories.d.ts +7 -0
  113. package/dist/stories/SiteFooter.stories.jsx +63 -0
  114. package/dist/stories/SiteHeader.stories.d.ts +10 -0
  115. package/dist/stories/SiteHeader.stories.jsx +94 -0
  116. package/dist/stories/TitleBar.stories.d.ts +6 -0
  117. package/dist/stories/TitleBar.stories.jsx +34 -0
  118. package/package.json +1 -1
package/dist/cases.json CHANGED
@@ -646,6 +646,86 @@
646
646
  }
647
647
  ]
648
648
  },
649
+ {
650
+ "id": "app-shell",
651
+ "title": "App shell",
652
+ "kind": "design",
653
+ "level": "page",
654
+ "area": "shell",
655
+ "situation": "A person opens the product and moves between its places, such as Inbox, Tasks and Settings, from every page.",
656
+ "do": [
657
+ "Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'.",
658
+ "Build the sidebar frame with `AppShell`. Its places are a `Navigation` of `NavigationGroup`s.",
659
+ "Make each place a `MenuItem` with an `href`, and mark the open one with `isSelected` and `aria-current=\"page\"`.",
660
+ "Put the account menu last in the sidebar, built as the case 'Account menu' says.",
661
+ "Give the page's `TitleBar` the page's name as the level 1 heading, and give `AppShell` the place's name as `title`. When the page is the place, the two are the same.",
662
+ "Pass `onSidebarHiddenChange` to `AppShell` so a person can hide the sidebar from `md` up. It adds a 'Hide sidebar' IconButton at the top of the column and a 'Show sidebar' IconButton when it is hidden, and moves focus between them. The phone menu has neither.",
663
+ "Add Cmd+B, or Ctrl+B, with `useHotkey('b', …)`, and have it change the same state. It does nothing while the person types in a field. Ignore it while a Modal, such as the 'Log Out' confirm, is open.",
664
+ "Close the phone menu in the `onClick` of an item in a Popover, such as Settings in the account menu. A choice in a Popover does not close the Drawer by itself.",
665
+ "Render a Modal that the sidebar opens, such as the 'Log Out' confirm, inside the sidebar node, so it is mounted once: in the column or in the Drawer.",
666
+ "Use `TabsContainer fill` with a `Tab` for each place, each with an `href` and the app's `router`, when there are four places or fewer. Name each with one short word.",
667
+ "With tabs across the top, put the name of the app at the start of the bar and the account menu at the end."
668
+ ],
669
+ "dont": [
670
+ "Do not use tabs for more than four places, or for places the person makes.",
671
+ "Do not show the sidebar beside the page on a phone.",
672
+ "Do not hide the sidebar with the shortcut alone. Give a person a visible 'Hide sidebar' button as well.",
673
+ "Do not let the tabs scroll sideways. When they do not fit at 375px, use the sidebar.",
674
+ "Do not mount the sidebar twice, once for the column and once for the menu."
675
+ ],
676
+ "native": "On macOS and iPad use a `NavigationSplitView` with a sidebar `List` in `Section`s. The system adds the hide button and its shortcut. On iPhone use a `TabView` for five places or fewer. On Android use a navigation drawer.",
677
+ "options": [
678
+ {
679
+ "id": "sidebar",
680
+ "title": "Sidebar in groups",
681
+ "useWhen": "There are more than four places, or the person makes some of them, such as projects or channels.",
682
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport AppShell from 'oneslash-design-system/components/appShell';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport Navigation, { NavigationGroup } from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport Modal from 'oneslash-design-system/components/modal';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Popover from 'oneslash-design-system/components/popover';\nimport Menu from 'oneslash-design-system/components/menu';\nimport Line from 'oneslash-design-system/components/line';\nimport useHotkey from 'oneslash-design-system/components/useHotkey';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Place = { id: string; label: string; icon: string; group: string; page: string; text: string };\n\n// The places. The top bar on a phone names the place; the page's own title is the level 1 heading, so a phone never shows the same words twice.\nconst places: Place[] = [\n { id: 'inbox', label: 'Inbox', icon: 'Inbox', group: 'Mail', page: 'Unread messages', text: 'Ben Carter shared the launch plan. Omar Reyes asked for the new screens by Friday.' },\n { id: 'sent', label: 'Sent', icon: 'Send', group: 'Mail', page: 'Sent this week', text: 'You sent 4 messages this week.' },\n { id: 'website', label: 'Website', icon: 'Globe', group: 'Projects', page: 'Home page redesign', text: '12 tasks are open. The next review is on Thursday.' },\n { id: 'mobile', label: 'Mobile App', icon: 'Smartphone', group: 'Projects', page: 'Version 2 release', text: '5 tasks are open. Dana Lee owns the release.' },\n];\n\nconst groups = ['Mail', 'Projects'];\n\n// A real app reads this from the session.\nconst me = 'Dana Lee';\n\nexport default function AppShellSidebar() {\n const [placeId, setPlaceId] = useState('inbox');\n // Below md the sidebar is a Drawer; this says whether it is open.\n const [navOpen, setNavOpen] = useState(false);\n // From md up the person can hide the column for room. The phone menu still has it.\n const [hidden, setHidden] = useState(false);\n const [accountAnchor, setAccountAnchor] = useState<HTMLElement | null>(null);\n const [accountOpen, setAccountOpen] = useState(false);\n const [confirming, setConfirming] = useState(false);\n const [loggingOut, setLoggingOut] = useState(false);\n const [loggedOut, setLoggedOut] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const accountButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // Stops the request if the example goes away before it ends.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n // Cmd+B, or Ctrl+B. It does nothing while the person types in a field, and nothing while the Log Out confirm is open.\n useHotkey('b', () => {\n if (!confirming) setHidden((h) => !h);\n });\n\n const place = places.find((p) => p.id === placeId) ?? places[0];\n\n // Cancel, Escape and a click outside. 'Cancel' puts focus back on the account Button, inside the Drawer on a phone.\n function cancelLogOut() {\n if (loggingOut) return;\n setConfirming(false);\n focusNext.current = () => accountButton.current?.focus();\n }\n\n function logOut() {\n if (loggingOut) return;\n setLoggingOut(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setLoggingOut(false);\n setConfirming(false);\n setLoggedOut(true);\n }, 1200);\n }\n\n // A real app goes to its login page here. The example shows a short logged-out page instead.\n if (loggedOut) {\n return (\n <Center fill>\n <Heading level={1} size=\"h5\">You are logged out</Heading>\n <Cluster>\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Log In\" onClickButton={() => { setLoggedOut(false); setPlaceId('inbox'); }} />\n </Cluster>\n </Center>\n );\n }\n\n // The sidebar is mounted once: in the column from md up, in the Drawer below it. Its Modal lives inside it.\n const sidebar = (\n <Navigation aria-label=\"Main\">\n <Paragraph size=\"body1\" measure=\"none\">Acme</Paragraph>\n {groups.map((group) => (\n <NavigationGroup key={group} label={group}>\n {places.filter((p) => p.group === group).map((p) => (\n <MenuItem\n key={p.id}\n size=\"small\"\n label={p.label}\n iconName={p.icon}\n href={`/${p.id}`}\n isSelected={p.id === place.id}\n aria-current={p.id === place.id ? 'page' : undefined}\n onClick={(event: { preventDefault: () => void }) => {\n // A real app lets the link go to its page. The example keeps the choice in state.\n event.preventDefault();\n setPlaceId(p.id);\n }}\n />\n ))}\n </NavigationGroup>\n ))}\n <Line />\n {/* The account menu is last. */}\n <Cluster>\n <Button\n ref={accountButton}\n size=\"small\"\n type=\"tertiary\"\n state={accountOpen ? 'selected' : 'enabled'}\n label={me}\n decoIcon={<UserImage userHandle={me} size={20} decorative />}\n aria-label={`${me}, account menu`}\n aria-haspopup=\"menu\"\n aria-expanded={accountOpen}\n onClickButton={(e: { currentTarget: HTMLElement }) => {\n setAccountAnchor(e.currentTarget);\n setAccountOpen((o) => !o);\n }}\n />\n </Cluster>\n <Popover open={accountOpen} anchorEl={accountAnchor} onClose={() => setAccountOpen(false)} returnFocus>\n <Menu navigable aria-label=\"Account\" width={200}>\n {/* A choice in a Popover does not close the phone menu: close it here. */}\n <MenuItem size=\"small\" iconName=\"Settings\" label=\"Settings\" onClick={() => { setAccountOpen(false); setNavOpen(false); }} />\n <MenuItem size=\"small\" iconName=\"CircleHelp\" label=\"Help\" onClick={() => { setAccountOpen(false); setNavOpen(false); }} />\n <Line />\n <MenuItem size=\"small\" iconName=\"LogOut\" label=\"Log Out\" onClick={() => { setAccountOpen(false); setConfirming(true); }} />\n </Menu>\n </Popover>\n <Modal\n isOpen={confirming}\n size=\"small\"\n title=\"Log Out\"\n onClose={cancelLogOut}\n actions={\n <>\n <Button size=\"small\" type=\"tertiary\" state={loggingOut ? 'disabled' : 'enabled'} label=\"Cancel\" onClickButton={cancelLogOut} />\n <Button size=\"small\" type=\"primary\" state=\"enabled\" label=\"Log Out\" loading={loggingOut} onClickButton={logOut} />\n </>\n }\n >\n <Paragraph measure=\"none\">You will need to log in again to use Acme on this device.</Paragraph>\n </Modal>\n </Navigation>\n );\n\n const newMessage = <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"New Message\" decoIcon=\"Plus\" />;\n\n return (\n <AppShell title={place.label} navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar} sidebarHidden={hidden} onSidebarHiddenChange={setHidden}>\n <Stack gap=\"large\">\n <TitleBar\n title={place.page}\n actions={newMessage}\n />\n <Paragraph tone=\"secondary\" measure=\"none\">{place.text}</Paragraph>\n </Stack>\n </AppShell>\n );\n}\n",
683
+ "uses": [
684
+ "AppShell",
685
+ "Button",
686
+ "Center",
687
+ "Cluster",
688
+ "Heading",
689
+ "Line",
690
+ "Menu",
691
+ "MenuItem",
692
+ "Modal",
693
+ "Navigation",
694
+ "NavigationGroup",
695
+ "Paragraph",
696
+ "Popover",
697
+ "Stack",
698
+ "TitleBar",
699
+ "UserImage",
700
+ "useHotkey"
701
+ ]
702
+ },
703
+ {
704
+ "id": "top-tabs",
705
+ "title": "Tabs across the top",
706
+ "useWhen": "There are four places or fewer, all fixed, each with a short name that fits on a phone.",
707
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport TabsContainer from 'oneslash-design-system/components/tabsContainer';\nimport Tab from 'oneslash-design-system/components/tab';\nimport Modal from 'oneslash-design-system/components/modal';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Popover from 'oneslash-design-system/components/popover';\nimport Menu from 'oneslash-design-system/components/menu';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport Line from 'oneslash-design-system/components/line';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Place = { id: string; label: string; page: string; text: string };\n\n// Four fixed places, one short word each, so the tabs fit on a phone.\nconst places: Place[] = [\n { id: 'inbox', label: 'Inbox', page: 'Unread messages', text: 'Ben Carter shared the launch plan. Omar Reyes asked for the new screens by Friday.' },\n { id: 'tasks', label: 'Tasks', page: 'My tasks', text: '7 tasks are open. 2 are due this week.' },\n { id: 'files', label: 'Files', page: 'Recent files', text: 'Omar Reyes added the new screens an hour ago.' },\n { id: 'team', label: 'Team', page: 'People and roles', text: 'Dana Lee, Ben Carter and Omar Reyes are in Acme.' },\n];\n\n// A real app reads this from the session.\nconst me = 'Dana Lee';\n\nexport default function AppShellTopTabs() {\n const [placeId, setPlaceId] = useState('inbox');\n const [accountAnchor, setAccountAnchor] = useState<HTMLElement | null>(null);\n const [accountOpen, setAccountOpen] = useState(false);\n const [confirming, setConfirming] = useState(false);\n const [loggingOut, setLoggingOut] = useState(false);\n const [loggedOut, setLoggedOut] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const accountButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // Stops the request if the example goes away before it ends.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n const place = places.find((p) => p.id === placeId) ?? places[0];\n // A real app passes the router from its framework, such as Next's useRouter(). Here it sets the open place.\n const router = { push: (url: string) => setPlaceId(url.split('/').pop() ?? 'inbox') };\n\n // 'Cancel' puts focus back on the account Button.\n function cancelLogOut() {\n if (loggingOut) return;\n setConfirming(false);\n focusNext.current = () => accountButton.current?.focus();\n }\n\n function logOut() {\n if (loggingOut) return;\n setLoggingOut(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setLoggingOut(false);\n setConfirming(false);\n setLoggedOut(true);\n }, 1200);\n }\n\n // A real app goes to its login page here. The example shows a short logged-out page instead.\n if (loggedOut) {\n return (\n <Center fill>\n <Heading level={1} size=\"h5\">You are logged out</Heading>\n <Cluster>\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Log In\" onClickButton={() => { setLoggedOut(false); setPlaceId('inbox'); }} />\n </Cluster>\n </Center>\n );\n }\n\n return (\n <PageShell>\n <Stack gap=\"large\">\n {/* The app's name at the start, the account menu at the end. */}\n <Cluster justify=\"between\">\n <Paragraph size=\"body1\" measure=\"none\">Acme</Paragraph>\n <Button\n ref={accountButton}\n size=\"small\"\n type=\"tertiary\"\n state={accountOpen ? 'selected' : 'enabled'}\n label={me}\n decoIcon={<UserImage userHandle={me} size={20} decorative />}\n aria-label={`${me}, account menu`}\n aria-haspopup=\"menu\"\n aria-expanded={accountOpen}\n onClickButton={(e: { currentTarget: HTMLElement }) => {\n setAccountAnchor(e.currentTarget);\n setAccountOpen((o) => !o);\n }}\n />\n </Cluster>\n <TabsContainer fill>\n {places.map((p) => (\n <Tab key={p.id} label={p.label} href={`/${p.id}`} router={router} isSelected={p.id === place.id} onClickTab={() => setPlaceId(p.id)} />\n ))}\n </TabsContainer>\n <TitleBar title={place.page} actions={<Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"New Message\" decoIcon=\"Plus\" />} />\n <Paragraph tone=\"secondary\" measure=\"none\">{place.text}</Paragraph>\n </Stack>\n <Popover open={accountOpen} anchorEl={accountAnchor} onClose={() => setAccountOpen(false)} returnFocus>\n <Menu navigable aria-label=\"Account\" width={200}>\n <MenuItem size=\"small\" iconName=\"Settings\" label=\"Settings\" onClick={() => setAccountOpen(false)} />\n <MenuItem size=\"small\" iconName=\"CircleHelp\" label=\"Help\" onClick={() => setAccountOpen(false)} />\n <Line />\n <MenuItem size=\"small\" iconName=\"LogOut\" label=\"Log Out\" onClick={() => { setAccountOpen(false); setConfirming(true); }} />\n </Menu>\n </Popover>\n <Modal\n isOpen={confirming}\n size=\"small\"\n title=\"Log Out\"\n onClose={cancelLogOut}\n actions={\n <>\n <Button size=\"small\" type=\"tertiary\" state={loggingOut ? 'disabled' : 'enabled'} label=\"Cancel\" onClickButton={cancelLogOut} />\n <Button size=\"small\" type=\"primary\" state=\"enabled\" label=\"Log Out\" loading={loggingOut} onClickButton={logOut} />\n </>\n }\n >\n <Paragraph measure=\"none\">You will need to log in again to use Acme on this device.</Paragraph>\n </Modal>\n </PageShell>\n );\n}\n",
708
+ "uses": [
709
+ "Button",
710
+ "Center",
711
+ "Cluster",
712
+ "Heading",
713
+ "Line",
714
+ "Menu",
715
+ "MenuItem",
716
+ "Modal",
717
+ "PageShell",
718
+ "Paragraph",
719
+ "Popover",
720
+ "Stack",
721
+ "Tab",
722
+ "TabsContainer",
723
+ "TitleBar",
724
+ "UserImage"
725
+ ]
726
+ }
727
+ ]
728
+ },
649
729
  {
650
730
  "id": "artifact-card",
651
731
  "title": "Document card",
@@ -674,13 +754,16 @@
674
754
  "id": "card",
675
755
  "title": "In the thread",
676
756
  "useWhen": "A reply made a document.",
677
- "source": "'use client';\nimport { Bot, FileText } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport SourceCard from 'oneslash-design-system/components/sourceCard';\nimport { Center, Grid, Stack } from 'oneslash-design-system/components/layout';\n\nconst agentName = 'Acme Agent';\n\nconst request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you write up the launch plan as a document?' };\nconst repliedAt = new Date('2025-01-15T11:41:00Z');\n// One sentence on what the agent made. The document itself stays out of the thread.\nconst reply = 'I wrote the launch plan for March 3 as a document.';\n\nconst doc = { title: 'Launch plan for March 3', meta: 'Document · 4 pages' };\n\n// The agent's marks, as the rule 'An agent says what it is' says.\nfunction agentMeta(at: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\n// A real app opens the document in a pane beside the thread and moves focus into it.\n// ODS has no side pane part yet, so this example shows the card only.\nfunction openDocument() {}\n\nexport default function ArtifactCardCard() {\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={request.from}\n avatar={<UserImage userHandle={request.from} decorative />}\n name={request.from}\n meta={<TimeStamp createdAt={request.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{request.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(repliedAt)}\n footer={\n <Grid columns={2} gap=\"medium\">\n <SourceCard icon={FileText} title={doc.title} meta={doc.meta} action=\"Open\" onClick={openDocument} />\n </Grid>\n }\n >\n <Paragraph measure=\"none\">{reply}</Paragraph>\n </Message>\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
757
+ "source": "'use client';\nimport { useRef, useState } from 'react';\nimport { Bot, FileText } from 'lucide-react';\nimport AppShell from 'oneslash-design-system/components/appShell';\nimport SidePane, { type SidePaneHandle } from 'oneslash-design-system/components/sidePane';\nimport Navigation from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport SourceCard from 'oneslash-design-system/components/sourceCard';\nimport { Grid, Stack } from 'oneslash-design-system/components/layout';\n\nconst agentName = 'Acme Agent';\n\nconst request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you write up the launch plan as a document?' };\nconst repliedAt = new Date('2025-01-15T11:41:00Z');\n// One sentence on what the agent made. The document itself stays out of the thread.\nconst reply = 'I wrote the launch plan for March 3 as a document.';\n\nconst doc = { title: 'Launch plan for March 3', meta: 'Document · 4 pages' };\n\n// The agent's marks, as the rule 'An agent says what it is' says.\nfunction agentMeta(at: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\nconst docParagraphs = [\n 'Acme ships the new home page on March 3. Omar Reyes owns the copy and Dana Lee the screens.',\n 'Ben Carter writes the announcement once the screens are approved.',\n];\n\n// The threads. A real app lets each link go to its page.\nconst sidebar = (\n <Navigation aria-label=\"Main\">\n <MenuItem\n size=\"small\"\n label=\"Launch plan\"\n iconName=\"MessageSquare\"\n href=\"/launch-plan\"\n isSelected\n aria-current=\"page\"\n onClick={(event: { preventDefault: () => void }) => event.preventDefault()}\n />\n </Navigation>\n);\n\nexport default function ArtifactCardCard() {\n const [navOpen, setNavOpen] = useState(false);\n // The pane opens from the card, so focus moves into it and goes back to the card on close.\n const [open, setOpen] = useState(false);\n const pane = useRef<SidePaneHandle>(null);\n\n // Pressed again while the pane is open, the card brings the pane forward instead of opening a second one.\n function openDocument() {\n if (open) pane.current?.focus();\n else setOpen(true);\n }\n\n return (\n <AppShell\n title=\"Launch plan\"\n navOpen={navOpen}\n onNavOpenChange={setNavOpen}\n sidebar={sidebar}\n pane={\n open && (\n <SidePane ref={pane} title={doc.title} onClose={() => setOpen(false)}>\n <Stack gap=\"medium\">\n {docParagraphs.map((text) => (\n <Paragraph key={text} measure=\"none\">{text}</Paragraph>\n ))}\n </Stack>\n </SidePane>\n )\n }\n >\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={request.from}\n avatar={<UserImage userHandle={request.from} decorative />}\n name={request.from}\n meta={<TimeStamp createdAt={request.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{request.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(repliedAt)}\n footer={\n <Grid columns={2} gap=\"medium\">\n <SourceCard icon={FileText} title={doc.title} meta={doc.meta} action=\"Open\" onClick={openDocument} />\n </Grid>\n }\n >\n <Paragraph measure=\"none\">{reply}</Paragraph>\n </Message>\n </Stack>\n </Stack>\n </AppShell>\n );\n}\n",
678
758
  "uses": [
679
- "Center",
759
+ "AppShell",
680
760
  "Grid",
681
761
  "Heading",
762
+ "MenuItem",
682
763
  "Message",
764
+ "Navigation",
683
765
  "Paragraph",
766
+ "SidePane",
684
767
  "SourceCard",
685
768
  "Stack",
686
769
  "Tag",
@@ -1497,17 +1580,18 @@
1497
1580
  "id": "in-shell",
1498
1581
  "title": "Inside the shell",
1499
1582
  "useWhen": "One route failed and the navigation still works.",
1500
- "source": "'use client';\nimport Image from 'oneslash-design-system/components/image';\nimport TabsContainer from 'oneslash-design-system/components/tabsContainer';\nimport Tab from 'oneslash-design-system/components/tab';\nimport Surface from 'oneslash-design-system/components/surface';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// The product's mark. A real app passes its own file.\nconst productMark =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' rx='10' fill='%232f6b4f'/%3E%3Cpath d='M20 9 31 31h-6l-5-11-5 11H9z' fill='%23fff'/%3E%3C/svg%3E\";\n\n// A real app passes the router from its framework, such as Next's useRouter().\nconst router = { push: (url: string) => console.info(`Go to ${url}`) };\n\n// A real app passes the reset() its framework gives the error page, such as Next's error.tsx.\nconst reset = () => console.info('Render the page again');\n\nexport default function ErrorPageInShell() {\n return (\n <Stack gap=\"large\">\n <Cluster gap=\"large\">\n <Image src={productMark} alt=\"Acme\" width={32} height={32} />\n <TabsContainer>\n <Tab label=\"Home\" isSelected={false} href=\"/\" router={router} onClickTab={() => {}} />\n <Tab label=\"Projects\" isSelected href=\"/projects\" router={router} onClickTab={() => {}} />\n <Tab label=\"Settings\" isSelected={false} href=\"/settings\" router={router} onClickTab={() => {}} />\n </TabsContainer>\n </Cluster>\n <Surface minHeight=\"tall\" align=\"center\">\n <Stack gap=\"xlarge\">\n <Stack gap=\"medium\">\n <Heading level={1} size=\"h5\">Something went wrong</Heading>\n <Paragraph tone=\"secondary\" measure=\"none\">This page could not load. Try again, or go back to the home page.</Paragraph>\n </Stack>\n <Cluster>\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Try Again\" onClickButton={reset} />\n <Button size=\"medium\" type=\"secondary\" state=\"enabled\" label=\"Go Home\" href=\"/\" />\n </Cluster>\n </Stack>\n </Surface>\n </Stack>\n );\n}\n",
1583
+ "source": "'use client';\nimport { useState } from 'react';\nimport AppShell from 'oneslash-design-system/components/appShell';\nimport Navigation, { NavigationGroup } from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport Surface from 'oneslash-design-system/components/surface';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app passes the reset() its framework gives the error page, such as Next's error.tsx.\nconst reset = () => console.info('Render the page again');\n\n// The places, and the projects the person made. The page that failed or loads is the current one.\nconst places = [\n { label: 'Home', icon: 'House', href: '/' },\n { label: 'Settings', icon: 'Settings', href: '/settings' },\n];\nconst projects = [\n { label: 'Website', icon: 'Globe', href: '/projects/website' },\n { label: 'Mobile App', icon: 'Smartphone', href: '/projects/mobile-app' },\n];\nconst current = '/projects/website';\n\nconst row = (p: { label: string; icon: string; href: string }) => (\n <MenuItem\n key={p.href}\n size=\"small\"\n label={p.label}\n iconName={p.icon}\n href={p.href}\n isSelected={p.href === current}\n aria-current={p.href === current ? 'page' : undefined}\n // A real app lets the link go to its page.\n onClick={(event: { preventDefault: () => void }) => event.preventDefault()}\n />\n);\n\nconst sidebar = (\n <Navigation aria-label=\"Main\">\n <Paragraph size=\"body1\" measure=\"none\">Acme</Paragraph>\n {places.map(row)}\n <NavigationGroup label=\"Projects\">{projects.map(row)}</NavigationGroup>\n </Navigation>\n);\n\nexport default function ErrorPageInShell() {\n // Below md the sidebar is a Drawer; this says whether it is open.\n const [navOpen, setNavOpen] = useState(false);\n return (\n <AppShell title=\"Website\" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar}>\n <Surface minHeight=\"tall\" align=\"center\">\n <Stack gap=\"xlarge\">\n <Stack gap=\"medium\">\n <Heading level={1} size=\"h5\">Something went wrong</Heading>\n <Paragraph tone=\"secondary\" measure=\"none\">This page could not load. Try again, or go back to the home page.</Paragraph>\n </Stack>\n <Cluster>\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Try Again\" onClickButton={reset} />\n <Button size=\"medium\" type=\"secondary\" state=\"enabled\" label=\"Go Home\" href=\"/\" />\n </Cluster>\n </Stack>\n </Surface>\n </AppShell>\n );\n}\n",
1501
1584
  "uses": [
1585
+ "AppShell",
1502
1586
  "Button",
1503
1587
  "Cluster",
1504
1588
  "Heading",
1505
- "Image",
1589
+ "MenuItem",
1590
+ "Navigation",
1591
+ "NavigationGroup",
1506
1592
  "Paragraph",
1507
1593
  "Stack",
1508
- "Surface",
1509
- "Tab",
1510
- "TabsContainer"
1594
+ "Surface"
1511
1595
  ]
1512
1596
  }
1513
1597
  ]
@@ -2184,6 +2268,69 @@
2184
2268
  }
2185
2269
  ]
2186
2270
  },
2271
+ {
2272
+ "id": "master-detail",
2273
+ "title": "List and detail",
2274
+ "kind": "design",
2275
+ "level": "page",
2276
+ "area": "shell",
2277
+ "situation": "A person opens an item from a list, such as a message or a report, and reads or acts on it.",
2278
+ "do": [
2279
+ "Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'.",
2280
+ "Use `SettingsLayout` with `navWidth=\"wide\"` for a list beside its detail. The list is a `Navigation` of `MenuItem` rows.",
2281
+ "Make each row a link with an `href`, so the open item has an address that can be shared and reloaded. Mark the open row with `isSelected` and `aria-current=\"page\"`.",
2282
+ "Keep one item open at all times from `md` up, the first at the start.",
2283
+ "Name the row with the sender or the title, and put the subject or the summary in `secondLabel`.",
2284
+ "Show the list first on a phone, then the detail alone with a Back Button named for the list: 'Back to Inbox'. Pass it as `back` of `SettingsLayout`.",
2285
+ "Title the page with a level 1 heading, such as 'Inbox'. The open item's title is a level 2 heading.",
2286
+ "Make each row of a list of long items a link to a page of its own. Put 'Back to Reports' in the page's `TitleBar` as `back`.",
2287
+ "Let 'Back to Reports' call the router's `back()` when the person came from the list, so the list keeps its scroll. Otherwise link to the list's address.",
2288
+ "After the person acts on an item, such as Archive, open the next one."
2289
+ ],
2290
+ "dont": [
2291
+ "Do not show the list and the detail together on a phone.",
2292
+ "Do not leave the detail empty with nothing open on a wide screen. Open the first item.",
2293
+ "Do not keep the open item only in state. Give it an address.",
2294
+ "Do not name the Back Button 'Back'. Name the list it goes to.",
2295
+ "Do not use a split for long items that need the whole width."
2296
+ ],
2297
+ "native": "On Apple use a `NavigationSplitView` with a list and a detail. On iPhone it shows the list, then pushes the detail with the system back button. On Android use a list-detail layout that shows one pane on a phone.",
2298
+ "options": [
2299
+ {
2300
+ "id": "split",
2301
+ "title": "List beside the detail",
2302
+ "useWhen": "The person works down the list, one item after another, such as an inbox.",
2303
+ "source": "'use client';\nimport { useState } from 'react';\nimport Navigation from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport { SettingsLayout } from 'oneslash-design-system/components/settingsSection';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Message = { id: string; from: string; subject: string; time: string; body: string[] };\n\nconst messages: Message[] = [\n { id: 'launch-plan', from: 'Ben Carter', subject: 'Launch plan is ready', time: '9:12 AM', body: ['The plan is in the shared folder. It covers the announcement, the pricing page and the support hand-off.', 'Can you read the pricing part before noon? Omar Reyes is waiting on it.'] },\n { id: 'new-screens', from: 'Omar Reyes', subject: 'New screens for Friday', time: '8:40 AM', body: ['I added the new home page screens. The sign-up form now sits above the pricing table.', 'Tell me what to change by Thursday.'] },\n { id: 'invoice', from: 'Ben Carter', subject: 'Invoice for October', time: 'Yesterday', body: ['The invoice for October is attached. It includes the three new seats.'] },\n { id: 'offsite', from: 'Omar Reyes', subject: 'Team offsite in March', time: 'Monday', body: ['I found two dates for the offsite. Please say which one works for you.'] },\n];\n\nexport default function MasterDetailSplit() {\n // One message is always open, the first at the start.\n const [openId, setOpenId] = useState(messages[0].id);\n // On a phone the list is the screen until a message is chosen, and Back returns to it.\n const [showDetail, setShowDetail] = useState(false);\n\n const message = messages.find((m) => m.id === openId) ?? messages[0];\n\n const list = (\n <Navigation aria-label=\"Messages\">\n {messages.map((m) => (\n <MenuItem\n key={m.id}\n size=\"medium\"\n label={m.from}\n secondLabel={m.subject}\n href={`/inbox/${m.id}`}\n isSelected={m.id === message.id}\n aria-current={m.id === message.id ? 'page' : undefined}\n onClick={(event: { preventDefault: () => void }) => {\n // A real app lets the link go to the message's own address, so it can be shared and reloaded. The example keeps the choice in state.\n event.preventDefault();\n setOpenId(m.id);\n setShowDetail(true);\n }}\n />\n ))}\n </Navigation>\n );\n\n return (\n <PageShell>\n <Stack gap=\"xlarge\">\n <Heading level={1} size=\"h5\">Inbox</Heading>\n <SettingsLayout\n navWidth=\"wide\"\n nav={list}\n showContent={showDetail}\n back={<Button size=\"small\" type=\"tertiary\" state=\"enabled\" decoIcon=\"ChevronLeft\" label=\"Back to Inbox\" onClickButton={() => setShowDetail(false)} />}\n >\n <Stack gap=\"small\">\n <Heading level={2} size=\"h6\">{message.subject}</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">{message.from}, {message.time}</Paragraph>\n </Stack>\n <Stack gap=\"medium\">\n {message.body.map((paragraph) => (\n <Paragraph key={paragraph} measure=\"none\">{paragraph}</Paragraph>\n ))}\n </Stack>\n <Cluster>\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Reply\" decoIcon=\"Reply\" />\n </Cluster>\n </SettingsLayout>\n </Stack>\n </PageShell>\n );\n}\n",
2304
+ "uses": [
2305
+ "Button",
2306
+ "Cluster",
2307
+ "Heading",
2308
+ "MenuItem",
2309
+ "Navigation",
2310
+ "PageShell",
2311
+ "Paragraph",
2312
+ "SettingsLayout",
2313
+ "Stack"
2314
+ ]
2315
+ },
2316
+ {
2317
+ "id": "list-then-page",
2318
+ "title": "List, then a page for each item",
2319
+ "useWhen": "Each item is long and has its own address, such as a report.",
2320
+ "source": "'use client';\nimport { useState } from 'react';\nimport Navigation from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\ntype Report = { id: string; title: string; summary: string; body: string[] };\n\nconst reports: Report[] = [\n {\n id: 'q3-review',\n title: 'Q3 review',\n summary: 'Revenue, churn and what changed since June.',\n body: [\n 'Revenue grew 12 percent over the quarter, led by the new team plan. Churn fell to 2.1 percent.',\n 'Support tickets about sign-up dropped by a third after the new form shipped in August.',\n 'The main risk is the pricing page, which still sends people to a contact form. Ben Carter owns the fix.',\n ],\n },\n {\n id: 'hiring-plan',\n title: 'Hiring plan',\n summary: 'Roles to open next half, and why.',\n body: [\n 'Two roles open in January: a designer for the web app and a support lead.',\n 'Omar Reyes will write both job posts. Dana Lee approves the budget on Monday.',\n ],\n },\n {\n id: 'roadmap',\n title: 'Roadmap',\n summary: 'What ships, in order, through March.',\n body: [\n 'The mobile app and the new billing page ship first. Integrations follow in February.',\n 'Each item lists its owner, its date and what must be true before it starts.',\n ],\n },\n];\n\nexport default function MasterDetailListThenPage() {\n const [openId, setOpenId] = useState<string | null>(null);\n const report = reports.find((r) => r.id === openId);\n\n // A real app goes to the page's address. Back calls the router's back() when the person came from the list, so the list keeps its scroll,\n // and otherwise links to the list's address. The example swaps the view.\n if (report) {\n return (\n <PageShell>\n <Stack gap=\"large\">\n <TitleBar\n title={report.title}\n back={<Button size=\"small\" type=\"tertiary\" state=\"enabled\" decoIcon=\"ChevronLeft\" label=\"Back to Reports\" onClickButton={() => setOpenId(null)} />}\n />\n {report.body.map((paragraph) => (\n <Paragraph key={paragraph} measure=\"body\">{paragraph}</Paragraph>\n ))}\n </Stack>\n </PageShell>\n );\n }\n\n return (\n <PageShell>\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Reports</Heading>\n <Navigation aria-label=\"Reports\">\n {reports.map((r) => (\n <MenuItem\n key={r.id}\n size=\"medium\"\n label={r.title}\n secondLabel={r.summary}\n iconRight=\"ChevronRight\"\n href={`/reports/${r.id}`}\n onClick={(event: { preventDefault: () => void }) => {\n event.preventDefault();\n setOpenId(r.id);\n }}\n />\n ))}\n </Navigation>\n </Stack>\n </PageShell>\n );\n}\n",
2321
+ "uses": [
2322
+ "Button",
2323
+ "Heading",
2324
+ "MenuItem",
2325
+ "Navigation",
2326
+ "PageShell",
2327
+ "Paragraph",
2328
+ "Stack",
2329
+ "TitleBar"
2330
+ ]
2331
+ }
2332
+ ]
2333
+ },
2187
2334
  {
2188
2335
  "id": "members-list",
2189
2336
  "title": "Members",
@@ -2748,6 +2895,68 @@
2748
2895
  }
2749
2896
  ]
2750
2897
  },
2898
+ {
2899
+ "id": "mobile-menu",
2900
+ "title": "Menu on a phone",
2901
+ "kind": "design",
2902
+ "level": "organism",
2903
+ "area": "shell",
2904
+ "situation": "A site's links and actions do not fit in the bar on a phone, and the person still needs to reach every one.",
2905
+ "do": [
2906
+ "Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'. The menu is a `Drawer` from the start side.",
2907
+ "Open it from an `IconButton` named 'Menu' at the start of the bar, with `aria-expanded` and `aria-controls`.",
2908
+ "Use the menu that `SiteHeader` builds for a few links. The links come first, then the actions. One main action stays in the bar as `phoneAction`.",
2909
+ "Build the menu from a `Drawer` for sections: the pages of the open section as `MenuItem` links in a `Navigation`. Put a `TabsContainer` of section `Tab`s above them when the bar does not show the sections.",
2910
+ "Put the 'Menu' IconButton in a real bar with a skip link, as `SiteHeader` builds.",
2911
+ "Open the menu on the section of the current page, and mark the current page with `isSelected` and `aria-current=\"page\"`.",
2912
+ "Close the menu when a page is chosen. A `Drawer` also closes on Close, Escape and the scrim.",
2913
+ "Close the menu when the window widens past `md`, so the page is never left locked. A `SiteHeader` does it; give your own `Drawer` `closeFrom=\"md\"`.",
2914
+ "Give the Drawer a name with `aria-label`, the same as the button that opens it."
2915
+ ],
2916
+ "dont": [
2917
+ "Do not leave a link without a way to reach it on a phone.",
2918
+ "Do not keep the menu open after a page is chosen.",
2919
+ "Do not put a Button that opens a Modal in the menu. On a phone the menu closes when it is chosen, so the Modal has no Button to give focus back to. Link to a page instead.",
2920
+ "Do not name the button only by its icon. Name it 'Menu'.",
2921
+ "Do not use more than four section tabs, or long names. They will not fit on a phone."
2922
+ ],
2923
+ "native": "On iPhone use a `TabView` for the main places and a `NavigationStack` for the pages in a section. On Android use a navigation drawer.",
2924
+ "options": [
2925
+ {
2926
+ "id": "links",
2927
+ "title": "Links and actions in one menu",
2928
+ "useWhen": "A site has a few links and its actions, such as 'Log In'.",
2929
+ "source": "'use client';\nimport SiteHeader from 'oneslash-design-system/components/siteHeader';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport Button from 'oneslash-design-system/components/button';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\nconst links = [\n { label: 'Features', href: '#features', current: true },\n { label: 'Pricing', href: '#pricing' },\n { label: 'Docs', href: '#docs' },\n];\n\nexport default function MobileMenuLinks() {\n return (\n <>\n {/* Below md the Menu IconButton opens a Drawer: the links first, then 'Log In'. Choosing one closes it. 'Sign Up' stays in the bar. */}\n <SiteHeader\n brand={{ href: '#top', name: 'Acme' }}\n links={links}\n actions={<Button size=\"medium\" type=\"tertiary\" state=\"enabled\" label=\"Log In\" href=\"#log-in\" />}\n phoneAction={<Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Sign Up\" href=\"#sign-up\" />}\n mainId=\"mobile-menu-links-main\"\n />\n <PageShell id=\"mobile-menu-links-main\" tabIndex={-1}>\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Features</Heading>\n <Paragraph tone=\"secondary\" measure=\"none\">On a phone, open Menu to reach every page. It closes when you choose one.</Paragraph>\n </Stack>\n </PageShell>\n </>\n );\n}\n",
2930
+ "uses": [
2931
+ "Button",
2932
+ "Heading",
2933
+ "PageShell",
2934
+ "Paragraph",
2935
+ "SiteHeader",
2936
+ "Stack"
2937
+ ]
2938
+ },
2939
+ {
2940
+ "id": "sections",
2941
+ "title": "Sections with their pages",
2942
+ "useWhen": "A site has sections that each hold many pages, and the person picks a section first.",
2943
+ "source": "'use client';\nimport { useState } from 'react';\nimport Drawer from 'oneslash-design-system/components/drawer';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport TabsContainer from 'oneslash-design-system/components/tabsContainer';\nimport Tab from 'oneslash-design-system/components/tab';\nimport Navigation from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Page = { id: string; label: string };\ntype Section = { id: string; label: string; pages: Page[] };\n\n// Four sections, one short word each. A real site reads these from its navigation.\nconst sections: Section[] = [\n { id: 'start', label: 'Start', pages: [{ id: 'install', label: 'Install' }, { id: 'first-steps', label: 'First steps' }] },\n { id: 'guides', label: 'Guides', pages: [{ id: 'sharing', label: 'Share a folder' }, { id: 'roles', label: 'Roles and access' }, { id: 'billing', label: 'Billing' }] },\n { id: 'reference', label: 'API', pages: [{ id: 'api', label: 'Endpoints' }, { id: 'limits', label: 'Limits' }] },\n { id: 'updates', label: 'News', pages: [{ id: 'changelog', label: 'Changelog' }] },\n];\n\nconst drawerId = 'mobile-menu-sections-drawer';\n\nexport default function MobileMenuSections() {\n const [open, setOpen] = useState(false);\n const [pageId, setPageId] = useState('sharing');\n const currentSection = sections.find((s) => s.pages.some((p) => p.id === pageId)) ?? sections[0];\n // The tabs show the section of the current page each time the menu opens.\n const [sectionId, setSectionId] = useState(currentSection.id);\n const shown = sections.find((s) => s.id === sectionId) ?? sections[0];\n const page = currentSection.pages.find((p) => p.id === pageId) ?? currentSection.pages[0];\n\n function openMenu() {\n setSectionId(currentSection.id);\n setOpen(true);\n }\n\n return (\n <PageShell>\n <Stack gap=\"large\">\n <Cluster gap=\"small\">\n {/* A real site shows this IconButton only below md, where the links are not in the bar. */}\n <IconButton\n color=\"iconOnly\"\n state=\"enabled\"\n size=\"medium\"\n iconName=\"Menu\"\n ariaLabel=\"Menu\"\n aria-expanded={open}\n aria-controls={drawerId}\n onClick={openMenu}\n />\n <Paragraph size=\"body1\" measure=\"none\">Acme Docs</Paragraph>\n </Cluster>\n <Heading level={1} size=\"h5\">{page.label}</Heading>\n <Paragraph tone=\"secondary\" measure=\"none\">This page is in {currentSection.label}. Open Menu to move to another section.</Paragraph>\n </Stack>\n {/* Section tabs at the top, the section's pages under them, the current page marked. A choice closes the Drawer. */}\n <Drawer id={drawerId} isOpen={open} onClose={() => setOpen(false)} aria-label=\"Menu\" side=\"start\" size=\"small\" closeFrom=\"md\">\n <Stack gap=\"large\">\n <TabsContainer fill>\n {sections.map((s) => (\n <Tab key={s.id} label={s.label} size=\"small\" isSelected={s.id === shown.id} onClickTab={() => setSectionId(s.id)} />\n ))}\n </TabsContainer>\n <Navigation aria-label={`${shown.label} pages`}>\n {shown.pages.map((p) => (\n <MenuItem\n key={p.id}\n size=\"small\"\n label={p.label}\n href={`/${shown.id}/${p.id}`}\n isSelected={p.id === pageId}\n aria-current={p.id === pageId ? 'page' : undefined}\n onClick={(event: { preventDefault: () => void }) => {\n // A real app lets the link go to its page. The example keeps the choice in state.\n event.preventDefault();\n setPageId(p.id);\n setOpen(false);\n }}\n />\n ))}\n </Navigation>\n </Stack>\n </Drawer>\n </PageShell>\n );\n}\n",
2944
+ "uses": [
2945
+ "Cluster",
2946
+ "Drawer",
2947
+ "Heading",
2948
+ "IconButton",
2949
+ "MenuItem",
2950
+ "Navigation",
2951
+ "PageShell",
2952
+ "Paragraph",
2953
+ "Stack",
2954
+ "Tab",
2955
+ "TabsContainer"
2956
+ ]
2957
+ }
2958
+ ]
2959
+ },
2751
2960
  {
2752
2961
  "id": "not-found-page",
2753
2962
  "title": "Page not found",
@@ -2784,17 +2993,18 @@
2784
2993
  "id": "in-shell",
2785
2994
  "title": "Inside the shell",
2786
2995
  "useWhen": "The address is inside the app and the navigation still works.",
2787
- "source": "'use client';\nimport Image from 'oneslash-design-system/components/image';\nimport TabsContainer from 'oneslash-design-system/components/tabsContainer';\nimport Tab from 'oneslash-design-system/components/tab';\nimport Surface from 'oneslash-design-system/components/surface';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// The product's mark. A real app passes its own file.\nconst productMark =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' rx='10' fill='%232f6b4f'/%3E%3Cpath d='M20 9 31 31h-6l-5-11-5 11H9z' fill='%23fff'/%3E%3C/svg%3E\";\n\n// A real app passes the router from its framework, such as Next's useRouter().\nconst router = { push: (url: string) => console.info(`Go to ${url}`) };\n\nexport default function NotFoundPageInShell() {\n return (\n <Stack gap=\"large\">\n <Cluster gap=\"large\">\n <Image src={productMark} alt=\"Acme\" width={32} height={32} />\n <TabsContainer>\n <Tab label=\"Home\" isSelected={false} href=\"/\" router={router} onClickTab={() => {}} />\n <Tab label=\"Projects\" isSelected href=\"/projects\" router={router} onClickTab={() => {}} />\n <Tab label=\"Settings\" isSelected={false} href=\"/settings\" router={router} onClickTab={() => {}} />\n </TabsContainer>\n </Cluster>\n <Surface minHeight=\"tall\" align=\"center\">\n <Stack gap=\"xlarge\">\n <Stack gap=\"medium\">\n <Heading level={1} size=\"h5\">Page not found</Heading>\n <Paragraph tone=\"secondary\" measure=\"none\">The link may be wrong, or the page was moved or removed.</Paragraph>\n </Stack>\n <Cluster>\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Go Home\" href=\"/\" />\n </Cluster>\n </Stack>\n </Surface>\n </Stack>\n );\n}\n",
2996
+ "source": "'use client';\nimport { useState } from 'react';\nimport AppShell from 'oneslash-design-system/components/appShell';\nimport Navigation, { NavigationGroup } from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport Surface from 'oneslash-design-system/components/surface';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// The places, and the projects the person made. The page that failed or loads is the current one.\nconst places = [\n { label: 'Home', icon: 'House', href: '/' },\n { label: 'Settings', icon: 'Settings', href: '/settings' },\n];\nconst projects = [\n { label: 'Website', icon: 'Globe', href: '/projects/website' },\n { label: 'Mobile App', icon: 'Smartphone', href: '/projects/mobile-app' },\n];\nconst current = '/projects/website';\n\nconst row = (p: { label: string; icon: string; href: string }) => (\n <MenuItem\n key={p.href}\n size=\"small\"\n label={p.label}\n iconName={p.icon}\n href={p.href}\n isSelected={p.href === current}\n aria-current={p.href === current ? 'page' : undefined}\n // A real app lets the link go to its page.\n onClick={(event: { preventDefault: () => void }) => event.preventDefault()}\n />\n);\n\nconst sidebar = (\n <Navigation aria-label=\"Main\">\n <Paragraph size=\"body1\" measure=\"none\">Acme</Paragraph>\n {places.map(row)}\n <NavigationGroup label=\"Projects\">{projects.map(row)}</NavigationGroup>\n </Navigation>\n);\n\nexport default function NotFoundPageInShell() {\n // Below md the sidebar is a Drawer; this says whether it is open.\n const [navOpen, setNavOpen] = useState(false);\n return (\n <AppShell title=\"Website\" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar}>\n <Surface minHeight=\"tall\" align=\"center\">\n <Stack gap=\"xlarge\">\n <Stack gap=\"medium\">\n <Heading level={1} size=\"h5\">Page not found</Heading>\n <Paragraph tone=\"secondary\" measure=\"none\">The link may be wrong, or the page was moved or removed.</Paragraph>\n </Stack>\n <Cluster>\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Go Home\" href=\"/\" />\n </Cluster>\n </Stack>\n </Surface>\n </AppShell>\n );\n}\n",
2788
2997
  "uses": [
2998
+ "AppShell",
2789
2999
  "Button",
2790
3000
  "Cluster",
2791
3001
  "Heading",
2792
- "Image",
3002
+ "MenuItem",
3003
+ "Navigation",
3004
+ "NavigationGroup",
2793
3005
  "Paragraph",
2794
3006
  "Stack",
2795
- "Surface",
2796
- "Tab",
2797
- "TabsContainer"
3007
+ "Surface"
2798
3008
  ]
2799
3009
  }
2800
3010
  ]
@@ -2960,6 +3170,47 @@
2960
3170
  }
2961
3171
  ]
2962
3172
  },
3173
+ {
3174
+ "id": "on-this-page",
3175
+ "title": "On this page",
3176
+ "kind": "design",
3177
+ "level": "organism",
3178
+ "area": "shell",
3179
+ "situation": "A person reads a long page and wants to see its sections, jump to one and know which one they are in.",
3180
+ "do": [
3181
+ "Put `OnThisPage` in the `aside` of `PageShell`. It sticks below a `SiteHeader` and shows from `xl`. `PageShell` gives each level 2 and 3 heading with an `id` a scroll margin, so `#sharing` lands below the header.",
3182
+ "Build `items` from the headings of the page, in page order: the level 2 headings and the level 3 headings under them. Give each heading an `id`.",
3183
+ "Use it when the page has two items or more. With fewer it renders nothing.",
3184
+ "Keep the labels the same as the headings, in the same case.",
3185
+ "Name the nav 'On this page', which is the default, or pass an `aria-label` that fits the page.",
3186
+ "Let a click scroll the heading to just under the header and keep its item current until the scroll ends. With reduced motion it jumps.",
3187
+ "Keep the aside to the list. A phone does not show it, so the page must read in order without it. The sections are not places: on a phone the person scrolls to them."
3188
+ ],
3189
+ "dont": [
3190
+ "Do not take the arrow keys to jump between sections. They scroll the page and move the cursor in a field.",
3191
+ "Do not list a page with one section.",
3192
+ "Do not add the items by hand for a page whose headings change. Build them from the headings.",
3193
+ "Do not mark the current item with color only. The bar beside it moves too.",
3194
+ "Do not put a second contents list in the page."
3195
+ ],
3196
+ "native": "On Apple use a `ScrollViewReader` with a `Menu` or `List` of sections that scrolls to an id. On Android use a `LazyColumn` with a `scrollToItem` list.",
3197
+ "options": [
3198
+ {
3199
+ "id": "aside",
3200
+ "title": "List of sections beside the page",
3201
+ "useWhen": "The page has two or more level 2 or 3 headings, and people jump between them.",
3202
+ "source": "'use client';\nimport SiteHeader from 'oneslash-design-system/components/siteHeader';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport OnThisPage from 'oneslash-design-system/components/onThisPage';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\n// The page's level 2 and 3 headings, in page order. A real site builds this from the page.\nconst sections = [\n { id: 'on-this-page-overview', label: 'Overview', level: 2 as const, text: 'Acme keeps your files in folders that the whole team can open. Everyone sees the same files.' },\n { id: 'on-this-page-sharing', label: 'Sharing', level: 2 as const, text: 'Share a folder with a person or a team. Dana Lee can share any folder she owns.' },\n { id: 'on-this-page-links', label: 'Share by link', level: 3 as const, text: 'A link opens the folder for anyone who has it. Turn the link off to stop it.' },\n { id: 'on-this-page-people', label: 'Share with people', level: 3 as const, text: 'Choose people by name. Ben Carter and Omar Reyes can view or edit.' },\n { id: 'on-this-page-roles', label: 'Roles and access', level: 2 as const, text: 'Owners change who has access. Editors change files. Viewers read them.' },\n { id: 'on-this-page-limits', label: 'Limits', level: 2 as const, text: 'A free team holds up to 5 GB. Paid teams hold as much as they need.' },\n];\n\n// Filler for the example, so each section is long enough to scroll.\nconst more = 'A change shows for everyone at once, so there is one copy of each file to look after. Older versions stay for 30 days, and an owner can bring one back.';\n\nconst items = sections.map(({ id, label, level }) => ({ id, label, level }));\n\nexport default function OnThisPageAside() {\n return (\n <>\n <SiteHeader\n brand={{ href: '#top', name: 'Acme Docs' }}\n links={[{ label: 'Guides', href: '#guides', current: true }, { label: 'Reference', href: '#reference' }]}\n mainId=\"on-this-page-main\"\n />\n {/* The list sticks below the header from xl. Below xl the page reads in order without it. */}\n <PageShell id=\"on-this-page-main\" tabIndex={-1} aside={<OnThisPage items={items} />}>\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Share a folder</Heading>\n {sections.map((s) => (\n <Stack key={s.id} gap=\"medium\">\n <Heading level={s.level} size={s.level === 2 ? 'h6' : 'subtitle1'} id={s.id}>{s.label}</Heading>\n <Paragraph measure=\"none\">{s.text}</Paragraph>\n <Paragraph tone=\"secondary\" measure=\"none\">{more}</Paragraph>\n <Paragraph tone=\"secondary\" measure=\"none\">{more}</Paragraph>\n </Stack>\n ))}\n </Stack>\n </PageShell>\n </>\n );\n}\n",
3203
+ "uses": [
3204
+ "Heading",
3205
+ "OnThisPage",
3206
+ "PageShell",
3207
+ "Paragraph",
3208
+ "SiteHeader",
3209
+ "Stack"
3210
+ ]
3211
+ }
3212
+ ]
3213
+ },
2963
3214
  {
2964
3215
  "id": "overflow-menu",
2965
3216
  "title": "More menu",
@@ -3046,6 +3297,96 @@
3046
3297
  }
3047
3298
  ]
3048
3299
  },
3300
+ {
3301
+ "id": "page-header",
3302
+ "title": "Page header with actions",
3303
+ "kind": "design",
3304
+ "level": "organism",
3305
+ "area": "shell",
3306
+ "situation": "A page names itself at the top and offers what the person can do with it.",
3307
+ "do": [
3308
+ "Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'.",
3309
+ "Use `TitleBar` with the page's name as the level 1 heading. Inside `AppShell` the top bar names the place on a phone. When the page is the place, the two are the same.",
3310
+ "Give the page one primary Button, first in `actions`.",
3311
+ "Put icon buttons after it, each in a `Tooltip` and named for what they act on: 'Search Home page'.",
3312
+ "Put a More menu last, as the case 'More menu' says: an `IconButton` with `iconName=\"Ellipsis\"`, `aria-haspopup=\"menu\"` and a name such as 'More actions for Home page'.",
3313
+ "Pass `phoneActions` with the primary Button and More. Below `md` they replace `actions`.",
3314
+ "Fold the icon buttons you leave out into the More menu, in the same order, so every action is still there. Put them first, before a `Line`. Keep a frequent action, such as Search, as an icon button in `phoneActions`.",
3315
+ "Pass `back` on a sub-page, a tertiary Button named for the page it goes to: 'Back to Website'. Below `md` it takes its own line.",
3316
+ "Let a long title wrap. Never cut it short."
3317
+ ],
3318
+ "dont": [
3319
+ "Do not add a breadcrumb. Back goes one step up, and the title says where the person is.",
3320
+ "Do not show two primary Buttons.",
3321
+ "Do not name an icon button only by its icon, or More only by the word.",
3322
+ "Do not leave an action out on a phone without a way to reach it.",
3323
+ "Do not name the Back Button 'Back'. Name the page."
3324
+ ],
3325
+ "native": "On Apple use a navigation title with `.toolbar` items: the primary action as a `ToolbarItem`, the rest in a `Menu`. The system back button names the page before it. On Android use a top app bar with an overflow menu.",
3326
+ "options": [
3327
+ {
3328
+ "id": "actions",
3329
+ "title": "The page's own actions",
3330
+ "useWhen": "The page is a place of its own, and the person can add to it, search it or change it.",
3331
+ "source": "'use client';\nimport { useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport Button from 'oneslash-design-system/components/button';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport Popover from 'oneslash-design-system/components/popover';\nimport Menu from 'oneslash-design-system/components/menu';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport Line from 'oneslash-design-system/components/line';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\nexport default function PageHeaderActions() {\n const [anchor, setAnchor] = useState<HTMLElement | null>(null);\n // Which More button opened the menu: on a phone the menu also holds Search and Filter.\n const [from, setFrom] = useState<'wide' | 'phone'>('wide');\n const [open, setOpen] = useState(false);\n const [chosen, setChosen] = useState('');\n\n function openMore(kind: 'wide' | 'phone', el: HTMLElement) {\n setFrom(kind);\n setAnchor(el);\n setOpen((o) => !o);\n }\n\n // Every item closes the menu. Its Popover gives focus back to the More button.\n function choose(label: string) {\n setOpen(false);\n setChosen(label);\n }\n\n const newTask = <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"New Task\" decoIcon=\"Plus\" onClickButton={() => setChosen('New Task')} />;\n\n const more = (kind: 'wide' | 'phone') => (\n <Tooltip title=\"More\">\n <IconButton\n color=\"iconOnly\"\n state={open && from === kind ? 'selected' : 'enabled'}\n size=\"medium\"\n iconName=\"Ellipsis\"\n ariaLabel=\"More actions for Home page\"\n aria-haspopup=\"menu\"\n aria-expanded={open && from === kind}\n onClick={(e: { currentTarget: HTMLElement }) => openMore(kind, e.currentTarget)}\n />\n </Tooltip>\n );\n\n return (\n <PageShell>\n <Stack gap=\"large\">\n {/* The title is the page's level 1 heading. One primary Button, then icon buttons, then More last. Below md only the primary and More stay. */}\n <TitleBar\n title=\"Home page\"\n actions={\n <>\n {newTask}\n <Tooltip title=\"Search\">\n <IconButton color=\"iconOnly\" state=\"enabled\" size=\"medium\" iconName=\"Search\" ariaLabel=\"Search Home page\" onClick={() => setChosen('Search')} />\n </Tooltip>\n <Tooltip title=\"Filter\">\n <IconButton color=\"iconOnly\" state=\"enabled\" size=\"medium\" iconName=\"Filter\" ariaLabel=\"Filter Home page\" onClick={() => setChosen('Filter')} />\n </Tooltip>\n {more('wide')}\n </>\n }\n phoneActions={\n <>\n {newTask}\n {more('phone')}\n </>\n }\n />\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">{chosen ? `You chose ${chosen}.` : '12 tasks are open. Updated 2 days ago by Dana Lee.'}</Paragraph>\n </Stack>\n <Popover open={open} anchorEl={anchor} onClose={() => setOpen(false)} returnFocus>\n <Menu navigable aria-label=\"Actions for Home page\" width={200}>\n {from === 'phone' && (\n <>\n <MenuItem size=\"small\" iconName=\"Search\" label=\"Search\" onClick={() => choose('Search')} />\n <MenuItem size=\"small\" iconName=\"Filter\" label=\"Filter\" onClick={() => choose('Filter')} />\n <Line />\n </>\n )}\n <MenuItem size=\"small\" iconName=\"Pencil\" label=\"Rename\" onClick={() => choose('Rename')} />\n <MenuItem size=\"small\" iconName=\"Copy\" label=\"Duplicate\" onClick={() => choose('Duplicate')} />\n <MenuItem size=\"small\" iconName=\"Archive\" label=\"Archive\" onClick={() => choose('Archive')} />\n </Menu>\n </Popover>\n </PageShell>\n );\n}\n",
3332
+ "uses": [
3333
+ "Button",
3334
+ "IconButton",
3335
+ "Line",
3336
+ "Menu",
3337
+ "MenuItem",
3338
+ "PageShell",
3339
+ "Paragraph",
3340
+ "Popover",
3341
+ "Stack",
3342
+ "TitleBar",
3343
+ "Tooltip"
3344
+ ]
3345
+ },
3346
+ {
3347
+ "id": "sub-page",
3348
+ "title": "A page one step down, with Back",
3349
+ "useWhen": "The page opens from another page, such as a task from its project.",
3350
+ "source": "'use client';\nimport { useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Button from 'oneslash-design-system/components/button';\nimport Navigation from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\nconst taskTitle = 'Move the sign-up form above the pricing table on the home page';\n\nexport default function PageHeaderSubPage() {\n // The task is a page one step down from the project's page.\n const [view, setView] = useState<'task' | 'project'>('task');\n const [done, setDone] = useState(false);\n\n if (view === 'project') {\n return (\n <PageShell>\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Website</Heading>\n <Navigation aria-label=\"Tasks\">\n <MenuItem\n size=\"medium\"\n label={taskTitle}\n secondLabel={done ? 'Done' : 'Open'}\n iconRight=\"ChevronRight\"\n href=\"/website/tasks/sign-up-form\"\n onClick={(event: { preventDefault: () => void }) => {\n // A real app lets the link go to the task's page. The example keeps the choice in state.\n event.preventDefault();\n setView('task');\n }}\n />\n </Navigation>\n </Stack>\n </PageShell>\n );\n }\n\n return (\n <PageShell>\n <Stack gap=\"large\">\n {/* Back names the page it goes to. Below md it takes its own line above the title, and a long title wraps. */}\n <TitleBar\n title={taskTitle}\n back={<Button size=\"small\" type=\"tertiary\" state=\"enabled\" decoIcon=\"ChevronLeft\" label=\"Back to Website\" onClickButton={() => setView('project')} />}\n actions={<Button size=\"medium\" type=\"primary\" state={done ? 'disabled' : 'enabled'} label=\"Mark Done\" onClickButton={() => setDone(true)} />}\n />\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">{done ? 'Done. Marked by Dana Lee.' : 'Assigned to Ben Carter. Due on Friday.'}</Paragraph>\n </Stack>\n </PageShell>\n );\n}\n",
3351
+ "uses": [
3352
+ "Button",
3353
+ "Heading",
3354
+ "MenuItem",
3355
+ "Navigation",
3356
+ "PageShell",
3357
+ "Paragraph",
3358
+ "Stack",
3359
+ "TitleBar"
3360
+ ]
3361
+ }
3362
+ ]
3363
+ },
3364
+ {
3365
+ "id": "phone-navigation",
3366
+ "title": "On a phone, a sidebar opens as a drawer and a list opens its detail",
3367
+ "kind": "rule",
3368
+ "level": "rule",
3369
+ "area": "shell",
3370
+ "situation": "A layout with a sidebar, a list beside its detail, or a side pane meets a phone screen.",
3371
+ "answer": "An app's sidebar opens in a `Drawer` from the start side, from a 'Menu' `IconButton` at the start of a top bar that names the place. `AppShell` does this. The Drawer closes on a choice, on Close, on Escape, on the scrim and when the window widens. A list beside its detail becomes two screens: the list, then the detail with a Back Button named for the list, as `SettingsLayout` does. A settings nav is such a list. A side pane takes the whole content area and has Close. It is never squeezed beside the content. A site's links go into the same kind of menu, and one main action may stay in the bar. Nothing is hidden on a phone without a way to reach it. There is no bottom tab bar on the web.",
3372
+ "why": "A drawer opens over the page, so the person still sees where they are, and closing it puts them back on the same page. One drawer, built into `AppShell`, works the same way in every app.",
3373
+ "do": [
3374
+ "Open the sidebar in a `Drawer` from the start side, from a 'Menu' `IconButton` at the start of a top bar that names the place. Use `AppShell`.",
3375
+ "Close the drawer on a choice, Close, Escape, the scrim and when the window widens past `md`.",
3376
+ "Turn a list beside its detail into two screens on a phone: the list first, then the detail with a Back Button named for the list.",
3377
+ "Let a side pane take the whole content area on a phone, with a Close button.",
3378
+ "Put a site's links in the same kind of menu, and keep at most one main action in the bar.",
3379
+ "Give every place a way to be reached on a phone, even one that is only a link."
3380
+ ],
3381
+ "dont": [
3382
+ "Do not hide a link on a phone without a menu that holds it.",
3383
+ "Do not show a sidebar beside the page on a phone, or squeeze a side pane beside the content.",
3384
+ "Do not replace the page with the app's sidebar. Open the drawer over it. A settings nav is a list beside its detail, so it is the first screen on a phone.",
3385
+ "Do not add a bottom tab bar on the web.",
3386
+ "Do not leave a drawer that Escape and a tap outside cannot close."
3387
+ ],
3388
+ "native": "On iPhone use a `TabView` or a `NavigationStack` that pushes the detail with the system back button, and a `.sheet` for a short task. On Android use a navigation drawer or a bottom bar, and push the detail with the system back."
3389
+ },
3049
3390
  {
3050
3391
  "id": "profile-form",
3051
3392
  "title": "Profile",
@@ -3428,15 +3769,15 @@
3428
3769
  "id": "region",
3429
3770
  "title": "In one pane",
3430
3771
  "useWhen": "The shell shows and one pane loads.",
3431
- "source": "'use client';\nimport Image from 'oneslash-design-system/components/image';\nimport TabsContainer from 'oneslash-design-system/components/tabsContainer';\nimport Tab from 'oneslash-design-system/components/tab';\nimport Surface from 'oneslash-design-system/components/surface';\nimport LoadingScreen from 'oneslash-design-system/components/loadingScreen';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// The product's mark. A real app passes its own file.\nconst productMark =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' rx='10' fill='%232f6b4f'/%3E%3Cpath d='M20 9 31 31h-6l-5-11-5 11H9z' fill='%23fff'/%3E%3C/svg%3E\";\n\n// A real app passes the router from its framework, such as Next's useRouter().\nconst router = { push: (url: string) => console.info(`Go to ${url}`) };\n\nexport default function RouteLoadingRegion() {\n return (\n <Stack gap=\"large\">\n <Cluster gap=\"large\">\n <Image src={productMark} alt=\"Acme\" width={32} height={32} />\n <TabsContainer>\n <Tab label=\"Home\" isSelected={false} href=\"/\" router={router} onClickTab={() => {}} />\n <Tab label=\"Projects\" isSelected href=\"/projects\" router={router} onClickTab={() => {}} />\n <Tab label=\"Settings\" isSelected={false} href=\"/settings\" router={router} onClickTab={() => {}} />\n </TabsContainer>\n </Cluster>\n <Surface minHeight=\"tall\" align=\"center\">\n <LoadingScreen />\n </Surface>\n </Stack>\n );\n}\n",
3772
+ "source": "'use client';\nimport { useState } from 'react';\nimport AppShell from 'oneslash-design-system/components/appShell';\nimport Navigation, { NavigationGroup } from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Surface from 'oneslash-design-system/components/surface';\nimport LoadingScreen from 'oneslash-design-system/components/loadingScreen';\n\n// The places, and the projects the person made. The page that failed or loads is the current one.\nconst places = [\n { label: 'Home', icon: 'House', href: '/' },\n { label: 'Settings', icon: 'Settings', href: '/settings' },\n];\nconst projects = [\n { label: 'Website', icon: 'Globe', href: '/projects/website' },\n { label: 'Mobile App', icon: 'Smartphone', href: '/projects/mobile-app' },\n];\nconst current = '/projects/website';\n\nconst row = (p: { label: string; icon: string; href: string }) => (\n <MenuItem\n key={p.href}\n size=\"small\"\n label={p.label}\n iconName={p.icon}\n href={p.href}\n isSelected={p.href === current}\n aria-current={p.href === current ? 'page' : undefined}\n // A real app lets the link go to its page.\n onClick={(event: { preventDefault: () => void }) => event.preventDefault()}\n />\n);\n\nconst sidebar = (\n <Navigation aria-label=\"Main\">\n <Paragraph size=\"body1\" measure=\"none\">Acme</Paragraph>\n {places.map(row)}\n <NavigationGroup label=\"Projects\">{projects.map(row)}</NavigationGroup>\n </Navigation>\n);\n\nexport default function RouteLoadingRegion() {\n // Below md the sidebar is a Drawer; this says whether it is open.\n const [navOpen, setNavOpen] = useState(false);\n return (\n <AppShell title=\"Website\" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar}>\n <Surface minHeight=\"tall\" align=\"center\">\n <LoadingScreen />\n </Surface>\n </AppShell>\n );\n}\n",
3432
3773
  "uses": [
3433
- "Cluster",
3434
- "Image",
3774
+ "AppShell",
3435
3775
  "LoadingScreen",
3436
- "Stack",
3437
- "Surface",
3438
- "Tab",
3439
- "TabsContainer"
3776
+ "MenuItem",
3777
+ "Navigation",
3778
+ "NavigationGroup",
3779
+ "Paragraph",
3780
+ "Surface"
3440
3781
  ]
3441
3782
  }
3442
3783
  ]
@@ -3655,6 +3996,134 @@
3655
3996
  ],
3656
3997
  "native": "On Apple use the system `Toggle` and `Picker` that save as they change, and a `Form` with one Save Button for a group of fields. On Android use a `Switch`."
3657
3998
  },
3999
+ {
4000
+ "id": "side-pane",
4001
+ "title": "Side pane",
4002
+ "kind": "design",
4003
+ "level": "organism",
4004
+ "area": "shell",
4005
+ "situation": "A person opens more about the page, such as its members, its history or a document, without leaving the page.",
4006
+ "do": [
4007
+ "Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail': on a phone a pane takes the whole content area.",
4008
+ "Put the pane in the `pane` of `AppShell`, as a `SidePane` with a `title` and `onClose`. Render it only while it is open.",
4009
+ "Open it from an `IconButton` with a name and `aria-expanded`, and give it `state=\"selected\"` while the pane is open.",
4010
+ "Show one pane at a time. Opening another replaces the first. Pressing the opener of the open pane calls `focus()` on the pane's ref instead of opening a second one.",
4011
+ "Let Close and Escape close the pane. Focus goes back to the opener.",
4012
+ "Open a pane only from the person's own action. It takes focus when it mounts.",
4013
+ "Make a pane resizable only when it holds a document: pass `width` and `onWidthChange`. The start edge then moves with the pointer and with the arrow keys.",
4014
+ "Use `Drawer side=\"end\"` with a `title` for a short task. On a phone it is a sheet from the bottom.",
4015
+ "Give a Drawer `initialFocus=\"body\"` when it holds a control, so focus lands on the control. Keep the Drawer open while its request runs.",
4016
+ "Show the result of a task in the page behind the Drawer, such as 'Assigned to Ben Carter.' Show no toast.",
4017
+ "Title a Drawer for its action in Title Case, as a Modal: 'Assign Task'. Title a pane that shows one thing with its name.",
4018
+ "Put 'Cancel' first and the action last, named with the title's verb: 'Assign Task' has an 'Assign' Button. If the request fails, keep the Drawer open and show an inline error Alert at its top, as the rule 'A form error shows next to the problem' says."
4019
+ ],
4020
+ "dont": [
4021
+ "Do not squeeze a pane beside the page on a phone.",
4022
+ "Do not open two panes at once.",
4023
+ "Do not open a pane when the page loads, or from a timer. It takes focus away from the person.",
4024
+ "Do not make a list of members resizable. Only a document needs room.",
4025
+ "Do not use a Drawer for something the person reads together with the page."
4026
+ ],
4027
+ "native": "On Apple use an inspector (`.inspector`) for a pane beside the page, and a `.sheet` with `presentationDetents` for a short task. On Android use a `ModalBottomSheet` for a short task.",
4028
+ "options": [
4029
+ {
4030
+ "id": "beside",
4031
+ "title": "Pane beside the page",
4032
+ "useWhen": "The person reads the pane and the page together, such as members, history or a document.",
4033
+ "source": "'use client';\nimport { useRef, useState } from 'react';\nimport AppShell from 'oneslash-design-system/components/appShell';\nimport SidePane, { type SidePaneHandle } from 'oneslash-design-system/components/sidePane';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport Navigation, { NavigationGroup } from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype PaneId = 'members' | 'brief';\n\nconst members = [\n { name: 'Dana Lee', role: 'Owner' },\n { name: 'Ben Carter', role: 'Editor' },\n { name: 'Omar Reyes', role: 'Editor' },\n];\n\nconst places = [\n { id: 'inbox', label: 'Inbox', icon: 'Inbox' },\n { id: 'tasks', label: 'Tasks', icon: 'ListChecks' },\n { id: 'files', label: 'Files', icon: 'Files' },\n];\n// The projects the person made\nconst projects = [\n { id: 'website', label: 'Website', icon: 'Globe' },\n { id: 'mobile-app', label: 'Mobile App', icon: 'Smartphone' },\n];\n\nexport default function SidePaneBeside() {\n const [navOpen, setNavOpen] = useState(false);\n const [placeId, setPlaceId] = useState('tasks');\n // One pane at a time. Opening another replaces it.\n const [open, setOpen] = useState<PaneId | null>(null);\n // Only the pane that holds a document can be resized.\n const [briefWidth, setBriefWidth] = useState(448);\n const pane = useRef<SidePaneHandle>(null);\n\n const place = [...places, ...projects].find((p) => p.id === placeId) ?? places[0];\n\n // Pressed again while its pane is open, the opener brings the pane forward instead of opening a second one.\n function opener(id: PaneId, label: string, icon: 'Users' | 'FileText') {\n return (\n <Tooltip title={label}>\n <IconButton\n color=\"iconOnly\"\n state={open === id ? 'selected' : 'enabled'}\n size=\"medium\"\n iconName={icon}\n ariaLabel={label}\n aria-expanded={open === id}\n onClick={() => (open === id ? pane.current?.focus() : setOpen(id))}\n />\n </Tooltip>\n );\n }\n\n const row = (p: { id: string; label: string; icon: string }) => (\n <MenuItem\n key={p.id}\n size=\"small\"\n label={p.label}\n iconName={p.icon}\n href={`/${p.id}`}\n isSelected={p.id === place.id}\n aria-current={p.id === place.id ? 'page' : undefined}\n onClick={(event: { preventDefault: () => void }) => {\n // A real app lets the link go to its page. The example keeps the choice in state.\n event.preventDefault();\n setPlaceId(p.id);\n }}\n />\n );\n\n const sidebar = (\n <Navigation aria-label=\"Main\">\n {places.map(row)}\n <NavigationGroup label=\"Projects\">{projects.map(row)}</NavigationGroup>\n </Navigation>\n );\n\n return (\n <AppShell\n title={place.label}\n navOpen={navOpen}\n onNavOpenChange={setNavOpen}\n sidebar={sidebar}\n pane={\n open && (\n <SidePane\n key={open}\n ref={pane}\n title={open === 'members' ? 'Members' : 'Brief'}\n onClose={() => setOpen(null)}\n width={open === 'brief' ? briefWidth : undefined}\n onWidthChange={open === 'brief' ? setBriefWidth : undefined}\n >\n {open === 'members' ? (\n <Stack gap=\"medium\">\n {members.map((m) => (\n <Cluster key={m.name}>\n <UserImage userHandle={m.name} decorative />\n <Paragraph size=\"body1\" measure=\"none\">{m.name}</Paragraph>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">{m.role}</Paragraph>\n </Cluster>\n ))}\n </Stack>\n ) : (\n <Stack gap=\"medium\">\n <Paragraph measure=\"none\">Acme ships the new home page on Friday. Omar Reyes owns the copy and Dana Lee the screens.</Paragraph>\n <Paragraph tone=\"secondary\" measure=\"none\">The pane stays beside the page, so the task and the brief are read together. Drag its edge, or use the arrow keys on it, to make it wider.</Paragraph>\n </Stack>\n )}\n </SidePane>\n )\n }\n >\n <Stack gap=\"large\">\n <TitleBar title=\"Launch plan\" actions={<>{opener('members', 'Members', 'Users')}{opener('brief', 'Brief', 'FileText')}</>} />\n <Paragraph tone=\"secondary\" measure=\"none\">Ben Carter is writing the announcement. Omar Reyes is waiting for the new screens.</Paragraph>\n </Stack>\n </AppShell>\n );\n}\n",
4034
+ "uses": [
4035
+ "AppShell",
4036
+ "Cluster",
4037
+ "IconButton",
4038
+ "MenuItem",
4039
+ "Navigation",
4040
+ "NavigationGroup",
4041
+ "Paragraph",
4042
+ "SidePane",
4043
+ "Stack",
4044
+ "TitleBar",
4045
+ "Tooltip",
4046
+ "UserImage"
4047
+ ]
4048
+ },
4049
+ {
4050
+ "id": "over",
4051
+ "title": "Drawer over the page",
4052
+ "useWhen": "The task is short and the page can be hidden for a moment, such as picking a person.",
4053
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Drawer from 'oneslash-design-system/components/drawer';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport RadioGroup from 'oneslash-design-system/components/radioGroup';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\nconst people = [\n { label: 'Dana Lee', value: 'dana' },\n { label: 'Ben Carter', value: 'ben' },\n { label: 'Omar Reyes', value: 'omar' },\n];\n\nexport default function SidePaneOver() {\n const [open, setOpen] = useState(false);\n // The person on the task, and the one picked in the sheet before Assign.\n const [assigned, setAssigned] = useState('');\n const [picked, setPicked] = useState('dana');\n const [saving, setSaving] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n\n // Stops the request if the example goes away before it ends.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n // Escape, the scrim, Close and Cancel all close it, except while the request runs.\n function close() {\n if (saving) return;\n setOpen(false);\n }\n\n function assign() {\n if (saving) return;\n setSaving(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setSaving(false);\n setAssigned(people.find((p) => p.value === picked)?.label ?? '');\n setOpen(false);\n }, 1200);\n }\n\n return (\n <PageShell>\n <Stack gap=\"large\">\n <TitleBar title=\"Launch plan\" actions={<Button size=\"medium\" type=\"secondary\" state=\"enabled\" label=\"Assign\" decoIcon=\"UserPlus\" onClickButton={() => setOpen(true)} />} />\n {/* The result shows here, where the person is looking, so there is no toast. */}\n <Paragraph tone=\"secondary\" measure=\"none\">{assigned ? `Assigned to ${assigned}.` : 'Nobody is assigned yet.'}</Paragraph>\n </Stack>\n <Drawer isOpen={open} onClose={close} side=\"end\" size=\"small\" title=\"Assign Task\" initialFocus=\"body\">\n <Stack gap=\"large\">\n <RadioGroup aria-label=\"Person\" options={people} selectedValue={picked} disabled={saving} onChange={setPicked} />\n <Cluster justify=\"end\">\n <Button size=\"small\" type=\"tertiary\" state={saving ? 'disabled' : 'enabled'} label=\"Cancel\" onClickButton={close} />\n <Button size=\"small\" type=\"primary\" state=\"enabled\" label=\"Assign\" loading={saving} onClickButton={assign} />\n </Cluster>\n </Stack>\n </Drawer>\n </PageShell>\n );\n}\n",
4054
+ "uses": [
4055
+ "Button",
4056
+ "Cluster",
4057
+ "Drawer",
4058
+ "PageShell",
4059
+ "Paragraph",
4060
+ "RadioGroup",
4061
+ "Stack",
4062
+ "TitleBar"
4063
+ ]
4064
+ }
4065
+ ]
4066
+ },
4067
+ {
4068
+ "id": "sidebar-nav",
4069
+ "title": "Sidebar with sections and counts",
4070
+ "kind": "design",
4071
+ "level": "organism",
4072
+ "area": "shell",
4073
+ "situation": "A person looks down the sidebar for a place, and for what has something new in it.",
4074
+ "do": [
4075
+ "Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'.",
4076
+ "Build it as a `Navigation` with `aria-label=\"Main\"`, and put the places in `NavigationGroup`s with a short `label`, such as 'Mail' and 'Tasks'.",
4077
+ "Make each place a `MenuItem` with an `href`. Mark the open one with `isSelected` and `aria-current=\"page\"`.",
4078
+ "Show the count of what has not been read, never a total, as a `tag` with `variant=\"textOnly\"`.",
4079
+ "Put the count in the row's name too: `aria-label=\"Inbox, 3 unread\"`. Start the name with the visible label.",
4080
+ "Show nothing at zero. Opening a place reads it, so its count goes away.",
4081
+ "Put 'New Task' at the top of its group, as a `MenuItem` with `role=\"button\"`. The new task opens at the top of the group.",
4082
+ "Make the row that holds the others a `MenuItem` with `role=\"button\"`, `aria-expanded` and a chevron in `iconRight`. Name it for the place: 'Acme'.",
4083
+ "Keep a place the person closed closed when they return. Save it for the person, such as in local storage or their profile.",
4084
+ "Show the sum of what is unread under a closed place on its own row, so nothing unread is out of sight.",
4085
+ "Show a place inside another with `level={2}` on its `MenuItem`, and keep its own icon.",
4086
+ "Give each 'New Task' a name that says where it goes: `aria-label=\"New task in Acme\"`. In a phone menu, close the menu in its `onClick`, since a button row does not close it."
4087
+ ],
4088
+ "dont": [
4089
+ "Do not show a total of everything, such as every task. A count is what needs the person.",
4090
+ "Do not show '0'. Leave the count out.",
4091
+ "Do not color a count red, even for a mention. A count is quiet text.",
4092
+ "Do not close a place with no sign of what is inside it. A closed place keeps its count.",
4093
+ "Do not close a place without `aria-expanded` on its row."
4094
+ ],
4095
+ "native": "On Apple use a sidebar `List` with `Section`s, a `.badge(count)` on each row, and a `DisclosureGroup` for places that hold places. On Android use a navigation drawer with a `Badge`.",
4096
+ "options": [
4097
+ {
4098
+ "id": "flat",
4099
+ "title": "One list in a few groups",
4100
+ "useWhen": "Each place is one row, and the places fall into a few groups.",
4101
+ "source": "'use client';\nimport { useState } from 'react';\nimport Navigation, { NavigationGroup } from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\ntype Place = { id: string; label: string; icon: string; group: string };\n\nconst initialPlaces: Place[] = [\n { id: 'inbox', label: 'Inbox', icon: 'Inbox', group: 'Mail' },\n { id: 'mentions', label: 'Mentions', icon: 'AtSign', group: 'Mail' },\n { id: 'sent', label: 'Sent', icon: 'Send', group: 'Mail' },\n { id: 'launch', label: 'Launch plan', icon: 'ListChecks', group: 'Tasks' },\n { id: 'review', label: 'Design review', icon: 'ListChecks', group: 'Tasks' },\n { id: 'pricing', label: 'Pricing page', icon: 'ListChecks', group: 'Tasks' },\n];\n\nconst groups = ['Mail', 'Tasks'];\n\n// What has not been read, by place. A place with none has no entry, and shows no count.\nconst initialUnread: Record<string, number> = { inbox: 3, mentions: 1, launch: 2 };\n\nexport default function SidebarNavFlat() {\n const [places, setPlaces] = useState(initialPlaces);\n const [currentId, setCurrentId] = useState('sent');\n const [unread, setUnread] = useState(initialUnread);\n const [created, setCreated] = useState(0);\n\n const current = places.find((p) => p.id === currentId) ?? places[0];\n\n // Opening a place reads it, so its count goes away.\n function open(id: string) {\n setCurrentId(id);\n setUnread((u) => ({ ...u, [id]: 0 }));\n }\n\n // The new task goes to the top of its group, and opens.\n function newTask() {\n const id = `new-${created + 1}`;\n setCreated(created + 1);\n setPlaces((all) => [{ id, label: `New task ${created + 1}`, icon: 'ListChecks', group: 'Tasks' }, ...all]);\n setCurrentId(id);\n }\n\n return (\n <Center>\n <Stack gap=\"large\">\n <Navigation aria-label=\"Main\">\n {groups.map((group) => (\n <NavigationGroup key={group} label={group}>\n {group === 'Tasks' && <MenuItem size=\"small\" iconName=\"Plus\" label=\"New Task\" role=\"button\" onClick={newTask} />}\n {places.filter((p) => p.group === group).map((p) => {\n const count = unread[p.id] ?? 0;\n return (\n <MenuItem\n key={p.id}\n size=\"small\"\n label={p.label}\n iconName={p.icon}\n href={`/${p.id}`}\n isSelected={p.id === current.id}\n aria-current={p.id === current.id ? 'page' : undefined}\n // A count is what has not been read, as quiet text. Nothing shows at zero, and the name says the count.\n tag={count > 0 ? { label: String(count), variant: 'textOnly' } : undefined}\n aria-label={count > 0 ? `${p.label}, ${count} unread` : undefined}\n onClick={(event: { preventDefault: () => void }) => {\n // A real app lets the link go to its page. The example keeps the choice in state.\n event.preventDefault();\n open(p.id);\n }}\n />\n );\n })}\n </NavigationGroup>\n ))}\n </Navigation>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">You are in {current.label}.</Paragraph>\n </Stack>\n </Center>\n );\n}\n",
4102
+ "uses": [
4103
+ "Center",
4104
+ "MenuItem",
4105
+ "Navigation",
4106
+ "NavigationGroup",
4107
+ "Paragraph",
4108
+ "Stack"
4109
+ ]
4110
+ },
4111
+ {
4112
+ "id": "nested",
4113
+ "title": "Places that hold places",
4114
+ "useWhen": "A place holds others, such as a workspace and its tasks, and the person wants to hide what they do not use.",
4115
+ "source": "'use client';\nimport { useEffect, useState } from 'react';\nimport Navigation, { NavigationGroup } from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\ntype Task = { id: string; label: string };\ntype Workspace = { id: string; name: string; tasks: Task[] };\n\nconst initialWorkspaces: Workspace[] = [\n {\n id: 'acme',\n name: 'Acme',\n tasks: [\n { id: 'launch', label: 'Launch plan' },\n { id: 'pricing', label: 'Pricing page' },\n ],\n },\n {\n id: 'studio',\n name: 'Side Studio',\n tasks: [\n { id: 'logo', label: 'New logo' },\n { id: 'site', label: 'Landing page' },\n ],\n },\n];\n\n// What has not been read, by place. A place with none has no entry, and shows no count.\nconst initialUnread: Record<string, number> = { pricing: 2, site: 1 };\n\nconst STORAGE_KEY = 'sidebar-nav-hidden-groups';\n\nexport default function SidebarNavNested() {\n const [workspaces, setWorkspaces] = useState(initialWorkspaces);\n const [currentId, setCurrentId] = useState('launch');\n const [unread, setUnread] = useState(initialUnread);\n const [created, setCreated] = useState(0);\n // The groups the person hid. They stay hidden when the person comes back, so a real app saves them per person.\n const [hiddenGroups, setHiddenGroups] = useState<string[]>([]);\n\n // Read after the first render, so the server and the browser start from the same page.\n useEffect(() => {\n try {\n const saved = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '[]');\n if (Array.isArray(saved)) setHiddenGroups(saved.filter((id) => typeof id === 'string'));\n } catch {\n // Storage can be blocked. The groups then start shown.\n }\n }, []);\n\n function toggleGroup(id: string) {\n const next = hiddenGroups.includes(id) ? hiddenGroups.filter((g) => g !== id) : [...hiddenGroups, id];\n setHiddenGroups(next);\n try {\n localStorage.setItem(STORAGE_KEY, JSON.stringify(next));\n } catch {\n // Storage can be blocked. The choice then lasts until the page closes.\n }\n }\n\n function open(id: string) {\n setCurrentId(id);\n setUnread((u) => ({ ...u, [id]: 0 }));\n }\n\n // The new task goes to the top of its group, and opens.\n function newTask(workspaceId: string) {\n const id = `new-${created + 1}`;\n setCreated(created + 1);\n setWorkspaces((all) => all.map((w) => (w.id === workspaceId ? { ...w, tasks: [{ id, label: `New task ${created + 1}` }, ...w.tasks] } : w)));\n setCurrentId(id);\n }\n\n const currentName = workspaces.flatMap((w) => w.tasks).find((t) => t.id === currentId)?.label ?? '';\n\n return (\n <Center>\n <Stack gap=\"large\">\n <Navigation aria-label=\"Main\">\n <NavigationGroup label=\"Workspaces\">\n {workspaces.map((w) => {\n const hidden = hiddenGroups.includes(w.id);\n // A closed place keeps its count, on its own row, so nothing unread is out of sight.\n const hiddenUnread = hidden ? w.tasks.reduce((sum, t) => sum + (unread[t.id] ?? 0), 0) : 0;\n return (\n <Stack key={w.id} gap=\"small\">\n {/* The row that holds the others shows or hides them. It keeps its name; aria-expanded says which. */}\n <MenuItem\n size=\"small\"\n label={w.name}\n iconName=\"Building2\"\n iconRight={hidden ? 'ChevronRight' : 'ChevronDown'}\n role=\"button\"\n aria-expanded={!hidden}\n // A closed place keeps its count here, and the name says it.\n tag={hiddenUnread > 0 ? { label: String(hiddenUnread), variant: 'textOnly' } : undefined}\n aria-label={hiddenUnread > 0 ? `${w.name}, ${hiddenUnread} unread` : undefined}\n onClick={() => toggleGroup(w.id)}\n />\n {/* Each workspace has its own New Task, so its name says which. In a phone menu, close the menu in this onClick. */}\n {!hidden && <MenuItem size=\"small\" level={2} iconName=\"Plus\" label=\"New Task\" aria-label={`New task in ${w.name}`} role=\"button\" onClick={() => newTask(w.id)} />}\n {!hidden && w.tasks.map((t) => (\n <MenuItem\n key={t.id}\n size=\"small\"\n label={t.label}\n level={2}\n iconName=\"ListChecks\"\n href={`/${w.id}/${t.id}`}\n isSelected={t.id === currentId}\n aria-current={t.id === currentId ? 'page' : undefined}\n tag={(unread[t.id] ?? 0) > 0 ? { label: String(unread[t.id]), variant: 'textOnly' } : undefined}\n aria-label={(unread[t.id] ?? 0) > 0 ? `${t.label}, ${unread[t.id]} unread` : undefined}\n onClick={(event: { preventDefault: () => void }) => {\n event.preventDefault();\n open(t.id);\n }}\n />\n ))}\n </Stack>\n );\n })}\n </NavigationGroup>\n </Navigation>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">You are in {currentName}.</Paragraph>\n </Stack>\n </Center>\n );\n}\n",
4116
+ "uses": [
4117
+ "Center",
4118
+ "MenuItem",
4119
+ "Navigation",
4120
+ "NavigationGroup",
4121
+ "Paragraph",
4122
+ "Stack"
4123
+ ]
4124
+ }
4125
+ ]
4126
+ },
3658
4127
  {
3659
4128
  "id": "sign-up-page",
3660
4129
  "title": "Sign-up page",
@@ -3751,6 +4220,121 @@
3751
4220
  }
3752
4221
  ]
3753
4222
  },
4223
+ {
4224
+ "id": "site-footer",
4225
+ "title": "Site footer",
4226
+ "kind": "design",
4227
+ "level": "organism",
4228
+ "area": "shell",
4229
+ "situation": "A person reaches the end of a site's page and looks for the pages that are not in the header, and who runs the site.",
4230
+ "do": [
4231
+ "Use `SiteFooter` at the end of the page, after `PageShell`. It is a `<footer>` with a `<nav aria-label=\"Footer\">`.",
4232
+ "Pass the brand, so the person can go home, and the links. Use `links` for a few and `columns` for many.",
4233
+ "Give each column a short `title`, such as 'Product', 'Company' and 'Legal'. A phone shows two columns across and a wide window up to four.",
4234
+ "Put the legal line last, in `legal`: the year and the name, and the license if there is one, such as '© 2026 Acme. Released under the MIT License.'",
4235
+ "Mark a link to another site with `external`. It opens in a new tab and the icon and the hidden words '(opens in a new tab)' say so.",
4236
+ "Keep the footer to links and the legal line. It holds every page the header leaves out, in plain words."
4237
+ ],
4238
+ "dont": [
4239
+ "Do not put a sales pitch, a heading or a Button in the footer. Use a call to action band above it.",
4240
+ "Do not open an external link in a new tab without saying so.",
4241
+ "Do not repeat a long sentence of the page in the footer.",
4242
+ "Do not hide a link on a phone. The columns sit two across.",
4243
+ "Do not put the legal line before the links."
4244
+ ],
4245
+ "native": "On Apple and Android an app has no footer. Put the links in a settings or an About screen, as a `List` of rows.",
4246
+ "options": [
4247
+ {
4248
+ "id": "simple",
4249
+ "title": "A row of links",
4250
+ "useWhen": "The site has a few links to show.",
4251
+ "source": "'use client';\nimport SiteFooter from 'oneslash-design-system/components/siteFooter';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\nconst links = [\n { label: 'Pricing', href: '#pricing' },\n { label: 'Changelog', href: '#changelog' },\n { label: 'Privacy', href: '#privacy' },\n { label: 'GitHub', href: 'https://github.com/acme/acme', external: true },\n];\n\nexport default function SiteFooterSimple() {\n return (\n <>\n {/* A real page puts its content in PageShell, then SiteFooter. Center keeps the footer in view here. */}\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Changelog</Heading>\n <Paragraph tone=\"secondary\" measure=\"none\">Version 2.4 adds shared folders. Ben Carter wrote the notes.</Paragraph>\n </Stack>\n </Center>\n {/* A few links in one row that wraps, then the legal line last. */}\n <SiteFooter\n brand={{ href: '#top', name: 'Acme' }}\n links={links}\n legal=\"© 2026 Acme. Released under the MIT License.\"\n />\n </>\n );\n}\n",
4252
+ "uses": [
4253
+ "Center",
4254
+ "Heading",
4255
+ "Paragraph",
4256
+ "SiteFooter",
4257
+ "Stack"
4258
+ ]
4259
+ },
4260
+ {
4261
+ "id": "columns",
4262
+ "title": "Links in groups",
4263
+ "useWhen": "The site has many links that fall into groups, such as product, company and legal.",
4264
+ "source": "'use client';\nimport SiteFooter from 'oneslash-design-system/components/siteFooter';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\nconst columns = [\n {\n title: 'Product',\n links: [\n { label: 'Features', href: '#features' },\n { label: 'Pricing', href: '#pricing' },\n { label: 'Changelog', href: '#changelog' },\n { label: 'Docs', href: '#docs' },\n ],\n },\n {\n title: 'Company',\n links: [\n { label: 'About', href: '#about' },\n { label: 'Blog', href: '#blog' },\n { label: 'Contact', href: '#contact' },\n ],\n },\n {\n title: 'Follow',\n links: [\n { label: 'GitHub', href: 'https://github.com/acme/acme', external: true },\n { label: 'Newsletter', href: 'https://acme.example/newsletter', external: true },\n ],\n },\n {\n title: 'Legal',\n links: [\n { label: 'Terms', href: '#terms' },\n { label: 'Privacy', href: '#privacy' },\n ],\n },\n];\n\nexport default function SiteFooterColumns() {\n return (\n <>\n {/* A real page puts its content in PageShell, then SiteFooter. Center keeps the footer in view here. */}\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">About Acme</Heading>\n <Paragraph tone=\"secondary\" measure=\"none\">Acme helps small teams share files and decide together.</Paragraph>\n </Stack>\n </Center>\n {/* Groups of links, two across on a phone and four across from md. The legal line is last. */}\n <SiteFooter\n brand={{ href: '#top', name: 'Acme' }}\n columns={columns}\n legal=\"© 2026 Acme. All rights reserved.\"\n />\n </>\n );\n}\n",
4265
+ "uses": [
4266
+ "Center",
4267
+ "Heading",
4268
+ "Paragraph",
4269
+ "SiteFooter",
4270
+ "Stack"
4271
+ ]
4272
+ }
4273
+ ]
4274
+ },
4275
+ {
4276
+ "id": "site-header",
4277
+ "title": "Site header",
4278
+ "kind": "design",
4279
+ "level": "organism",
4280
+ "area": "shell",
4281
+ "situation": "A site's pages name the site at the top and show the person where to go and what to do next.",
4282
+ "do": [
4283
+ "Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail': below `md` the links go into a menu and one main action stays in the bar.",
4284
+ "Use `SiteHeader` for a few pages. Pass the brand, at most five `links`, and mark the page the person is on with `current`.",
4285
+ "Pass what must stay in the bar on a phone as `phoneAction`. On a product site that is the main action, named 'Open App' or 'Sign Up'. It is last at every width. Do not repeat it in `actions`.",
4286
+ "Pass the secondary Buttons, such as 'Log In', as `actions`. They go into the menu on a phone.",
4287
+ "Give `PageShell` `id` and `tabIndex={-1}` to match `mainId`, so the 'Skip to content' link moves focus into the page.",
4288
+ "Give a site with sections one `TabsContainer` of `Tab`s with `href`, four sections or fewer and one short word each. Pass it as `nav` to `SiteHeader` with `links` empty: it is a second row of the bar at every width.",
4289
+ "Pass search and the theme menu as `phoneAction`, so they stay at the end of the bar on a phone. With no `links` and no `actions` there is no menu.",
4290
+ "Keep the section tabs in the bar, so no section is hidden. On a phone, put the pages of the open section in a menu, as the case 'Menu on a phone' shows in 'Sections with their pages'.",
4291
+ "Open the theme menu as the case 'Theme switcher' says, and name the search `IconButton` 'Search'."
4292
+ ],
4293
+ "dont": [
4294
+ "Do not show more than five links in the bar.",
4295
+ "Do not show two primary Buttons in the bar.",
4296
+ "Do not hide a link on a phone without a menu that holds it.",
4297
+ "Do not put a Button that opens a Modal in `actions`. On a phone the menu closes when it is chosen, so the Modal has no Button to give focus back to. Link to a page instead.",
4298
+ "Do not turn a product site's few pages into tabs. Use `links`. Tabs are for sections that each hold many pages."
4299
+ ],
4300
+ "native": "On Apple a site header has no counterpart: an app uses a `NavigationStack` with a navigation bar. On Android use a top app bar.",
4301
+ "options": [
4302
+ {
4303
+ "id": "links",
4304
+ "title": "Links and one main action",
4305
+ "useWhen": "A product site has a few pages and one main action, such as 'Sign Up'.",
4306
+ "source": "'use client';\nimport SiteHeader from 'oneslash-design-system/components/siteHeader';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport Button from 'oneslash-design-system/components/button';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\nconst links = [\n { label: 'Features', href: '#features' },\n { label: 'Pricing', href: '#pricing', current: true },\n { label: 'Changelog', href: '#changelog' },\n { label: 'Docs', href: '#docs' },\n];\n\nexport default function SiteHeaderLinks() {\n return (\n <>\n {/* From md the links are a row in the bar. Below md they and 'Log In' are in the Menu; Sign Up stays beside it. */}\n <SiteHeader\n brand={{ href: '#top', name: 'Acme' }}\n links={links}\n actions={<Button size=\"medium\" type=\"tertiary\" state=\"enabled\" label=\"Log In\" href=\"#log-in\" />}\n phoneAction={<Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Sign Up\" href=\"#sign-up\" />}\n mainId=\"site-header-main\"\n />\n {/* The skip link goes here: the id matches mainId, and tabIndex -1 lets focus move in. */}\n <PageShell id=\"site-header-main\" tabIndex={-1}>\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Pricing</Heading>\n <Paragraph tone=\"secondary\" measure=\"none\">Acme is free for up to three people. Add more people when your team grows.</Paragraph>\n </Stack>\n </PageShell>\n </>\n );\n}\n",
4307
+ "uses": [
4308
+ "Button",
4309
+ "Heading",
4310
+ "PageShell",
4311
+ "Paragraph",
4312
+ "SiteHeader",
4313
+ "Stack"
4314
+ ]
4315
+ },
4316
+ {
4317
+ "id": "sections",
4318
+ "title": "Sections with their own tabs",
4319
+ "useWhen": "A docs site has sections that each hold many pages.",
4320
+ "source": "'use client';\nimport { useState } from 'react';\nimport SiteHeader from 'oneslash-design-system/components/siteHeader';\nimport TabsContainer from 'oneslash-design-system/components/tabsContainer';\nimport Tab from 'oneslash-design-system/components/tab';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport Popover from 'oneslash-design-system/components/popover';\nimport Menu from 'oneslash-design-system/components/menu';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\ntype Mode = 'light' | 'dark' | 'system';\n\n// Four sections, one short word each. Each holds many pages.\nconst sections = [\n { id: 'start', label: 'Start', page: 'Start here' },\n { id: 'guides', label: 'Guides', page: 'Guides' },\n { id: 'reference', label: 'API', page: 'API reference' },\n { id: 'updates', label: 'News', page: 'News' },\n];\n\nconst modes: { value: Mode; label: string; icon: 'Sun' | 'Moon' | 'Monitor' }[] = [\n { value: 'light', label: 'Light', icon: 'Sun' },\n { value: 'dark', label: 'Dark', icon: 'Moon' },\n { value: 'system', label: 'System', icon: 'Monitor' },\n];\n\nexport default function SiteHeaderSections() {\n const [sectionId, setSectionId] = useState('guides');\n const [mode, setMode] = useState<Mode>('system');\n const [anchor, setAnchor] = useState<HTMLElement | null>(null);\n const [open, setOpen] = useState(false);\n const section = sections.find((s) => s.id === sectionId) ?? sections[0];\n const current = modes.find((m) => m.value === mode) ?? modes[2];\n // A real app passes the router from its framework, such as Next's useRouter(). Here it sets the open section.\n const router = { push: (url: string) => setSectionId(url.split('/').pop() ?? 'start') };\n\n return (\n <>\n {/* The brand, then search and the theme menu as `phoneAction`, so they stay in the bar at every width. The section Tabs are `nav`, a second row of the bar. */}\n <SiteHeader\n brand={{ href: '#top', name: 'Acme Docs' }}\n links={[]}\n phoneAction={\n <>\n <Tooltip title=\"Search\">\n <IconButton color=\"iconOnly\" state=\"enabled\" size=\"medium\" iconName=\"Search\" ariaLabel=\"Search\" />\n </Tooltip>\n <Tooltip title={`Theme: ${current.label}`}>\n <IconButton\n color=\"iconOnly\"\n state={open ? 'selected' : 'enabled'}\n size=\"medium\"\n iconName={current.icon}\n ariaLabel={`Theme: ${current.label}`}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n onClick={(e: { currentTarget: HTMLElement }) => {\n setAnchor(e.currentTarget);\n setOpen((o) => !o);\n }}\n />\n </Tooltip>\n </>\n }\n nav={\n <TabsContainer fill>\n {sections.map((s) => (\n <Tab key={s.id} label={s.label} href={`/${s.id}`} router={router} isSelected={s.id === section.id} onClickTab={() => setSectionId(s.id)} />\n ))}\n </TabsContainer>\n }\n mainId=\"site-header-sections-main\"\n />\n <PageShell id=\"site-header-sections-main\" tabIndex={-1}>\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">{section.page}</Heading>\n <Paragraph tone=\"secondary\" measure=\"none\">The pages in {section.label} are listed beside this page on a wide screen, and in the menu on a phone.</Paragraph>\n </Stack>\n </PageShell>\n <Popover open={open} anchorEl={anchor} onClose={() => setOpen(false)} returnFocus>\n <Menu navigable aria-label=\"Theme\" width={180}>\n {modes.map((m) => (\n <MenuItem\n key={m.value}\n size=\"small\"\n iconName={m.icon}\n label={m.label}\n isSelected={m.value === mode}\n role=\"menuitemradio\"\n onClick={() => { setMode(m.value); setOpen(false); }}\n />\n ))}\n </Menu>\n </Popover>\n </>\n );\n}\n",
4321
+ "uses": [
4322
+ "Heading",
4323
+ "IconButton",
4324
+ "Menu",
4325
+ "MenuItem",
4326
+ "PageShell",
4327
+ "Paragraph",
4328
+ "Popover",
4329
+ "SiteHeader",
4330
+ "Stack",
4331
+ "Tab",
4332
+ "TabsContainer",
4333
+ "Tooltip"
4334
+ ]
4335
+ }
4336
+ ]
4337
+ },
3754
4338
  {
3755
4339
  "id": "slash-command-list",
3756
4340
  "title": "Command list",
@@ -3886,6 +4470,69 @@
3886
4470
  }
3887
4471
  ]
3888
4472
  },
4473
+ {
4474
+ "id": "theme-switcher",
4475
+ "title": "Theme switcher",
4476
+ "kind": "design",
4477
+ "level": "organism",
4478
+ "area": "shell",
4479
+ "situation": "A person chooses between a light page, a dark page, or the one their device uses.",
4480
+ "do": [
4481
+ "Offer three choices, in this order: 'Light', 'Dark' and 'System'. 'System' follows the device and is the default.",
4482
+ "Name the menu's `IconButton` for the current choice, in sentence case: 'Theme: Dark'. Show the icon of the current choice: a sun, a moon or a monitor.",
4483
+ "Open a navigable menu: `<Popover returnFocus>` around `<Menu navigable aria-label=\"Theme\">`. Set `aria-haspopup=\"menu\"` and `aria-expanded` on the button, and `state=\"selected\"` while the menu is open.",
4484
+ "Give each item `role=\"menuitemradio\"` and `isSelected` on the current one, and close the menu on a choice.",
4485
+ "Use a `SegmentedControl` named 'Theme' with `width=\"fit\"` in a `SettingsSection` on a settings page. It saves in place and shows nothing, as the rule 'A setting saves in place, or with one Save Button' says.",
4486
+ "Change the page as soon as a choice is made. A choice kept on the device cannot fail, so show no message and no toast.",
4487
+ "Keep the choice on the device, such as in a cookie or local storage, and read it before the page paints, so the page never flashes the wrong theme.",
4488
+ "For 'System', set no class and follow `prefers-color-scheme`, and change the page when the device changes.",
4489
+ "Set the choice's class on `<html>`. The example keeps the choice in state, because it must not touch the document."
4490
+ ],
4491
+ "dont": [
4492
+ "Do not add a brand theme as a fourth choice. A brand theme is another setting.",
4493
+ "Do not name the button for the action, such as 'Dark mode'. Name it for what is on.",
4494
+ "Do not use a toggle that only flips between light and dark. It hides System.",
4495
+ "Do not mark the current choice with color only.",
4496
+ "Do not show both the menu and the segmented control on the same page.",
4497
+ "Do not save the theme to the person's account with this case. A save that can fail follows the rule 'A setting saves in place, or with one Save Button'."
4498
+ ],
4499
+ "native": "On Apple and Android follow the system appearance and offer no switcher. If the app has one, use a `Picker` of Light, Dark and System in settings.",
4500
+ "options": [
4501
+ {
4502
+ "id": "menu",
4503
+ "title": "Menu in the header",
4504
+ "useWhen": "The site has no settings page, or the person should reach the theme from every page.",
4505
+ "source": "'use client';\nimport { useState } from 'react';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport Popover from 'oneslash-design-system/components/popover';\nimport Menu from 'oneslash-design-system/components/menu';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Link from 'oneslash-design-system/components/link';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Mode = 'light' | 'dark' | 'system';\n\nconst modes: { value: Mode; label: string; icon: 'Sun' | 'Moon' | 'Monitor' }[] = [\n { value: 'light', label: 'Light', icon: 'Sun' },\n { value: 'dark', label: 'Dark', icon: 'Moon' },\n { value: 'system', label: 'System', icon: 'Monitor' },\n];\n\nexport default function ThemeSwitcherMenu() {\n // The example keeps the choice in state. A real app keeps it for the person and sets the `dark` class on <html>.\n const [mode, setMode] = useState<Mode>('system');\n const [anchor, setAnchor] = useState<HTMLElement | null>(null);\n const [open, setOpen] = useState(false);\n const current = modes.find((m) => m.value === mode) ?? modes[2];\n\n return (\n <PageShell>\n <Stack gap=\"large\">\n <Cluster justify=\"between\">\n <Link href=\"#top\" size=\"subtitle1\">Acme</Link>\n <Tooltip title={`Theme: ${current.label}`}>\n <IconButton\n color=\"iconOnly\"\n state={open ? 'selected' : 'enabled'}\n size=\"medium\"\n iconName={current.icon}\n ariaLabel={`Theme: ${current.label}`}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n onClick={(e: { currentTarget: HTMLElement }) => {\n setAnchor(e.currentTarget);\n setOpen((o) => !o);\n }}\n />\n </Tooltip>\n </Cluster>\n <Heading level={1} size=\"h5\">Welcome back, Dana</Heading>\n <Paragraph tone=\"secondary\" measure=\"none\">\n {mode === 'system' ? 'Acme follows your device.' : `Acme is set to ${mode}.`} In a real app the page changes now.\n </Paragraph>\n </Stack>\n <Popover open={open} anchorEl={anchor} onClose={() => setOpen(false)} returnFocus>\n <Menu navigable aria-label=\"Theme\" width={180}>\n {modes.map((m) => (\n <MenuItem\n key={m.value}\n size=\"small\"\n iconName={m.icon}\n label={m.label}\n isSelected={m.value === mode}\n role=\"menuitemradio\"\n onClick={() => { setMode(m.value); setOpen(false); }}\n />\n ))}\n </Menu>\n </Popover>\n </PageShell>\n );\n}\n",
4506
+ "uses": [
4507
+ "Cluster",
4508
+ "Heading",
4509
+ "IconButton",
4510
+ "Link",
4511
+ "Menu",
4512
+ "MenuItem",
4513
+ "PageShell",
4514
+ "Paragraph",
4515
+ "Popover",
4516
+ "Stack",
4517
+ "Tooltip"
4518
+ ]
4519
+ },
4520
+ {
4521
+ "id": "segmented",
4522
+ "title": "Segmented control on a settings page",
4523
+ "useWhen": "The choice is a setting among others, on a settings page.",
4524
+ "source": "'use client';\nimport { useState } from 'react';\nimport Heading from 'oneslash-design-system/components/heading';\nimport SettingsSection from 'oneslash-design-system/components/settingsSection';\nimport SegmentedControl from 'oneslash-design-system/components/segmentedControl';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\nconst options = [\n { value: 'light', label: 'Light' },\n { value: 'dark', label: 'Dark' },\n { value: 'system', label: 'System' },\n];\n\nexport default function ThemeSwitcherSegmented() {\n // The example keeps the choice in state. A real app keeps it for the person and sets the `dark` class on <html>.\n const [mode, setMode] = useState('system');\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Settings</Heading>\n <SettingsSection title=\"Appearance\" description=\"System follows your device.\">\n {/* Kept on the device, so it saves in place and shows nothing: the page changes at once. */}\n <Cluster>\n <SegmentedControl size=\"small\" width=\"fit\" aria-label=\"Theme\" options={options} value={mode} onChange={setMode} />\n </Cluster>\n </SettingsSection>\n </Stack>\n </Center>\n );\n}\n",
4525
+ "uses": [
4526
+ "Center",
4527
+ "Cluster",
4528
+ "Heading",
4529
+ "SegmentedControl",
4530
+ "SettingsSection",
4531
+ "Stack"
4532
+ ]
4533
+ }
4534
+ ]
4535
+ },
3889
4536
  {
3890
4537
  "id": "type-to-confirm",
3891
4538
  "title": "Type to confirm",