oneslash-design-system 2.21.0 → 2.22.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/dist/cases/app-shell/top-tabs.jsx +10 -4
- package/dist/cases/app-shell.md +13 -5
- package/dist/cases/pricing-section/cards.jsx +3 -2
- package/dist/cases/pricing-section.md +4 -2
- package/dist/cases/settings-page/top-tabs.jsx +9 -6
- package/dist/cases/settings-page.md +13 -7
- package/dist/cases.json +6 -4
- package/dist/components/button.d.ts +2 -0
- package/dist/components/button.jsx +2 -2
- package/dist/components/lightbox.d.ts +4 -1
- package/dist/components/lightbox.jsx +48 -3
- package/dist/components/menuItem.jsx +1 -1
- 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/stories/Button.stories.jsx +12 -8
- package/dist/stories/Lightbox.stories.d.ts +3 -0
- package/dist/stories/Lightbox.stories.jsx +44 -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 +1 -1
|
@@ -3,6 +3,7 @@ import { useEffect, useRef, useState } from 'react';
|
|
|
3
3
|
import TitleBar from '../../components/titleBar';
|
|
4
4
|
import TabsContainer from '../../components/tabsContainer';
|
|
5
5
|
import Tab from '../../components/tab';
|
|
6
|
+
import TabPanel from '../../components/tabPanel';
|
|
6
7
|
import Modal from '../../components/modal';
|
|
7
8
|
import Heading from '../../components/heading';
|
|
8
9
|
import Paragraph from '../../components/paragraph';
|
|
@@ -82,11 +83,16 @@ export default function AppShellTopTabs() {
|
|
|
82
83
|
setAccountOpen(function (o) { return !o; });
|
|
83
84
|
}}/>
|
|
84
85
|
</Cluster>
|
|
85
|
-
<TabsContainer fill>
|
|
86
|
-
{places.map(function (p) { return (<Tab key={p.id} label={p.label} href={"/".concat(p.id)} router={router} isSelected={p.id === place.id} onClickTab={function () { return setPlaceId(p.id); }}/>); })}
|
|
86
|
+
<TabsContainer fill aria-label="Main">
|
|
87
|
+
{places.map(function (p) { return (<Tab key={p.id} id={"app-shell-tab-".concat(p.id)} controls={"app-shell-panel-".concat(p.id)} label={p.label} href={"/".concat(p.id)} router={router} isSelected={p.id === place.id} onClickTab={function () { return setPlaceId(p.id); }}/>); })}
|
|
87
88
|
</TabsContainer>
|
|
88
|
-
|
|
89
|
-
<
|
|
89
|
+
{/* Every place is in the page. Only the open one shows. */}
|
|
90
|
+
{places.map(function (p) { return (<TabPanel key={p.id} id={"app-shell-panel-".concat(p.id)} labelledBy={"app-shell-tab-".concat(p.id)} selected={p.id === place.id}>
|
|
91
|
+
<Stack gap="large">
|
|
92
|
+
<TitleBar title={p.page} actions={<Button size="medium" type="primary" state="enabled" label="New Message" decoIcon="Plus"/>}/>
|
|
93
|
+
<Paragraph tone="secondary" measure="none">{p.text}</Paragraph>
|
|
94
|
+
</Stack>
|
|
95
|
+
</TabPanel>); })}
|
|
90
96
|
</Stack>
|
|
91
97
|
<Popover open={accountOpen} anchorEl={accountAnchor} onClose={function () { return setAccountOpen(false); }} returnFocus>
|
|
92
98
|
<Menu navigable aria-label="Account" width={200}>
|
package/dist/cases/app-shell.md
CHANGED
|
@@ -214,7 +214,7 @@ export default function AppShellSidebar() {
|
|
|
214
214
|
|
|
215
215
|
Use when: There are four places or fewer, all fixed, each with a short name that fits on a phone.
|
|
216
216
|
|
|
217
|
-
Uses: `Button`, `Center`, `Cluster`, `Heading`, `Line`, `Menu`, `MenuItem`, `Modal`, `PageShell`, `Paragraph`, `Popover`, `Stack`, `Tab`, `TabsContainer`, `TitleBar`, `UserImage`
|
|
217
|
+
Uses: `Button`, `Center`, `Cluster`, `Heading`, `Line`, `Menu`, `MenuItem`, `Modal`, `PageShell`, `Paragraph`, `Popover`, `Stack`, `Tab`, `TabPanel`, `TabsContainer`, `TitleBar`, `UserImage`
|
|
218
218
|
|
|
219
219
|
```tsx
|
|
220
220
|
'use client';
|
|
@@ -222,6 +222,7 @@ import { useEffect, useRef, useState } from 'react';
|
|
|
222
222
|
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
223
223
|
import TabsContainer from 'oneslash-design-system/components/tabsContainer';
|
|
224
224
|
import Tab from 'oneslash-design-system/components/tab';
|
|
225
|
+
import TabPanel from 'oneslash-design-system/components/tabPanel';
|
|
225
226
|
import Modal from 'oneslash-design-system/components/modal';
|
|
226
227
|
import Heading from 'oneslash-design-system/components/heading';
|
|
227
228
|
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
@@ -324,13 +325,20 @@ export default function AppShellTopTabs() {
|
|
|
324
325
|
}}
|
|
325
326
|
/>
|
|
326
327
|
</Cluster>
|
|
327
|
-
<TabsContainer fill>
|
|
328
|
+
<TabsContainer fill aria-label="Main">
|
|
328
329
|
{places.map((p) => (
|
|
329
|
-
<Tab key={p.id} label={p.label} href={`/${p.id}`} router={router} isSelected={p.id === place.id} onClickTab={() => setPlaceId(p.id)} />
|
|
330
|
+
<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)} />
|
|
330
331
|
))}
|
|
331
332
|
</TabsContainer>
|
|
332
|
-
|
|
333
|
-
|
|
333
|
+
{/* Every place is in the page. Only the open one shows. */}
|
|
334
|
+
{places.map((p) => (
|
|
335
|
+
<TabPanel key={p.id} id={`app-shell-panel-${p.id}`} labelledBy={`app-shell-tab-${p.id}`} selected={p.id === place.id}>
|
|
336
|
+
<Stack gap="large">
|
|
337
|
+
<TitleBar title={p.page} actions={<Button size="medium" type="primary" state="enabled" label="New Message" decoIcon="Plus" />} />
|
|
338
|
+
<Paragraph tone="secondary" measure="none">{p.text}</Paragraph>
|
|
339
|
+
</Stack>
|
|
340
|
+
</TabPanel>
|
|
341
|
+
))}
|
|
334
342
|
</Stack>
|
|
335
343
|
<Popover open={accountOpen} anchorEl={accountAnchor} onClose={() => setAccountOpen(false)} returnFocus>
|
|
336
344
|
<Menu navigable aria-label="Account" width={200}>
|
|
@@ -20,8 +20,9 @@ export default function PricingSectionCards() {
|
|
|
20
20
|
<SectionIntro id="pricing" name="Pricing" statement="Pick the plan that fits your team."/>
|
|
21
21
|
<Stack gap="medium">
|
|
22
22
|
{/* Three across from md, stacked on a phone. A visitor has no current plan, so each plan asks to sign up. */}
|
|
23
|
+
{/* The small padding leaves room for the longest label, 'Sign Up for Business', inside its Button at md. */}
|
|
23
24
|
<Grid columns={3}>
|
|
24
|
-
{plans.map(function (p) { return (<Surface key={p.id} padding="
|
|
25
|
+
{plans.map(function (p) { return (<Surface key={p.id} padding="small">
|
|
25
26
|
<Stack gap="large">
|
|
26
27
|
<Stack gap="small">
|
|
27
28
|
<Heading level={3} size="h6">{p.name}</Heading>
|
|
@@ -29,7 +30,7 @@ export default function PricingSectionCards() {
|
|
|
29
30
|
</Stack>
|
|
30
31
|
<List items={p.includes} size="body2" marker="dot"/>
|
|
31
32
|
{/* The one primary Button is the plan to start with. Each is a link, so it works without a script. */}
|
|
32
|
-
<Button size="medium" type={p.id === 'pro' ? 'primary' : 'secondary'} state="enabled" label={"Sign Up for ".concat(p.name)} href={"https://acme.example/sign-up?plan=".concat(p.id)}/>
|
|
33
|
+
<Button size="medium" type={p.id === 'pro' ? 'primary' : 'secondary'} state="enabled" label={"Sign Up for ".concat(p.name)} href={"https://acme.example/sign-up?plan=".concat(p.id)} fullWidth/>
|
|
33
34
|
</Stack>
|
|
34
35
|
</Surface>); })}
|
|
35
36
|
</Grid>
|
|
@@ -6,7 +6,7 @@ A visitor to the public site compares the plans and signs up for one.
|
|
|
6
6
|
|
|
7
7
|
- Follow the rule 'A marketing page asks for one main action, in the same words everywhere'.
|
|
8
8
|
- 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.
|
|
9
|
-
- 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.
|
|
9
|
+
- 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.
|
|
10
10
|
- 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.
|
|
11
11
|
- 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'.
|
|
12
12
|
- Put the section's name in `SectionIntro`, so the section has a level 2 heading and a link of its own.
|
|
@@ -51,9 +51,10 @@ export default function PricingSectionCards() {
|
|
|
51
51
|
<SectionIntro id="pricing" name="Pricing" statement="Pick the plan that fits your team." />
|
|
52
52
|
<Stack gap="medium">
|
|
53
53
|
{/* Three across from md, stacked on a phone. A visitor has no current plan, so each plan asks to sign up. */}
|
|
54
|
+
{/* The small padding leaves room for the longest label, 'Sign Up for Business', inside its Button at md. */}
|
|
54
55
|
<Grid columns={3}>
|
|
55
56
|
{plans.map((p) => (
|
|
56
|
-
<Surface key={p.id} padding="
|
|
57
|
+
<Surface key={p.id} padding="small">
|
|
57
58
|
<Stack gap="large">
|
|
58
59
|
<Stack gap="small">
|
|
59
60
|
<Heading level={3} size="h6">{p.name}</Heading>
|
|
@@ -67,6 +68,7 @@ export default function PricingSectionCards() {
|
|
|
67
68
|
state="enabled"
|
|
68
69
|
label={`Sign Up for ${p.name}`}
|
|
69
70
|
href={`https://acme.example/sign-up?plan=${p.id}`}
|
|
71
|
+
fullWidth
|
|
70
72
|
/>
|
|
71
73
|
</Stack>
|
|
72
74
|
</Surface>
|
|
@@ -21,6 +21,7 @@ import Switch from '../../components/switch';
|
|
|
21
21
|
import Button from '../../components/button';
|
|
22
22
|
import TabsContainer from '../../components/tabsContainer';
|
|
23
23
|
import Tab from '../../components/tab';
|
|
24
|
+
import TabPanel from '../../components/tabPanel';
|
|
24
25
|
import SettingsSection, { SettingsColumns } from '../../components/settingsSection';
|
|
25
26
|
import { formatMoney } from '../../components/formatNumber';
|
|
26
27
|
import { Center, Cluster, Stack } from '../../components/layout';
|
|
@@ -116,15 +117,17 @@ export default function SettingsPageTopTabs() {
|
|
|
116
117
|
<List items={invoices} size="body2"/>
|
|
117
118
|
</SettingsSection>
|
|
118
119
|
</SettingsColumns>);
|
|
120
|
+
var panels = { profile: profile, notifications: notifications, billing: billing };
|
|
119
121
|
return (<Center width="page">
|
|
120
122
|
<Stack gap="xlarge">
|
|
121
|
-
<Heading level={1} size="h5">Settings</Heading>
|
|
122
|
-
<TabsContainer>
|
|
123
|
-
{areas.map(function (a) { return (<Tab key={a.id} label={a.label} href={"/settings/".concat(a.id)} router={router} isSelected={area === a.id} onClickTab={function () { return setArea(a.id); }}/>); })}
|
|
123
|
+
<Heading level={1} size="h5" id="settings-page-tabs-title">Settings</Heading>
|
|
124
|
+
<TabsContainer aria-labelledby="settings-page-tabs-title">
|
|
125
|
+
{areas.map(function (a) { return (<Tab key={a.id} id={"settings-page-tabs-tab-".concat(a.id)} controls={"settings-page-tabs-panel-".concat(a.id)} label={a.label} href={"/settings/".concat(a.id)} router={router} isSelected={area === a.id} onClickTab={function () { return setArea(a.id); }}/>); })}
|
|
124
126
|
</TabsContainer>
|
|
125
|
-
{area
|
|
126
|
-
{
|
|
127
|
-
|
|
127
|
+
{/* Every area is in the page. Only the open one shows. */}
|
|
128
|
+
{areas.map(function (a) { return (<TabPanel key={a.id} id={"settings-page-tabs-panel-".concat(a.id)} labelledBy={"settings-page-tabs-tab-".concat(a.id)} selected={area === a.id}>
|
|
129
|
+
{panels[a.id]}
|
|
130
|
+
</TabPanel>); })}
|
|
128
131
|
</Stack>
|
|
129
132
|
</Center>);
|
|
130
133
|
}
|
|
@@ -28,7 +28,7 @@ A person opens the settings of the product and looks for one area, such as Profi
|
|
|
28
28
|
|
|
29
29
|
Use when: Four areas or fewer, with short names that fit on a phone.
|
|
30
30
|
|
|
31
|
-
Uses: `Button`, `Center`, `Cluster`, `Form`, `FormField`, `Heading`, `List`, `Paragraph`, `SettingsColumns`, `SettingsSection`, `Stack`, `Switch`, `Tab`, `TabsContainer`, `TextField`, `formatMoney`
|
|
31
|
+
Uses: `Button`, `Center`, `Cluster`, `Form`, `FormField`, `Heading`, `List`, `Paragraph`, `SettingsColumns`, `SettingsSection`, `Stack`, `Switch`, `Tab`, `TabPanel`, `TabsContainer`, `TextField`, `formatMoney`
|
|
32
32
|
|
|
33
33
|
```tsx
|
|
34
34
|
'use client';
|
|
@@ -43,6 +43,7 @@ import Switch from 'oneslash-design-system/components/switch';
|
|
|
43
43
|
import Button from 'oneslash-design-system/components/button';
|
|
44
44
|
import TabsContainer from 'oneslash-design-system/components/tabsContainer';
|
|
45
45
|
import Tab from 'oneslash-design-system/components/tab';
|
|
46
|
+
import TabPanel from 'oneslash-design-system/components/tabPanel';
|
|
46
47
|
import SettingsSection, { SettingsColumns } from 'oneslash-design-system/components/settingsSection';
|
|
47
48
|
import { formatMoney } from 'oneslash-design-system/components/formatNumber';
|
|
48
49
|
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
@@ -146,18 +147,23 @@ export default function SettingsPageTopTabs() {
|
|
|
146
147
|
</SettingsColumns>
|
|
147
148
|
);
|
|
148
149
|
|
|
150
|
+
const panels = { profile, notifications, billing };
|
|
151
|
+
|
|
149
152
|
return (
|
|
150
153
|
<Center width="page">
|
|
151
154
|
<Stack gap="xlarge">
|
|
152
|
-
<Heading level={1} size="h5">Settings</Heading>
|
|
153
|
-
<TabsContainer>
|
|
155
|
+
<Heading level={1} size="h5" id="settings-page-tabs-title">Settings</Heading>
|
|
156
|
+
<TabsContainer aria-labelledby="settings-page-tabs-title">
|
|
154
157
|
{areas.map((a) => (
|
|
155
|
-
<Tab key={a.id} label={a.label} href={`/settings/${a.id}`} router={router} isSelected={area === a.id} onClickTab={() => setArea(a.id)} />
|
|
158
|
+
<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)} />
|
|
156
159
|
))}
|
|
157
160
|
</TabsContainer>
|
|
158
|
-
{area
|
|
159
|
-
{
|
|
160
|
-
|
|
161
|
+
{/* Every area is in the page. Only the open one shows. */}
|
|
162
|
+
{areas.map((a) => (
|
|
163
|
+
<TabPanel key={a.id} id={`settings-page-tabs-panel-${a.id}`} labelledBy={`settings-page-tabs-tab-${a.id}`} selected={area === a.id}>
|
|
164
|
+
{panels[a.id]}
|
|
165
|
+
</TabPanel>
|
|
166
|
+
))}
|
|
161
167
|
</Stack>
|
|
162
168
|
</Center>
|
|
163
169
|
);
|
package/dist/cases.json
CHANGED
|
@@ -821,7 +821,7 @@
|
|
|
821
821
|
"id": "top-tabs",
|
|
822
822
|
"title": "Tabs across the top",
|
|
823
823
|
"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={
|
|
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 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
825
|
"uses": [
|
|
826
826
|
"Button",
|
|
827
827
|
"Center",
|
|
@@ -836,6 +836,7 @@
|
|
|
836
836
|
"Popover",
|
|
837
837
|
"Stack",
|
|
838
838
|
"Tab",
|
|
839
|
+
"TabPanel",
|
|
839
840
|
"TabsContainer",
|
|
840
841
|
"TitleBar",
|
|
841
842
|
"UserImage"
|
|
@@ -5025,7 +5026,7 @@
|
|
|
5025
5026
|
"do": [
|
|
5026
5027
|
"Follow the rule 'A marketing page asks for one main action, in the same words everywhere'.",
|
|
5027
5028
|
"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.",
|
|
5029
|
+
"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
5030
|
"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
5031
|
"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
5032
|
"Put the section's name in `SectionIntro`, so the section has a level 2 heading and a link of its own.",
|
|
@@ -5045,7 +5046,7 @@
|
|
|
5045
5046
|
"id": "cards",
|
|
5046
5047
|
"title": "Plan cards side by side",
|
|
5047
5048
|
"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=\"
|
|
5049
|
+
"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
5050
|
"uses": [
|
|
5050
5051
|
"Button",
|
|
5051
5052
|
"Grid",
|
|
@@ -5694,7 +5695,7 @@
|
|
|
5694
5695
|
"id": "top-tabs",
|
|
5695
5696
|
"title": "Tabs across the top",
|
|
5696
5697
|
"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
|
|
5698
|
+
"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
5699
|
"uses": [
|
|
5699
5700
|
"Button",
|
|
5700
5701
|
"Center",
|
|
@@ -5709,6 +5710,7 @@
|
|
|
5709
5710
|
"Stack",
|
|
5710
5711
|
"Switch",
|
|
5711
5712
|
"Tab",
|
|
5713
|
+
"TabPanel",
|
|
5712
5714
|
"TabsContainer",
|
|
5713
5715
|
"TextField",
|
|
5714
5716
|
"formatMoney"
|
|
@@ -18,6 +18,8 @@ interface ButtonProps extends React.AriaAttributes {
|
|
|
18
18
|
onClickButton?: any;
|
|
19
19
|
onClickActionIcon?: () => void;
|
|
20
20
|
className?: string;
|
|
21
|
+
/** Fills the width of its container, as a `<button>` and as a link. Without it a link Button is as wide as its label. */
|
|
22
|
+
fullWidth?: boolean;
|
|
21
23
|
/** Shows a spinner in the icon slot and keeps the label. The button stays focusable (`aria-disabled`) and ignores presses, so a form cannot submit twice. */
|
|
22
24
|
loading?: boolean;
|
|
23
25
|
/** Renders a link that looks like the button. A path goes through `next/link`; an `http(s)://` URL is a plain `<a>`. */
|
|
@@ -28,7 +28,7 @@ import { LoadingSmall } from './loadingScreen';
|
|
|
28
28
|
import { focusRing, focusRingDanger, pressFeedback, pressFeedbackAny, stateTransition } from './sharedStyles';
|
|
29
29
|
/** The ref reaches the `<button>`, or the `<a>` when `href` is set, so a page can move focus to it */
|
|
30
30
|
var Button = forwardRef(function Button(_a, ref) {
|
|
31
|
-
var size = _a.size, type = _a.type, _b = _a.color, color = _b === void 0 ? 'default' : _b, state = _a.state, label = _a.label, secondLabel = _a.secondLabel, decoIcon = _a.decoIcon, actionIcon = _a.actionIcon, onClickButton = _a.onClickButton, onClickActionIcon = _a.onClickActionIcon, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.
|
|
31
|
+
var size = _a.size, type = _a.type, _b = _a.color, color = _b === void 0 ? 'default' : _b, state = _a.state, label = _a.label, secondLabel = _a.secondLabel, decoIcon = _a.decoIcon, actionIcon = _a.actionIcon, onClickButton = _a.onClickButton, onClickActionIcon = _a.onClickActionIcon, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.fullWidth, fullWidth = _d === void 0 ? false : _d, _e = _a.loading, loading = _e === void 0 ? false : _e, href = _a.href, _f = _a.openInNewTab, openInNewTab = _f === void 0 ? false : _f, replace = _a.replace, _g = _a.htmlType, htmlType = _g === void 0 ? 'button' : _g, rest = __rest(_a, ["size", "type", "color", "state", "label", "secondLabel", "decoIcon", "actionIcon", "onClickButton", "onClickActionIcon", "className", "fullWidth", "loading", "href", "openInNewTab", "replace", "htmlType"]);
|
|
32
32
|
var isLink = href !== undefined;
|
|
33
33
|
// Horizontal padding sits on the button so an icon and the label are inset equally
|
|
34
34
|
var sizeClasses = {
|
|
@@ -94,7 +94,7 @@ var Button = forwardRef(function Button(_a, ref) {
|
|
|
94
94
|
// gets the press feedback for non-buttons and a zero-specificity fit width that `w-full` overrides.
|
|
95
95
|
var linkClasses = state === 'disabled' || loading ? '[:where(&)]:w-fit' : "[:where(&)]:w-fit ".concat(pressFeedbackAny);
|
|
96
96
|
// Hover is pure CSS; `state="hovered"` and `state="focused"` only exist to show those states in docs
|
|
97
|
-
var buttonClasses = "\n flex flex-row items-center rounded-control ".concat(justify, " ").concat(stateTransition, " ").concat(isLink ? linkClasses : loading ? '' : pressFeedback, "\n ").concat(color === 'danger' ? focusRingDanger : focusRing, "\n ").concat(sizeClasses, "\n ").concat(state === 'selected' ? stateClasses.selected : '', "\n ").concat(state === 'enabled' || state === 'hovered' ? "".concat(baseTypeClasses, " ").concat(loading ? 'cursor-wait' : "".concat(stateClasses.enabled, " ").concat(hoverTypeClasses)) : '', "\n ").concat(state === 'focused' ? "".concat(baseTypeClasses, " ").concat(hoverTypeClasses, " ").concat(stateClasses.focused) : '', "\n ").concat(state === 'disabled' ? stateClasses.disabled : '', "\n ").concat(className, "\n ");
|
|
97
|
+
var buttonClasses = "\n flex flex-row items-center rounded-control ".concat(justify, " ").concat(stateTransition, " ").concat(isLink ? linkClasses : loading ? '' : pressFeedback, "\n ").concat(color === 'danger' ? focusRingDanger : focusRing, "\n ").concat(sizeClasses, "\n ").concat(state === 'selected' ? stateClasses.selected : '', "\n ").concat(state === 'enabled' || state === 'hovered' ? "".concat(baseTypeClasses, " ").concat(loading ? 'cursor-wait' : "".concat(stateClasses.enabled, " ").concat(hoverTypeClasses)) : '', "\n ").concat(state === 'focused' ? "".concat(baseTypeClasses, " ").concat(hoverTypeClasses, " ").concat(stateClasses.focused) : '', "\n ").concat(state === 'disabled' ? stateClasses.disabled : '', "\n ").concat(className).concat(fullWidth ? ' w-full' : '', "\n ");
|
|
98
98
|
var content = (<>
|
|
99
99
|
{/* Group IconLeft and label in a flex container for left alignment */}
|
|
100
100
|
<div className={"flex items-center ".concat(size === 'tiny' ? 'gap-0.5' : 'gap-1')}>
|
|
@@ -23,7 +23,10 @@ interface LightboxProps {
|
|
|
23
23
|
* backdrop and Close close it, and the Modal gives focus back to what opened it. Images only: no video.
|
|
24
24
|
*/
|
|
25
25
|
export default function Lightbox({ images, index, onIndexChange, isOpen, onClose, 'aria-label': ariaLabel, }: LightboxProps): React.JSX.Element | null;
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* A thumbnail that opens the Lightbox: a button named 'Open image: <alt>' around a cropped Figure. When its image
|
|
28
|
+
* fails, a tile with 'Image not loaded' takes its place in the same box, and it still opens the viewer.
|
|
29
|
+
*/
|
|
27
30
|
export declare function LightboxThumbnail({ image, onOpen }: {
|
|
28
31
|
image: LightboxImage;
|
|
29
32
|
onOpen: () => void;
|
|
@@ -149,12 +149,57 @@ export default function Lightbox(_a) {
|
|
|
149
149
|
</div>
|
|
150
150
|
</Modal>);
|
|
151
151
|
}
|
|
152
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* A thumbnail that opens the Lightbox: a button named 'Open image: <alt>' around a cropped Figure. When its image
|
|
154
|
+
* fails, a tile with 'Image not loaded' takes its place in the same box, and it still opens the viewer.
|
|
155
|
+
*/
|
|
153
156
|
export function LightboxThumbnail(_a) {
|
|
154
157
|
var image = _a.image, onOpen = _a.onOpen;
|
|
155
|
-
|
|
158
|
+
var ref = useRef(null);
|
|
159
|
+
// The src that failed, so a new src starts over and a late result for an old one changes nothing
|
|
160
|
+
var _b = useState(null), failedSrc = _b[0], setFailedSrc = _b[1];
|
|
161
|
+
var broken = failedSrc === image.src;
|
|
162
|
+
useIsomorphicLayoutEffect(function () {
|
|
163
|
+
var _a;
|
|
164
|
+
if (broken)
|
|
165
|
+
return;
|
|
166
|
+
var img = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.querySelector('img');
|
|
167
|
+
if (!img)
|
|
168
|
+
return;
|
|
169
|
+
var src = image.src;
|
|
170
|
+
var live = true;
|
|
171
|
+
var fail = function () {
|
|
172
|
+
if (live)
|
|
173
|
+
setFailedSrc(src);
|
|
174
|
+
};
|
|
175
|
+
var probe = null;
|
|
176
|
+
img.addEventListener('error', fail);
|
|
177
|
+
// An image that failed before this listener existed (server-rendered HTML) is complete with no pixels. decode()
|
|
178
|
+
// rejects for it; a loaded image resolves, and one still loading is not complete and waits for the error event.
|
|
179
|
+
if (img.complete) {
|
|
180
|
+
img.decode().catch(function () {
|
|
181
|
+
if (!live || img.naturalWidth !== 0)
|
|
182
|
+
return;
|
|
183
|
+
// A good image with no natural size (an SVG with only a viewBox) loads again; a broken one fails again.
|
|
184
|
+
// The probe is never put in the page.
|
|
185
|
+
probe = document.createElement('img');
|
|
186
|
+
probe.onerror = fail;
|
|
187
|
+
probe.src = src;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
return function () {
|
|
191
|
+
live = false;
|
|
192
|
+
img.removeEventListener('error', fail);
|
|
193
|
+
if (probe)
|
|
194
|
+
probe.onerror = null;
|
|
195
|
+
};
|
|
196
|
+
}, [image.src, broken]);
|
|
197
|
+
return (<button ref={ref} type="button" aria-label={"Open image: ".concat(image.alt)} onClick={onOpen} className={"block w-full cursor-zoom-in rounded-container transition-opacity hover:opacity-90 motion-reduce:transition-none ".concat(focusRing)}>
|
|
156
198
|
<Figure crop={4 / 3}>
|
|
157
|
-
<
|
|
199
|
+
{broken ? (<div className="absolute inset-0 flex flex-col items-center justify-center gap-small bg-background-panel p-small text-center">
|
|
200
|
+
<Icon icon={ImageOff} size="small" color="disabled"/>
|
|
201
|
+
<span className="text-caption text-fg-secondary">Image not loaded</span>
|
|
202
|
+
</div>) : (<Image src={image.src} alt=""/>)}
|
|
158
203
|
</Figure>
|
|
159
204
|
</button>);
|
|
160
205
|
}
|
|
@@ -43,7 +43,7 @@ export default function MenuItem(_a) {
|
|
|
43
43
|
<div className="flex items-center gap-2 flex-shrink-0">
|
|
44
44
|
{tag && (<Tag variant={tag.variant || 'contained'} size={tagSize} label={tag.label} iconName={tag.iconName}
|
|
45
45
|
// 'default' has a fill that stays visible on the menu background
|
|
46
|
-
color={(_b = tag.color) !== null && _b !== void 0 ? _b : 'default'}/>)}
|
|
46
|
+
color={(_b = tag.color) !== null && _b !== void 0 ? _b : 'default'} onSelectedRow={!!isSelected}/>)}
|
|
47
47
|
<IconSlot icon={iconRight} className={"".concat(iconSize, " ").concat(isSelected ? 'text-primary-contrast' : 'text-fg-secondary', " flex-shrink-0")}/>
|
|
48
48
|
{rightAction && (<div onClick={function (e) { return e.stopPropagation(); }}>
|
|
49
49
|
{rightAction}
|
|
@@ -17,6 +17,11 @@ export interface SiteHeaderLink {
|
|
|
17
17
|
/** The page the reader is on: gets `aria-current="page"` */
|
|
18
18
|
current?: boolean;
|
|
19
19
|
}
|
|
20
|
+
/** A titled group of links: the pages of one section */
|
|
21
|
+
export interface SiteHeaderSection {
|
|
22
|
+
title: string;
|
|
23
|
+
links: SiteHeaderLink[];
|
|
24
|
+
}
|
|
20
25
|
interface SiteHeaderProps {
|
|
21
26
|
brand: SiteBrand;
|
|
22
27
|
/** The main places, in order. From md a row in the bar; below md in the menu. */
|
|
@@ -36,6 +41,11 @@ interface SiteHeaderProps {
|
|
|
36
41
|
* It never moves into the Menu, so keep it short enough for a phone.
|
|
37
42
|
*/
|
|
38
43
|
nav?: React.ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* The pages of the open section, such as a docs section's page list. Below md they show in the menu under the main links,
|
|
46
|
+
* titled, with the `current` page marked. From md they are not shown: the page lists them itself.
|
|
47
|
+
*/
|
|
48
|
+
sectionLinks?: SiteHeaderSection;
|
|
39
49
|
/** The Menu IconButton's name, and the Drawer's. Default 'Menu'. */
|
|
40
50
|
menuLabel?: string;
|
|
41
51
|
/** The skip link's text. Default 'Skip to content'. */
|
|
@@ -46,10 +56,11 @@ interface SiteHeaderProps {
|
|
|
46
56
|
/**
|
|
47
57
|
* A site's bar, sticky at the top: a skip link, the brand, the main links and the actions. Below md the
|
|
48
58
|
* links and `actions` move into a start Drawer a Menu IconButton opens; the brand and the `phoneAction` stay.
|
|
49
|
-
* With no `links` and no `actions` there is no Main nav, no Menu IconButton and no Drawer
|
|
59
|
+
* With no `links` and no `actions` there is no Main nav, no Menu IconButton and no Drawer, unless `sectionLinks` gives the menu
|
|
60
|
+
* the open section's pages.
|
|
50
61
|
* While mounted it sets `--os-header-offset` (its height) on `<html>`; `PageShell` with `aside` gives its level 2 and 3 headings
|
|
51
62
|
* `scroll-margin-top: var(--os-header-offset, 0px)`, so a `#hash` link lands below the bar. Other headings need the same.
|
|
52
63
|
* Use one SiteHeader per page: there is one `--os-header-offset`, and unmounting any header removes it.
|
|
53
64
|
*/
|
|
54
|
-
export default function SiteHeader({ brand, links, actions, phoneAction, nav, menuLabel, skipLabel, mainId, }: SiteHeaderProps): React.JSX.Element;
|
|
65
|
+
export default function SiteHeader({ brand, links, actions, phoneAction, nav, sectionLinks, menuLabel, skipLabel, mainId, }: SiteHeaderProps): React.JSX.Element;
|
|
55
66
|
export { SiteHeader };
|
|
@@ -10,16 +10,18 @@ var WIDE = '(min-width: 768px)';
|
|
|
10
10
|
/**
|
|
11
11
|
* A site's bar, sticky at the top: a skip link, the brand, the main links and the actions. Below md the
|
|
12
12
|
* links and `actions` move into a start Drawer a Menu IconButton opens; the brand and the `phoneAction` stay.
|
|
13
|
-
* With no `links` and no `actions` there is no Main nav, no Menu IconButton and no Drawer
|
|
13
|
+
* With no `links` and no `actions` there is no Main nav, no Menu IconButton and no Drawer, unless `sectionLinks` gives the menu
|
|
14
|
+
* the open section's pages.
|
|
14
15
|
* While mounted it sets `--os-header-offset` (its height) on `<html>`; `PageShell` with `aside` gives its level 2 and 3 headings
|
|
15
16
|
* `scroll-margin-top: var(--os-header-offset, 0px)`, so a `#hash` link lands below the bar. Other headings need the same.
|
|
16
17
|
* Use one SiteHeader per page: there is one `--os-header-offset`, and unmounting any header removes it.
|
|
17
18
|
*/
|
|
18
19
|
export default function SiteHeader(_a) {
|
|
19
|
-
var brand = _a.brand, links = _a.links, actions = _a.actions, phoneAction = _a.phoneAction, nav = _a.nav, _b = _a.menuLabel, menuLabel = _b === void 0 ? 'Menu' : _b, _c = _a.skipLabel, skipLabel = _c === void 0 ? 'Skip to content' : _c, _d = _a.mainId, mainId = _d === void 0 ? 'main' : _d;
|
|
20
|
+
var brand = _a.brand, links = _a.links, actions = _a.actions, phoneAction = _a.phoneAction, nav = _a.nav, sectionLinks = _a.sectionLinks, _b = _a.menuLabel, menuLabel = _b === void 0 ? 'Menu' : _b, _c = _a.skipLabel, skipLabel = _c === void 0 ? 'Skip to content' : _c, _d = _a.mainId, mainId = _d === void 0 ? 'main' : _d;
|
|
20
21
|
var drawerId = useId();
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
var sectionTitleId = useId();
|
|
23
|
+
// Without links, actions or section links there is nothing for a Menu to hold
|
|
24
|
+
var hasMenu = links.length > 0 || !!actions || !!(sectionLinks === null || sectionLinks === void 0 ? void 0 : sectionLinks.links.length);
|
|
23
25
|
var _e = useState(false), menuOpen = _e[0], setMenuOpen = _e[1];
|
|
24
26
|
var barRef = useRef(null);
|
|
25
27
|
// Set when widening closes the Drawer while focus was in it: the Menu IconButton it would go back to is hidden from md up
|
|
@@ -85,14 +87,15 @@ export default function SiteHeader(_a) {
|
|
|
85
87
|
if (choice && e.currentTarget.contains(choice) && !choice.hasAttribute('aria-haspopup'))
|
|
86
88
|
setMenuOpen(false);
|
|
87
89
|
};
|
|
90
|
+
var list = function (items, vertical) { return (<ul className={"m-0 flex list-none p-0 ".concat(vertical ? 'flex-col gap-0.5' : 'flex-wrap items-center gap-x-1 gap-y-0.5')}>
|
|
91
|
+
{items.map(function (link) { return (<li key={link.href + link.label}>
|
|
92
|
+
<a href={link.href} aria-current={link.current ? 'page' : undefined} className={"block whitespace-nowrap rounded-control no-underline hover:bg-background-accent200 ".concat(vertical ? 'px-3 py-2.5 text-body1' : 'px-2 py-1.5 text-body2', " ").concat(link.current ? 'bg-background-accent100 text-fg-primary' : 'text-fg-secondary hover:text-fg-primary', " ").concat(focusRing)}>
|
|
93
|
+
{link.label}
|
|
94
|
+
</a>
|
|
95
|
+
</li>); })}
|
|
96
|
+
</ul>); };
|
|
88
97
|
var linkList = function (vertical) { return (<nav aria-label="Main" className={vertical ? '' : 'hidden min-w-0 flex-1 md:block'}>
|
|
89
|
-
|
|
90
|
-
{links.map(function (link) { return (<li key={link.href + link.label}>
|
|
91
|
-
<a href={link.href} aria-current={link.current ? 'page' : undefined} className={"block whitespace-nowrap rounded-control no-underline hover:bg-background-accent200 ".concat(vertical ? 'px-3 py-2.5 text-body1' : 'px-2 py-1.5 text-body2', " ").concat(link.current ? 'bg-background-accent100 text-fg-primary' : 'text-fg-secondary hover:text-fg-primary', " ").concat(focusRing)}>
|
|
92
|
-
{link.label}
|
|
93
|
-
</a>
|
|
94
|
-
</li>); })}
|
|
95
|
-
</ul>
|
|
98
|
+
{list(links, vertical)}
|
|
96
99
|
</nav>); };
|
|
97
100
|
// The Drawer is a sibling of the header: a sticky header is a stacking context, and the panel must sit above the page
|
|
98
101
|
return (<>
|
|
@@ -116,7 +119,13 @@ export default function SiteHeader(_a) {
|
|
|
116
119
|
</header>
|
|
117
120
|
{hasMenu && (<Drawer id={drawerId} isOpen={menuOpen} onClose={function () { return setMenuOpen(false); }} aria-label={menuLabel} side="start" size="small">
|
|
118
121
|
<div onClick={closeOnChoice} className="flex flex-col gap-4">
|
|
119
|
-
{linkList(true)}
|
|
122
|
+
{(links.length > 0 || !(sectionLinks === null || sectionLinks === void 0 ? void 0 : sectionLinks.links.length)) && linkList(true)}
|
|
123
|
+
{sectionLinks && sectionLinks.links.length > 0 && (<nav aria-labelledby={sectionTitleId}>
|
|
124
|
+
<h2 id={sectionTitleId} className="px-3 pb-1 text-caption text-fg-secondary">
|
|
125
|
+
{sectionLinks.title}
|
|
126
|
+
</h2>
|
|
127
|
+
{list(sectionLinks.links, true)}
|
|
128
|
+
</nav>)}
|
|
120
129
|
{actions && <div className="flex flex-col items-start gap-2">{actions}</div>}
|
|
121
130
|
</div>
|
|
122
131
|
</Drawer>)}
|
package/dist/components/tag.d.ts
CHANGED
|
@@ -23,6 +23,11 @@ interface TagProps {
|
|
|
23
23
|
* `state="selected"` still gives the selected look then, but it is only a look. No effect without `onClick`.
|
|
24
24
|
*/
|
|
25
25
|
toggle?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Set by a row with the selected fill (`bg-primary-dark`), such as a selected `MenuItem`. A `dot` or `textOnly`
|
|
28
|
+
* tag then uses `primary-contrast` for its text, dot and border. A `contained` tag keeps its own fill.
|
|
29
|
+
*/
|
|
30
|
+
onSelectedRow?: boolean;
|
|
26
31
|
}
|
|
27
|
-
export default function Tag({ variant, size, state, color, label, secondLabel, iconName, icon, onClick, disabled, 'aria-label': ariaLabel, toggle, }: TagProps): React.JSX.Element;
|
|
32
|
+
export default function Tag({ variant, size, state, color, label, secondLabel, iconName, icon, onClick, disabled, 'aria-label': ariaLabel, toggle, onSelectedRow, }: TagProps): React.JSX.Element;
|
|
28
33
|
export {};
|
package/dist/components/tag.jsx
CHANGED
|
@@ -48,7 +48,7 @@ var colorConfig = {
|
|
|
48
48
|
},
|
|
49
49
|
};
|
|
50
50
|
export default function Tag(_a) {
|
|
51
|
-
var variant = _a.variant, size = _a.size, _b = _a.state, state = _b === void 0 ? 'enabled' : _b, color = _a.color, label = _a.label, secondLabel = _a.secondLabel, iconName = _a.iconName, icon = _a.icon, onClick = _a.onClick, _c = _a.disabled, disabled = _c === void 0 ? false : _c, ariaLabel = _a["aria-label"], _d = _a.toggle, toggle = _d === void 0 ? true : _d;
|
|
51
|
+
var variant = _a.variant, size = _a.size, _b = _a.state, state = _b === void 0 ? 'enabled' : _b, color = _a.color, label = _a.label, secondLabel = _a.secondLabel, iconName = _a.iconName, icon = _a.icon, onClick = _a.onClick, _c = _a.disabled, disabled = _c === void 0 ? false : _c, ariaLabel = _a["aria-label"], _d = _a.toggle, toggle = _d === void 0 ? true : _d, _e = _a.onSelectedRow, onSelectedRow = _e === void 0 ? false : _e;
|
|
52
52
|
// Size and padding
|
|
53
53
|
var sizeClasses = {
|
|
54
54
|
medium: 'text-body2 px-2 py-1',
|
|
@@ -73,9 +73,14 @@ export default function Tag(_a) {
|
|
|
73
73
|
else if (variant === 'contained') {
|
|
74
74
|
bgClasses = 'bg-background-accent300';
|
|
75
75
|
}
|
|
76
|
+
// On a selected row's fill only primary-contrast is readable; a contained tag keeps its own fill
|
|
77
|
+
var onRowFill = onSelectedRow && variant !== 'contained';
|
|
76
78
|
// Font color
|
|
77
79
|
var fontClasses = '';
|
|
78
|
-
if (
|
|
80
|
+
if (onRowFill) {
|
|
81
|
+
fontClasses = 'text-primary-contrast';
|
|
82
|
+
}
|
|
83
|
+
else if (variant === 'dot') {
|
|
79
84
|
fontClasses = 'text-fg-primary';
|
|
80
85
|
}
|
|
81
86
|
else if (colorStyles) {
|
|
@@ -99,20 +104,20 @@ export default function Tag(_a) {
|
|
|
99
104
|
}
|
|
100
105
|
else if (colorStyles) {
|
|
101
106
|
if (variant === 'textOnly' && colorStyles.hasBorderTextOnly) {
|
|
102
|
-
borderClasses = "border ".concat(colorStyles.border);
|
|
107
|
+
borderClasses = onRowFill ? 'border border-primary-contrast' : "border ".concat(colorStyles.border);
|
|
103
108
|
}
|
|
104
109
|
else if (variant === 'contained') {
|
|
105
110
|
borderClasses = "border ".concat(colorStyles.border);
|
|
106
111
|
}
|
|
107
112
|
}
|
|
108
113
|
else if (isSelected && variant === 'textOnly') {
|
|
109
|
-
borderClasses = 'border border-accent-main';
|
|
114
|
+
borderClasses = onRowFill ? 'border border-primary-contrast' : 'border border-accent-main';
|
|
110
115
|
}
|
|
111
116
|
else if (variant === 'contained') {
|
|
112
117
|
borderClasses = 'border border-misc-divider';
|
|
113
118
|
}
|
|
114
119
|
// Dot color
|
|
115
|
-
var dotColor = (colorStyles === null || colorStyles === void 0 ? void 0 : colorStyles.dot) || colorConfig.default.dot;
|
|
120
|
+
var dotColor = onRowFill ? 'bg-primary-contrast' : (colorStyles === null || colorStyles === void 0 ? void 0 : colorStyles.dot) || colorConfig.default.dot;
|
|
116
121
|
var isDisabled = !!onClick && disabled;
|
|
117
122
|
// Hover (only when not selected, not disabled, no color, and onClick is provided)
|
|
118
123
|
var hoverClasses = !isSelected && !isDisabled && !color && variant === 'contained' && onClick
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useRef, useState } from "react";
|
|
2
2
|
import { ChevronDown, ChevronRight, ExternalLink, Plus, Star } from "lucide-react";
|
|
3
3
|
import Button from "../components/button";
|
|
4
|
+
import { Stack } from "../components/layout";
|
|
4
5
|
var meta = {
|
|
5
6
|
title: "Components/Button",
|
|
6
7
|
component: Button,
|
|
@@ -188,15 +189,18 @@ export var Submit = {
|
|
|
188
189
|
<Button size="medium" type="tertiary" state="enabled" label="Reset" htmlType="reset"/>
|
|
189
190
|
</form>); },
|
|
190
191
|
};
|
|
191
|
-
//
|
|
192
|
-
// label stays at the start and the icon sits at the far edge.
|
|
192
|
+
// `fullWidth` fills the container, as a <button> and as a link. A lone label is centered. With an
|
|
193
|
+
// action icon the label stays at the start and the icon sits at the far edge. Without it a link
|
|
194
|
+
// is as wide as its label, even in a stretching Stack.
|
|
193
195
|
export var FullWidth = {
|
|
194
|
-
render: function () { return (<div
|
|
195
|
-
<
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
render: function () { return (<div data-testid="column" style={{ width: "320px" }}>
|
|
197
|
+
<Stack gap="medium">
|
|
198
|
+
<Button size="medium" type="primary" state="enabled" label="Continue" fullWidth/>
|
|
199
|
+
<Button size="medium" type="secondary" state="enabled" label="Add item" decoIcon={Plus} fullWidth/>
|
|
200
|
+
<Button size="medium" type="tertiary" state="enabled" label="Filters" actionIcon={ChevronDown} fullWidth/>
|
|
201
|
+
<Button size="medium" type="primary" state="enabled" label="Link, full width" href="/gallery" fullWidth/>
|
|
202
|
+
<Button size="medium" type="primary" state="enabled" label="Link, fits content" href="/gallery"/>
|
|
203
|
+
</Stack>
|
|
200
204
|
</div>); },
|
|
201
205
|
};
|
|
202
206
|
// For tests/interactions.spec.ts: the ref reaches the <button> and the link, so focus can be moved to them
|
|
@@ -6,3 +6,6 @@ type Story = StoryObj<typeof Lightbox>;
|
|
|
6
6
|
export declare const Gallery: Story;
|
|
7
7
|
export declare const One: Story;
|
|
8
8
|
export declare const Broken: Story;
|
|
9
|
+
export declare const BrokenThumbnail: Story;
|
|
10
|
+
export declare const ThumbnailHydrateProbe: Story;
|
|
11
|
+
export declare const ThumbnailHydrateGoodProbe: Story;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
1
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { renderToString } from "react-dom/server";
|
|
3
|
+
import { hydrateRoot } from "react-dom/client";
|
|
2
4
|
import Lightbox, { LightboxThumbnail } from "../components/lightbox";
|
|
3
5
|
var meta = {
|
|
4
6
|
title: "Components/Lightbox",
|
|
@@ -38,3 +40,44 @@ export var One = {
|
|
|
38
40
|
export var Broken = {
|
|
39
41
|
render: function () { return (<GalleryDemo images={[{ src: "data:image/png;base64,bm90IGFuIGltYWdl", alt: "The launch checklist pinned to a board" }, images[0], images[1]]} open/>); },
|
|
40
42
|
};
|
|
43
|
+
var brokenFirst = [{ src: "data:image/png;base64,bm90IGFuIGltYWdl", alt: "The launch checklist pinned to a board" }, images[0], images[1]];
|
|
44
|
+
// Closed, with a first thumbnail that fails: its tile is the size of the others and still opens the viewer.
|
|
45
|
+
export var BrokenThumbnail = {
|
|
46
|
+
tags: ["shell"],
|
|
47
|
+
render: function () { return <GalleryDemo images={brokenFirst}/>; },
|
|
48
|
+
};
|
|
49
|
+
// Test-only: the thumbnail's server markup is put on the page, its image fails (or, with a good image, loads), and
|
|
50
|
+
// only then does React hydrate it.
|
|
51
|
+
function HydrateProbe(_a) {
|
|
52
|
+
var _b = _a.image, image = _b === void 0 ? brokenFirst[0] : _b, _c = _a.after, after = _c === void 0 ? "error" : _c;
|
|
53
|
+
var ref = useRef(null);
|
|
54
|
+
useEffect(function () {
|
|
55
|
+
var el = ref.current;
|
|
56
|
+
if (!el)
|
|
57
|
+
return;
|
|
58
|
+
var thumb = <LightboxThumbnail image={image} onOpen={function () { }}/>;
|
|
59
|
+
el.innerHTML = renderToString(thumb);
|
|
60
|
+
var img = el.querySelector("img");
|
|
61
|
+
var root = null;
|
|
62
|
+
var hydrate = function () {
|
|
63
|
+
root = hydrateRoot(el, thumb);
|
|
64
|
+
};
|
|
65
|
+
img === null || img === void 0 ? void 0 : img.addEventListener(after, hydrate, { once: true });
|
|
66
|
+
return function () {
|
|
67
|
+
img === null || img === void 0 ? void 0 : img.removeEventListener(after, hydrate);
|
|
68
|
+
var r = root;
|
|
69
|
+
if (r)
|
|
70
|
+
setTimeout(function () { return r.unmount(); });
|
|
71
|
+
};
|
|
72
|
+
}, []);
|
|
73
|
+
return <div ref={ref} style={{ width: 160 }}/>;
|
|
74
|
+
}
|
|
75
|
+
export var ThumbnailHydrateProbe = {
|
|
76
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
77
|
+
render: function () { return <HydrateProbe />; },
|
|
78
|
+
};
|
|
79
|
+
// Test-only: a good thumbnail that has loaded before React hydrates it.
|
|
80
|
+
export var ThumbnailHydrateGoodProbe = {
|
|
81
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
82
|
+
render: function () { return <HydrateProbe image={images[0]} after="load"/>; },
|
|
83
|
+
};
|
|
@@ -96,3 +96,11 @@ export var Danger = {
|
|
|
96
96
|
isSelected: false,
|
|
97
97
|
},
|
|
98
98
|
};
|
|
99
|
+
export var SelectedWithTags = {
|
|
100
|
+
render: function () { return (<div style={{ width: 280 }} className="flex flex-col gap-1">
|
|
101
|
+
<MenuItem label="Inbox" iconName="Inbox" isSelected tag={{ label: "3", variant: "textOnly" }}/>
|
|
102
|
+
<MenuItem label="Online" iconName="Users" isSelected tag={{ label: "Live", variant: "dot", color: "success" }}/>
|
|
103
|
+
<MenuItem label="Drafts" iconName="File" tag={{ label: "3", variant: "textOnly" }}/>
|
|
104
|
+
<MenuItem label="Offline" iconName="Users" tag={{ label: "Away", variant: "dot", color: "warning" }}/>
|
|
105
|
+
</div>); },
|
|
106
|
+
};
|
|
@@ -6,5 +6,9 @@ type Story = StoryObj<typeof SiteHeader>;
|
|
|
6
6
|
export declare const Links: Story;
|
|
7
7
|
export declare const Phone: Story;
|
|
8
8
|
export declare const LongLabels: Story;
|
|
9
|
+
export declare const SectionLinks: Story;
|
|
10
|
+
export declare const SectionLinksOpen: Story;
|
|
11
|
+
export declare const SectionsOnlyProbe: Story;
|
|
12
|
+
export declare const EmptySectionProbe: Story;
|
|
9
13
|
export declare const Probe: Story;
|
|
10
14
|
export declare const UnmountProbe: Story;
|
|
@@ -1,7 +1,45 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
1
37
|
import React, { useEffect, useState } from "react";
|
|
2
38
|
import SiteHeader from "../components/siteHeader";
|
|
3
39
|
import Button from "../components/button";
|
|
4
40
|
import Paragraph from "../components/paragraph";
|
|
41
|
+
import TabsContainer from "../components/tabsContainer";
|
|
42
|
+
import Tab from "../components/tab";
|
|
5
43
|
var meta = {
|
|
6
44
|
title: "Components/SiteHeader",
|
|
7
45
|
component: SiteHeader,
|
|
@@ -71,6 +109,57 @@ export var LongLabels = {
|
|
|
71
109
|
<Page />
|
|
72
110
|
</Bleed>); },
|
|
73
111
|
};
|
|
112
|
+
var sectionLinks = {
|
|
113
|
+
title: "Components",
|
|
114
|
+
links: [
|
|
115
|
+
{ label: "Button", href: "#button" },
|
|
116
|
+
{ label: "Tag", href: "#tag", current: true },
|
|
117
|
+
{ label: "Tooltip", href: "#tooltip" },
|
|
118
|
+
],
|
|
119
|
+
};
|
|
120
|
+
// Also shot at 375px (the "shell" tag): the section's pages are only in the menu, so the bar is the same as in Links
|
|
121
|
+
export var SectionLinks = {
|
|
122
|
+
tags: ["shell"],
|
|
123
|
+
render: function () { return (<Bleed>
|
|
124
|
+
<SiteHeader brand={brand} links={links.slice(0, 3)} actions={actions} phoneAction={phoneAction} sectionLinks={sectionLinks}/>
|
|
125
|
+
<Page />
|
|
126
|
+
</Bleed>); },
|
|
127
|
+
};
|
|
128
|
+
// Shot at 375px only (the "phone" tag): the menu open, the main links, then the section's pages, titled
|
|
129
|
+
export var SectionLinksOpen = {
|
|
130
|
+
tags: ["phone", "!autodocs"],
|
|
131
|
+
render: SectionLinks.render,
|
|
132
|
+
play: function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
133
|
+
var _c;
|
|
134
|
+
var canvasElement = _b.canvasElement;
|
|
135
|
+
return __generator(this, function (_d) {
|
|
136
|
+
(_c = canvasElement.querySelector('button[aria-label="Menu"]')) === null || _c === void 0 ? void 0 : _c.click();
|
|
137
|
+
return [2 /*return*/];
|
|
138
|
+
});
|
|
139
|
+
}); },
|
|
140
|
+
};
|
|
141
|
+
// For tests/interactions.spec.ts only: a docs bar with section tabs as `nav`, no links and no actions, and the section's pages
|
|
142
|
+
export var SectionsOnlyProbe = {
|
|
143
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
144
|
+
render: function Render() {
|
|
145
|
+
var _a = useState("components"), tab = _a[0], setTab = _a[1];
|
|
146
|
+
return (<Bleed>
|
|
147
|
+
<SiteHeader brand={brand} links={[]} sectionLinks={sectionLinks} nav={<TabsContainer fill>
|
|
148
|
+
<Tab label="Guides" isSelected={tab === "guides"} onClickTab={function () { return setTab("guides"); }}/>
|
|
149
|
+
<Tab label="Components" isSelected={tab === "components"} onClickTab={function () { return setTab("components"); }}/>
|
|
150
|
+
</TabsContainer>}/>
|
|
151
|
+
<Page />
|
|
152
|
+
</Bleed>);
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
// For tests/interactions.spec.ts only: no links, one action and a section with no pages, so the menu is as without `sectionLinks`
|
|
156
|
+
export var EmptySectionProbe = {
|
|
157
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
158
|
+
render: function () { return (<Bleed>
|
|
159
|
+
<SiteHeader brand={brand} links={[]} actions={actions} phoneAction={phoneAction} sectionLinks={{ title: "Components", links: [] }}/>
|
|
160
|
+
<Page />
|
|
161
|
+
</Bleed>); },
|
|
162
|
+
};
|
|
74
163
|
// For tests/interactions.spec.ts only: five links with long labels and two actions, checked at 375px and 768px
|
|
75
164
|
export var Probe = {
|
|
76
165
|
tags: ["!dev", "!autodocs", "test-only"],
|