oneslash-design-system 2.21.0 → 2.23.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.
- package/README.md +1 -1
- package/dist/DESIGN.md +12 -1
- package/dist/cases/admin-inbox/split.jsx +22 -10
- package/dist/cases/admin-inbox.md +28 -23
- package/dist/cases/api-keys.md +1 -1
- package/dist/cases/app-shell/top-tabs.jsx +10 -4
- package/dist/cases/app-shell.md +13 -5
- package/dist/cases/breadcrumb/back-link.d.ts +1 -0
- package/dist/cases/breadcrumb/back-link.jsx +23 -0
- package/dist/cases/breadcrumb/trail.d.ts +1 -0
- package/dist/cases/breadcrumb/trail.jsx +28 -0
- package/dist/cases/breadcrumb.md +105 -0
- package/dist/cases/date-field/calendar.d.ts +1 -0
- package/dist/cases/date-field/calendar.jsx +80 -0
- package/dist/cases/date-field/typed.d.ts +1 -0
- package/dist/cases/date-field/typed.jsx +58 -0
- package/dist/cases/date-field.md +232 -0
- package/dist/cases/docs-component-page/reference.jsx +11 -1
- package/dist/cases/docs-component-page.md +19 -8
- package/dist/cases/file-upload/files.d.ts +1 -0
- package/dist/cases/file-upload/files.jsx +118 -0
- package/dist/cases/file-upload/picture.d.ts +1 -0
- package/dist/cases/file-upload/picture.jsx +50 -0
- package/dist/cases/file-upload.md +270 -0
- package/dist/cases/filter-menu.md +1 -1
- package/dist/cases/image-viewer/with-video.d.ts +1 -0
- package/dist/cases/image-viewer/with-video.jsx +42 -0
- package/dist/cases/image-viewer.md +72 -4
- package/dist/cases/master-detail/split.jsx +17 -10
- package/dist/cases/master-detail.md +26 -24
- package/dist/cases/message-reactions/picker.d.ts +1 -0
- package/dist/cases/message-reactions/picker.jsx +145 -0
- package/dist/cases/message-reactions/quick-pick.jsx +1 -1
- package/dist/cases/message-reactions.md +184 -3
- package/dist/cases/page-header.md +1 -1
- package/dist/cases/people-row/names.d.ts +1 -0
- package/dist/cases/people-row/names.jsx +20 -0
- package/dist/cases/people-row/stack.d.ts +1 -0
- package/dist/cases/people-row/stack.jsx +33 -0
- package/dist/cases/people-row.md +110 -0
- package/dist/cases/pricing-section/cards.jsx +3 -2
- package/dist/cases/pricing-section.md +4 -2
- package/dist/cases/profile-form/form.jsx +21 -10
- package/dist/cases/profile-form.md +38 -9
- package/dist/cases/settings-page/top-tabs.jsx +9 -6
- package/dist/cases/settings-page.md +13 -7
- package/dist/cases.json +312 -29
- package/dist/components/avatarStack.d.ts +22 -0
- package/dist/components/avatarStack.jsx +32 -0
- package/dist/components/breadcrumb.d.ts +12 -0
- package/dist/components/breadcrumb.jsx +24 -0
- package/dist/components/button.d.ts +2 -0
- package/dist/components/button.jsx +2 -2
- package/dist/components/calendar.d.ts +19 -0
- package/dist/components/calendar.jsx +126 -0
- package/dist/components/dateField.d.ts +35 -0
- package/dist/components/dateField.jsx +76 -0
- package/dist/components/dropZone.d.ts +53 -0
- package/dist/components/dropZone.jsx +136 -0
- package/dist/components/emojiPicker.d.ts +22 -0
- package/dist/components/emojiPicker.jsx +161 -0
- package/dist/components/itemList.d.ts +31 -0
- package/dist/components/itemList.jsx +81 -0
- package/dist/components/lightbox.d.ts +35 -8
- package/dist/components/lightbox.jsx +99 -23
- package/dist/components/menuItem.d.ts +1 -1
- package/dist/components/menuItem.jsx +4 -4
- package/dist/components/siteHeader.d.ts +13 -2
- package/dist/components/siteHeader.jsx +21 -12
- package/dist/components/tag.d.ts +6 -1
- package/dist/components/tag.jsx +10 -5
- package/dist/internal/date.d.ts +35 -0
- package/dist/internal/date.js +122 -0
- package/dist/internal/dropZone.d.ts +28 -0
- package/dist/internal/dropZone.js +42 -0
- package/dist/internal/emoji.d.ts +13 -0
- package/dist/internal/emoji.js +182 -0
- package/dist/internal/overlayStack.js +1 -1
- package/dist/internal/people.d.ts +1 -0
- package/dist/internal/people.js +12 -0
- package/dist/native-mapping.json +45 -3
- package/dist/stories/AvatarStack.stories.d.ts +7 -0
- package/dist/stories/AvatarStack.stories.jsx +46 -0
- package/dist/stories/Breadcrumb.stories.d.ts +7 -0
- package/dist/stories/Breadcrumb.stories.jsx +26 -0
- package/dist/stories/Button.stories.jsx +12 -8
- package/dist/stories/Calendar.stories.d.ts +6 -0
- package/dist/stories/Calendar.stories.jsx +15 -0
- package/dist/stories/Cases.generated.stories.d.ts +10 -0
- package/dist/stories/Cases.generated.stories.jsx +20 -0
- package/dist/stories/DateField.stories.d.ts +10 -0
- package/dist/stories/DateField.stories.jsx +132 -0
- package/dist/stories/DropZone.stories.d.ts +12 -0
- package/dist/stories/DropZone.stories.jsx +151 -0
- package/dist/stories/EmojiPicker.stories.d.ts +6 -0
- package/dist/stories/EmojiPicker.stories.jsx +92 -0
- package/dist/stories/ItemList.stories.d.ts +9 -0
- package/dist/stories/ItemList.stories.jsx +86 -0
- package/dist/stories/Lightbox.stories.d.ts +7 -0
- package/dist/stories/Lightbox.stories.jsx +88 -1
- package/dist/stories/MenuItem.stories.d.ts +1 -0
- package/dist/stories/MenuItem.stories.jsx +8 -0
- package/dist/stories/SiteHeader.stories.d.ts +4 -0
- package/dist/stories/SiteHeader.stories.jsx +89 -0
- package/package.json +3 -2
package/dist/cases.json
CHANGED
|
@@ -213,13 +213,12 @@
|
|
|
213
213
|
"id": "split",
|
|
214
214
|
"title": "List beside the message",
|
|
215
215
|
"useWhen": "Many messages arrive, and the owner works down them one after another.",
|
|
216
|
-
"source": "'use client';\nimport { useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport
|
|
216
|
+
"source": "'use client';\nimport { useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport ItemList from 'oneslash-design-system/components/itemList';\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 { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Message = { id: string; from: string; subject: string; date: string; body: string[]; read: boolean };\n\nconst first: Message[] = [\n { id: 'talk', from: 'Ben Carter', subject: 'A talk in January?', date: 'Nov 16, 2026', body: ['I saw your page about error messages. Do you give talks?', 'We are planning a day for our design team in January.'], read: false },\n { id: 'share', from: 'Omar Reyes', subject: 'Sharing the case study', date: 'Nov 15, 2026', body: ['Is the plan changes case study open to everyone?', 'I would like to share it with my team.'], read: false },\n { id: 'thanks', from: 'Maya Brooks', subject: 'Thank you for the reading list', date: 'Nov 14, 2026', body: ['I read the piece on poor connections twice.'], read: false },\n { id: 'password', from: 'Leo Park', subject: 'The case study password', date: 'Nov 12, 2026', body: ['Could you share the password for the case studies?', 'I would like to show it to my team.'], read: true },\n { id: 'hiring', from: 'Sara Idris', subject: 'We are hiring in the spring', date: 'Nov 10, 2026', body: ['We are hiring a designer in the spring. Would you like to talk?'], read: true },\n { id: 'newsletter', from: 'Noah Quinn', subject: 'Is there a newsletter?', date: 'Nov 9, 2026', body: ['Your design system notes helped our team.'], read: true },\n];\n\nexport default function AdminInboxSplit() {\n const [messages, setMessages] = useState(first);\n // One message is always open, the first at the start.\n const [openId, setOpenId] = useState(first[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 // A real app passes the router from its framework, such as Next's useRouter(), and reads the open message from its\n // address, so it can be shared and reloaded. Here both set the open message.\n const router = {\n push: (url: string) => setOpenId(url.split('/').pop() ?? first[0].id),\n replace: (url: string) => setOpenId(url.split('/').pop() ?? first[0].id),\n };\n\n const message = messages.find((m) => m.id === openId) ?? messages[0];\n const unread = messages.filter((m) => !m.read).length;\n\n function toggle(id: string) {\n setMessages((list) => list.map((m) => (m.id === id ? { ...m, read: !m.read } : m)));\n }\n\n // From md, Up and Down open the next message and focus follows. On a phone they move focus, and Enter opens.\n const list = (\n <ItemList\n id=\"admin-inbox-split\"\n aria-label=\"Messages\"\n items={messages.map((m) => ({\n id: m.id,\n label: m.from,\n secondLabel: m.subject,\n tag: m.read ? undefined : { label: 'Unread', color: 'info' },\n }))}\n selectedId={message.id}\n onSelect={(id, how) => {\n // A move with the arrows replaces the address, so Back leaves the list instead of stepping through every message.\n // With `href` rows, the link itself pushes on a click, so call only `replace`, on a keyboard move.\n if (how === 'keyboard') router.replace(`/admin/messages/${id}`);\n else router.push(`/admin/messages/${id}`);\n setShowDetail(true);\n }}\n />\n );\n\n return (\n <PageShell>\n <Stack gap=\"xlarge\">\n <PageHeader level={1} title=\"Messages\" lede={`${unread} of ${messages.length} unread`} />\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 Messages\" 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.date}</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=\"secondary\" state=\"enabled\" decoIcon=\"CircleCheck\" label={message.read ? 'Mark as Unread' : 'Mark as Read'} onClickButton={() => toggle(message.id)} />\n </Cluster>\n </SettingsLayout>\n </Stack>\n </PageShell>\n );\n}\n",
|
|
217
217
|
"uses": [
|
|
218
218
|
"Button",
|
|
219
219
|
"Cluster",
|
|
220
220
|
"Heading",
|
|
221
|
-
"
|
|
222
|
-
"Navigation",
|
|
221
|
+
"ItemList",
|
|
223
222
|
"PageHeader",
|
|
224
223
|
"PageShell",
|
|
225
224
|
"Paragraph",
|
|
@@ -715,7 +714,7 @@
|
|
|
715
714
|
"do": [
|
|
716
715
|
"List each key with its name, the start of the key in the mono face, when it was created and when it was last used. Say 'Never used' when it was not.",
|
|
717
716
|
"Show only a prefix of 14 characters in the list, with an ellipsis. Never show a whole key again once the Modal is closed.",
|
|
718
|
-
"Open a Modal titled 'Create Key' from a 'Create Key' Button, with
|
|
717
|
+
"Open a Modal titled 'Create Key' from a 'Create Key' Button, with 'Name', and 'Expires on' when keys can expire, as the case 'Date field' says. Then 'Cancel' and 'Create'.",
|
|
719
718
|
"Say under the name what to put in it: 'Say what will use it, such as CI pipeline.'",
|
|
720
719
|
"Keep the Modal open when the key is made, change its title to 'Key Created' and show the key in a `CopyField` with `reveal=\"once\"` and `mono`. The field says 'Copy it now. You will not see it again.'",
|
|
721
720
|
"Give the Modal one Button, 'Done'. Ignore Escape and a click outside while the key shows, so a stray click cannot lose it.",
|
|
@@ -821,7 +820,7 @@
|
|
|
821
820
|
"id": "top-tabs",
|
|
822
821
|
"title": "Tabs across the top",
|
|
823
822
|
"useWhen": "There are four places or fewer, all fixed, each with a short name that fits on a phone.",
|
|
824
|
-
"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={
|
|
823
|
+
"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 TabPanel from 'oneslash-design-system/components/tabPanel';\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 aria-label=\"Main\">\n {places.map((p) => (\n <Tab key={p.id} id={`app-shell-tab-${p.id}`} controls={`app-shell-panel-${p.id}`} label={p.label} href={`/${p.id}`} router={router} isSelected={p.id === place.id} onClickTab={() => setPlaceId(p.id)} />\n ))}\n </TabsContainer>\n {/* Every place is in the page. Only the open one shows. */}\n {places.map((p) => (\n <TabPanel key={p.id} id={`app-shell-panel-${p.id}`} labelledBy={`app-shell-tab-${p.id}`} selected={p.id === place.id}>\n <Stack gap=\"large\">\n <TitleBar title={p.page} actions={<Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"New Message\" decoIcon=\"Plus\" />} />\n <Paragraph tone=\"secondary\" measure=\"none\">{p.text}</Paragraph>\n </Stack>\n </TabPanel>\n ))}\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",
|
|
825
824
|
"uses": [
|
|
826
825
|
"Button",
|
|
827
826
|
"Center",
|
|
@@ -836,6 +835,7 @@
|
|
|
836
835
|
"Popover",
|
|
837
836
|
"Stack",
|
|
838
837
|
"Tab",
|
|
838
|
+
"TabPanel",
|
|
839
839
|
"TabsContainer",
|
|
840
840
|
"TitleBar",
|
|
841
841
|
"UserImage"
|
|
@@ -1069,6 +1069,61 @@
|
|
|
1069
1069
|
}
|
|
1070
1070
|
]
|
|
1071
1071
|
},
|
|
1072
|
+
{
|
|
1073
|
+
"id": "breadcrumb",
|
|
1074
|
+
"title": "Breadcrumb",
|
|
1075
|
+
"kind": "design",
|
|
1076
|
+
"level": "organism",
|
|
1077
|
+
"area": "content",
|
|
1078
|
+
"situation": "A page on a site sits under other pages, and the person needs to see where it is and go back up.",
|
|
1079
|
+
"do": [
|
|
1080
|
+
"Put `Breadcrumb` above the `PageHeader`, from the top level down to this page.",
|
|
1081
|
+
"Name each level by its page's title: 'Docs', 'Components', 'Code Block'.",
|
|
1082
|
+
"Put the current page last. It is not a link, and it is marked as the current page.",
|
|
1083
|
+
"Link every other level to its page.",
|
|
1084
|
+
"Use a tertiary `Button` with `decoIcon=\"ChevronLeft\"` and `href` for a page one level down, named for the index: 'Back to Blog'.",
|
|
1085
|
+
"Let a long trail wrap on a phone. Never cut a level short."
|
|
1086
|
+
],
|
|
1087
|
+
"dont": [
|
|
1088
|
+
"Do not put a breadcrumb in an app page. Follow the case 'Page header with actions': Back goes one step up.",
|
|
1089
|
+
"Do not repeat the page's title as a link in the trail. The last level is the page itself, as text.",
|
|
1090
|
+
"Do not show more than four levels. A trail that long says the site has too many levels.",
|
|
1091
|
+
"Do not name a level by its address or a code, such as 'docs' or 'cmp-12'.",
|
|
1092
|
+
"Do not use a breadcrumb for a page two levels deep. One link back to its index is enough."
|
|
1093
|
+
],
|
|
1094
|
+
"native": "On Apple the navigation stack and its back button do this job. On Android use the top app bar with Up.",
|
|
1095
|
+
"options": [
|
|
1096
|
+
{
|
|
1097
|
+
"id": "trail",
|
|
1098
|
+
"title": "A linked trail above the title",
|
|
1099
|
+
"useWhen": "The page is three or more levels deep, such as a page in a docs site or a help center.",
|
|
1100
|
+
"source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport Breadcrumb from 'oneslash-design-system/components/breadcrumb';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { PageSection, Stack } from 'oneslash-design-system/components/layout';\n\n// Each level is named by its page's title. The last is this page, so it is not a link.\nconst trail = [\n { label: 'Docs', href: '/docs' },\n { label: 'Components', href: '/docs/components' },\n { label: 'Code Block' },\n];\n\nexport default function BreadcrumbTrail() {\n return (\n <PageShell>\n <Stack gap=\"giant\">\n <Stack gap=\"large\">\n <Breadcrumb items={trail} />\n <PageHeader level={1} title=\"Code Block\" lede=\"Shows code in a mono face, with a Copy Button and an optional file name.\" />\n </Stack>\n <PageSection>\n <SectionIntro id=\"breadcrumb-use\" name=\"When to use it\">\n <Paragraph>Use it for a command or a file a person will copy. For a word of code inside a sentence, use inline code.</Paragraph>\n </SectionIntro>\n </PageSection>\n </Stack>\n </PageShell>\n );\n}\n",
|
|
1101
|
+
"uses": [
|
|
1102
|
+
"Breadcrumb",
|
|
1103
|
+
"PageHeader",
|
|
1104
|
+
"PageSection",
|
|
1105
|
+
"PageShell",
|
|
1106
|
+
"Paragraph",
|
|
1107
|
+
"SectionIntro",
|
|
1108
|
+
"Stack"
|
|
1109
|
+
]
|
|
1110
|
+
},
|
|
1111
|
+
{
|
|
1112
|
+
"id": "back-link",
|
|
1113
|
+
"title": "One link back to the index",
|
|
1114
|
+
"useWhen": "The page is two levels deep, one under its index, such as a post under the blog.",
|
|
1115
|
+
"source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport Button from 'oneslash-design-system/components/button';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\nexport default function BreadcrumbBackLink() {\n return (\n <PageShell>\n <Stack gap=\"giant\">\n <Stack gap=\"large\">\n {/* One level up: a link named for the index it goes to */}\n <Cluster>\n <Button size=\"small\" type=\"tertiary\" state=\"enabled\" decoIcon=\"ChevronLeft\" label=\"Back to Blog\" href=\"/blog\" />\n </Cluster>\n <PageHeader\n level={1}\n title=\"How task threads work\"\n lede=\"One piece of work and all of its talk, in one thread.\"\n facts={[{ label: 'Published', value: 'Nov 12, 2026' }]}\n />\n </Stack>\n <Stack gap=\"large\">\n <Paragraph>A task thread holds the messages, the files and the decisions for one piece of work. Anyone who opens the task sees all of it.</Paragraph>\n <Paragraph>When the work is done, the thread stays, so the reasons stay with it.</Paragraph>\n </Stack>\n </Stack>\n </PageShell>\n );\n}\n",
|
|
1116
|
+
"uses": [
|
|
1117
|
+
"Button",
|
|
1118
|
+
"Cluster",
|
|
1119
|
+
"PageHeader",
|
|
1120
|
+
"PageShell",
|
|
1121
|
+
"Paragraph",
|
|
1122
|
+
"Stack"
|
|
1123
|
+
]
|
|
1124
|
+
}
|
|
1125
|
+
]
|
|
1126
|
+
},
|
|
1072
1127
|
{
|
|
1073
1128
|
"id": "breakdown-list",
|
|
1074
1129
|
"title": "Breakdown of a total",
|
|
@@ -1966,6 +2021,72 @@
|
|
|
1966
2021
|
}
|
|
1967
2022
|
]
|
|
1968
2023
|
},
|
|
2024
|
+
{
|
|
2025
|
+
"id": "date-field",
|
|
2026
|
+
"title": "Date field",
|
|
2027
|
+
"kind": "design",
|
|
2028
|
+
"level": "organism",
|
|
2029
|
+
"area": "settings",
|
|
2030
|
+
"situation": "A person gives one day, such as when a token expires or their date of birth.",
|
|
2031
|
+
"do": [
|
|
2032
|
+
"Use `DateField`. The person types the date as MM/DD/YYYY, such as '11/16/2026', or picks it from the calendar.",
|
|
2033
|
+
"Store the value as an ISO day, such as '2026-11-16'. Write it in text as 'Nov 16, 2026'.",
|
|
2034
|
+
"Pass `min` or `max` as an ISO day when only some days can be chosen. Days outside them cannot be picked in the calendar.",
|
|
2035
|
+
"Let the field say why a date cannot be used: 'Choose Nov 16, 2026 or later.' for a day before `min`, and 'Choose Dec 31, 2026 or earlier.' for a day after `max`.",
|
|
2036
|
+
"Let the field say how to fix a date that is not real, such as '02/30/2026': 'Enter a real date as MM/DD/YYYY.' A two-digit year says 'Enter the year in four digits, like 2026.'",
|
|
2037
|
+
"Name the format in the helper text, and say what an empty field means: 'MM/DD/YYYY. Leave empty for no end date.'",
|
|
2038
|
+
"Pass `calendar={false}` for a date years away, such as a date of birth. Paging a calendar back 30 years takes too long.",
|
|
2039
|
+
"Read the second argument of `onChange`: `''` with `error: null` is an empty field, and `''` with an error is a date typed wrong. Do not submit while `error` is set. The field already shows why under itself.",
|
|
2040
|
+
"Treat an empty optional date as no date, such as no end date for a token.",
|
|
2041
|
+
"Show a problem from the form, such as a required date left empty, through `errorText`, as the rule 'A form error shows next to the problem' says: 'Enter your date of birth as MM/DD/YYYY.'",
|
|
2042
|
+
"Save a date in a group of fields with one Save Button, as the rule 'A setting saves in place, or with one Save Button' says.",
|
|
2043
|
+
"Put an expiry date in the create Modal of the case 'API keys', under 'Name'. The example shows the fields on a page to keep it short."
|
|
2044
|
+
],
|
|
2045
|
+
"dont": [
|
|
2046
|
+
"Do not ask for a date in three `Select`s for the month, the day and the year.",
|
|
2047
|
+
"Do not make the calendar the only way in. A person who knows the date types it.",
|
|
2048
|
+
"Do not use the browser's own date input. It looks different in each browser and cannot follow the theme.",
|
|
2049
|
+
"Do not show the stored ISO day to the person. Show '11/16/2026' in the field and 'Nov 16, 2026' in text.",
|
|
2050
|
+
"Do not build a date range from two `DateField`s in a filter. Use the presets of the case 'Filter menu'."
|
|
2051
|
+
],
|
|
2052
|
+
"native": "On Apple use a `DatePicker` with `.compact` style and a `ClosedRange` for the days that can be chosen; use `.wheel` for a date of birth. On Android use the Material date picker with text input on.",
|
|
2053
|
+
"options": [
|
|
2054
|
+
{
|
|
2055
|
+
"id": "calendar",
|
|
2056
|
+
"title": "Typed or picked from a calendar",
|
|
2057
|
+
"useWhen": "The date is near today and the person picks it, such as when a token expires.",
|
|
2058
|
+
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Form from 'oneslash-design-system/components/form';\nimport FormField from 'oneslash-design-system/components/formField';\nimport TextField from 'oneslash-design-system/components/textField';\nimport DateField from 'oneslash-design-system/components/dateField';\nimport CopyField from 'oneslash-design-system/components/copyField';\nimport Button from 'oneslash-design-system/components/button';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// In an app, these fields sit in the 'Create Key' Modal of the case 'API keys'.\n// \"Today\" in this example. A real app passes its own today as `min`, as 'YYYY-MM-DD'.\nconst today = '2026-11-16';\n// The token the server made. A real app gets it once, in the reply to the create request.\nconst madeToken = 'acme_tok_9Rk2vQ7mXa4LwT8cZp1Hd6Ns';\n\nconst months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n// '2026-12-16' as 'Dec 16, 2026', for the line under the new token\nfunction formatDay(day: string) {\n const [year, month, date] = day.split('-').map(Number);\n return `${months[month - 1]} ${date}, ${year}`;\n}\n\nexport default function DateFieldCalendar() {\n const [name, setName] = useState('');\n const [nameError, setNameError] = useState('');\n // The day as 'YYYY-MM-DD', or '' for no end date\n const [expires, setExpires] = useState('');\n // The field's own message for a date typed wrong. While it is set, the token is not created.\n const [expiresError, setExpiresError] = useState<string | null>(null);\n const [creating, setCreating] = useState(false);\n const [made, setMade] = useState<{ name: string; expires: string } | null>(null);\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 function handleCreate() {\n if (creating) return;\n setNameError(name.trim() ? '' : 'Enter a name for the token.');\n // A date typed wrong shows its message under the field. An empty date means no end date.\n if (!name.trim() || expiresError) return;\n setCreating(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setCreating(false);\n setMade({ name: name.trim(), expires });\n }, 1200);\n }\n\n function handleDone() {\n setMade(null);\n setName('');\n setExpires('');\n setExpiresError(null);\n }\n\n return (\n <Center width=\"form\">\n <Stack gap=\"large\">\n <Stack gap=\"small\">\n <Heading level={1} size=\"h5\">New access token</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">A token lets a script use Acme as you until the day it expires.</Paragraph>\n </Stack>\n {made ? (\n <Stack gap=\"large\">\n <CopyField id=\"date-field-token\" label={made.name} value={madeToken} mono reveal=\"once\" />\n <Paragraph size=\"body2\" measure=\"none\">{made.expires ? `Expires ${formatDay(made.expires)}.` : 'Never expires.'}</Paragraph>\n <Cluster>\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Done\" onClickButton={handleDone} />\n </Cluster>\n </Stack>\n ) : (\n <Form aria-label=\"New access token\" gap=\"large\" onSubmit={handleCreate}>\n <FormField id=\"date-field-name\" label=\"Name\" help=\"Say what will use it, such as Deploy script.\" error={nameError}>\n {(f) => (\n <TextField\n id={f.id}\n aria-describedby={f['aria-describedby']}\n aria-invalid={f['aria-invalid']}\n value={name}\n disabled={creating}\n autoComplete=\"off\"\n onChange={(e) => { setName(e.target.value); setNameError(''); }}\n />\n )}\n </FormField>\n {/* Typed as MM/DD/YYYY or picked from the calendar. A day before today says 'Choose Nov 16, 2026 or later.'\n The second argument of onChange tells an empty field (no error) from a date typed wrong. */}\n <DateField\n id=\"date-field-expires\"\n label=\"Expires on\"\n value={expires}\n onChange={(day, detail) => { setExpires(day); setExpiresError(detail.error); }}\n min={today}\n disabled={creating}\n helperText=\"MM/DD/YYYY. Leave empty for no end date.\"\n />\n <Cluster>\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Create Token\" htmlType=\"submit\" loading={creating} />\n </Cluster>\n </Form>\n )}\n </Stack>\n </Center>\n );\n}\n",
|
|
2059
|
+
"uses": [
|
|
2060
|
+
"Button",
|
|
2061
|
+
"Center",
|
|
2062
|
+
"Cluster",
|
|
2063
|
+
"CopyField",
|
|
2064
|
+
"DateField",
|
|
2065
|
+
"Form",
|
|
2066
|
+
"FormField",
|
|
2067
|
+
"Heading",
|
|
2068
|
+
"Paragraph",
|
|
2069
|
+
"Stack",
|
|
2070
|
+
"TextField"
|
|
2071
|
+
]
|
|
2072
|
+
},
|
|
2073
|
+
{
|
|
2074
|
+
"id": "typed",
|
|
2075
|
+
"title": "Typed only",
|
|
2076
|
+
"useWhen": "The date is far from today and the person knows it, such as a date of birth.",
|
|
2077
|
+
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Form from 'oneslash-design-system/components/form';\nimport DateField from 'oneslash-design-system/components/dateField';\nimport Button from 'oneslash-design-system/components/button';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// \"Today\" in this example. A real app passes its own today as `max`, as 'YYYY-MM-DD'.\nconst today = '2026-11-16';\n\nexport default function DateFieldTyped() {\n // The day as 'YYYY-MM-DD'\n const [saved, setSaved] = useState('1990-04-12');\n const [birth, setBirth] = useState('1990-04-12');\n // The field's own message for a date typed wrong or after today. While it is set, nothing is saved.\n const [birthError, setBirthError] = useState<string | null>(null);\n // The form's message for an empty field\n const [error, setError] = useState('');\n const [saving, setSaving] = useState(false);\n const [justSaved, setJustSaved] = useState(false);\n const timers = useRef<ReturnType<typeof setTimeout>[]>([]);\n const savedTimer = useRef<ReturnType<typeof setTimeout>>();\n\n // Stops the request and the 'Saved' if the example goes away before they end.\n useEffect(() => () => {\n timers.current.forEach(clearTimeout);\n clearTimeout(savedTimer.current);\n }, []);\n\n function handleSave() {\n if (saving || birthError) return;\n if (!birth) {\n setError('Enter your date of birth as MM/DD/YYYY.');\n return;\n }\n setError('');\n setSaving(true);\n // Stands in for the request to the server.\n timers.current.push(setTimeout(() => {\n setSaving(false);\n setSaved(birth);\n setJustSaved(true);\n clearTimeout(savedTimer.current);\n savedTimer.current = setTimeout(() => setJustSaved(false), 2000);\n }, 1200));\n }\n\n const changed = birth !== saved;\n\n return (\n <Center width=\"form\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Personal details</Heading>\n <Form aria-label=\"Personal details\" gap=\"large\" onSubmit={handleSave}>\n {/* Typed only: a date of birth is years away, where paging a calendar would take too long */}\n <DateField\n id=\"date-field-birth\"\n label=\"Date of birth\"\n value={birth}\n onChange={(day, detail) => { setBirth(day); setBirthError(detail.error); setJustSaved(false); setError(''); }}\n max={today}\n required\n calendar={false}\n disabled={saving}\n errorText={error || undefined}\n />\n <Cluster>\n <Button size=\"medium\" type=\"primary\" state={changed || saving ? 'enabled' : 'disabled'} label={justSaved ? 'Saved' : 'Save'} htmlType=\"submit\" loading={saving} />\n </Cluster>\n </Form>\n </Stack>\n </Center>\n );\n}\n",
|
|
2078
|
+
"uses": [
|
|
2079
|
+
"Button",
|
|
2080
|
+
"Center",
|
|
2081
|
+
"Cluster",
|
|
2082
|
+
"DateField",
|
|
2083
|
+
"Form",
|
|
2084
|
+
"Heading",
|
|
2085
|
+
"Stack"
|
|
2086
|
+
]
|
|
2087
|
+
}
|
|
2088
|
+
]
|
|
2089
|
+
},
|
|
1969
2090
|
{
|
|
1970
2091
|
"id": "device-login",
|
|
1971
2092
|
"title": "Device login",
|
|
@@ -2029,7 +2150,8 @@
|
|
|
2029
2150
|
"area": "content",
|
|
2030
2151
|
"situation": "A person opens the page of one part of a design system or a code library to see what it looks like, how to write it and what it takes.",
|
|
2031
2152
|
"do": [
|
|
2032
|
-
"Use `PageHeader` with `level={1}`: the part's name is the one level 1 heading, with
|
|
2153
|
+
"Use `PageHeader` with `level={1}`: the part's name is the one level 1 heading, with a `lede` of one sentence that says what it is for.",
|
|
2154
|
+
"Put a `Breadcrumb` above the title, as the case 'Breadcrumb' says. It names the part's group, so leave out the `eyebrow`.",
|
|
2033
2155
|
"Show the part live first, in a `Surface` with `align=\"center\"`, so a person sees it before reading about it.",
|
|
2034
2156
|
"Put the code of that same example in a `CodeBlock` with a `label` such as 'Tag example', so the Copy Button and the scroll region have a name.",
|
|
2035
2157
|
"Switch between the example and its code with `TabsContainer`, `Tab` and `TabPanel`: give each `Tab` an `id` and `controls`, and keep both panels in the page.",
|
|
@@ -2051,8 +2173,9 @@
|
|
|
2051
2173
|
"id": "reference",
|
|
2052
2174
|
"title": "A page that documents one part",
|
|
2053
2175
|
"useWhen": "Each part of a library has a page with an example, its code and its props.",
|
|
2054
|
-
"source": "'use client';\nimport { useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport OnThisPage from 'oneslash-design-system/components/onThisPage';\nimport Surface from 'oneslash-design-system/components/surface';\nimport TabsContainer from 'oneslash-design-system/components/tabsContainer';\nimport Tab from 'oneslash-design-system/components/tab';\nimport TabPanel from 'oneslash-design-system/components/tabPanel';\nimport CodeBlock from 'oneslash-design-system/components/codeBlock';\nimport TableContainer from 'oneslash-design-system/components/tableContainer';\nimport TableHeader from 'oneslash-design-system/components/tableHeader';\nimport TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';\nimport TableRow from 'oneslash-design-system/components/tableRow';\nimport TableCell from 'oneslash-design-system/components/tableCell';\nimport Tag from 'oneslash-design-system/components/tag';\nimport Heading from 'oneslash-design-system/components/heading';\nimport List from 'oneslash-design-system/components/list';\nimport { Grid, PageSection, Stack } from 'oneslash-design-system/components/layout';\n\n// One part, documented. A real site builds the props and the code from the part's own source.\nconst sections = [\n { id: 'docs-component-page-example', label: 'Example' },\n { id: 'docs-component-page-props', label: 'Props' },\n { id: 'docs-component-page-use', label: 'When to use it' },\n];\n\nconst code = `<Tag\n variant=\"contained\"\n size=\"medium\"\n color=\"success\"\n label=\"Paid\"\n/>`;\n\n// Prop, Type, Default, Description\nconst props = [\n { name: 'variant', type: \"'contained' | 'textOnly' | 'dot'\", initial: 'None, required', text: 'How it is drawn: a filled pill, text only, or a dot before the text.' },\n { name: 'size', type: \"'medium' | 'small' | 'tiny'\", initial: 'None, required', text: 'How large it is set.' },\n { name: 'state', type: \"'enabled' | 'selected'\", initial: \"'enabled'\", text: 'Selected draws the tag as chosen, such as an active filter.' },\n { name: 'label', type: 'ReactNode', initial: 'None, required', text: 'The words in the tag.' },\n];\n\nexport default function DocsComponentPageReference() {\n const [view, setView] = useState<'example' | 'code'>('example');\n return (\n <PageShell aside={<OnThisPage items={sections} />}>\n <Stack gap=\"giant\">\n <
|
|
2176
|
+
"source": "'use client';\nimport { useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport Breadcrumb from 'oneslash-design-system/components/breadcrumb';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport OnThisPage from 'oneslash-design-system/components/onThisPage';\nimport Surface from 'oneslash-design-system/components/surface';\nimport TabsContainer from 'oneslash-design-system/components/tabsContainer';\nimport Tab from 'oneslash-design-system/components/tab';\nimport TabPanel from 'oneslash-design-system/components/tabPanel';\nimport CodeBlock from 'oneslash-design-system/components/codeBlock';\nimport TableContainer from 'oneslash-design-system/components/tableContainer';\nimport TableHeader from 'oneslash-design-system/components/tableHeader';\nimport TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';\nimport TableRow from 'oneslash-design-system/components/tableRow';\nimport TableCell from 'oneslash-design-system/components/tableCell';\nimport Tag from 'oneslash-design-system/components/tag';\nimport Heading from 'oneslash-design-system/components/heading';\nimport List from 'oneslash-design-system/components/list';\nimport { Grid, PageSection, Stack } from 'oneslash-design-system/components/layout';\n\n// One part, documented. A real site builds the props and the code from the part's own source.\nconst sections = [\n { id: 'docs-component-page-example', label: 'Example' },\n { id: 'docs-component-page-props', label: 'Props' },\n { id: 'docs-component-page-use', label: 'When to use it' },\n];\n\nconst code = `<Tag\n variant=\"contained\"\n size=\"medium\"\n color=\"success\"\n label=\"Paid\"\n/>`;\n\n// The page's place, from the top level down. The last level is this page, so it is not a link.\nconst trail = [\n { label: 'Docs', href: '/docs' },\n { label: 'Components', href: '/docs/components' },\n { label: 'Tag' },\n];\n\n// Prop, Type, Default, Description\nconst props = [\n { name: 'variant', type: \"'contained' | 'textOnly' | 'dot'\", initial: 'None, required', text: 'How it is drawn: a filled pill, text only, or a dot before the text.' },\n { name: 'size', type: \"'medium' | 'small' | 'tiny'\", initial: 'None, required', text: 'How large it is set.' },\n { name: 'state', type: \"'enabled' | 'selected'\", initial: \"'enabled'\", text: 'Selected draws the tag as chosen, such as an active filter.' },\n { name: 'label', type: 'ReactNode', initial: 'None, required', text: 'The words in the tag.' },\n];\n\nexport default function DocsComponentPageReference() {\n const [view, setView] = useState<'example' | 'code'>('example');\n return (\n <PageShell aside={<OnThisPage items={sections} />}>\n <Stack gap=\"giant\">\n <Stack gap=\"large\">\n <Breadcrumb items={trail} />\n <PageHeader\n level={1}\n title=\"Tag\"\n lede=\"A short label that says what state something is in, such as Paid or Draft.\"\n />\n </Stack>\n <PageSection gap=\"xlarge\">\n <SectionIntro id=\"docs-component-page-example\" name=\"Example\" />\n <Stack gap=\"large\">\n {/* The tabs only switch what is shown. Both panels are in the server HTML. */}\n <TabsContainer aria-label=\"Example views\">\n <Tab id=\"docs-component-page-tab-example\" controls=\"docs-component-page-panel-example\" size=\"small\" label=\"Example\" isSelected={view === 'example'} onClickTab={() => setView('example')} />\n <Tab id=\"docs-component-page-tab-code\" controls=\"docs-component-page-panel-code\" size=\"small\" label=\"Code\" isSelected={view === 'code'} onClickTab={() => setView('code')} />\n </TabsContainer>\n <TabPanel id=\"docs-component-page-panel-example\" labelledBy=\"docs-component-page-tab-example\" selected={view === 'example'}>\n <Surface align=\"center\" minHeight=\"short\">\n <Tag variant=\"contained\" size=\"medium\" color=\"success\" label=\"Paid\" />\n </Surface>\n </TabPanel>\n <TabPanel id=\"docs-component-page-panel-code\" labelledBy=\"docs-component-page-tab-code\" selected={view === 'code'}>\n <CodeBlock id=\"docs-component-page-code\" label=\"Tag example\" language=\"TypeScript\" code={code} />\n </TabPanel>\n </Stack>\n </PageSection>\n <PageSection gap=\"xlarge\">\n <SectionIntro id=\"docs-component-page-props\" name=\"Props\" />\n {/* The name says which part's props these are. A wide table scrolls inside this region, not the page. */}\n <TableContainer aria-label=\"Tag props\" minWidth=\"720px\">\n <TableHeader>\n <TableRow>\n <TableHeaderCell width=\"120px\">Prop</TableHeaderCell>\n <TableHeaderCell width=\"260px\">Type</TableHeaderCell>\n <TableHeaderCell width=\"140px\">Default</TableHeaderCell>\n <TableHeaderCell>Description</TableHeaderCell>\n </TableRow>\n </TableHeader>\n {props.map((p) => (\n <TableRow key={p.name}>\n <TableCell width=\"120px\">{p.name}</TableCell>\n <TableCell width=\"260px\">{p.type}</TableCell>\n <TableCell width=\"140px\">{p.initial}</TableCell>\n <TableCell>{p.text}</TableCell>\n </TableRow>\n ))}\n </TableContainer>\n </PageSection>\n <PageSection gap=\"xlarge\">\n <SectionIntro id=\"docs-component-page-use\" name=\"When to use it\" />\n <Grid columns={2} gap=\"xxlarge\">\n <Stack gap=\"medium\">\n <Heading level={3} size=\"h6\">Do</Heading>\n <List marker=\"dot\" items={['Say the state in the words, and use the color to back it up.', 'Keep a tag to one or two words.']} />\n </Stack>\n <Stack gap=\"medium\">\n <Heading level={3} size=\"h6\">Don't</Heading>\n <List marker=\"dot\" items={['Do not use a tag as a button. Use a Button.', 'Do not rely on the color alone to say the state.']} />\n </Stack>\n </Grid>\n </PageSection>\n </Stack>\n </PageShell>\n );\n}\n",
|
|
2055
2177
|
"uses": [
|
|
2178
|
+
"Breadcrumb",
|
|
2056
2179
|
"CodeBlock",
|
|
2057
2180
|
"Grid",
|
|
2058
2181
|
"Heading",
|
|
@@ -2496,6 +2619,71 @@
|
|
|
2496
2619
|
}
|
|
2497
2620
|
]
|
|
2498
2621
|
},
|
|
2622
|
+
{
|
|
2623
|
+
"id": "file-upload",
|
|
2624
|
+
"title": "File upload",
|
|
2625
|
+
"kind": "design",
|
|
2626
|
+
"level": "organism",
|
|
2627
|
+
"area": "settings",
|
|
2628
|
+
"situation": "A person adds a file from their device, such as a new profile picture or the receipts for a report.",
|
|
2629
|
+
"do": [
|
|
2630
|
+
"Use `DropZone`. A person can drop a file on it or choose one with its Button, so it works with a keyboard, a screen reader and touch.",
|
|
2631
|
+
"Use `size=\"compact\"` around the picture for one picture, with `buttonLabel=\"Change Picture\"`. Use the large zone with `multiple` and `maxFiles` for a list.",
|
|
2632
|
+
"Say what is allowed in `hint`, with the size from `formatBytes`: 'JPG, PNG or WebP, up to 5 MB'.",
|
|
2633
|
+
"Pass `accept` and `maxBytes`. The zone checks each file and reports the ones that do not pass, each with a reason.",
|
|
2634
|
+
"Turn each reason into words under the zone, through `FormField`, as the rule 'A form error shows next to the problem' says: 'Choose a JPG, PNG or WebP picture.' and 'Choose a picture under 5 MB.'",
|
|
2635
|
+
"Name the file when several are added at once: 'Hotel invoice.docx is not a PDF, PNG or JPG file.'",
|
|
2636
|
+
"Pass the `FormField`'s `aria-describedby` and `aria-invalid` to the zone, and the same error words as `status`, so the error is read with the control.",
|
|
2637
|
+
"Save a picture as soon as it is chosen, as the rule 'A setting saves in place, or with one Save Button' says. Show `loading` on 'Change Picture' while it saves, by passing `loading` to the zone, and nothing when it works.",
|
|
2638
|
+
"Show each file in a list as a `FileChip` with its type, its size and a remove button: 'Remove Hotel receipt.pdf'.",
|
|
2639
|
+
"Keep the list to the limit the hint names, across every choice: 'Add up to 5 files.'",
|
|
2640
|
+
"Save a list with one Save Button. It is disabled while nothing changed, shows `loading` while it saves, and reads 'Saved' for 2 seconds."
|
|
2641
|
+
],
|
|
2642
|
+
"dont": [
|
|
2643
|
+
"Do not make dropping the only way to add a file.",
|
|
2644
|
+
"Do not show a file error in a toast. Show it under the zone.",
|
|
2645
|
+
"Do not change the Button's label while it saves, such as to 'Saving…'.",
|
|
2646
|
+
"Do not write a size by hand. Use `formatBytes`, and check against the same number of bytes it shows.",
|
|
2647
|
+
"Do not refuse a file without saying why."
|
|
2648
|
+
],
|
|
2649
|
+
"native": "On Apple use a `PhotosPicker` for a picture and `.fileImporter` for files, and take drops with `.dropDestination`. On Android use the photo picker and the system file picker.",
|
|
2650
|
+
"options": [
|
|
2651
|
+
{
|
|
2652
|
+
"id": "picture",
|
|
2653
|
+
"title": "One picture beside its preview",
|
|
2654
|
+
"useWhen": "One picture replaces the one shown, such as a profile picture.",
|
|
2655
|
+
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Heading from 'oneslash-design-system/components/heading';\nimport FormField from 'oneslash-design-system/components/formField';\nimport DropZone, { type FileRejection } from 'oneslash-design-system/components/dropZone';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport { formatBytes } from 'oneslash-design-system/components/formatNumber';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\n// A picture the person chose. A real app uploads the file and gets a URL back.\nconst chosenPicture =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' fill='%232f6b4f'/%3E%3Ccircle cx='32' cy='25' r='11' fill='%23fff'/%3E%3Cpath d='M10 64c2-15 11-22 22-22s20 7 22 22z' fill='%23fff'/%3E%3C/svg%3E\";\n\n// 5 MB as formatBytes counts it (base 1024), so the words and the check agree\nconst maxBytes = 5 * 1024 * 1024;\n\n// The zone reports a reason. The words are this page's, shown under the zone.\nfunction say(rejections: FileRejection[]) {\n const reason = rejections[0].reason;\n if (reason === 'type') return 'Choose a JPG, PNG or WebP picture.';\n if (reason === 'size') return `Choose a picture under ${formatBytes(maxBytes)}.`;\n return 'Choose one picture.';\n}\n\nexport default function FileUploadPicture() {\n const [picture, setPicture] = useState<string | undefined>(undefined);\n const [saving, setSaving] = useState(false);\n const [error, setError] = useState('');\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 // The picture is one control on its own, so it saves as soon as it is chosen. Nothing shows when it works.\n // A real app crops the picture to a square in its own code or on the server.\n function handleFiles() {\n setError('');\n setSaving(true);\n // Stands in for the upload.\n timer.current = setTimeout(() => {\n setSaving(false);\n setPicture(chosenPicture);\n }, 900);\n }\n\n return (\n <Center width=\"form\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Profile</Heading>\n <FormField id=\"file-upload-picture\" label=\"Picture\" error={error}>\n {(f) => (\n <DropZone\n id={f.id}\n size=\"compact\"\n label=\"Drop a picture here\"\n buttonLabel=\"Change Picture\"\n hint={`JPG, PNG or WebP, up to ${formatBytes(maxBytes)}`}\n accept={['image/jpeg', 'image/png', 'image/webp']}\n maxBytes={maxBytes}\n loading={saving}\n aria-describedby={f['aria-describedby']}\n aria-invalid={f['aria-invalid']}\n status={error || undefined}\n onFiles={handleFiles}\n onReject={(rejections) => setError(say(rejections))}\n >\n <UserImage userHandle=\"Dana Lee\" userImgUrl={picture} size={64} />\n </DropZone>\n )}\n </FormField>\n </Stack>\n </Center>\n );\n}\n",
|
|
2656
|
+
"uses": [
|
|
2657
|
+
"Center",
|
|
2658
|
+
"DropZone",
|
|
2659
|
+
"FormField",
|
|
2660
|
+
"Heading",
|
|
2661
|
+
"Stack",
|
|
2662
|
+
"UserImage",
|
|
2663
|
+
"formatBytes"
|
|
2664
|
+
]
|
|
2665
|
+
},
|
|
2666
|
+
{
|
|
2667
|
+
"id": "files",
|
|
2668
|
+
"title": "Files that join a list",
|
|
2669
|
+
"useWhen": "A few files are added to a list, such as attachments to a request.",
|
|
2670
|
+
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Form from 'oneslash-design-system/components/form';\nimport FormField from 'oneslash-design-system/components/formField';\nimport DropZone, { type FileRejection } from 'oneslash-design-system/components/dropZone';\nimport FileChip from 'oneslash-design-system/components/fileChip';\nimport Button from 'oneslash-design-system/components/button';\nimport { formatBytes } from 'oneslash-design-system/components/formatNumber';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Chosen = { id: string; name: string; size: number };\n\nconst maxFiles = 5;\n// 10 MB as formatBytes counts it (base 1024), so the words and the check agree\nconst maxBytes = 10 * 1024 * 1024;\n\n// Two receipts saved earlier. A real app loads them with the request.\nconst savedFiles: Chosen[] = [\n { id: 'f1', name: 'Hotel receipt.pdf', size: 248_000 },\n { id: 'f2', name: 'Taxi receipt.png', size: 1_820_000 },\n];\n\nconst kindOf = (name: string) => (name.split('.').pop() ?? '').toUpperCase();\n\n// The zone reports reasons. The words are this page's, one line per file, shown under the zone,\n// with the limit line when the same choice also had more files than the list has room for.\nfunction say(rejections: FileRejection[], limit: string) {\n return rejections\n .map((r) =>\n r.reason === 'type'\n ? `${r.name} is not a PDF, PNG or JPG file.`\n : r.reason === 'size'\n ? `${r.name} is over ${formatBytes(maxBytes)}.`\n : `Add up to ${maxFiles} files.`,\n )\n .concat(limit ? [limit] : [])\n .filter((line, i, all) => all.indexOf(line) === i)\n .join(' ');\n}\n\nexport default function FileUploadFiles() {\n const [files, setFiles] = useState<Chosen[]>(savedFiles);\n const [saved, setSaved] = useState<Chosen[]>(savedFiles);\n const [error, setError] = useState('');\n const [saving, setSaving] = useState(false);\n const [justSaved, setJustSaved] = useState(false);\n const timers = useRef<ReturnType<typeof setTimeout>[]>([]);\n const savedTimer = useRef<ReturnType<typeof setTimeout>>();\n // Gives each chosen file its own id, so two files with one name are two rows.\n const count = useRef(0);\n // The limit line from the choice being handled. The zone calls onFiles, then onReject, for one choice,\n // so onReject can keep it beside the reasons. It is cleared once that choice is done.\n const limitLine = useRef('');\n\n // Stops the request and the 'Saved' if the example goes away before they end.\n useEffect(() => () => {\n timers.current.forEach(clearTimeout);\n clearTimeout(savedTimer.current);\n }, []);\n\n // The list holds five at most. The zone checks one choice; the page checks the list.\n function handleFiles(chosen: File[]) {\n const room = maxFiles - files.length;\n const added = chosen.slice(0, Math.max(0, room)).map((file) => {\n count.current += 1;\n return { id: `new-${count.current}`, name: file.name, size: file.size };\n });\n setFiles((list) => [...list, ...added]);\n limitLine.current = chosen.length > room ? `Add up to ${maxFiles} files.` : '';\n Promise.resolve().then(() => { limitLine.current = ''; });\n setError(limitLine.current);\n setJustSaved(false);\n }\n\n function handleRemove(id: string) {\n if (saving) return;\n setFiles((list) => list.filter((f) => f.id !== id));\n setError('');\n setJustSaved(false);\n }\n\n // The list is a group with one Save Button: 'Saved' shows for 2 seconds, and the Button is disabled while nothing changed.\n function handleSave() {\n if (saving) return;\n setSaving(true);\n setError('');\n // Stands in for the upload and the request to the server.\n timers.current.push(setTimeout(() => {\n setSaving(false);\n setSaved(files);\n setJustSaved(true);\n clearTimeout(savedTimer.current);\n savedTimer.current = setTimeout(() => setJustSaved(false), 2000);\n }, 1200));\n }\n\n const changed = files.length !== saved.length || files.some((f, i) => f.id !== saved[i].id);\n\n return (\n <Center width=\"form\">\n <Stack gap=\"large\">\n <Stack gap=\"small\">\n <Heading level={1} size=\"h5\">Expense report</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">Add the receipts for your trip on Nov 12, 2026.</Paragraph>\n </Stack>\n <Form aria-label=\"Receipts\" gap=\"large\" onSubmit={handleSave}>\n <FormField id=\"file-upload-files\" label=\"Receipts\" error={error}>\n {(f) => (\n <DropZone\n id={f.id}\n label=\"Drop receipts here\"\n buttonLabel=\"Choose Files\"\n hint={`PDF, PNG or JPG, up to ${formatBytes(maxBytes)} each. Add up to ${maxFiles} files.`}\n accept={['application/pdf', 'image/png', 'image/jpeg']}\n maxBytes={maxBytes}\n multiple\n maxFiles={maxFiles}\n disabled={saving}\n aria-describedby={f['aria-describedby']}\n aria-invalid={f['aria-invalid']}\n status={error || undefined}\n onFiles={handleFiles}\n onReject={(rejections) => setError(say(rejections, limitLine.current))}\n />\n )}\n </FormField>\n {files.length > 0 && (\n <Stack gap=\"small\" align=\"start\">\n {files.map((file) => (\n <FileChip\n key={file.id}\n name={file.name}\n kind={kindOf(file.name)}\n meta={formatBytes(file.size)}\n onRemove={() => handleRemove(file.id)}\n />\n ))}\n </Stack>\n )}\n <Cluster>\n <Button size=\"medium\" type=\"primary\" state={changed || saving ? 'enabled' : 'disabled'} label={justSaved ? 'Saved' : 'Save'} htmlType=\"submit\" loading={saving} />\n </Cluster>\n </Form>\n </Stack>\n </Center>\n );\n}\n",
|
|
2671
|
+
"uses": [
|
|
2672
|
+
"Button",
|
|
2673
|
+
"Center",
|
|
2674
|
+
"Cluster",
|
|
2675
|
+
"DropZone",
|
|
2676
|
+
"FileChip",
|
|
2677
|
+
"Form",
|
|
2678
|
+
"FormField",
|
|
2679
|
+
"Heading",
|
|
2680
|
+
"Paragraph",
|
|
2681
|
+
"Stack",
|
|
2682
|
+
"formatBytes"
|
|
2683
|
+
]
|
|
2684
|
+
}
|
|
2685
|
+
]
|
|
2686
|
+
},
|
|
2499
2687
|
{
|
|
2500
2688
|
"id": "filter-menu",
|
|
2501
2689
|
"title": "Filter menu",
|
|
@@ -2519,7 +2707,7 @@
|
|
|
2519
2707
|
"Do not use a Tooltip as the only place that names the current filter.",
|
|
2520
2708
|
"Do not mark the current choice with color only.",
|
|
2521
2709
|
"Do not keep the menu open after a choice.",
|
|
2522
|
-
"Do not add a custom date range in a menu. ODS has no date picker
|
|
2710
|
+
"Do not add a custom date range in a menu. ODS has no date range picker.",
|
|
2523
2711
|
"Do not put a destructive item in a filter menu."
|
|
2524
2712
|
],
|
|
2525
2713
|
"native": "On Apple use a `Menu` with a `Picker` inside it, so the current choice gets a check mark. On Android use a dropdown menu with radio items.",
|
|
@@ -2666,21 +2854,24 @@
|
|
|
2666
2854
|
"Render one `Lightbox` for the page with the list of images, the `index`, `onIndexChange`, `isOpen` and `onClose`. Give it an `aria-label` that names the set, such as \"Pictures\".",
|
|
2667
2855
|
"Write alt text that says what the image shows, such as \"A laptop on a wooden desk, its screen blue\". It names the thumbnail and stands in for an image that fails to load.",
|
|
2668
2856
|
"Add a `caption` when the image needs words. The viewer shows it under the image and uses it as its title.",
|
|
2669
|
-
"Pass two or more images to get the arrows: the viewer shows 'Previous image'
|
|
2857
|
+
"Pass two or more images to get the arrows: the viewer shows 'Previous image' and 'Next image' ('Previous video' and 'Next video' when that item is a video) and '2 of 3' after the title. ArrowLeft, ArrowRight and a swipe step; the first and the last item stop there.",
|
|
2670
2858
|
"Pass a single image in a list too, so the page keeps one way to open an image. The viewer then shows no arrows and no count.",
|
|
2671
2859
|
"Let Escape, the backdrop and 'Close' close the viewer. Focus goes back to the thumbnail that opened it.",
|
|
2672
|
-
"Count on the viewer when an image fails to load: it shows 'This image could not be loaded.' with its alt text, and the arrows still work.",
|
|
2673
|
-
"Follow the case 'Attachments' for images that sit in a message."
|
|
2860
|
+
"Count on the viewer when an image or a video fails to load: it shows 'This image could not be loaded.' or 'This video could not be loaded.' with its alt text, and the arrows still work.",
|
|
2861
|
+
"Follow the case 'Attachments' for images that sit in a message.",
|
|
2862
|
+
"Give every video a captions file. The viewer shows the captions by default.",
|
|
2863
|
+
"Let the arrow keys seek a video while it has focus. The viewer steps with them from its buttons, and pauses a video when it steps away or closes."
|
|
2674
2864
|
],
|
|
2675
2865
|
"dont": [
|
|
2676
2866
|
"Do not open an image from a click on an `Image`. Use `LightboxThumbnail`, a button that a keyboard reaches.",
|
|
2677
2867
|
"Do not leave the alt text empty on a thumbnail, or write \"image\" or a file name.",
|
|
2678
2868
|
"Do not build a full-screen layer with a portal of your own. `Lightbox` is a dialog with a focus trap and the focus return.",
|
|
2679
2869
|
"Do not handle Escape or the arrow keys with a listener of your own. The viewer does.",
|
|
2680
|
-
"Do not use the viewer for
|
|
2870
|
+
"Do not use the viewer for a page that has one image and nothing to see larger.",
|
|
2871
|
+
"Do not start a video by itself or loop it.",
|
|
2681
2872
|
"Do not hide the arrows on a phone. A swipe is a second way to step, not the only one."
|
|
2682
2873
|
],
|
|
2683
|
-
"native": "On Apple use a `fullScreenCover` with a `TabView` in `page` style, and `accessibilityLabel` on each image. On Android use a full-screen dialog with a `HorizontalPager` and a content description on each image.",
|
|
2874
|
+
"native": "On Apple use a `fullScreenCover` with a `TabView` in `page` style, and `accessibilityLabel` on each image. On Android use a full-screen dialog with a `HorizontalPager` and a content description on each image. A video page uses the system player (`VideoPlayer`, or Media3 on Android) with its captions on, and does not start by itself.",
|
|
2684
2875
|
"options": [
|
|
2685
2876
|
{
|
|
2686
2877
|
"id": "gallery",
|
|
@@ -2710,6 +2901,20 @@
|
|
|
2710
2901
|
"Paragraph",
|
|
2711
2902
|
"SectionIntro"
|
|
2712
2903
|
]
|
|
2904
|
+
},
|
|
2905
|
+
{
|
|
2906
|
+
"id": "with-video",
|
|
2907
|
+
"title": "Images and a video",
|
|
2908
|
+
"useWhen": "A gallery that holds a short video, such as a clip from a walk or a screen recording.",
|
|
2909
|
+
"source": "'use client';\nimport { useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport Lightbox, { LightboxThumbnail, type LightboxItem } from 'oneslash-design-system/components/lightbox';\nimport { Grid, PageSection } from 'oneslash-design-system/components/layout';\n\n// Two drawings stand in for the photos, and a short clip with its captions for the screen recording.\n// A real page passes its own files.\nconst hillside =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 120'%3E%3Crect width='160' height='120' fill='%23dfe9f2'/%3E%3Ccircle cx='120' cy='32' r='14' fill='%23f2c46d'/%3E%3Cpath d='M0 90 50 60l40 22 30-18 40 24v32H0z' fill='%232f6b4f'/%3E%3C/svg%3E\";\nconst desk =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 120'%3E%3Crect width='160' height='120' fill='%23efe6da'/%3E%3Crect x='30' y='30' width='100' height='60' rx='6' fill='%23333d47'/%3E%3Crect x='38' y='38' width='84' height='44' rx='2' fill='%2389b4d9'/%3E%3Crect x='20' y='92' width='120' height='6' rx='3' fill='%238a6d4b'/%3E%3C/svg%3E\";\n// The poster is the clip's first frame. It shows before the video plays, and as its thumbnail.\nconst clipPoster =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 240'%3E%3Crect width='320' height='240' fill='%23dfe9f2'/%3E%3Ccircle cx='240' cy='64' r='28' fill='%23f2c46d'/%3E%3Cpath d='M0 180 100 120l80 44 60-36 80 48v64H0z' fill='%232f6b4f'/%3E%3Ccircle cx='20' cy='200' r='14' fill='%23e08a5b'/%3E%3C/svg%3E\";\n\nconst items: LightboxItem[] = [\n { src: hillside, alt: 'A green hillside under a pale sky with the sun on the right', caption: 'The hill behind the new office.' },\n {\n kind: 'video',\n src: '/media/hillside-ball.webm',\n poster: clipPoster,\n alt: 'A ball rolls along the foot of a green hillside',\n caption: 'A short clip from the first walk.',\n // Every video has a captions file. The viewer shows the captions by default.\n captions: { src: '/media/hillside-ball.vtt', srclang: 'en', label: 'English' },\n },\n { src: desk, alt: 'A laptop on a wooden desk, its screen blue', caption: 'A desk set up for the first day.' },\n];\n\nexport default function ImageViewerWithVideo() {\n const [open, setOpen] = useState(false);\n const [index, setIndex] = useState(0);\n return (\n <PageShell>\n <PageSection gap=\"xlarge\">\n <SectionIntro id=\"image-viewer-with-video-intro\" name=\"Pictures\" statement=\"The office, and a walk on the hill.\" />\n {/* An image's thumbnail is named 'Open image: <alt>', the video's 'Play video: <alt>'. The video never starts by itself. */}\n <Grid compact columns={3}>\n {items.map((item, i) => (\n <LightboxThumbnail\n key={item.alt}\n image={item}\n onOpen={() => {\n setIndex(i);\n setOpen(true);\n }}\n />\n ))}\n </Grid>\n </PageSection>\n <Lightbox images={items} index={index} onIndexChange={setIndex} isOpen={open} onClose={() => setOpen(false)} aria-label=\"Pictures\" />\n </PageShell>\n );\n}\n",
|
|
2910
|
+
"uses": [
|
|
2911
|
+
"Grid",
|
|
2912
|
+
"Lightbox",
|
|
2913
|
+
"LightboxThumbnail",
|
|
2914
|
+
"PageSection",
|
|
2915
|
+
"PageShell",
|
|
2916
|
+
"SectionIntro"
|
|
2917
|
+
]
|
|
2713
2918
|
}
|
|
2714
2919
|
]
|
|
2715
2920
|
},
|
|
@@ -3432,8 +3637,9 @@
|
|
|
3432
3637
|
"situation": "A person opens an item from a list, such as a message or a report, and reads or acts on it.",
|
|
3433
3638
|
"do": [
|
|
3434
3639
|
"Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'.",
|
|
3435
|
-
"Use `SettingsLayout` with `navWidth=\"wide\"` for
|
|
3436
|
-
"
|
|
3640
|
+
"Use `SettingsLayout` with `navWidth=\"wide\"` and an `ItemList` for the list. From `md`, Up and Down open the next item; on a phone they move focus and Enter opens.",
|
|
3641
|
+
"Give the open item an address that can be shared and reloaded, and pass its id to `ItemList` as `selectedId`. That marks its row as the current one.",
|
|
3642
|
+
"Replace the address on a move with the arrows, so Back leaves the list instead of stepping through every item.",
|
|
3437
3643
|
"Keep one item open at all times from `md` up, the first at the start.",
|
|
3438
3644
|
"Name the row with the sender or the title, and put the subject or the summary in `secondLabel`.",
|
|
3439
3645
|
"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`.",
|
|
@@ -3455,13 +3661,12 @@
|
|
|
3455
3661
|
"id": "split",
|
|
3456
3662
|
"title": "List beside the detail",
|
|
3457
3663
|
"useWhen": "The person works down the list, one item after another, such as an inbox.",
|
|
3458
|
-
"source": "'use client';\nimport { useState } from 'react';\nimport
|
|
3664
|
+
"source": "'use client';\nimport { useState } from 'react';\nimport ItemList from 'oneslash-design-system/components/itemList';\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 // A real app passes the router from its framework, such as Next's useRouter(), and reads the open message from its\n // address, so it can be shared and reloaded. Here both set the open message.\n const router = {\n push: (url: string) => setOpenId(url.split('/').pop() ?? messages[0].id),\n replace: (url: string) => setOpenId(url.split('/').pop() ?? messages[0].id),\n };\n\n const message = messages.find((m) => m.id === openId) ?? messages[0];\n\n // From md, Up and Down open the next message and focus follows. On a phone they move focus, and Enter opens.\n const list = (\n <ItemList\n id=\"master-detail-split\"\n aria-label=\"Messages\"\n items={messages.map((m) => ({ id: m.id, label: m.from, secondLabel: m.subject }))}\n selectedId={message.id}\n onSelect={(id, how) => {\n // A move with the arrows replaces the address, so Back leaves the list instead of stepping through every message.\n // With `href` rows, the link itself pushes on a click, so call only `replace`, on a keyboard move.\n if (how === 'keyboard') router.replace(`/inbox/${id}`);\n else router.push(`/inbox/${id}`);\n setShowDetail(true);\n }}\n />\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",
|
|
3459
3665
|
"uses": [
|
|
3460
3666
|
"Button",
|
|
3461
3667
|
"Cluster",
|
|
3462
3668
|
"Heading",
|
|
3463
|
-
"
|
|
3464
|
-
"Navigation",
|
|
3669
|
+
"ItemList",
|
|
3465
3670
|
"PageShell",
|
|
3466
3671
|
"Paragraph",
|
|
3467
3672
|
"SettingsLayout",
|
|
@@ -3937,7 +4142,8 @@
|
|
|
3937
4142
|
"Mark the emoji the person already used with an 'Added' tag. Picking it again removes it.",
|
|
3938
4143
|
"Close the quick pick when an emoji is picked. Focus goes back to the button that opened it.",
|
|
3939
4144
|
"Move focus to the 'Add reaction' button when the chip that had it disappears, because its count reached 0.",
|
|
3940
|
-
"
|
|
4145
|
+
"Use `quick-pick` when six emoji cover most reactions, and `picker` when people use many. Both name each emoji in words.",
|
|
4146
|
+
"Open the picker from 'Add reaction' in a `<Popover returnFocus>` around `EmojiPicker`. Pass the person's emoji as `selected`, so they show pressed. A pick adds or removes the reaction and closes the Popover."
|
|
3941
4147
|
],
|
|
3942
4148
|
"dont": [
|
|
3943
4149
|
"Do not show a chip with a count of 0.",
|
|
@@ -3945,7 +4151,7 @@
|
|
|
3945
4151
|
"Do not wait for the server before the count changes.",
|
|
3946
4152
|
"Do not open the quick pick on hover. Open it on a press."
|
|
3947
4153
|
],
|
|
3948
|
-
"native": "On Apple a reaction is added from the row's `contextMenu`, with Add Reaction.",
|
|
4154
|
+
"native": "On Apple a reaction is added from the row's `contextMenu`, with Add Reaction, offering a few presets. For any emoji, use the system emoji keyboard (Apple) or `EmojiPickerView` (Android).",
|
|
3949
4155
|
"options": [
|
|
3950
4156
|
{
|
|
3951
4157
|
"id": "chips",
|
|
@@ -3970,7 +4176,7 @@
|
|
|
3970
4176
|
"id": "quick-pick",
|
|
3971
4177
|
"title": "Quick pick",
|
|
3972
4178
|
"useWhen": "A person adds a reaction from the six emoji people use most.",
|
|
3973
|
-
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\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 Tag from 'oneslash-design-system/components/tag';\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 { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads this from the session.\nconst me = 'Dana Lee';\n\n// The six emoji people use most, each named in words
|
|
4179
|
+
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\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 Tag from 'oneslash-design-system/components/tag';\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 { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads this from the session.\nconst me = 'Dana Lee';\n\n// The six emoji people use most, each named in words.\nconst quickEmoji = [\n { emoji: '👍', name: 'Thumbs up' },\n { emoji: '❤️', name: 'Heart' },\n { emoji: '😂', name: 'Tears of joy' },\n { emoji: '🎉', name: 'Party popper' },\n { emoji: '👀', name: 'Eyes' },\n { emoji: '🚀', name: 'Rocket' },\n];\nconst emojiName = (emoji: string) => quickEmoji.find((q) => q.emoji === emoji)?.name ?? emoji;\n\ntype Reaction = { emoji: string; by: string[] };\ntype Row = { id: string; from: string; at: Date; text: string; reactions: Reaction[] };\n\nconst firstThread: Row[] = [\n {\n id: 'm1',\n from: 'Ben Carter',\n at: new Date('2025-01-15T11:40:00Z'),\n text: 'The pricing page is live.',\n reactions: [{ emoji: '👍', by: ['Omar Reyes', me] }],\n },\n { id: 'm2', from: 'Omar Reyes', at: new Date('2025-01-15T11:42:00Z'), text: 'Nice work. I will share it with the sales team.', reactions: [] },\n];\n\nconst firstName = (name: string) => name.split(' ')[0];\n\n// 'Omar and you': other people by first name, the person last.\nfunction whoReacted(by: string[]) {\n const names = [...by.filter((n) => n !== me).map(firstName), ...(by.includes(me) ? ['you'] : [])];\n if (names.length === 1) return names[0] === 'you' ? 'You' : names[0];\n return `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}`;\n}\n\n// 'Thumbs up, 3 reactions'. The chip's aria-pressed says whether the person reacted.\nfunction chipName(r: Reaction) {\n const count = `${r.by.length} ${r.by.length === 1 ? 'reaction' : 'reactions'}`;\n return `${emojiName(r.emoji)}, ${count}`;\n}\n\nexport default function MessageReactionsQuickPick() {\n const [thread, setThread] = useState(firstThread);\n // Each row's 'Add reaction' button by row id. When the chip that had focus goes away, focus goes there.\n const addButtons = useRef<Record<string, HTMLButtonElement | HTMLAnchorElement | null>>({});\n const focusAdd = useRef<string | null>(null);\n\n useEffect(() => {\n if (!focusAdd.current) return;\n addButtons.current[focusAdd.current]?.focus();\n focusAdd.current = null;\n });\n // The row whose quick pick is open, and the button it opens from. Both stay set while it fades out.\n const [pickRow, setPickRow] = useState<Row | null>(null);\n const [pickAnchor, setPickAnchor] = useState<HTMLElement | null>(null);\n const [pickOpen, setPickOpen] = useState(false);\n\n // The count changes at once. A real app sends the change to the server and puts it back if that fails.\n function toggle(rowId: string, emoji: string) {\n const row = thread.find((m) => m.id === rowId);\n const chip = row?.reactions.find((r) => r.emoji === emoji);\n // The person's reaction was the last one, so the chip goes away.\n if (chip && chip.by.length === 1 && chip.by[0] === me) focusAdd.current = rowId;\n setThread((rows) =>\n rows.map((m) => {\n if (m.id !== rowId) return m;\n const has = m.reactions.find((r) => r.emoji === emoji);\n const reactions = has\n ? m.reactions.map((r) =>\n r.emoji !== emoji ? r : { ...r, by: r.by.includes(me) ? r.by.filter((n) => n !== me) : [...r.by, me] },\n )\n : [...m.reactions, { emoji, by: [me] }];\n // A chip with no reactions left goes away.\n return { ...m, reactions: reactions.filter((r) => r.by.length > 0) };\n }),\n );\n }\n\n function openPick(m: Row, anchor: HTMLElement) {\n if (pickOpen && pickRow?.id === m.id) {\n setPickOpen(false);\n return;\n }\n setPickRow(m);\n setPickAnchor(anchor);\n setPickOpen(true);\n }\n\n // Escape, a click outside and a pick close it. Popover's returnFocus gives focus back to 'Add reaction'.\n function closePick() {\n setPickOpen(false);\n }\n\n function pick(emoji: string) {\n if (!pickRow) return;\n closePick();\n toggle(pickRow.id, emoji);\n }\n\n // The open row, read from the thread so the quick pick shows its reactions as they are now.\n const openRow = thread.find((m) => m.id === pickRow?.id);\n\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 {thread.map((m) => (\n <Message\n key={m.id}\n aria-label={m.from}\n avatar={<UserImage userHandle={m.from} decorative />}\n name={m.from}\n meta={<TimeStamp createdAt={m.at} dateFormat=\"absolute\" data=\"time\" />}\n footer={\n <Cluster gap=\"small\">\n {m.reactions.map((r) => (\n <Tooltip key={r.emoji} title={whoReacted(r.by)}>\n <Tag\n variant=\"contained\"\n size=\"small\"\n state={r.by.includes(me) ? 'selected' : 'enabled'}\n label={`${r.emoji} ${r.by.length}`}\n aria-label={chipName(r)}\n onClick={() => toggle(m.id, r.emoji)}\n />\n </Tooltip>\n ))}\n <Tooltip title=\"Add reaction\">\n <IconButton\n color=\"iconOnly\"\n state={pickOpen && pickRow?.id === m.id ? 'selected' : 'enabled'}\n size=\"small\"\n ref={(el) => { addButtons.current[m.id] = el; }}\n iconName=\"SmilePlus\"\n ariaLabel={`Add reaction to message from ${m.from}`}\n aria-haspopup=\"menu\"\n aria-expanded={pickOpen && pickRow?.id === m.id}\n onClick={(e: { currentTarget: HTMLElement }) => openPick(m, e.currentTarget)}\n />\n </Tooltip>\n </Cluster>\n }\n >\n <Paragraph measure=\"none\">{m.text}</Paragraph>\n </Message>\n ))}\n </Stack>\n </Stack>\n {/* A navigable Menu focuses its first item and takes the arrow keys, Home, End and letters. */}\n <Popover open={pickOpen} anchorEl={pickAnchor} onClose={closePick} returnFocus>\n <Menu navigable aria-label=\"Add reaction\" width={200}>\n {quickEmoji.map((q) => (\n <MenuItem\n key={q.emoji}\n size=\"small\"\n icon={q.emoji}\n label={q.name}\n // Picking an emoji the person already used removes it.\n tag={openRow?.reactions.some((r) => r.emoji === q.emoji && r.by.includes(me)) ? { label: 'Added', variant: 'textOnly' } : undefined}\n onClick={() => pick(q.emoji)}\n />\n ))}\n </Menu>\n </Popover>\n </Center>\n );\n}\n",
|
|
3974
4180
|
"uses": [
|
|
3975
4181
|
"Center",
|
|
3976
4182
|
"Cluster",
|
|
@@ -3987,6 +4193,27 @@
|
|
|
3987
4193
|
"Tooltip",
|
|
3988
4194
|
"UserImage"
|
|
3989
4195
|
]
|
|
4196
|
+
},
|
|
4197
|
+
{
|
|
4198
|
+
"id": "picker",
|
|
4199
|
+
"title": "Emoji picker",
|
|
4200
|
+
"useWhen": "People react with more than the usual six emoji.",
|
|
4201
|
+
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\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 Tag from 'oneslash-design-system/components/tag';\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 EmojiPicker from 'oneslash-design-system/components/emojiPicker';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads this from the session.\nconst me = 'Dana Lee';\n\n// Each reaction keeps the emoji's name in words, from the picker, for its chip's aria-label.\ntype Reaction = { emoji: string; name: string; by: string[] };\ntype Row = { id: string; from: string; at: Date; text: string; reactions: Reaction[] };\n\nconst firstThread: Row[] = [\n {\n id: 'm1',\n from: 'Ben Carter',\n at: new Date('2025-01-15T11:40:00Z'),\n text: 'The pricing page is live.',\n reactions: [\n { emoji: '👍', name: 'Thumbs up', by: ['Omar Reyes', me] },\n { emoji: '🙌', name: 'Raised hands', by: ['Omar Reyes'] },\n ],\n },\n { id: 'm2', from: 'Omar Reyes', at: new Date('2025-01-15T11:42:00Z'), text: 'Nice work. I will share it with the sales team.', reactions: [] },\n];\n\nconst firstName = (name: string) => name.split(' ')[0];\n\n// 'Omar and you': other people by first name, the person last.\nfunction whoReacted(by: string[]) {\n const names = [...by.filter((n) => n !== me).map(firstName), ...(by.includes(me) ? ['you'] : [])];\n if (names.length === 1) return names[0] === 'you' ? 'You' : names[0];\n return `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}`;\n}\n\n// 'Thumbs up, 3 reactions'. The chip's aria-pressed says whether the person reacted.\nfunction chipName(r: Reaction) {\n const count = `${r.by.length} ${r.by.length === 1 ? 'reaction' : 'reactions'}`;\n return `${r.name}, ${count}`;\n}\n\nexport default function MessageReactionsPicker() {\n const [thread, setThread] = useState(firstThread);\n // Each row's 'Add reaction' button by row id. When the chip that had focus goes away, focus goes there.\n const addButtons = useRef<Record<string, HTMLButtonElement | HTMLAnchorElement | null>>({});\n const focusAdd = useRef<string | null>(null);\n\n useEffect(() => {\n if (!focusAdd.current) return;\n addButtons.current[focusAdd.current]?.focus();\n focusAdd.current = null;\n });\n // The row whose picker is open, and the button it opens from. Both stay set while it fades out.\n const [pickRow, setPickRow] = useState<Row | null>(null);\n const [pickAnchor, setPickAnchor] = useState<HTMLElement | null>(null);\n const [pickOpen, setPickOpen] = useState(false);\n\n // The count changes at once. A real app sends the change to the server and puts it back if that fails.\n function toggle(rowId: string, emoji: string, name: string) {\n const row = thread.find((m) => m.id === rowId);\n const chip = row?.reactions.find((r) => r.emoji === emoji);\n // The person's reaction was the last one, so the chip goes away.\n if (chip && chip.by.length === 1 && chip.by[0] === me) focusAdd.current = rowId;\n setThread((rows) =>\n rows.map((m) => {\n if (m.id !== rowId) return m;\n const has = m.reactions.find((r) => r.emoji === emoji);\n const reactions = has\n ? m.reactions.map((r) =>\n r.emoji !== emoji ? r : { ...r, by: r.by.includes(me) ? r.by.filter((n) => n !== me) : [...r.by, me] },\n )\n : [...m.reactions, { emoji, name, by: [me] }];\n // A chip with no reactions left goes away.\n return { ...m, reactions: reactions.filter((r) => r.by.length > 0) };\n }),\n );\n }\n\n function openPick(m: Row, anchor: HTMLElement) {\n if (pickOpen && pickRow?.id === m.id) {\n setPickOpen(false);\n return;\n }\n setPickRow(m);\n setPickAnchor(anchor);\n setPickOpen(true);\n }\n\n // Escape, a click outside and a pick close it. Popover's returnFocus gives focus back to 'Add reaction'.\n function closePick() {\n setPickOpen(false);\n }\n\n // The open row, read from the thread so the picker shows its reactions as they are now.\n const openRow = thread.find((m) => m.id === pickRow?.id);\n const mine = openRow ? openRow.reactions.filter((r) => r.by.includes(me)).map((r) => r.emoji) : [];\n\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 {thread.map((m) => (\n <Message\n key={m.id}\n aria-label={m.from}\n avatar={<UserImage userHandle={m.from} decorative />}\n name={m.from}\n meta={<TimeStamp createdAt={m.at} dateFormat=\"absolute\" data=\"time\" />}\n footer={\n <Cluster gap=\"small\">\n {m.reactions.map((r) => (\n <Tooltip key={r.emoji} title={whoReacted(r.by)}>\n <Tag\n variant=\"contained\"\n size=\"small\"\n state={r.by.includes(me) ? 'selected' : 'enabled'}\n label={`${r.emoji} ${r.by.length}`}\n aria-label={chipName(r)}\n onClick={() => toggle(m.id, r.emoji, r.name)}\n />\n </Tooltip>\n ))}\n <Tooltip title=\"Add reaction\">\n <IconButton\n color=\"iconOnly\"\n state={pickOpen && pickRow?.id === m.id ? 'selected' : 'enabled'}\n size=\"small\"\n ref={(el) => { addButtons.current[m.id] = el; }}\n iconName=\"SmilePlus\"\n ariaLabel={`Add reaction to message from ${m.from}`}\n aria-haspopup=\"dialog\"\n aria-expanded={pickOpen && pickRow?.id === m.id}\n onClick={(e: { currentTarget: HTMLElement }) => openPick(m, e.currentTarget)}\n />\n </Tooltip>\n </Cluster>\n }\n >\n <Paragraph measure=\"none\">{m.text}</Paragraph>\n </Message>\n ))}\n </Stack>\n </Stack>\n {/* The picker focuses its search. ArrowDown enters the grid; Tab and Shift+Tab move between the search and the grid. */}\n <Popover open={pickOpen} anchorEl={pickAnchor} onClose={closePick} returnFocus>\n <EmojiPicker\n id=\"message-reactions-picker\"\n aria-label=\"Add reaction\"\n // The emoji the person already used show pressed. Picking one again removes it.\n selected={mine}\n onPick={(emoji) => {\n if (!pickRow) return;\n closePick();\n toggle(pickRow.id, emoji.char, emoji.name);\n }}\n />\n </Popover>\n </Center>\n );\n}\n",
|
|
4202
|
+
"uses": [
|
|
4203
|
+
"Center",
|
|
4204
|
+
"Cluster",
|
|
4205
|
+
"EmojiPicker",
|
|
4206
|
+
"Heading",
|
|
4207
|
+
"IconButton",
|
|
4208
|
+
"Message",
|
|
4209
|
+
"Paragraph",
|
|
4210
|
+
"Popover",
|
|
4211
|
+
"Stack",
|
|
4212
|
+
"Tag",
|
|
4213
|
+
"TimeStamp",
|
|
4214
|
+
"Tooltip",
|
|
4215
|
+
"UserImage"
|
|
4216
|
+
]
|
|
3990
4217
|
}
|
|
3991
4218
|
]
|
|
3992
4219
|
},
|
|
@@ -4582,7 +4809,7 @@
|
|
|
4582
4809
|
"Let a long title wrap. Never cut it short."
|
|
4583
4810
|
],
|
|
4584
4811
|
"dont": [
|
|
4585
|
-
"Do not add a breadcrumb. Back goes one step up
|
|
4812
|
+
"Do not add a breadcrumb to an app page. Back goes one step up. A docs or help page three levels deep follows the case 'Breadcrumb'.",
|
|
4586
4813
|
"Do not show two primary Buttons.",
|
|
4587
4814
|
"Do not name an icon button only by its icon, or More only by the word.",
|
|
4588
4815
|
"Do not leave an action out on a phone without a way to reach it.",
|
|
@@ -4837,6 +5064,59 @@
|
|
|
4837
5064
|
}
|
|
4838
5065
|
]
|
|
4839
5066
|
},
|
|
5067
|
+
{
|
|
5068
|
+
"id": "people-row",
|
|
5069
|
+
"title": "People on an item",
|
|
5070
|
+
"kind": "design",
|
|
5071
|
+
"level": "organism",
|
|
5072
|
+
"area": "chat",
|
|
5073
|
+
"situation": "A thread or a task shows who is on it, and the person can find out who they all are.",
|
|
5074
|
+
"do": [
|
|
5075
|
+
"Use `AvatarStack` for four or more people. Past `max` its last circle counts the rest, such as '+3'.",
|
|
5076
|
+
"Make the stack one button with `onClick`, and name it for what it opens: 'Show the 6 people in this thread'.",
|
|
5077
|
+
"Open a `<Popover returnFocus>` from the stack with a `List` of every name and role, such as 'Ben Carter, Admin'. Escape or a click outside closes it, and Escape puts focus back on the stack.",
|
|
5078
|
+
"Show one to three people as faces and their names: 'Dana Lee, Ben Carter and Omar Reyes'. Make each face `UserImage decorative`, because the names say who is there.",
|
|
5079
|
+
"Keep the same order everywhere, the person who started the item first.",
|
|
5080
|
+
"Use the person's name as `userHandle`, so a person with no picture shows their initial."
|
|
5081
|
+
],
|
|
5082
|
+
"dont": [
|
|
5083
|
+
"Do not put a `Tooltip` on each face. A face is not focusable, so a keyboard or touch cannot reach it.",
|
|
5084
|
+
"Do not make a face the only way to know who is there. Name everyone in the list or in text.",
|
|
5085
|
+
"Do not list everyone as faces when the row would wrap. Use the stack and its count.",
|
|
5086
|
+
"Do not make each face its own button that does something else, such as removing the person."
|
|
5087
|
+
],
|
|
5088
|
+
"native": "On Apple show overlapping images in an `HStack` with negative spacing, as one accessibility element with the names, and a `Menu` or popover that lists everyone. On Android use the same in a `Row`, with a dropdown menu.",
|
|
5089
|
+
"options": [
|
|
5090
|
+
{
|
|
5091
|
+
"id": "stack",
|
|
5092
|
+
"title": "Overlapping faces that open a list",
|
|
5093
|
+
"useWhen": "Four or more people are on a thread or a task, shown in its header.",
|
|
5094
|
+
"source": "'use client';\nimport { useState } from 'react';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport AvatarStack from 'oneslash-design-system/components/avatarStack';\nimport Popover from 'oneslash-design-system/components/popover';\nimport List from 'oneslash-design-system/components/list';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// The person who started the thread comes first, here and everywhere these people are listed.\nconst people = [\n { name: 'Ben Carter', role: 'Admin' },\n { name: 'Dana Lee', role: 'Member' },\n { name: 'Omar Reyes', role: 'Member' },\n { name: 'Mia Park', role: 'Member' },\n { name: 'Leo Grant', role: 'Guest' },\n { name: 'Ana Silva', role: 'Guest' },\n];\n\nexport default function PeopleRowStack() {\n // The open list is anchored on the stack's button, and focus goes back to it on close.\n const [anchor, setAnchor] = useState<HTMLElement | null>(null);\n return (\n <Stack gap=\"large\">\n <Cluster justify=\"between\">\n <Stack gap=\"small\">\n <Heading level={1} size=\"h5\">Launch checklist</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">Started by Ben Carter on Nov 12, 2026</Paragraph>\n </Stack>\n <AvatarStack\n people={people}\n aria-label={`Show the ${people.length} people in this thread`}\n aria-haspopup=\"dialog\"\n aria-expanded={anchor !== null}\n onClick={(event) => setAnchor(anchor ? null : event.currentTarget)}\n />\n </Cluster>\n <Popover id=\"people-row-people\" open={anchor !== null} anchorEl={anchor} onClose={() => setAnchor(null)} returnFocus>\n <List items={people.map((p) => `${p.name}, ${p.role}`)} />\n </Popover>\n </Stack>\n );\n}\n",
|
|
5095
|
+
"uses": [
|
|
5096
|
+
"AvatarStack",
|
|
5097
|
+
"Cluster",
|
|
5098
|
+
"Heading",
|
|
5099
|
+
"List",
|
|
5100
|
+
"Paragraph",
|
|
5101
|
+
"Popover",
|
|
5102
|
+
"Stack"
|
|
5103
|
+
]
|
|
5104
|
+
},
|
|
5105
|
+
{
|
|
5106
|
+
"id": "names",
|
|
5107
|
+
"title": "Faces beside the names",
|
|
5108
|
+
"useWhen": "One to three people are on it, and their names fit.",
|
|
5109
|
+
"source": "'use client';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// The person who started the task comes first, here and everywhere these people are listed.\nconst people = ['Dana Lee', 'Ben Carter', 'Omar Reyes'];\n\nexport default function PeopleRowNames() {\n return (\n <Stack gap=\"small\">\n <Heading level={1} size=\"h5\">Fix the sign-up email</Heading>\n <Cluster gap=\"small\">\n {/* The names say who is there, so the faces are decorative */}\n <Cluster gap=\"small\">\n {people.map((name) => (\n <UserImage key={name} userHandle={name} size={24} decorative />\n ))}\n </Cluster>\n {/* The same words as the people in the array, in the wording AvatarStack names a group with: 'A, B and C' */}\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">Dana Lee, Ben Carter and Omar Reyes</Paragraph>\n </Cluster>\n </Stack>\n );\n}\n",
|
|
5110
|
+
"uses": [
|
|
5111
|
+
"Cluster",
|
|
5112
|
+
"Heading",
|
|
5113
|
+
"Paragraph",
|
|
5114
|
+
"Stack",
|
|
5115
|
+
"UserImage"
|
|
5116
|
+
]
|
|
5117
|
+
}
|
|
5118
|
+
]
|
|
5119
|
+
},
|
|
4840
5120
|
{
|
|
4841
5121
|
"id": "phone-navigation",
|
|
4842
5122
|
"title": "On a phone, a sidebar opens as a drawer and a list opens its detail",
|
|
@@ -5025,7 +5305,7 @@
|
|
|
5025
5305
|
"do": [
|
|
5026
5306
|
"Follow the rule 'A marketing page asks for one main action, in the same words everywhere'.",
|
|
5027
5307
|
"Show the same plans as the case 'Plan picker', word for word: the names, the prices and what each includes. A price comes from `formatMoney`, as the rule 'A number shows its unit and never shows 0 for unknown' says.",
|
|
5028
|
-
"Make each plan a `Surface` with its name as a level 3 heading, its price, a `List` of what it includes and one `Button`. Put them in `Grid columns={3}`, which stacks them on a phone.",
|
|
5308
|
+
"Make each plan a `Surface` with its name as a level 3 heading, its price, a `List` of what it includes and one `Button` with `fullWidth`. Put them in `Grid columns={3}`, which stacks them on a phone. Give each `Surface` `padding=\"small\"`, so the longest label stays inside its Button from md.",
|
|
5029
5309
|
"Name each Button for the plan: 'Sign Up for Free', 'Sign Up for Pro', 'Sign Up for Business'. Give it an `href` to the sign-up page with the plan in the address, so it works as a link.",
|
|
5030
5310
|
"Make the Button of the plan most visitors start on primary, and the others secondary. A visitor has no current plan, so no card carries 'Current plan'.",
|
|
5031
5311
|
"Put the section's name in `SectionIntro`, so the section has a level 2 heading and a link of its own.",
|
|
@@ -5045,7 +5325,7 @@
|
|
|
5045
5325
|
"id": "cards",
|
|
5046
5326
|
"title": "Plan cards side by side",
|
|
5047
5327
|
"useWhen": "The plans a visitor can sign up for are shown on the public site, two or three at once.",
|
|
5048
|
-
"source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\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 List from 'oneslash-design-system/components/list';\nimport Button from 'oneslash-design-system/components/button';\nimport { formatMoney } from 'oneslash-design-system/components/formatNumber';\nimport { Grid, PageSection, Stack } from 'oneslash-design-system/components/layout';\n\n// The same plans as the case 'Plan picker': names, prices and what each includes. A real site reads them from one place.\nconst plans = [\n { id: 'free', name: 'Free', price: `${formatMoney(0)} per month`, includes: ['3 members', '50 AI agent responses a month', '1 GB of storage'] },\n { id: 'pro', name: 'Pro', price: `${formatMoney(8)} per member per month`, includes: ['Unlimited members', '1,000 AI agent responses a month', '50 GB of storage', 'Export to PDF'] },\n { id: 'business', name: 'Business', price: `${formatMoney(16)} per member per month`, includes: ['Unlimited members', '10,000 AI agent responses a month', '500 GB of storage', 'Export to PDF', 'Priority support'] },\n];\n\nexport default function PricingSectionCards() {\n return (\n <PageShell>\n <PageSection gap=\"xxlarge\">\n <SectionIntro id=\"pricing\" name=\"Pricing\" statement=\"Pick the plan that fits your team.\" />\n <Stack gap=\"medium\">\n {/* Three across from md, stacked on a phone. A visitor has no current plan, so each plan asks to sign up. */}\n <Grid columns={3}>\n {plans.map((p) => (\n <Surface key={p.id} padding=\"
|
|
5328
|
+
"source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\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 List from 'oneslash-design-system/components/list';\nimport Button from 'oneslash-design-system/components/button';\nimport { formatMoney } from 'oneslash-design-system/components/formatNumber';\nimport { Grid, PageSection, Stack } from 'oneslash-design-system/components/layout';\n\n// The same plans as the case 'Plan picker': names, prices and what each includes. A real site reads them from one place.\nconst plans = [\n { id: 'free', name: 'Free', price: `${formatMoney(0)} per month`, includes: ['3 members', '50 AI agent responses a month', '1 GB of storage'] },\n { id: 'pro', name: 'Pro', price: `${formatMoney(8)} per member per month`, includes: ['Unlimited members', '1,000 AI agent responses a month', '50 GB of storage', 'Export to PDF'] },\n { id: 'business', name: 'Business', price: `${formatMoney(16)} per member per month`, includes: ['Unlimited members', '10,000 AI agent responses a month', '500 GB of storage', 'Export to PDF', 'Priority support'] },\n];\n\nexport default function PricingSectionCards() {\n return (\n <PageShell>\n <PageSection gap=\"xxlarge\">\n <SectionIntro id=\"pricing\" name=\"Pricing\" statement=\"Pick the plan that fits your team.\" />\n <Stack gap=\"medium\">\n {/* Three across from md, stacked on a phone. A visitor has no current plan, so each plan asks to sign up. */}\n {/* The small padding leaves room for the longest label, 'Sign Up for Business', inside its Button at md. */}\n <Grid columns={3}>\n {plans.map((p) => (\n <Surface key={p.id} padding=\"small\">\n <Stack gap=\"large\">\n <Stack gap=\"small\">\n <Heading level={3} size=\"h6\">{p.name}</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">{p.price}</Paragraph>\n </Stack>\n <List items={p.includes} size=\"body2\" marker=\"dot\" />\n {/* The one primary Button is the plan to start with. Each is a link, so it works without a script. */}\n <Button\n size=\"medium\"\n type={p.id === 'pro' ? 'primary' : 'secondary'}\n state=\"enabled\"\n label={`Sign Up for ${p.name}`}\n href={`https://acme.example/sign-up?plan=${p.id}`}\n fullWidth\n />\n </Stack>\n </Surface>\n ))}\n </Grid>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">Prices in USD. Pro and Business bill each member monthly.</Paragraph>\n </Stack>\n </PageSection>\n </PageShell>\n );\n}\n",
|
|
5049
5329
|
"uses": [
|
|
5050
5330
|
"Button",
|
|
5051
5331
|
"Grid",
|
|
@@ -5121,7 +5401,8 @@
|
|
|
5121
5401
|
"Wrap each field in a `FormField` and pass `id` and `aria-describedby` to the control, and `aria-invalid` to a `TextField` or `Textarea`. This ties its label, help and error to it.",
|
|
5122
5402
|
"Show a problem with a field under it, as the rule 'A form error shows next to the problem' says: 'Enter your name.' and 'Use at least 8 characters.'",
|
|
5123
5403
|
"Disable the field while its request runs, and keep what the person typed when the save fails.",
|
|
5124
|
-
"Use `UserImage` with the person's name as `userHandle`, so a person with no picture sees their initial."
|
|
5404
|
+
"Use `UserImage` with the person's name as `userHandle`, so a person with no picture sees their initial.",
|
|
5405
|
+
"Follow the case 'File upload' for the picture."
|
|
5125
5406
|
],
|
|
5126
5407
|
"dont": [
|
|
5127
5408
|
"Do not add one Save Button for the whole page. Each group saves by itself.",
|
|
@@ -5136,19 +5417,20 @@
|
|
|
5136
5417
|
"id": "form",
|
|
5137
5418
|
"title": "Picture, name and password",
|
|
5138
5419
|
"useWhen": "People sign in with a password and can change their own picture and name.",
|
|
5139
|
-
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Form from 'oneslash-design-system/components/form';\nimport FormField from 'oneslash-design-system/components/formField';\nimport TextField from 'oneslash-design-system/components/textField';\nimport Button from 'oneslash-design-system/components/button';\nimport Alert from 'oneslash-design-system/components/alert';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport SettingsSection from 'oneslash-design-system/components/settingsSection';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A picture the person chose. A real app uploads the file and gets a URL back.\nconst chosenPicture =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' fill='%232f6b4f'/%3E%3Ccircle cx='32' cy='25' r='11' fill='%23fff'/%3E%3Cpath d='M10 64c2-15 11-22 22-22s20 7 22 22z' fill='%23fff'/%3E%3C/svg%3E\";\n\nconst minPasswordLength = 8;\n// Stands in for the server's check. In this example every current password is right except this one.\nconst wrongCurrentPassword = 'incorrect';\n\nexport default function ProfileForm() {\n const [picture, setPicture] = useState<string | undefined>(undefined);\n // Which picture Button was pressed, so only that one shows `loading`.\n const [savingPicture, setSavingPicture] = useState<'change' | 'remove' | null>(null);\n const [pictureError, setPictureError] = useState('');\n\n const [savedName, setSavedName] = useState('Dana Lee');\n const [name, setName] = useState('Dana Lee');\n const [nameError, setNameError] = useState('');\n const [savingName, setSavingName] = useState(false);\n const [nameSaved, setNameSaved] = useState(false);\n\n const [currentPassword, setCurrentPassword] = useState('');\n const [currentPasswordError, setCurrentPasswordError] = useState('');\n const [password, setPassword] = useState('');\n const [passwordError, setPasswordError] = useState('');\n const [savingPassword, setSavingPassword] = useState(false);\n const [passwordSaved, setPasswordSaved] = useState(false);\n\n const timers = useRef<ReturnType<typeof setTimeout>[]>([]);\n // One 'Saved' timer per group, cleared before a new one starts, so an old one cannot end a new 'Saved' early.\n const nameSavedTimer = useRef<ReturnType<typeof setTimeout>>();\n const passwordSavedTimer = useRef<ReturnType<typeof setTimeout>>();\n // The first picture save fails, as if the upload dropped, so the example shows both paths.\n const pictureFails = useRef(true);\n\n // Stops every request and every 'Saved' if the example goes away before they end.\n useEffect(() => () => {\n timers.current.forEach(clearTimeout);\n clearTimeout(nameSavedTimer.current);\n clearTimeout(passwordSavedTimer.current);\n }, []);\n\n // Stands in for the request to the server.\n function later(callback: () => void, ms: number) {\n timers.current.push(setTimeout(callback, ms));\n }\n\n // The picture is one control on its own, so it saves as soon as it is chosen or removed. Nothing shows when it works.\n // When it fails, the old picture stays and a line under the Buttons says why.\n function savePicture(next: string | undefined, pressed: 'change' | 'remove') {\n if (savingPicture) return;\n setPictureError('');\n setSavingPicture(pressed);\n later(() => {\n setSavingPicture(null);\n if (pictureFails.current) {\n pictureFails.current = false;\n setPictureError('Could not save. Try again.');\n return;\n }\n setPicture(next);\n }, 900);\n }\n\n // The name is a group with one Save Button: 'Saved' shows for 2 seconds, and the Button is disabled while nothing changed.\n function handleSaveName() {\n if (savingName) return;\n if (!name.trim()) {\n setNameError('Enter your name.');\n return;\n }\n setNameError('');\n setSavingName(true);\n later(() => {\n setSavedName(name.trim());\n setName(name.trim());\n setSavingName(false);\n setNameSaved(true);\n clearTimeout(nameSavedTimer.current);\n nameSavedTimer.current = setTimeout(() => setNameSaved(false), 2000);\n }, 1200);\n }\n\n function handleUpdatePassword() {\n if (savingPassword || !currentPassword || !password) return;\n setCurrentPasswordError('');\n if (password.length < minPasswordLength) {\n setPasswordError(`Use at least ${minPasswordLength} characters.`);\n return;\n }\n setPasswordError('');\n setSavingPassword(true);\n later(() => {\n setSavingPassword(false);\n // A wrong current password shows under that field, and both fields keep what the person typed.\n if (currentPassword === wrongCurrentPassword) {\n setCurrentPasswordError('This is not your current password. Enter it again.');\n return;\n }\n setCurrentPassword('');\n setPassword('');\n setPasswordSaved(true);\n clearTimeout(passwordSavedTimer.current);\n passwordSavedTimer.current = setTimeout(() => setPasswordSaved(false), 2000);\n }, 1200);\n }\n\n const nameChanged = name !== savedName;\n\n return (\n <Center width=\"page\">\n <Stack gap=\"xlarge\">\n <Heading level={1} size=\"h5\">Profile</Heading>\n\n <SettingsSection title=\"Picture\" description=\"Shown beside your name in Acme.\">\n <Cluster gap=\"large\">\n <UserImage userHandle={savedName} userImgUrl={picture} size={64} />\n <Stack gap=\"small\">\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"secondary\" state={savingPicture === 'remove' ? 'disabled' : 'enabled'} label=\"Change Picture\" loading={savingPicture === 'change'} onClickButton={() => savePicture(chosenPicture, 'change')} />\n {picture && <Button size=\"small\" type=\"tertiary\" state={savingPicture === 'change' ? 'disabled' : 'enabled'} label=\"Remove\" aria-label=\"Remove picture\" loading={savingPicture === 'remove'} onClickButton={() => savePicture(undefined, 'remove')} />}\n </Cluster>\n {pictureError && <Alert type=\"error\" variant=\"inline\" autoDismiss={false} message={pictureError} />}\n </Stack>\n </Cluster>\n </SettingsSection>\n\n <SettingsSection title=\"Name\" description=\"How people see you in messages and on tasks.\">\n <Form aria-label=\"Name\" gap=\"medium\" onSubmit={handleSaveName}>\n <FormField id=\"profile-form-name\" label=\"Name\" error={nameError}>\n {(f) => (\n <TextField\n id={f.id}\n aria-describedby={f['aria-describedby']}\n aria-invalid={f['aria-invalid']}\n value={name}\n disabled={savingName}\n autoComplete=\"name\"\n onChange={(e) => { setName(e.target.value); setNameError(''); setNameSaved(false); }}\n />\n )}\n </FormField>\n <Cluster>\n <Button size=\"medium\" type=\"primary\" state={nameChanged || savingName ? 'enabled' : 'disabled'} label={nameSaved ? 'Saved' : 'Save'} htmlType=\"submit\" loading={savingName} />\n </Cluster>\n </Form>\n </SettingsSection>\n\n <SettingsSection title=\"Password\" description=\"Sign in with dana@acme.example and a password.\">\n <Form aria-label=\"Password\" gap=\"medium\" onSubmit={handleUpdatePassword}>\n <FormField id=\"profile-form-current-password\" label=\"Current password\" error={currentPasswordError}>\n {(f) => (\n <TextField\n id={f.id}\n type=\"password\"\n aria-describedby={f['aria-describedby']}\n aria-invalid={f['aria-invalid']}\n value={currentPassword}\n disabled={savingPassword}\n autoComplete=\"current-password\"\n onChange={(e) => { setCurrentPassword(e.target.value); setCurrentPasswordError(''); setPasswordSaved(false); }}\n />\n )}\n </FormField>\n <FormField id=\"profile-form-password\" label=\"New password\" help={`Use at least ${minPasswordLength} characters.`} error={passwordError}>\n {(f) => (\n <TextField\n id={f.id}\n type=\"password\"\n aria-describedby={f['aria-describedby']}\n aria-invalid={f['aria-invalid']}\n value={password}\n disabled={savingPassword}\n autoComplete=\"new-password\"\n onChange={(e) => { setPassword(e.target.value); setPasswordError(''); setPasswordSaved(false); }}\n />\n )}\n </FormField>\n <Cluster>\n <Button size=\"medium\" type=\"primary\" state={(currentPassword && password) || savingPassword ? 'enabled' : 'disabled'} label={passwordSaved ? 'Saved' : 'Update Password'} htmlType=\"submit\" loading={savingPassword} />\n </Cluster>\n </Form>\n </SettingsSection>\n </Stack>\n </Center>\n );\n}\n",
|
|
5420
|
+
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Form from 'oneslash-design-system/components/form';\nimport FormField from 'oneslash-design-system/components/formField';\nimport TextField from 'oneslash-design-system/components/textField';\nimport Button from 'oneslash-design-system/components/button';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport DropZone, { type FileRejection } from 'oneslash-design-system/components/dropZone';\nimport { formatBytes } from 'oneslash-design-system/components/formatNumber';\nimport SettingsSection from 'oneslash-design-system/components/settingsSection';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A picture the person chose. A real app uploads the file and gets a URL back.\nconst chosenPicture =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' fill='%232f6b4f'/%3E%3Ccircle cx='32' cy='25' r='11' fill='%23fff'/%3E%3Cpath d='M10 64c2-15 11-22 22-22s20 7 22 22z' fill='%23fff'/%3E%3C/svg%3E\";\n\n// 5 MB as formatBytes counts it (base 1024), so the words and the check agree\nconst maxPictureBytes = 5 * 1024 * 1024;\n\n// The zone reports a reason. The words are this page's, shown under the picture.\nfunction sayRejected(rejections: FileRejection[]) {\n const reason = rejections[0].reason;\n if (reason === 'type') return 'Choose a JPG, PNG or WebP picture.';\n if (reason === 'size') return `Choose a picture under ${formatBytes(maxPictureBytes)}.`;\n return 'Choose one picture.';\n}\n\nconst minPasswordLength = 8;\n// Stands in for the server's check. In this example every current password is right except this one.\nconst wrongCurrentPassword = 'incorrect';\n\nexport default function ProfileForm() {\n const [picture, setPicture] = useState<string | undefined>(undefined);\n // Which picture Button was pressed, so only that one shows `loading`.\n const [savingPicture, setSavingPicture] = useState<'change' | 'remove' | null>(null);\n const [pictureError, setPictureError] = useState('');\n\n const [savedName, setSavedName] = useState('Dana Lee');\n const [name, setName] = useState('Dana Lee');\n const [nameError, setNameError] = useState('');\n const [savingName, setSavingName] = useState(false);\n const [nameSaved, setNameSaved] = useState(false);\n\n const [currentPassword, setCurrentPassword] = useState('');\n const [currentPasswordError, setCurrentPasswordError] = useState('');\n const [password, setPassword] = useState('');\n const [passwordError, setPasswordError] = useState('');\n const [savingPassword, setSavingPassword] = useState(false);\n const [passwordSaved, setPasswordSaved] = useState(false);\n\n const timers = useRef<ReturnType<typeof setTimeout>[]>([]);\n // One 'Saved' timer per group, cleared before a new one starts, so an old one cannot end a new 'Saved' early.\n const nameSavedTimer = useRef<ReturnType<typeof setTimeout>>();\n const passwordSavedTimer = useRef<ReturnType<typeof setTimeout>>();\n // The first picture save fails, as if the upload dropped, so the example shows both paths.\n const pictureFails = useRef(true);\n\n // Stops every request and every 'Saved' if the example goes away before they end.\n useEffect(() => () => {\n timers.current.forEach(clearTimeout);\n clearTimeout(nameSavedTimer.current);\n clearTimeout(passwordSavedTimer.current);\n }, []);\n\n // Stands in for the request to the server.\n function later(callback: () => void, ms: number) {\n timers.current.push(setTimeout(callback, ms));\n }\n\n // The picture is one control on its own, so it saves as soon as it is chosen or removed. Nothing shows when it works.\n // When it fails, the old picture stays and a line under the Buttons says why.\n function savePicture(next: string | undefined, pressed: 'change' | 'remove') {\n if (savingPicture) return;\n setPictureError('');\n setSavingPicture(pressed);\n later(() => {\n setSavingPicture(null);\n if (pictureFails.current) {\n pictureFails.current = false;\n setPictureError('Could not save. Try again.');\n return;\n }\n setPicture(next);\n }, 900);\n }\n\n // The name is a group with one Save Button: 'Saved' shows for 2 seconds, and the Button is disabled while nothing changed.\n function handleSaveName() {\n if (savingName) return;\n if (!name.trim()) {\n setNameError('Enter your name.');\n return;\n }\n setNameError('');\n setSavingName(true);\n later(() => {\n setSavedName(name.trim());\n setName(name.trim());\n setSavingName(false);\n setNameSaved(true);\n clearTimeout(nameSavedTimer.current);\n nameSavedTimer.current = setTimeout(() => setNameSaved(false), 2000);\n }, 1200);\n }\n\n function handleUpdatePassword() {\n if (savingPassword || !currentPassword || !password) return;\n setCurrentPasswordError('');\n if (password.length < minPasswordLength) {\n setPasswordError(`Use at least ${minPasswordLength} characters.`);\n return;\n }\n setPasswordError('');\n setSavingPassword(true);\n later(() => {\n setSavingPassword(false);\n // A wrong current password shows under that field, and both fields keep what the person typed.\n if (currentPassword === wrongCurrentPassword) {\n setCurrentPasswordError('This is not your current password. Enter it again.');\n return;\n }\n setCurrentPassword('');\n setPassword('');\n setPasswordSaved(true);\n clearTimeout(passwordSavedTimer.current);\n passwordSavedTimer.current = setTimeout(() => setPasswordSaved(false), 2000);\n }, 1200);\n }\n\n const nameChanged = name !== savedName;\n\n return (\n <Center width=\"page\">\n <Stack gap=\"xlarge\">\n <Heading level={1} size=\"h5\">Profile</Heading>\n\n <SettingsSection title=\"Picture\" description=\"Shown beside your name in Acme.\">\n {/* The error shows under the picture and its Buttons, and is read with the zone. */}\n <FormField id=\"profile-form-picture\" label=\"New picture\" error={pictureError}>\n {(f) => (\n <Cluster gap=\"small\">\n <DropZone\n id={f.id}\n size=\"compact\"\n label=\"Drop a picture here\"\n buttonLabel=\"Change Picture\"\n hint={`JPG, PNG or WebP, up to ${formatBytes(maxPictureBytes)}`}\n accept={['image/jpeg', 'image/png', 'image/webp']}\n maxBytes={maxPictureBytes}\n loading={savingPicture === 'change'}\n disabled={savingPicture === 'remove'}\n aria-describedby={f['aria-describedby']}\n aria-invalid={f['aria-invalid']}\n status={pictureError || undefined}\n onFiles={() => savePicture(chosenPicture, 'change')}\n onReject={(rejections) => setPictureError(sayRejected(rejections))}\n >\n <UserImage userHandle={savedName} userImgUrl={picture} size={64} />\n </DropZone>\n {picture && <Button size=\"small\" type=\"tertiary\" state={savingPicture === 'change' ? 'disabled' : 'enabled'} label=\"Remove\" aria-label=\"Remove picture\" loading={savingPicture === 'remove'} onClickButton={() => savePicture(undefined, 'remove')} />}\n </Cluster>\n )}\n </FormField>\n </SettingsSection>\n\n <SettingsSection title=\"Name\" description=\"How people see you in messages and on tasks.\">\n <Form aria-label=\"Name\" gap=\"medium\" onSubmit={handleSaveName}>\n <FormField id=\"profile-form-name\" label=\"Name\" error={nameError}>\n {(f) => (\n <TextField\n id={f.id}\n aria-describedby={f['aria-describedby']}\n aria-invalid={f['aria-invalid']}\n value={name}\n disabled={savingName}\n autoComplete=\"name\"\n onChange={(e) => { setName(e.target.value); setNameError(''); setNameSaved(false); }}\n />\n )}\n </FormField>\n <Cluster>\n <Button size=\"medium\" type=\"primary\" state={nameChanged || savingName ? 'enabled' : 'disabled'} label={nameSaved ? 'Saved' : 'Save'} htmlType=\"submit\" loading={savingName} />\n </Cluster>\n </Form>\n </SettingsSection>\n\n <SettingsSection title=\"Password\" description=\"Sign in with dana@acme.example and a password.\">\n <Form aria-label=\"Password\" gap=\"medium\" onSubmit={handleUpdatePassword}>\n <FormField id=\"profile-form-current-password\" label=\"Current password\" error={currentPasswordError}>\n {(f) => (\n <TextField\n id={f.id}\n type=\"password\"\n aria-describedby={f['aria-describedby']}\n aria-invalid={f['aria-invalid']}\n value={currentPassword}\n disabled={savingPassword}\n autoComplete=\"current-password\"\n onChange={(e) => { setCurrentPassword(e.target.value); setCurrentPasswordError(''); setPasswordSaved(false); }}\n />\n )}\n </FormField>\n <FormField id=\"profile-form-password\" label=\"New password\" help={`Use at least ${minPasswordLength} characters.`} error={passwordError}>\n {(f) => (\n <TextField\n id={f.id}\n type=\"password\"\n aria-describedby={f['aria-describedby']}\n aria-invalid={f['aria-invalid']}\n value={password}\n disabled={savingPassword}\n autoComplete=\"new-password\"\n onChange={(e) => { setPassword(e.target.value); setPasswordError(''); setPasswordSaved(false); }}\n />\n )}\n </FormField>\n <Cluster>\n <Button size=\"medium\" type=\"primary\" state={(currentPassword && password) || savingPassword ? 'enabled' : 'disabled'} label={passwordSaved ? 'Saved' : 'Update Password'} htmlType=\"submit\" loading={savingPassword} />\n </Cluster>\n </Form>\n </SettingsSection>\n </Stack>\n </Center>\n );\n}\n",
|
|
5140
5421
|
"uses": [
|
|
5141
|
-
"Alert",
|
|
5142
5422
|
"Button",
|
|
5143
5423
|
"Center",
|
|
5144
5424
|
"Cluster",
|
|
5425
|
+
"DropZone",
|
|
5145
5426
|
"Form",
|
|
5146
5427
|
"FormField",
|
|
5147
5428
|
"Heading",
|
|
5148
5429
|
"SettingsSection",
|
|
5149
5430
|
"Stack",
|
|
5150
5431
|
"TextField",
|
|
5151
|
-
"UserImage"
|
|
5432
|
+
"UserImage",
|
|
5433
|
+
"formatBytes"
|
|
5152
5434
|
]
|
|
5153
5435
|
}
|
|
5154
5436
|
]
|
|
@@ -5694,7 +5976,7 @@
|
|
|
5694
5976
|
"id": "top-tabs",
|
|
5695
5977
|
"title": "Tabs across the top",
|
|
5696
5978
|
"useWhen": "Four areas or fewer, with short names that fit on a phone.",
|
|
5697
|
-
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport List from 'oneslash-design-system/components/list';\nimport Form from 'oneslash-design-system/components/form';\nimport FormField from 'oneslash-design-system/components/formField';\nimport TextField from 'oneslash-design-system/components/textField';\nimport Switch from 'oneslash-design-system/components/switch';\nimport Button from 'oneslash-design-system/components/button';\nimport TabsContainer from 'oneslash-design-system/components/tabsContainer';\nimport Tab from 'oneslash-design-system/components/tab';\nimport SettingsSection, { SettingsColumns } from 'oneslash-design-system/components/settingsSection';\nimport { formatMoney } from 'oneslash-design-system/components/formatNumber';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Area = 'profile' | 'notifications' | 'billing';\n\n// Four areas or fewer, each named with one short word, so the tabs fit on a phone. Each tab is a page of its own in a real app, so it has an `href`.\nconst areas: { id: Area; label: string }[] = [\n { id: 'profile', label: 'Profile' },\n { id: 'notifications', label: 'Notifications' },\n { id: 'billing', label: 'Billing' },\n];\n\nconst invoices = [`November 2026, ${formatMoney(24)}`, `October 2026, ${formatMoney(24)}`, `September 2026, ${formatMoney(24)}`];\n\nexport default function SettingsPageTopTabs() {\n const [area, setArea] = useState<Area>('profile');\n const [savedName, setSavedName] = useState('Dana Lee');\n const [name, setName] = useState('Dana Lee');\n const [nameError, setNameError] = useState('');\n const [saving, setSaving] = useState(false);\n const [saved, setSaved] = useState(false);\n const [values, setValues] = useState({ mentions: true, digest: false });\n const [busy, setBusy] = useState({ mentions: false, digest: false });\n // A real app passes the router from its framework, such as Next's useRouter(). Here it sets the open area.\n const router = { push: (url: string) => setArea(url.split('/').pop() as Area) };\n const timers = useRef<ReturnType<typeof setTimeout>[]>([]);\n // Cleared before a new 'Saved' starts, so an old timer cannot end it early.\n const savedTimer = useRef<ReturnType<typeof setTimeout>>();\n\n // Stops every request and the 'Saved' if the example goes away before they end.\n useEffect(() => () => {\n timers.current.forEach(clearTimeout);\n clearTimeout(savedTimer.current);\n }, []);\n\n // A group of fields has one Save Button: `loading`, then 'Saved' for 2 seconds.\n function handleSave() {\n if (saving) return;\n if (!name.trim()) {\n setNameError('Enter your name.');\n return;\n }\n setNameError('');\n setSaving(true);\n // Stands in for the request to the server.\n timers.current.push(setTimeout(() => {\n setSavedName(name.trim());\n setName(name.trim());\n setSaving(false);\n setSaved(true);\n clearTimeout(savedTimer.current);\n savedTimer.current = setTimeout(() => setSaved(false), 2000);\n }, 1200));\n }\n\n // A switch on its own saves as soon as it changes, and shows nothing when it works.\n function handleSwitch(key: 'mentions' | 'digest', next: boolean) {\n setBusy((current) => ({ ...current, [key]: true }));\n setValues((current) => ({ ...current, [key]: next }));\n timers.current.push(setTimeout(() => setBusy((current) => ({ ...current, [key]: false })), 900));\n }\n\n const profile = (\n <SettingsColumns>\n <SettingsSection id=\"settings-page-tabs-name\" title=\"Name\" description=\"How people see you in messages and on tasks.\">\n <Form aria-label=\"Name\" gap=\"medium\" onSubmit={handleSave}>\n <FormField id=\"settings-page-tabs-name-field\" label=\"Name\" error={nameError}>\n {(f) => <TextField id={f.id} aria-describedby={f['aria-describedby']} aria-invalid={f['aria-invalid']} value={name} disabled={saving} onChange={(e) => { setName(e.target.value); setNameError(''); setSaved(false); }} />}\n </FormField>\n <Cluster>\n <Button size=\"medium\" type=\"primary\" state={name !== savedName || saving ? 'enabled' : 'disabled'} label={saved ? 'Saved' : 'Save'} htmlType=\"submit\" loading={saving} />\n </Cluster>\n </Form>\n </SettingsSection>\n <SettingsSection id=\"settings-page-tabs-email\" title=\"Email\" description=\"Where Acme writes to you.\">\n <FormField id=\"settings-page-tabs-email-field\" label=\"Email\" help=\"Only support can change this. Write to help@acme.example.\">\n {(f) => <TextField id={f.id} aria-describedby={f['aria-describedby']} value=\"dana@acme.example\" readOnly onChange={() => {}} />}\n </FormField>\n </SettingsSection>\n </SettingsColumns>\n );\n\n const notifications = (\n <SettingsColumns>\n <SettingsSection id=\"settings-page-tabs-email-alerts\" title=\"Email\" description=\"Sent to dana@acme.example.\">\n <Switch id=\"settings-page-tabs-mentions\" label=\"Mentions\" description=\"An email when someone mentions you.\" checked={values.mentions} busy={busy.mentions} onChange={(next) => handleSwitch('mentions', next)} />\n <Switch id=\"settings-page-tabs-digest\" label=\"Weekly digest\" description=\"A summary of last week, every Monday.\" checked={values.digest} busy={busy.digest} onChange={(next) => handleSwitch('digest', next)} />\n </SettingsSection>\n </SettingsColumns>\n );\n\n const billing = (\n <SettingsColumns>\n <SettingsSection id=\"settings-page-tabs-plan\" title=\"Plan\" description=\"Pro plan, 3 members.\">\n <Paragraph size=\"body2\" measure=\"none\">Renews on Dec 1, 2026. Only owners can change the plan.</Paragraph>\n </SettingsSection>\n <SettingsSection id=\"settings-page-tabs-invoices\" title=\"Invoices\" description=\"The last three months.\">\n <List items={invoices} size=\"body2\" />\n </SettingsSection>\n </SettingsColumns>\n );\n\n return (\n <Center width=\"page\">\n <Stack gap=\"xlarge\">\n <Heading level={1} size=\"h5\">Settings</Heading>\n <TabsContainer>\n {areas.map((a) => (\n <Tab key={a.id} label={a.label} href={`/settings/${a.id}`} router={router} isSelected={area === a.id} onClickTab={() => setArea(a.id)} />\n ))}\n </TabsContainer>\n {area
|
|
5979
|
+
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport List from 'oneslash-design-system/components/list';\nimport Form from 'oneslash-design-system/components/form';\nimport FormField from 'oneslash-design-system/components/formField';\nimport TextField from 'oneslash-design-system/components/textField';\nimport Switch from 'oneslash-design-system/components/switch';\nimport Button from 'oneslash-design-system/components/button';\nimport TabsContainer from 'oneslash-design-system/components/tabsContainer';\nimport Tab from 'oneslash-design-system/components/tab';\nimport TabPanel from 'oneslash-design-system/components/tabPanel';\nimport SettingsSection, { SettingsColumns } from 'oneslash-design-system/components/settingsSection';\nimport { formatMoney } from 'oneslash-design-system/components/formatNumber';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Area = 'profile' | 'notifications' | 'billing';\n\n// Four areas or fewer, each named with one short word, so the tabs fit on a phone. Each tab is a page of its own in a real app, so it has an `href`.\nconst areas: { id: Area; label: string }[] = [\n { id: 'profile', label: 'Profile' },\n { id: 'notifications', label: 'Notifications' },\n { id: 'billing', label: 'Billing' },\n];\n\nconst invoices = [`November 2026, ${formatMoney(24)}`, `October 2026, ${formatMoney(24)}`, `September 2026, ${formatMoney(24)}`];\n\nexport default function SettingsPageTopTabs() {\n const [area, setArea] = useState<Area>('profile');\n const [savedName, setSavedName] = useState('Dana Lee');\n const [name, setName] = useState('Dana Lee');\n const [nameError, setNameError] = useState('');\n const [saving, setSaving] = useState(false);\n const [saved, setSaved] = useState(false);\n const [values, setValues] = useState({ mentions: true, digest: false });\n const [busy, setBusy] = useState({ mentions: false, digest: false });\n // A real app passes the router from its framework, such as Next's useRouter(). Here it sets the open area.\n const router = { push: (url: string) => setArea(url.split('/').pop() as Area) };\n const timers = useRef<ReturnType<typeof setTimeout>[]>([]);\n // Cleared before a new 'Saved' starts, so an old timer cannot end it early.\n const savedTimer = useRef<ReturnType<typeof setTimeout>>();\n\n // Stops every request and the 'Saved' if the example goes away before they end.\n useEffect(() => () => {\n timers.current.forEach(clearTimeout);\n clearTimeout(savedTimer.current);\n }, []);\n\n // A group of fields has one Save Button: `loading`, then 'Saved' for 2 seconds.\n function handleSave() {\n if (saving) return;\n if (!name.trim()) {\n setNameError('Enter your name.');\n return;\n }\n setNameError('');\n setSaving(true);\n // Stands in for the request to the server.\n timers.current.push(setTimeout(() => {\n setSavedName(name.trim());\n setName(name.trim());\n setSaving(false);\n setSaved(true);\n clearTimeout(savedTimer.current);\n savedTimer.current = setTimeout(() => setSaved(false), 2000);\n }, 1200));\n }\n\n // A switch on its own saves as soon as it changes, and shows nothing when it works.\n function handleSwitch(key: 'mentions' | 'digest', next: boolean) {\n setBusy((current) => ({ ...current, [key]: true }));\n setValues((current) => ({ ...current, [key]: next }));\n timers.current.push(setTimeout(() => setBusy((current) => ({ ...current, [key]: false })), 900));\n }\n\n const profile = (\n <SettingsColumns>\n <SettingsSection id=\"settings-page-tabs-name\" title=\"Name\" description=\"How people see you in messages and on tasks.\">\n <Form aria-label=\"Name\" gap=\"medium\" onSubmit={handleSave}>\n <FormField id=\"settings-page-tabs-name-field\" label=\"Name\" error={nameError}>\n {(f) => <TextField id={f.id} aria-describedby={f['aria-describedby']} aria-invalid={f['aria-invalid']} value={name} disabled={saving} onChange={(e) => { setName(e.target.value); setNameError(''); setSaved(false); }} />}\n </FormField>\n <Cluster>\n <Button size=\"medium\" type=\"primary\" state={name !== savedName || saving ? 'enabled' : 'disabled'} label={saved ? 'Saved' : 'Save'} htmlType=\"submit\" loading={saving} />\n </Cluster>\n </Form>\n </SettingsSection>\n <SettingsSection id=\"settings-page-tabs-email\" title=\"Email\" description=\"Where Acme writes to you.\">\n <FormField id=\"settings-page-tabs-email-field\" label=\"Email\" help=\"Only support can change this. Write to help@acme.example.\">\n {(f) => <TextField id={f.id} aria-describedby={f['aria-describedby']} value=\"dana@acme.example\" readOnly onChange={() => {}} />}\n </FormField>\n </SettingsSection>\n </SettingsColumns>\n );\n\n const notifications = (\n <SettingsColumns>\n <SettingsSection id=\"settings-page-tabs-email-alerts\" title=\"Email\" description=\"Sent to dana@acme.example.\">\n <Switch id=\"settings-page-tabs-mentions\" label=\"Mentions\" description=\"An email when someone mentions you.\" checked={values.mentions} busy={busy.mentions} onChange={(next) => handleSwitch('mentions', next)} />\n <Switch id=\"settings-page-tabs-digest\" label=\"Weekly digest\" description=\"A summary of last week, every Monday.\" checked={values.digest} busy={busy.digest} onChange={(next) => handleSwitch('digest', next)} />\n </SettingsSection>\n </SettingsColumns>\n );\n\n const billing = (\n <SettingsColumns>\n <SettingsSection id=\"settings-page-tabs-plan\" title=\"Plan\" description=\"Pro plan, 3 members.\">\n <Paragraph size=\"body2\" measure=\"none\">Renews on Dec 1, 2026. Only owners can change the plan.</Paragraph>\n </SettingsSection>\n <SettingsSection id=\"settings-page-tabs-invoices\" title=\"Invoices\" description=\"The last three months.\">\n <List items={invoices} size=\"body2\" />\n </SettingsSection>\n </SettingsColumns>\n );\n\n const panels = { profile, notifications, billing };\n\n return (\n <Center width=\"page\">\n <Stack gap=\"xlarge\">\n <Heading level={1} size=\"h5\" id=\"settings-page-tabs-title\">Settings</Heading>\n <TabsContainer aria-labelledby=\"settings-page-tabs-title\">\n {areas.map((a) => (\n <Tab key={a.id} id={`settings-page-tabs-tab-${a.id}`} controls={`settings-page-tabs-panel-${a.id}`} label={a.label} href={`/settings/${a.id}`} router={router} isSelected={area === a.id} onClickTab={() => setArea(a.id)} />\n ))}\n </TabsContainer>\n {/* Every area is in the page. Only the open one shows. */}\n {areas.map((a) => (\n <TabPanel key={a.id} id={`settings-page-tabs-panel-${a.id}`} labelledBy={`settings-page-tabs-tab-${a.id}`} selected={area === a.id}>\n {panels[a.id]}\n </TabPanel>\n ))}\n </Stack>\n </Center>\n );\n}\n",
|
|
5698
5980
|
"uses": [
|
|
5699
5981
|
"Button",
|
|
5700
5982
|
"Center",
|
|
@@ -5709,6 +5991,7 @@
|
|
|
5709
5991
|
"Stack",
|
|
5710
5992
|
"Switch",
|
|
5711
5993
|
"Tab",
|
|
5994
|
+
"TabPanel",
|
|
5712
5995
|
"TabsContainer",
|
|
5713
5996
|
"TextField",
|
|
5714
5997
|
"formatMoney"
|