oneslash-design-system 2.17.0 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/DESIGN.md +55 -14
- package/dist/cases/accept-invite.md +1 -5
- package/dist/cases/account-menu/menu.d.ts +1 -0
- package/dist/cases/account-menu/menu.jsx +99 -0
- package/dist/cases/account-menu.md +164 -0
- package/dist/cases/agent-asks-before-risky-action.md +0 -4
- package/dist/cases/agent-cancels-when-unanswered.md +0 -4
- package/dist/cases/agent-options.md +0 -4
- package/dist/cases/agent-pending-reply.md +0 -4
- package/dist/cases/agent-plan-proposal.md +0 -4
- package/dist/cases/agent-question.md +0 -4
- package/dist/cases/agent-refuses-clearly.md +0 -4
- package/dist/cases/agent-says-what-it-is.md +0 -2
- package/dist/cases/agent-settings/form.d.ts +1 -0
- package/dist/cases/agent-settings/form.jsx +164 -0
- package/dist/cases/agent-settings.md +259 -0
- package/dist/cases/agent-shows-progress.md +0 -2
- package/dist/cases/agent-shows-sources.md +0 -2
- package/dist/cases/api-keys/list.d.ts +1 -0
- package/dist/cases/api-keys/list.jsx +162 -0
- package/dist/cases/api-keys.md +229 -0
- package/dist/cases/app-shell/sidebar.d.ts +1 -0
- package/dist/cases/app-shell/sidebar.jsx +124 -0
- package/dist/cases/app-shell/top-tabs.d.ts +1 -0
- package/dist/cases/app-shell/top-tabs.jsx +106 -0
- package/dist/cases/app-shell.md +364 -0
- package/dist/cases/artifact-card/card.jsx +32 -6
- package/dist/cases/artifact-card.md +55 -11
- package/dist/cases/auth-gate-loading.md +0 -4
- package/dist/cases/check-your-email.md +0 -4
- package/dist/cases/collapsible-search/popover.d.ts +1 -0
- package/dist/cases/collapsible-search/popover.jsx +74 -0
- package/dist/cases/collapsible-search.md +143 -0
- package/dist/cases/composer-limit.md +0 -4
- package/dist/cases/confirm-destructive-action.md +0 -4
- package/dist/cases/confirm-dialogs.md +0 -4
- package/dist/cases/conversation-starters.md +0 -4
- package/dist/cases/create-modal.md +0 -4
- package/dist/cases/danger-zone/collapsed.d.ts +1 -0
- package/dist/cases/danger-zone/collapsed.jsx +75 -0
- package/dist/cases/danger-zone/shown.d.ts +1 -0
- package/dist/cases/danger-zone/shown.jsx +95 -0
- package/dist/cases/danger-zone.md +263 -0
- package/dist/cases/device-login.md +0 -4
- package/dist/cases/email-confirmed.md +0 -4
- package/dist/cases/empty-list.md +0 -4
- package/dist/cases/empty-lists.md +0 -4
- package/dist/cases/empty-not-set-up.md +0 -4
- package/dist/cases/empty-search.md +0 -4
- package/dist/cases/error-page/in-shell.jsx +26 -17
- package/dist/cases/error-page.md +42 -25
- package/dist/cases/feedback-form.md +0 -4
- package/dist/cases/filter-menu/presets.d.ts +1 -0
- package/dist/cases/filter-menu/presets.jsx +53 -0
- package/dist/cases/filter-menu/with-clear.d.ts +1 -0
- package/dist/cases/filter-menu/with-clear.jsx +56 -0
- package/dist/cases/filter-menu.md +204 -0
- package/dist/cases/forgot-password.md +0 -4
- package/dist/cases/form-errors.md +0 -4
- package/dist/cases/import-checklist.md +0 -4
- package/dist/cases/inline-form-feedback.md +0 -4
- package/dist/cases/integrations-list/nested.d.ts +1 -0
- package/dist/cases/integrations-list/nested.jsx +164 -0
- package/dist/cases/integrations-list/rows.d.ts +1 -0
- package/dist/cases/integrations-list/rows.jsx +134 -0
- package/dist/cases/integrations-list.md +379 -0
- package/dist/cases/invite-member.md +0 -4
- package/dist/cases/load-failure.md +0 -4
- package/dist/cases/log-out-confirm.md +0 -4
- package/dist/cases/login-page.md +0 -4
- package/dist/cases/master-detail/list-then-page.d.ts +1 -0
- package/dist/cases/master-detail/list-then-page.jsx +65 -0
- package/dist/cases/master-detail/split.d.ts +1 -0
- package/dist/cases/master-detail/split.jsx +49 -0
- package/dist/cases/master-detail.md +213 -0
- package/dist/cases/members-list/rows.d.ts +1 -0
- package/dist/cases/members-list/rows.jsx +318 -0
- package/dist/cases/members-list/table.d.ts +1 -0
- package/dist/cases/members-list/table.jsx +351 -0
- package/dist/cases/members-list.md +799 -0
- package/dist/cases/mention-list.md +0 -4
- package/dist/cases/message-actions.md +0 -4
- package/dist/cases/message-attachments.md +0 -4
- package/dist/cases/message-composer.md +0 -4
- package/dist/cases/message-edit.md +0 -4
- package/dist/cases/message-reactions.md +0 -4
- package/dist/cases/message-row.md +0 -4
- package/dist/cases/mobile-menu/links.d.ts +1 -0
- package/dist/cases/mobile-menu/links.jsx +24 -0
- package/dist/cases/mobile-menu/sections.d.ts +1 -0
- package/dist/cases/mobile-menu/sections.jsx +61 -0
- package/dist/cases/mobile-menu.md +170 -0
- package/dist/cases/not-found-page/in-shell.jsx +26 -17
- package/dist/cases/not-found-page.md +41 -24
- package/dist/cases/notification-menu/menu.d.ts +1 -0
- package/dist/cases/notification-menu/menu.jsx +74 -0
- package/dist/cases/notification-menu.md +135 -0
- package/dist/cases/oauth-consent.md +0 -4
- package/dist/cases/on-off-settings/list.d.ts +1 -0
- package/dist/cases/on-off-settings/list.jsx +97 -0
- package/dist/cases/on-off-settings.md +116 -0
- package/dist/cases/on-this-page/aside.d.ts +1 -0
- package/dist/cases/on-this-page/aside.jsx +39 -0
- package/dist/cases/on-this-page.md +80 -0
- package/dist/cases/overflow-menu/in-a-header.d.ts +1 -0
- package/dist/cases/overflow-menu/in-a-header.jsx +128 -0
- package/dist/cases/overflow-menu/on-a-row.d.ts +1 -0
- package/dist/cases/overflow-menu/on-a-row.jsx +183 -0
- package/dist/cases/overflow-menu.md +410 -0
- package/dist/cases/page-header/actions.d.ts +1 -0
- package/dist/cases/page-header/actions.jsx +65 -0
- package/dist/cases/page-header/sub-page.d.ts +1 -0
- package/dist/cases/page-header/sub-page.jsx +37 -0
- package/dist/cases/page-header.md +195 -0
- package/dist/cases/phone-navigation.md +32 -0
- package/dist/cases/profile-form/form.d.ts +1 -0
- package/dist/cases/profile-form/form.jsx +153 -0
- package/dist/cases/profile-form.md +236 -0
- package/dist/cases/quick-switcher/modal.d.ts +1 -0
- package/dist/cases/quick-switcher/modal.jsx +114 -0
- package/dist/cases/quick-switcher.md +205 -0
- package/dist/cases/range-switch/segmented.d.ts +1 -0
- package/dist/cases/range-switch/segmented.jsx +30 -0
- package/dist/cases/range-switch.md +67 -0
- package/dist/cases/rename.md +0 -4
- package/dist/cases/reply-feedback.md +0 -4
- package/dist/cases/reply-sources.md +0 -4
- package/dist/cases/route-loading/region.jsx +27 -18
- package/dist/cases/route-loading.md +42 -23
- package/dist/cases/scope-picker/menu.d.ts +1 -0
- package/dist/cases/scope-picker/menu.jsx +47 -0
- package/dist/cases/scope-picker.md +97 -0
- package/dist/cases/set-new-password.md +0 -4
- package/dist/cases/settings-page/side-nav.d.ts +1 -0
- package/dist/cases/settings-page/side-nav.jsx +171 -0
- package/dist/cases/settings-page/top-tabs.d.ts +1 -0
- package/dist/cases/settings-page/top-tabs.jsx +129 -0
- package/dist/cases/settings-page.md +378 -0
- package/dist/cases/settings-save.md +35 -0
- package/dist/cases/side-pane/beside.d.ts +1 -0
- package/dist/cases/side-pane/beside.jsx +79 -0
- package/dist/cases/side-pane/over.d.ts +1 -0
- package/dist/cases/side-pane/over.jsx +58 -0
- package/dist/cases/side-pane.md +238 -0
- package/dist/cases/sidebar-nav/flat.d.ts +1 -0
- package/dist/cases/sidebar-nav/flat.jsx +81 -0
- package/dist/cases/sidebar-nav/nested.d.ts +1 -0
- package/dist/cases/sidebar-nav/nested.jsx +122 -0
- package/dist/cases/sidebar-nav.md +261 -0
- package/dist/cases/sign-up-page.md +1 -5
- package/dist/cases/site-footer/columns.d.ts +1 -0
- package/dist/cases/site-footer/columns.jsx +51 -0
- package/dist/cases/site-footer/simple.d.ts +1 -0
- package/dist/cases/site-footer/simple.jsx +24 -0
- package/dist/cases/site-footer.md +133 -0
- package/dist/cases/site-header/links.d.ts +1 -0
- package/dist/cases/site-header/links.jsx +26 -0
- package/dist/cases/site-header/sections.d.ts +1 -0
- package/dist/cases/site-header/sections.jsx +64 -0
- package/dist/cases/site-header.md +183 -0
- package/dist/cases/slash-command-list.md +0 -4
- package/dist/cases/success-feedback.md +0 -4
- package/dist/cases/tag-filter/tags.d.ts +1 -0
- package/dist/cases/tag-filter/tags.jsx +226 -0
- package/dist/cases/tag-filter.md +298 -0
- package/dist/cases/theme-switcher/menu.d.ts +1 -0
- package/dist/cases/theme-switcher/menu.jsx +47 -0
- package/dist/cases/theme-switcher/segmented.d.ts +1 -0
- package/dist/cases/theme-switcher/segmented.jsx +26 -0
- package/dist/cases/theme-switcher.md +149 -0
- package/dist/cases/type-to-confirm.md +0 -4
- package/dist/cases/typing-and-status.md +0 -4
- package/dist/cases/unsaved-changes-guard.md +0 -4
- package/dist/cases/upgrade-prompt.md +0 -4
- package/dist/cases.json +1737 -315
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +2 -2
- package/dist/components/appShell.d.ts +44 -0
- package/dist/components/appShell.jsx +121 -0
- package/dist/components/button.jsx +5 -2
- package/dist/components/checkBox.d.ts +5 -1
- package/dist/components/checkBox.jsx +2 -2
- package/dist/components/copyField.d.ts +20 -0
- package/dist/components/copyField.jsx +99 -0
- package/dist/components/drawer.d.ts +31 -0
- package/dist/components/drawer.jsx +121 -0
- package/dist/components/formField.d.ts +34 -0
- package/dist/components/formField.jsx +28 -0
- package/dist/components/heading.d.ts +5 -1
- package/dist/components/heading.jsx +2 -2
- package/dist/components/link.d.ts +6 -1
- package/dist/components/link.jsx +11 -3
- package/dist/components/menu.jsx +2 -2
- package/dist/components/menuItem.d.ts +10 -2
- package/dist/components/menuItem.jsx +4 -3
- package/dist/components/modal.jsx +12 -23
- package/dist/components/navigation.d.ts +9 -1
- package/dist/components/navigation.jsx +15 -3
- package/dist/components/onThisPage.d.ts +29 -0
- package/dist/components/onThisPage.jsx +151 -0
- package/dist/components/pageShell.d.ts +7 -1
- package/dist/components/pageShell.jsx +14 -1
- package/dist/components/popover.jsx +4 -0
- package/dist/components/radioGroup.d.ts +5 -1
- package/dist/components/radioGroup.jsx +2 -2
- package/dist/components/segmentedControl.d.ts +22 -0
- package/dist/components/segmentedControl.jsx +54 -0
- package/dist/components/select.d.ts +5 -1
- package/dist/components/select.jsx +2 -2
- package/dist/components/settingsSection.d.ts +36 -0
- package/dist/components/settingsSection.jsx +65 -0
- package/dist/components/sidePane.d.ts +32 -0
- package/dist/components/sidePane.jsx +128 -0
- package/dist/components/siteFooter.d.ts +24 -0
- package/dist/components/siteFooter.jsx +48 -0
- package/dist/components/siteHeader.d.ts +55 -0
- package/dist/components/siteHeader.jsx +125 -0
- package/dist/components/slidingIndicator.d.ts +50 -0
- package/dist/components/slidingIndicator.jsx +102 -0
- package/dist/components/switch.d.ts +25 -0
- package/dist/components/switch.jsx +55 -0
- package/dist/components/tab.jsx +5 -11
- package/dist/components/tabsContainer.jsx +5 -67
- package/dist/components/textField.d.ts +12 -2
- package/dist/components/textField.jsx +11 -4
- package/dist/components/textarea.d.ts +5 -1
- package/dist/components/textarea.jsx +3 -3
- package/dist/components/titleBar.d.ts +17 -0
- package/dist/components/titleBar.jsx +17 -0
- package/dist/components/useHotkey.d.ts +7 -0
- package/dist/components/useHotkey.js +24 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +13 -0
- package/dist/internal/copyField.d.ts +5 -0
- package/dist/internal/copyField.js +61 -0
- package/dist/internal/hotkey.d.ts +16 -0
- package/dist/internal/hotkey.js +20 -0
- package/dist/internal/overlayStack.d.ts +24 -0
- package/dist/internal/overlayStack.js +71 -0
- package/dist/internal/resize.d.ts +9 -0
- package/dist/internal/resize.js +31 -0
- package/dist/internal/scrollSpy.d.ts +24 -0
- package/dist/internal/scrollSpy.js +53 -0
- package/dist/internal/siteBrand.d.ts +6 -0
- package/dist/internal/siteBrand.jsx +11 -0
- package/dist/internal/switch.d.ts +5 -0
- package/dist/internal/switch.js +9 -0
- package/dist/native-mapping.json +72 -0
- package/dist/stories/AppShell.stories.d.ts +15 -0
- package/dist/stories/AppShell.stories.jsx +137 -0
- package/dist/stories/Cases.generated.stories.d.ts +42 -0
- package/dist/stories/Cases.generated.stories.jsx +84 -0
- package/dist/stories/CopyField.stories.d.ts +11 -0
- package/dist/stories/CopyField.stories.jsx +65 -0
- package/dist/stories/Drawer.stories.d.ts +10 -0
- package/dist/stories/Drawer.stories.jsx +123 -0
- package/dist/stories/FormField.stories.d.ts +6 -0
- package/dist/stories/FormField.stories.jsx +44 -0
- package/dist/stories/Link.stories.d.ts +1 -0
- package/dist/stories/Link.stories.jsx +8 -0
- package/dist/stories/Navigation.stories.d.ts +1 -0
- package/dist/stories/Navigation.stories.jsx +17 -1
- package/dist/stories/OnThisPage.stories.d.ts +10 -0
- package/dist/stories/OnThisPage.stories.jsx +105 -0
- package/dist/stories/SegmentedControl.stories.d.ts +8 -0
- package/dist/stories/SegmentedControl.stories.jsx +33 -0
- package/dist/stories/SettingsSection.stories.d.ts +12 -0
- package/dist/stories/SettingsSection.stories.jsx +91 -0
- package/dist/stories/SidePane.stories.d.ts +6 -0
- package/dist/stories/SidePane.stories.jsx +37 -0
- package/dist/stories/SiteFooter.stories.d.ts +7 -0
- package/dist/stories/SiteFooter.stories.jsx +63 -0
- package/dist/stories/SiteHeader.stories.d.ts +10 -0
- package/dist/stories/SiteHeader.stories.jsx +94 -0
- package/dist/stories/Switch.stories.d.ts +14 -0
- package/dist/stories/Switch.stories.jsx +87 -0
- package/dist/stories/TextField.stories.d.ts +1 -0
- package/dist/stories/TextField.stories.jsx +13 -0
- package/dist/stories/TitleBar.stories.d.ts +6 -0
- package/dist/stories/TitleBar.stories.jsx +34 -0
- package/package.json +5 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import Navigation from "../components/navigation";
|
|
2
|
+
import Navigation, { NavigationGroup } from "../components/navigation";
|
|
3
3
|
import MenuItem from "../components/menuItem";
|
|
4
4
|
var meta = {
|
|
5
5
|
title: "Components/Navigation",
|
|
@@ -29,3 +29,19 @@ export var WithNestedItems = {
|
|
|
29
29
|
</Navigation>
|
|
30
30
|
</div>); },
|
|
31
31
|
};
|
|
32
|
+
export var Groups = {
|
|
33
|
+
render: function () { return (<div style={{ height: "460px", width: 240 }}>
|
|
34
|
+
<Navigation aria-label="Settings">
|
|
35
|
+
<NavigationGroup label="Account">
|
|
36
|
+
<MenuItem label="Profile" iconName="User" isSelected aria-current="page"/>
|
|
37
|
+
<MenuItem label="Notifications" iconName="Bell"/>
|
|
38
|
+
<MenuItem label="Security" iconName="Lock"/>
|
|
39
|
+
</NavigationGroup>
|
|
40
|
+
<NavigationGroup label="Workspace">
|
|
41
|
+
<MenuItem label="General" iconName="Settings"/>
|
|
42
|
+
<MenuItem label="Members" iconName="Users"/>
|
|
43
|
+
<MenuItem label="Billing" iconName="CreditCard"/>
|
|
44
|
+
</NavigationGroup>
|
|
45
|
+
</Navigation>
|
|
46
|
+
</div>); },
|
|
47
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import OnThisPage from "../components/onThisPage";
|
|
3
|
+
declare const meta: Meta<typeof OnThisPage>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof OnThisPage>;
|
|
6
|
+
export declare const LongPage: Story;
|
|
7
|
+
export declare const Probe: Story;
|
|
8
|
+
export declare const HeaderProbe: Story;
|
|
9
|
+
export declare const HashProbe: Story;
|
|
10
|
+
export declare const HashScrolledProbe: Story;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React, { useLayoutEffect } from "react";
|
|
2
|
+
import OnThisPage from "../components/onThisPage";
|
|
3
|
+
import SiteHeader from "../components/siteHeader";
|
|
4
|
+
import PageShell from "../components/pageShell";
|
|
5
|
+
import Heading from "../components/heading";
|
|
6
|
+
import Paragraph from "../components/paragraph";
|
|
7
|
+
var meta = {
|
|
8
|
+
title: "Components/OnThisPage",
|
|
9
|
+
component: OnThisPage,
|
|
10
|
+
parameters: { layout: "fullscreen" },
|
|
11
|
+
};
|
|
12
|
+
export default meta;
|
|
13
|
+
var Bleed = function (_a) {
|
|
14
|
+
var children = _a.children;
|
|
15
|
+
return <div style={{ margin: "-1rem" }}>{children}</div>;
|
|
16
|
+
};
|
|
17
|
+
var items = [
|
|
18
|
+
{ id: "overview", label: "Overview" },
|
|
19
|
+
{ id: "set-up", label: "Set up" },
|
|
20
|
+
{ id: "invite-people", label: "Invite people", level: 3 },
|
|
21
|
+
{ id: "billing", label: "Billing" },
|
|
22
|
+
{ id: "close-account", label: "Close your account" },
|
|
23
|
+
];
|
|
24
|
+
// The first sections are tall; the last two are short, so neither can ever scroll up to the top
|
|
25
|
+
var heights = ["70vh", "70vh", "70vh", "160px", "120px"];
|
|
26
|
+
var Sections = function () { return (<>
|
|
27
|
+
{items.map(function (item, i) { return (<section key={item.id} style={{ minHeight: heights[i] }}>
|
|
28
|
+
<Heading level={item.level === 3 ? 3 : 2} size={item.level === 3 ? "h6" : "h5"} id={item.id}>
|
|
29
|
+
{item.label}
|
|
30
|
+
</Heading>
|
|
31
|
+
<Paragraph tone="secondary">Dana Lee set up Acme for the team. Ben Carter and Omar Reyes join next week.</Paragraph>
|
|
32
|
+
</section>); })}
|
|
33
|
+
</>); };
|
|
34
|
+
// The marker beside the current heading, on a page in two columns
|
|
35
|
+
export var LongPage = {
|
|
36
|
+
render: function () { return (<Bleed>
|
|
37
|
+
<div style={{ display: "flex", gap: "32px", padding: "32px", alignItems: "flex-start" }}>
|
|
38
|
+
<div style={{ flex: 1, minWidth: 0 }}>
|
|
39
|
+
<Sections />
|
|
40
|
+
</div>
|
|
41
|
+
<div style={{ position: "sticky", top: "32px", width: "220px", flexShrink: 0 }}>
|
|
42
|
+
<OnThisPage items={items}/>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</Bleed>); },
|
|
46
|
+
};
|
|
47
|
+
// For tests/interactions.spec.ts only: PageShell's aside from xl, a long page with a short last section
|
|
48
|
+
export var Probe = {
|
|
49
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
50
|
+
render: function () { return (<Bleed>
|
|
51
|
+
<PageShell id="main" aside={<OnThisPage items={items}/>}>
|
|
52
|
+
<Sections />
|
|
53
|
+
</PageShell>
|
|
54
|
+
</Bleed>); },
|
|
55
|
+
};
|
|
56
|
+
// For tests/interactions.spec.ts only: a SiteHeader above PageShell's aside and OnThisPage
|
|
57
|
+
export var HeaderProbe = {
|
|
58
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
59
|
+
render: function () { return (<Bleed>
|
|
60
|
+
<SiteHeader brand={{ href: "/", name: "Acme" }} links={[{ label: "Docs", href: "#docs", current: true }, { label: "Pricing", href: "#pricing" }]}/>
|
|
61
|
+
<PageShell id="main" tabIndex={-1} aside={<OnThisPage items={items}/>}>
|
|
62
|
+
<style>{"h2, h3 { scroll-margin-top: var(--os-header-offset, 0px); }"}</style>
|
|
63
|
+
<Sections />
|
|
64
|
+
</PageShell>
|
|
65
|
+
</Bleed>); },
|
|
66
|
+
};
|
|
67
|
+
// Does what the browser does on a server-rendered page: jump to the #hash before any effect runs, so before
|
|
68
|
+
// SiteHeader has set --os-header-offset (a layout effect runs before every passive effect)
|
|
69
|
+
// With scrolledOn, the person then scrolls to the end, still before the header publishes
|
|
70
|
+
var JumpToHash = function (_a) {
|
|
71
|
+
var _b = _a.scrolledOn, scrolledOn = _b === void 0 ? false : _b;
|
|
72
|
+
useLayoutEffect(function () {
|
|
73
|
+
var _a;
|
|
74
|
+
var id = decodeURIComponent(window.location.hash.slice(1));
|
|
75
|
+
if (id)
|
|
76
|
+
(_a = document.getElementById(id)) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ block: "start", behavior: "instant" });
|
|
77
|
+
if (scrolledOn)
|
|
78
|
+
window.scrollTo({ top: document.documentElement.scrollHeight, behavior: "instant" });
|
|
79
|
+
}, [scrolledOn]);
|
|
80
|
+
return null;
|
|
81
|
+
};
|
|
82
|
+
// For tests/interactions.spec.ts only: HeaderProbe opened with a #hash, with the headings on the page before the header publishes
|
|
83
|
+
export var HashProbe = {
|
|
84
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
85
|
+
render: function () { return (<Bleed>
|
|
86
|
+
<SiteHeader brand={{ href: "/", name: "Acme" }} links={[{ label: "Docs", href: "#docs", current: true }, { label: "Pricing", href: "#pricing" }]}/>
|
|
87
|
+
<PageShell id="main" tabIndex={-1} aside={<OnThisPage items={items}/>}>
|
|
88
|
+
<style>{"h2, h3 { scroll-margin-top: var(--os-header-offset, 0px); }"}</style>
|
|
89
|
+
<Sections />
|
|
90
|
+
</PageShell>
|
|
91
|
+
<JumpToHash />
|
|
92
|
+
</Bleed>); },
|
|
93
|
+
};
|
|
94
|
+
// For tests/interactions.spec.ts only: HashProbe, but scrolled on past the #hash heading before the header publishes
|
|
95
|
+
export var HashScrolledProbe = {
|
|
96
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
97
|
+
render: function () { return (<Bleed>
|
|
98
|
+
<SiteHeader brand={{ href: "/", name: "Acme" }} links={[{ label: "Docs", href: "#docs", current: true }, { label: "Pricing", href: "#pricing" }]}/>
|
|
99
|
+
<PageShell id="main" tabIndex={-1} aside={<OnThisPage items={items}/>}>
|
|
100
|
+
<style>{"h2, h3 { scroll-margin-top: var(--os-header-offset, 0px); }"}</style>
|
|
101
|
+
<Sections />
|
|
102
|
+
</PageShell>
|
|
103
|
+
<JumpToHash scrolledOn/>
|
|
104
|
+
</Bleed>); },
|
|
105
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import SegmentedControl from "../components/segmentedControl";
|
|
3
|
+
declare const meta: Meta<typeof SegmentedControl>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof SegmentedControl>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Small: Story;
|
|
8
|
+
export declare const Fit: Story;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import SegmentedControl from "../components/segmentedControl";
|
|
3
|
+
var meta = {
|
|
4
|
+
title: "Components/SegmentedControl",
|
|
5
|
+
component: SegmentedControl,
|
|
6
|
+
argTypes: {
|
|
7
|
+
size: { control: "select", options: ["medium", "small", "tiny"] },
|
|
8
|
+
"aria-label": { control: "text" },
|
|
9
|
+
},
|
|
10
|
+
decorators: [function (Story) { return <div style={{ width: 360 }}><Story /></div>; }],
|
|
11
|
+
};
|
|
12
|
+
export default meta;
|
|
13
|
+
var options = [
|
|
14
|
+
{ value: "week", label: "Week" },
|
|
15
|
+
{ value: "month", label: "Month" },
|
|
16
|
+
{ value: "year", label: "Year" },
|
|
17
|
+
];
|
|
18
|
+
var Wrapper = function (args) {
|
|
19
|
+
var _a = useState(args.value), value = _a[0], setValue = _a[1];
|
|
20
|
+
return <SegmentedControl {...args} value={value} onChange={setValue}/>;
|
|
21
|
+
};
|
|
22
|
+
export var Default = {
|
|
23
|
+
render: function (args) { return <Wrapper {...args}/>; },
|
|
24
|
+
args: { options: options, value: "month", "aria-label": "Range" },
|
|
25
|
+
};
|
|
26
|
+
export var Small = {
|
|
27
|
+
render: function (args) { return <Wrapper {...args}/>; },
|
|
28
|
+
args: { options: options, value: "week", "aria-label": "Range", size: "small" },
|
|
29
|
+
};
|
|
30
|
+
export var Fit = {
|
|
31
|
+
render: function (args) { return <Wrapper {...args}/>; },
|
|
32
|
+
args: { options: options, value: "week", "aria-label": "Range", size: "small", width: "fit" },
|
|
33
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import SettingsSection from "../components/settingsSection";
|
|
3
|
+
declare const meta: Meta<typeof SettingsSection>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof SettingsSection>;
|
|
6
|
+
export declare const Sections: Story;
|
|
7
|
+
export declare const Danger: Story;
|
|
8
|
+
export declare const Layout: Story;
|
|
9
|
+
export declare const LayoutStrictMode: StoryObj<{
|
|
10
|
+
initialOpen: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const ListDetail: Story;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import SettingsSection, { SettingsColumns, SettingsLayout } from "../components/settingsSection";
|
|
3
|
+
import FormField from "../components/formField";
|
|
4
|
+
import TextField from "../components/textField";
|
|
5
|
+
import Switch from "../components/switch";
|
|
6
|
+
import Button from "../components/button";
|
|
7
|
+
import Paragraph from "../components/paragraph";
|
|
8
|
+
import Navigation, { NavigationGroup } from "../components/navigation";
|
|
9
|
+
import MenuItem from "../components/menuItem";
|
|
10
|
+
import TitleBar from "../components/titleBar";
|
|
11
|
+
var meta = {
|
|
12
|
+
title: "Components/SettingsSection",
|
|
13
|
+
component: SettingsSection,
|
|
14
|
+
};
|
|
15
|
+
export default meta;
|
|
16
|
+
export var Sections = {
|
|
17
|
+
render: function () { return (<div style={{ maxWidth: 880 }}>
|
|
18
|
+
<SettingsColumns>
|
|
19
|
+
<SettingsSection id="settings-profile" title="Profile" description="How others see you in Acme.">
|
|
20
|
+
<FormField id="settings-name" label="Name">
|
|
21
|
+
{function (f) { return <TextField id={f.id} aria-describedby={f["aria-describedby"]} value="Dana Lee" onChange={function () { }}/>; }}
|
|
22
|
+
</FormField>
|
|
23
|
+
<FormField id="settings-email" label="Email">
|
|
24
|
+
{function (f) { return <TextField id={f.id} aria-describedby={f["aria-describedby"]} value="dana@acme.example" onChange={function () { }}/>; }}
|
|
25
|
+
</FormField>
|
|
26
|
+
</SettingsSection>
|
|
27
|
+
<SettingsSection id="settings-notifications" title="Notifications" description="Choose what reaches your inbox.">
|
|
28
|
+
<Switch id="settings-mentions" label="Mentions" description="When someone mentions you." checked onChange={function () { }}/>
|
|
29
|
+
<Switch id="settings-digest" label="Weekly digest" checked={false} onChange={function () { }}/>
|
|
30
|
+
</SettingsSection>
|
|
31
|
+
</SettingsColumns>
|
|
32
|
+
</div>); },
|
|
33
|
+
};
|
|
34
|
+
export var Danger = {
|
|
35
|
+
render: function () { return (<div style={{ maxWidth: 440 }}>
|
|
36
|
+
<SettingsSection id="settings-danger" tone="danger" title="Delete workspace" description="Removes Acme and everything in it. This cannot be undone.">
|
|
37
|
+
<Button type="secondary" color="danger" label="Delete Workspace" state="enabled" size="medium"/>
|
|
38
|
+
</SettingsSection>
|
|
39
|
+
</div>); },
|
|
40
|
+
};
|
|
41
|
+
// At 375px only the nav shows until an item is chosen, then only the content and a back Button (tests/interactions.spec.ts checks it).
|
|
42
|
+
function LayoutProbe(_a) {
|
|
43
|
+
var _b = _a.initialOpen, initialOpen = _b === void 0 ? false : _b;
|
|
44
|
+
var _c = React.useState(initialOpen), open = _c[0], setOpen = _c[1];
|
|
45
|
+
return (<SettingsLayout showContent={open} back={<Button type="tertiary" size="small" state="enabled" label="Back to Settings" onClickButton={function () { return setOpen(false); }}/>} nav={<Navigation aria-label="Settings">
|
|
46
|
+
<NavigationGroup label="Account">
|
|
47
|
+
<MenuItem label="Profile" iconName="User" role="button" aria-current={open ? "page" : undefined} onClick={function () { return setOpen(true); }}/>
|
|
48
|
+
</NavigationGroup>
|
|
49
|
+
</Navigation>}>
|
|
50
|
+
<SettingsSection title="Profile" description="How others see you in Acme.">
|
|
51
|
+
<Paragraph>Dana Lee</Paragraph>
|
|
52
|
+
</SettingsSection>
|
|
53
|
+
</SettingsLayout>);
|
|
54
|
+
}
|
|
55
|
+
export var Layout = {
|
|
56
|
+
render: function () { return <LayoutProbe />; },
|
|
57
|
+
};
|
|
58
|
+
// For tests/interactions.spec.ts only: under StrictMode the mount effect runs twice, and a load at 375px must still focus nothing
|
|
59
|
+
export var LayoutStrictMode = {
|
|
60
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
61
|
+
args: { initialOpen: false },
|
|
62
|
+
render: function (args) { return (<React.StrictMode>
|
|
63
|
+
<LayoutProbe {...args}/>
|
|
64
|
+
</React.StrictMode>); },
|
|
65
|
+
};
|
|
66
|
+
// A list beside its detail: the wide nav column holds rows, and on a phone the list is the page and
|
|
67
|
+
// a row opens its detail with a Back Button, the same drill-in as the settings nav.
|
|
68
|
+
// Also shot at 375px by tests/stories.spec.ts (the "shell" tag): there only the list shows.
|
|
69
|
+
var threads = [
|
|
70
|
+
{ id: "launch", from: "Ben Carter", subject: "Launch plan for the home page" },
|
|
71
|
+
{ id: "screens", from: "Omar Reyes", subject: "New screens by Friday" },
|
|
72
|
+
{ id: "pricing", from: "Ben Carter", subject: "Pricing table copy" },
|
|
73
|
+
];
|
|
74
|
+
function ListDetailBox() {
|
|
75
|
+
var _a = React.useState(false), open = _a[0], setOpen = _a[1];
|
|
76
|
+
var _b = React.useState("launch"), current = _b[0], setCurrent = _b[1];
|
|
77
|
+
var thread = threads.find(function (t) { return t.id === current; });
|
|
78
|
+
return (<SettingsLayout navWidth="wide" showContent={open} back={<Button type="tertiary" size="small" state="enabled" label="Back to Inbox" decoIcon="ChevronLeft" onClickButton={function () { return setOpen(false); }}/>} nav={<Navigation aria-label="Inbox">
|
|
79
|
+
{threads.map(function (t) { return (<MenuItem key={t.id} size="small" label={t.from} secondLabel={t.subject} role="button" isSelected={t.id === current} aria-current={t.id === current ? "page" : undefined} onClick={function () {
|
|
80
|
+
setCurrent(t.id);
|
|
81
|
+
setOpen(true);
|
|
82
|
+
}}/>); })}
|
|
83
|
+
</Navigation>}>
|
|
84
|
+
<TitleBar title={thread.subject}/>
|
|
85
|
+
<Paragraph>{thread.from}: the details are in the brief. Reply here when you have read it.</Paragraph>
|
|
86
|
+
</SettingsLayout>);
|
|
87
|
+
}
|
|
88
|
+
export var ListDetail = {
|
|
89
|
+
tags: ["shell"],
|
|
90
|
+
render: function () { return <ListDetailBox />; },
|
|
91
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import SidePane from "../components/sidePane";
|
|
3
|
+
import IconButton from "../components/iconButton";
|
|
4
|
+
import Paragraph from "../components/paragraph";
|
|
5
|
+
import TitleBar from "../components/titleBar";
|
|
6
|
+
var meta = {
|
|
7
|
+
title: "Components/SidePane",
|
|
8
|
+
component: SidePane,
|
|
9
|
+
parameters: { layout: "fullscreen" },
|
|
10
|
+
};
|
|
11
|
+
export default meta;
|
|
12
|
+
// A page with a document open beside it. From lg up the pane's start edge is a handle: drag it, or
|
|
13
|
+
// focus it and press the arrow keys (16px a step), Home and End.
|
|
14
|
+
function ResizableBox() {
|
|
15
|
+
var _a = useState(true), open = _a[0], setOpen = _a[1];
|
|
16
|
+
var _b = useState(448), width = _b[0], setWidth = _b[1];
|
|
17
|
+
return (<div style={{ margin: "-1rem", display: "flex", height: "100dvh" }}>
|
|
18
|
+
{/* Below lg the open pane takes the page's place, as in AppShell */}
|
|
19
|
+
<div style={{ flex: 1, minWidth: 0, padding: "24px" }} className={open ? "hidden lg:block" : undefined}>
|
|
20
|
+
<TitleBar title="Launch plan" actions={<IconButton color="iconOnly" state={open ? "selected" : "enabled"} size="medium" iconName="FileText" ariaLabel="Brief" aria-expanded={open} onClick={function () { return setOpen(true); }}/>}/>
|
|
21
|
+
<div style={{ marginTop: "16px" }}>
|
|
22
|
+
<Paragraph tone="secondary">Ben Carter: the brief is in the pane. Leave notes on anything that needs a change.</Paragraph>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
{open && (<SidePane title="Brief" onClose={function () { return setOpen(false); }} width={width} onWidthChange={setWidth}>
|
|
26
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "12px" }}>
|
|
27
|
+
<Paragraph measure="none">Acme ships the new home page on Friday. Omar Reyes owns the copy and Dana Lee the screens.</Paragraph>
|
|
28
|
+
<Paragraph measure="none" tone="secondary">The pane stays beside the page, so the thread and the brief read together.</Paragraph>
|
|
29
|
+
</div>
|
|
30
|
+
</SidePane>)}
|
|
31
|
+
</div>);
|
|
32
|
+
}
|
|
33
|
+
// Also shot at 375px by tests/stories.spec.ts (the "shell" tag): there the pane takes the whole width
|
|
34
|
+
export var Resizable = {
|
|
35
|
+
tags: ["shell"],
|
|
36
|
+
render: function () { return <ResizableBox />; },
|
|
37
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import SiteFooter from "../components/siteFooter";
|
|
3
|
+
declare const meta: Meta<typeof SiteFooter>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof SiteFooter>;
|
|
6
|
+
export declare const Columns: Story;
|
|
7
|
+
export declare const Simple: Story;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import SiteFooter from "../components/siteFooter";
|
|
3
|
+
var meta = {
|
|
4
|
+
title: "Components/SiteFooter",
|
|
5
|
+
component: SiteFooter,
|
|
6
|
+
parameters: { layout: "fullscreen" },
|
|
7
|
+
};
|
|
8
|
+
export default meta;
|
|
9
|
+
var Bleed = function (_a) {
|
|
10
|
+
var children = _a.children;
|
|
11
|
+
return <div style={{ margin: "-1rem" }}>{children}</div>;
|
|
12
|
+
};
|
|
13
|
+
var brand = { href: "/", name: "Acme" };
|
|
14
|
+
var columns = [
|
|
15
|
+
{
|
|
16
|
+
title: "Product",
|
|
17
|
+
links: [
|
|
18
|
+
{ label: "Features", href: "#features" },
|
|
19
|
+
{ label: "Pricing", href: "#pricing" },
|
|
20
|
+
{ label: "Changelog", href: "#changelog" },
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
title: "Company",
|
|
25
|
+
links: [
|
|
26
|
+
{ label: "About", href: "#about" },
|
|
27
|
+
{ label: "Careers", href: "#careers" },
|
|
28
|
+
{ label: "Contact", href: "#contact" },
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
title: "Resources",
|
|
33
|
+
links: [
|
|
34
|
+
{ label: "Documentation", href: "#documentation" },
|
|
35
|
+
{ label: "Status", href: "https://status.example.com", external: true },
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
title: "Legal",
|
|
40
|
+
links: [
|
|
41
|
+
{ label: "Privacy", href: "#privacy" },
|
|
42
|
+
{ label: "Terms of Use", href: "#terms" },
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
// Also shot at 375px by tests/stories.spec.ts (the "shell" tag): two columns across
|
|
47
|
+
export var Columns = {
|
|
48
|
+
tags: ["shell"],
|
|
49
|
+
render: function () { return (<Bleed>
|
|
50
|
+
<SiteFooter brand={brand} columns={columns} legal="© 2026 Acme"/>
|
|
51
|
+
</Bleed>); },
|
|
52
|
+
};
|
|
53
|
+
export var Simple = {
|
|
54
|
+
tags: ["shell"],
|
|
55
|
+
render: function () { return (<Bleed>
|
|
56
|
+
<SiteFooter links={[
|
|
57
|
+
{ label: "Privacy", href: "#privacy" },
|
|
58
|
+
{ label: "Terms of Use", href: "#terms" },
|
|
59
|
+
{ label: "Status", href: "https://status.example.com", external: true },
|
|
60
|
+
{ label: "Contact", href: "#contact" },
|
|
61
|
+
]} legal="© 2026 Acme"/>
|
|
62
|
+
</Bleed>); },
|
|
63
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import SiteHeader from "../components/siteHeader";
|
|
3
|
+
declare const meta: Meta<typeof SiteHeader>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof SiteHeader>;
|
|
6
|
+
export declare const Links: Story;
|
|
7
|
+
export declare const Phone: Story;
|
|
8
|
+
export declare const LongLabels: Story;
|
|
9
|
+
export declare const Probe: Story;
|
|
10
|
+
export declare const UnmountProbe: Story;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import SiteHeader from "../components/siteHeader";
|
|
3
|
+
import Button from "../components/button";
|
|
4
|
+
import Paragraph from "../components/paragraph";
|
|
5
|
+
var meta = {
|
|
6
|
+
title: "Components/SiteHeader",
|
|
7
|
+
component: SiteHeader,
|
|
8
|
+
parameters: { layout: "fullscreen" },
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
// The story frame pads its content; a site header is the top of a page, so it takes the padding back
|
|
12
|
+
var Bleed = function (_a) {
|
|
13
|
+
var children = _a.children;
|
|
14
|
+
return <div style={{ margin: "-1rem" }}>{children}</div>;
|
|
15
|
+
};
|
|
16
|
+
// A square mark for Acme, inline so the story needs no network
|
|
17
|
+
var logo = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='28' viewBox='0 0 96 28'%3E%3Crect width='28' height='28' rx='7' fill='%23336' /%3E%3Ctext x='36' y='21' font-family='sans-serif' font-size='18' font-weight='700' fill='%23336'%3EAcme%3C/text%3E%3C/svg%3E";
|
|
18
|
+
var brand = { href: "/", name: "Acme", src: logo, width: 96, height: 28 };
|
|
19
|
+
var links = [
|
|
20
|
+
{ label: "Features", href: "#features", current: true },
|
|
21
|
+
{ label: "Pricing", href: "#pricing" },
|
|
22
|
+
{ label: "Documentation", href: "#documentation" },
|
|
23
|
+
{ label: "Changelog", href: "#changelog" },
|
|
24
|
+
{ label: "Company", href: "#company" },
|
|
25
|
+
];
|
|
26
|
+
// Log In is secondary: in the menu below md. Sign Up is the main action: in the bar at every width.
|
|
27
|
+
var actions = <Button size="medium" type="tertiary" state="enabled" label="Log In" href="#log-in"/>;
|
|
28
|
+
var phoneAction = <Button size="medium" type="primary" state="enabled" label="Sign Up" href="#sign-up"/>;
|
|
29
|
+
var longLinks = [
|
|
30
|
+
{ label: "Product Features", href: "#features", current: true },
|
|
31
|
+
{ label: "Pricing and Plans", href: "#pricing" },
|
|
32
|
+
{ label: "Documentation", href: "#documentation" },
|
|
33
|
+
{ label: "Release Changelog", href: "#changelog" },
|
|
34
|
+
{ label: "About the Company", href: "#company" },
|
|
35
|
+
];
|
|
36
|
+
var Page = function () { return (<div style={{ padding: "24px", display: "flex", flexDirection: "column", gap: "12px" }}>
|
|
37
|
+
<Paragraph tone="secondary">Ship the launch plan this week. Ben Carter has the new screens.</Paragraph>
|
|
38
|
+
</div>); };
|
|
39
|
+
// Also shot at 375px by tests/stories.spec.ts (the "shell" tag): the brand, Menu and one action in the bar
|
|
40
|
+
export var Links = {
|
|
41
|
+
tags: ["shell"],
|
|
42
|
+
render: function () { return (<Bleed>
|
|
43
|
+
<SiteHeader brand={brand} links={links} actions={actions} phoneAction={phoneAction}/>
|
|
44
|
+
<Page />
|
|
45
|
+
</Bleed>); },
|
|
46
|
+
};
|
|
47
|
+
// Opens the menu once the page is up, so the story shows it
|
|
48
|
+
var OpenMenu = function (_a) {
|
|
49
|
+
var children = _a.children;
|
|
50
|
+
useEffect(function () {
|
|
51
|
+
var _a;
|
|
52
|
+
(_a = document.querySelector('button[aria-label="Menu"]')) === null || _a === void 0 ? void 0 : _a.click();
|
|
53
|
+
}, []);
|
|
54
|
+
return <>{children}</>;
|
|
55
|
+
};
|
|
56
|
+
// Shot at 375px only (the "phone" tag): the menu open, with the links and the other action
|
|
57
|
+
export var Phone = {
|
|
58
|
+
tags: ["phone"],
|
|
59
|
+
render: function () { return (<Bleed>
|
|
60
|
+
<OpenMenu>
|
|
61
|
+
<SiteHeader brand={brand} links={links} actions={actions} phoneAction={phoneAction}/>
|
|
62
|
+
<Page />
|
|
63
|
+
</OpenMenu>
|
|
64
|
+
</Bleed>); },
|
|
65
|
+
};
|
|
66
|
+
// Shot at 768px only (the "tablet" tag): the full bar from md, with long labels
|
|
67
|
+
export var LongLabels = {
|
|
68
|
+
tags: ["tablet"],
|
|
69
|
+
render: function () { return (<Bleed>
|
|
70
|
+
<SiteHeader brand={brand} links={longLinks} actions={actions} phoneAction={phoneAction}/>
|
|
71
|
+
<Page />
|
|
72
|
+
</Bleed>); },
|
|
73
|
+
};
|
|
74
|
+
// For tests/interactions.spec.ts only: five links with long labels and two actions, checked at 375px and 768px
|
|
75
|
+
export var Probe = {
|
|
76
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
77
|
+
render: function () { return (<Bleed>
|
|
78
|
+
<SiteHeader brand={brand} links={longLinks} actions={actions} phoneAction={phoneAction}/>
|
|
79
|
+
<main id="main" tabIndex={-1}>
|
|
80
|
+
<Page />
|
|
81
|
+
</main>
|
|
82
|
+
</Bleed>); },
|
|
83
|
+
};
|
|
84
|
+
// For tests/interactions.spec.ts only: a Button that removes the header, so the test sees --os-header-offset go with it
|
|
85
|
+
export var UnmountProbe = {
|
|
86
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
87
|
+
render: function Render() {
|
|
88
|
+
var _a = useState(true), shown = _a[0], setShown = _a[1];
|
|
89
|
+
return (<Bleed>
|
|
90
|
+
{shown && <SiteHeader brand={brand} links={links}/>}
|
|
91
|
+
<Button size="medium" type="secondary" state="enabled" label="Remove Header" onClickButton={function () { return setShown(false); }}/>
|
|
92
|
+
</Bleed>);
|
|
93
|
+
},
|
|
94
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import Switch from "../components/switch";
|
|
3
|
+
declare const meta: Meta<typeof Switch>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Switch>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const WithDescription: Story;
|
|
8
|
+
export declare const Busy: Story;
|
|
9
|
+
export declare const Error: Story;
|
|
10
|
+
export declare const Disabled: Story;
|
|
11
|
+
interface ProbeArgs {
|
|
12
|
+
fails: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const Probe: StoryObj<ProbeArgs>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
+
import Switch from "../components/switch";
|
|
3
|
+
import Paragraph from "../components/paragraph";
|
|
4
|
+
var meta = {
|
|
5
|
+
title: "Components/Switch",
|
|
6
|
+
component: Switch,
|
|
7
|
+
argTypes: {
|
|
8
|
+
label: { control: "text" },
|
|
9
|
+
description: { control: "text" },
|
|
10
|
+
checked: { control: "boolean" },
|
|
11
|
+
disabled: { control: "boolean" },
|
|
12
|
+
busy: { control: "boolean" },
|
|
13
|
+
error: { control: "text" },
|
|
14
|
+
},
|
|
15
|
+
decorators: [function (Story) { return <div style={{ width: 360 }}><Story /></div>; }],
|
|
16
|
+
};
|
|
17
|
+
export default meta;
|
|
18
|
+
var SwitchWrapper = function (args) {
|
|
19
|
+
var _a = useState(!!args.checked), checked = _a[0], setChecked = _a[1];
|
|
20
|
+
return <Switch {...args} checked={checked} onChange={setChecked}/>;
|
|
21
|
+
};
|
|
22
|
+
export var Default = {
|
|
23
|
+
render: function (args) { return <SwitchWrapper {...args}/>; },
|
|
24
|
+
args: { id: "switch-default", label: "Email alerts", checked: true },
|
|
25
|
+
};
|
|
26
|
+
export var WithDescription = {
|
|
27
|
+
render: function (args) { return <SwitchWrapper {...args}/>; },
|
|
28
|
+
args: {
|
|
29
|
+
id: "switch-description",
|
|
30
|
+
label: "Weekly summary",
|
|
31
|
+
description: "A short email every Monday with last week's activity.",
|
|
32
|
+
checked: false,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
export var Busy = {
|
|
36
|
+
render: function (args) { return <SwitchWrapper {...args}/>; },
|
|
37
|
+
args: { id: "switch-busy", label: "Email alerts", checked: true, busy: true },
|
|
38
|
+
};
|
|
39
|
+
export var Error = {
|
|
40
|
+
render: function (args) { return <SwitchWrapper {...args}/>; },
|
|
41
|
+
args: {
|
|
42
|
+
id: "switch-error",
|
|
43
|
+
label: "Email alerts",
|
|
44
|
+
checked: false,
|
|
45
|
+
error: "Could not save. Try again.",
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
export var Disabled = {
|
|
49
|
+
render: function (args) { return <SwitchWrapper {...args}/>; },
|
|
50
|
+
args: { id: "switch-disabled", label: "Email alerts", checked: true, disabled: true },
|
|
51
|
+
};
|
|
52
|
+
// For tests/interactions.spec.ts: the parent sets `busy`, then keeps the new value or, when `fails`,
|
|
53
|
+
// puts `checked` back and sets `error`. The Switch itself stays controlled.
|
|
54
|
+
function ProbeBox(_a) {
|
|
55
|
+
var fails = _a.fails;
|
|
56
|
+
var _b = useState(false), checked = _b[0], setChecked = _b[1];
|
|
57
|
+
var _c = useState(false), busy = _c[0], setBusy = _c[1];
|
|
58
|
+
var _d = useState(), error = _d[0], setError = _d[1];
|
|
59
|
+
var _e = useState(0), calls = _e[0], setCalls = _e[1];
|
|
60
|
+
var timer = useRef(undefined);
|
|
61
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
62
|
+
var change = function (next) {
|
|
63
|
+
setCalls(function (n) { return n + 1; });
|
|
64
|
+
setError(undefined);
|
|
65
|
+
setBusy(true);
|
|
66
|
+
setChecked(next);
|
|
67
|
+
timer.current = setTimeout(function () {
|
|
68
|
+
setBusy(false);
|
|
69
|
+
if (fails) {
|
|
70
|
+
setChecked(!next);
|
|
71
|
+
setError("Could not save. Try again.");
|
|
72
|
+
}
|
|
73
|
+
}, 300);
|
|
74
|
+
};
|
|
75
|
+
return (<div style={{ width: 360 }}>
|
|
76
|
+
<Switch id="probe-switch" label="Email alerts" checked={checked} busy={busy} error={error} onChange={change}/>
|
|
77
|
+
<Paragraph>
|
|
78
|
+
Calls: <output data-testid="calls">{calls}</output>
|
|
79
|
+
</Paragraph>
|
|
80
|
+
</div>);
|
|
81
|
+
}
|
|
82
|
+
export var Probe = {
|
|
83
|
+
// For tests/interactions.spec.ts only: hidden from the sidebar and the docs, and skipped by the visual gate
|
|
84
|
+
tags: ["!dev", "!autodocs", "test-only"],
|
|
85
|
+
args: { fails: false },
|
|
86
|
+
render: function (args) { return <ProbeBox {...args}/>; },
|
|
87
|
+
};
|
|
@@ -191,3 +191,16 @@ export var ReadOnly = {
|
|
|
191
191
|
size: "medium",
|
|
192
192
|
},
|
|
193
193
|
};
|
|
194
|
+
// A search field has no visible label, so `aria-label` names it. `role="combobox"` with `aria-expanded`,
|
|
195
|
+
// `aria-controls` and `aria-activedescendant` points it at a list under it, as in a quick switcher.
|
|
196
|
+
export var SearchWithName = {
|
|
197
|
+
render: function (args) { return <TextFieldWrapper {...args}/>; },
|
|
198
|
+
args: {
|
|
199
|
+
id: "search-textfield",
|
|
200
|
+
type: "search",
|
|
201
|
+
"aria-label": "Search invoices",
|
|
202
|
+
placeholder: "Search invoices",
|
|
203
|
+
value: "",
|
|
204
|
+
size: "medium",
|
|
205
|
+
},
|
|
206
|
+
};
|