@bridgebrew/design-system 0.0.0-stage → 0.1.9
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 +21 -2
- package/browser.tsx +227 -0
- package/design-system.css +110 -0
- package/e2e.test.ts +253 -0
- package/highlight.ts +29 -0
- package/model.test.ts +69 -0
- package/package.json +72 -3
- package/stories/action.tsx +101 -0
- package/stories/data-display.tsx +371 -0
- package/stories/feedback.tsx +109 -0
- package/stories/foundations.tsx +157 -0
- package/stories/input.tsx +851 -0
- package/stories/interaction.tsx +76 -0
- package/stories/layout.tsx +510 -0
- package/stories/navigation.tsx +220 -0
- package/stories/overlay.tsx +293 -0
- package/stories/parts.tsx +201 -0
- package/stories.ts +149 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// Navigation: where the page sits, which item shows, the app's sidebar, and tabs.
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import {
|
|
4
|
+
Avatar, Badge, Breadcrumb, Bullets, Button, CommandScope, Icon, KeyHint, useCommands, formatKeys, Section, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent,
|
|
5
|
+
SidebarGroupTrigger, SidebarHeader, SidebarItem, SidebarResizeHandle, SidebarSection, SidebarTree, SidebarTreeItem,
|
|
6
|
+
SIDEBAR_DEFAULT_WIDTH, StatusIcon, Tabs, TabsContent, TabsList, TabsTrigger,
|
|
7
|
+
FollowProvider, gestureOf, ScreenLink, type Follow, type FollowTarget,
|
|
8
|
+
} from '@bridge/ui';
|
|
9
|
+
import { Group, Sample } from './parts.tsx';
|
|
10
|
+
|
|
11
|
+
const full = ['Workspace', 'Projects', 'Website', 'Launch checklist'];
|
|
12
|
+
|
|
13
|
+
function BreadcrumbStory() {
|
|
14
|
+
const [path, setPath] = React.useState(full);
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
<Group title="Items" description="The last item is the current page; the others link (href) or act (onClick)." layout="stack" code={`<Breadcrumb items={[{ label: 'Settings' }]} />\n<Breadcrumb items={[{ label: 'Workspace', href: '#workspace' }, { label: 'Contacts', href: '#contacts' }, { label: 'Ada Lindqvist' }]} />\n<Breadcrumb items={[{ label: 'Archive' }, { label: '2025' }, { label: 'Invoices' }]} />`}>
|
|
18
|
+
<Sample title="one level" wide><Breadcrumb items={[{ label: 'Settings' }]} /></Sample>
|
|
19
|
+
<Sample title="links" wide><Breadcrumb items={[{ label: 'Workspace', href: '#workspace' }, { label: 'Contacts', href: '#contacts' }, { label: 'Ada Lindqvist' }]} /></Sample>
|
|
20
|
+
<Sample title="plain ancestors" description="Neither href nor onClick: text only" wide><Breadcrumb items={[{ label: 'Archive' }, { label: '2025' }, { label: 'Invoices' }]} /></Sample>
|
|
21
|
+
</Group>
|
|
22
|
+
<Group title="Examples" description="Each ancestor is a button back to it; the current page takes the focus." layout="stack" code={`<Breadcrumb items={path.map((label, index) => ({ label, ...(index < path.length - 1 && { onClick: () => setPath(path.slice(0, index + 1)) }) }))} />\n<Button variant="ghost" size="sm" disabled={path.length === full.length} onClick={() => setPath(full)}><Icon name="rotate-cw" />Reset</Button>`}>
|
|
23
|
+
<Sample title="navigate up" description={`At: ${path.at(-1)}`} wide>
|
|
24
|
+
<Breadcrumb items={path.map((label, index) => ({ label, ...(index < path.length - 1 && { onClick: () => setPath(path.slice(0, index + 1)) }) }))} />
|
|
25
|
+
<Button variant="ghost" size="sm" disabled={path.length === full.length} onClick={() => setPath(full)}><Icon name="rotate-cw" />Reset</Button>
|
|
26
|
+
</Sample>
|
|
27
|
+
</Group>
|
|
28
|
+
</>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const tree = [
|
|
33
|
+
{ id: 'website', label: 'Website', icon: 'globe', children: [{ id: 'launch', label: 'Launch checklist' }, { id: 'seo', label: 'SEO audit' }] },
|
|
34
|
+
{ id: 'mobile', label: 'Mobile app', icon: 'box', children: [{ id: 'onboarding', label: 'Onboarding' }, { id: 'push', label: 'Push notifications', children: [{ id: 'ios', label: 'iOS' }, { id: 'android', label: 'Android' }] }] },
|
|
35
|
+
{ id: 'billing', label: 'Billing', icon: 'receipt' },
|
|
36
|
+
];
|
|
37
|
+
interface Node { id: string; label: string; icon?: string; children?: Node[] }
|
|
38
|
+
|
|
39
|
+
function BulletsStory() {
|
|
40
|
+
const slides = ['Overview', 'Activity', 'People', 'Files', 'Settings'];
|
|
41
|
+
const [shown, setShown] = React.useState(1);
|
|
42
|
+
return (
|
|
43
|
+
<>
|
|
44
|
+
<Group title="Examples" description="A click goes to an item; nothing renders below two." layout="grid" code={`<Bullets count={slides.length} index={shown} onSelect={setShown} labelOf={(i) => slides[i]!} />\n<Bullets count={4} index={2} />`}>
|
|
45
|
+
<Sample title="interactive" description={`Showing ${slides[shown]}`}>
|
|
46
|
+
<Bullets count={slides.length} index={shown} onSelect={setShown} labelOf={(i) => slides[i]!} />
|
|
47
|
+
</Sample>
|
|
48
|
+
<Sample title="indicator" description="Without onSelect, they only say where one is">
|
|
49
|
+
<Bullets count={4} index={2} />
|
|
50
|
+
</Sample>
|
|
51
|
+
</Group>
|
|
52
|
+
</>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function SidebarStory() {
|
|
57
|
+
const [active, setActive] = React.useState('inbox');
|
|
58
|
+
const [open, setOpen] = React.useState<Record<string, boolean>>({ website: true, mobile: false, push: false });
|
|
59
|
+
const [width, setWidth] = React.useState(SIDEBAR_DEFAULT_WIDTH);
|
|
60
|
+
const item = (id: string, label: string, icon: string, count?: number) => (
|
|
61
|
+
<SidebarItem key={id} active={active === id} icon={<Icon name={icon} />} count={count} onClick={() => setActive(id)}>{label}</SidebarItem>
|
|
62
|
+
);
|
|
63
|
+
const node = ({ id, label, icon, children }: Node, depth = 0): React.ReactNode => (
|
|
64
|
+
<SidebarTreeItem
|
|
65
|
+
key={id}
|
|
66
|
+
label={label}
|
|
67
|
+
depth={depth}
|
|
68
|
+
icon={<Icon name={icon ?? 'file-text'} size={14} />}
|
|
69
|
+
active={active === id}
|
|
70
|
+
onSelect={() => setActive(id)}
|
|
71
|
+
{...(children && { expanded: open[id] ?? false, onExpandedChange: (next: boolean) => setOpen((current) => ({ ...current, [id]: next })) })}
|
|
72
|
+
trailing={id === 'launch' ? <StatusIcon status="in-progress" size="sm" /> : undefined}
|
|
73
|
+
>
|
|
74
|
+
{children?.map((child) => node(child, depth + 1))}
|
|
75
|
+
</SidebarTreeItem>
|
|
76
|
+
);
|
|
77
|
+
return (
|
|
78
|
+
<>
|
|
79
|
+
<Group title="Examples" description="Items, a section, collapsible groups, a tree (↑ ↓ ← →), a footer; drag the right edge to resize." layout="fill">
|
|
80
|
+
<div className="ds-sidebar-frame" style={{ '--sidebar-width': `${width}px` } as React.CSSProperties}>
|
|
81
|
+
<Sidebar aria-label="Example navigation">
|
|
82
|
+
<SidebarContent>
|
|
83
|
+
<SidebarHeader><Avatar name="Northwind" size="lg" shape="square" tint /><Section size="sm" title="Northwind" /></SidebarHeader>
|
|
84
|
+
{item('inbox', 'Inbox', 'inbox', 4)}
|
|
85
|
+
{item('my-issues', 'My issues', 'square-pen')}
|
|
86
|
+
{item('activity', 'Activity', 'activity', 12)}
|
|
87
|
+
<SidebarSection>Workspace</SidebarSection>
|
|
88
|
+
{item('contacts', 'Contacts', 'users')}
|
|
89
|
+
{item('settings', 'Settings', 'settings')}
|
|
90
|
+
<SidebarGroup defaultExpanded>
|
|
91
|
+
<SidebarGroupTrigger variant="section" trailing={<Badge>3</Badge>}>Projects</SidebarGroupTrigger>
|
|
92
|
+
<SidebarGroupContent>
|
|
93
|
+
<SidebarTree aria-label="Projects">{tree.map((each) => node(each))}</SidebarTree>
|
|
94
|
+
</SidebarGroupContent>
|
|
95
|
+
</SidebarGroup>
|
|
96
|
+
<SidebarGroup defaultExpanded={false}>
|
|
97
|
+
<SidebarGroupTrigger teamDot="oklch(65% 0.15 250)">Design team</SidebarGroupTrigger>
|
|
98
|
+
<SidebarGroupContent>
|
|
99
|
+
{item('design-issues', 'Issues', 'list')}
|
|
100
|
+
{item('design-cycles', 'Cycles', 'rotate-cw')}
|
|
101
|
+
</SidebarGroupContent>
|
|
102
|
+
</SidebarGroup>
|
|
103
|
+
</SidebarContent>
|
|
104
|
+
<SidebarFooter>{item('help', 'Help and docs', 'book-open')}</SidebarFooter>
|
|
105
|
+
</Sidebar>
|
|
106
|
+
<SidebarResizeHandle width={width} onWidthChange={setWidth} />
|
|
107
|
+
<div className="ds-sidebar-main">
|
|
108
|
+
<Section title={`Open: ${active}`} description={`Sidebar width ${width}px (190 to half the window; double-click the edge for 220).`} />
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
</Group>
|
|
112
|
+
<Group title="Items" description="SidebarItem: an icon, a label, a count; active, hover." layout="fill">
|
|
113
|
+
<div className="ds-sidebar-strip">
|
|
114
|
+
<Sidebar aria-label="Item states">
|
|
115
|
+
<SidebarItem icon={<Icon name="home" />}>Default</SidebarItem>
|
|
116
|
+
<SidebarItem active icon={<Icon name="star" />}>Active</SidebarItem>
|
|
117
|
+
<SidebarItem icon={<Icon name="inbox" />} count={8}>With a count</SidebarItem>
|
|
118
|
+
<SidebarItem teamDot="oklch(70% 0.15 150)">With a team dot</SidebarItem>
|
|
119
|
+
<SidebarSection>A section label</SidebarSection>
|
|
120
|
+
</Sidebar>
|
|
121
|
+
</div>
|
|
122
|
+
</Group>
|
|
123
|
+
</>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function TabsStory() {
|
|
128
|
+
const [tab, setTab] = React.useState<string | number | null>('activity');
|
|
129
|
+
return (
|
|
130
|
+
<>
|
|
131
|
+
<Group title="Examples" description="← → move between tabs; counts are muted beside the label." layout="fill" code={`<Tabs value={tab} onValueChange={setTab}>\n <TabsList>\n <TabsTrigger value="overview">Overview</TabsTrigger>\n <TabsTrigger value="activity" count={12}>Activity</TabsTrigger>\n <TabsTrigger value="people" count={4}>People</TabsTrigger>\n <TabsTrigger value="files" disabled>Files</TabsTrigger>\n </TabsList>\n <TabsContent value="overview"><Section title="Overview" description="The project's summary, owners and dates." /></TabsContent>\n <TabsContent value="activity"><Section title="Activity" description="12 events this week: 3 comments, 9 status changes." /></TabsContent>\n <TabsContent value="people"><Section title="People" description="Ada, Bruno, Chloé and Dmitri work on it." /></TabsContent>\n</Tabs>`}>
|
|
132
|
+
<Tabs value={tab} onValueChange={setTab}>
|
|
133
|
+
<TabsList>
|
|
134
|
+
<TabsTrigger value="overview">Overview</TabsTrigger>
|
|
135
|
+
<TabsTrigger value="activity" count={12}>Activity</TabsTrigger>
|
|
136
|
+
<TabsTrigger value="people" count={4}>People</TabsTrigger>
|
|
137
|
+
<TabsTrigger value="files" disabled>Files</TabsTrigger>
|
|
138
|
+
</TabsList>
|
|
139
|
+
<TabsContent value="overview"><Section title="Overview" description="The project's summary, owners and dates." /></TabsContent>
|
|
140
|
+
<TabsContent value="activity"><Section title="Activity" description="12 events this week: 3 comments, 9 status changes." /></TabsContent>
|
|
141
|
+
<TabsContent value="people"><Section title="People" description="Ada, Bruno, Chloé and Dmitri work on it." /></TabsContent>
|
|
142
|
+
</Tabs>
|
|
143
|
+
</Group>
|
|
144
|
+
<Group title="States" layout="stack" code={`<Tabs defaultValue="a">\n <TabsList>\n <TabsTrigger value="a">Active</TabsTrigger>\n <TabsTrigger value="b">Inactive</TabsTrigger>\n <TabsTrigger value="c" disabled>Disabled</TabsTrigger>\n </TabsList>\n</Tabs>`}>
|
|
145
|
+
<Sample title="active, inactive, disabled" wide>
|
|
146
|
+
<Tabs defaultValue="a">
|
|
147
|
+
<TabsList>
|
|
148
|
+
<TabsTrigger value="a">Active</TabsTrigger>
|
|
149
|
+
<TabsTrigger value="b">Inactive</TabsTrigger>
|
|
150
|
+
<TabsTrigger value="c" disabled>Disabled</TabsTrigger>
|
|
151
|
+
</TabsList>
|
|
152
|
+
</Tabs>
|
|
153
|
+
</Sample>
|
|
154
|
+
</Group>
|
|
155
|
+
</>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function CommandDemo() {
|
|
160
|
+
const [log, setLog] = React.useState('Nothing yet');
|
|
161
|
+
const say = (text: string) => () => setLog(text);
|
|
162
|
+
useCommands([
|
|
163
|
+
{ id: 'new', label: 'New contact', keys: 'N', icon: 'plus', group: 'Contacts', run: say('New contact') },
|
|
164
|
+
{ id: 'go-people', label: 'Go to People', keys: 'G P', icon: 'users', navigation: true, run: say('Go to People') },
|
|
165
|
+
{ id: 'archive', label: 'Archive', keys: 'Meta+Backspace', icon: 'archive', group: 'Contacts', run: say('Archive') },
|
|
166
|
+
{ id: 'locked', label: 'Delete everything', disabled: true, run: say('never') },
|
|
167
|
+
]);
|
|
168
|
+
return (
|
|
169
|
+
<>
|
|
170
|
+
<KeyHint keys="N"><Button variant="outline" size="sm" onClick={say('New contact')}><Icon name="plus" />New</Button></KeyHint>
|
|
171
|
+
<KeyHint keys="Meta+Backspace"><Button variant="outline" size="sm" onClick={say('Archive')}><Icon name="archive" />Archive</Button></KeyHint>
|
|
172
|
+
<span>Last run: {log}</span>
|
|
173
|
+
</>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function CommandStory() {
|
|
178
|
+
return (
|
|
179
|
+
<>
|
|
180
|
+
<Group title="Key formats" description="formatKeys writes a key as the platform shows it." code={`{['L', 'Shift+J', 'Meta+Enter', 'G P'].map((keys) => <Sample key={keys} title={keys}><code>{formatKeys(keys)}</code></Sample>)}`}>
|
|
181
|
+
{['L', 'Shift+J', 'Meta+Enter', 'G P'].map((keys) => <Sample key={keys} title={keys}><code>{formatKeys(keys)}</code></Sample>)}
|
|
182
|
+
</Group>
|
|
183
|
+
<Group title="Examples" description="Click here, then press N, G then P, or ⌘K for the menu; the hints are always shown." layout="stack" code={`<CommandScope active hints="always" subject="Ada Lindqvist"><CommandDemo /></CommandScope>`}>
|
|
184
|
+
<Sample title="CommandScope, useCommands and KeyHint" wide>
|
|
185
|
+
<CommandScope active hints="always" subject="Ada Lindqvist"><CommandDemo /></CommandScope>
|
|
186
|
+
</Sample>
|
|
187
|
+
</Group>
|
|
188
|
+
</>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function ScreenLinkStory() {
|
|
193
|
+
const [followed, setFollowed] = React.useState<string>('nothing yet');
|
|
194
|
+
// The shell provides FollowProvider around each window; here a stand-in says what a click asked for.
|
|
195
|
+
const follow = React.useMemo<Follow>(() => ({
|
|
196
|
+
href: (target: FollowTarget) => `#${'node' in target ? target.node : target.item ?? ''}`,
|
|
197
|
+
follow: (target, event) => setFollowed(`${JSON.stringify(target)} (${gestureOf(event)})`),
|
|
198
|
+
}), []);
|
|
199
|
+
return (
|
|
200
|
+
<>
|
|
201
|
+
<Group title="Examples" description="Plain click: this window; ⌘ or middle click: a window beside; ⌥: a new desk." layout="stack" code={`<FollowProvider value={follow}>\n <ScreenLink to={{ item: 'ada' }}>Ada Lindqvist</ScreenLink>\n <ScreenLink to={{ node: 'contacts' }}>Contacts</ScreenLink>\n</FollowProvider>\n<ScreenLink to={{ item: 'ada' }}>Ada Lindqvist</ScreenLink>`}>
|
|
202
|
+
<FollowProvider value={follow}>
|
|
203
|
+
<Sample title="an item of this screen" description={`Followed: ${followed}`} wide>
|
|
204
|
+
<ScreenLink to={{ item: 'ada' }}>Ada Lindqvist</ScreenLink>
|
|
205
|
+
</Sample>
|
|
206
|
+
<Sample title="a view of the workspace" wide>
|
|
207
|
+
<ScreenLink to={{ node: 'contacts' }}>Contacts</ScreenLink>
|
|
208
|
+
</Sample>
|
|
209
|
+
</FollowProvider>
|
|
210
|
+
<Sample title="outside a shell" description="No href, nothing to follow" wide>
|
|
211
|
+
<ScreenLink to={{ item: 'ada' }}>Ada Lindqvist</ScreenLink>
|
|
212
|
+
</Sample>
|
|
213
|
+
</Group>
|
|
214
|
+
</>
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export const navigation = { 'screen-link': ScreenLinkStory,
|
|
219
|
+
command: CommandStory, breadcrumb: BreadcrumbStory, bullets: BulletsStory, sidebar: SidebarStory, tabs: TabsStory,
|
|
220
|
+
};
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
// Overlay: dialogs, menus and tooltips, each opened for real (they render in a portal, in the page's theme).
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import {
|
|
4
|
+
Button, buttonVariants, Card, ContextMenu, ContextMenuTrigger, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription,
|
|
5
|
+
DialogFooter, DialogHeader, DialogMaximize, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuContent,
|
|
6
|
+
DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger,
|
|
7
|
+
Field, FieldDescription, FieldError, FieldLabel, Icon, Input, Section, SnoozeDialog, SnoozeMenu, snoozeWakeLabel, Textarea, Tooltip,
|
|
8
|
+
TooltipContent, TooltipTrigger, useToast,
|
|
9
|
+
Popover, PopoverContent, PopoverTrigger, List, ListItem, Wizard, WizardStep, useWizard,
|
|
10
|
+
} from '@bridge/ui';
|
|
11
|
+
import { Tip } from './action.tsx';
|
|
12
|
+
import { Group, Sample } from './parts.tsx';
|
|
13
|
+
|
|
14
|
+
const CloseButton = () => (
|
|
15
|
+
<DialogClose render={<Button variant="ghost" size="icon-sm" aria-label="Close" />}><Icon name="x" size={14} /></DialogClose>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
function DialogStory() {
|
|
19
|
+
const { toast } = useToast();
|
|
20
|
+
const [open, setOpen] = React.useState(false);
|
|
21
|
+
const [name, setName] = React.useState('');
|
|
22
|
+
const [error, setError] = React.useState<string>();
|
|
23
|
+
const [confirming, setConfirming] = React.useState(false);
|
|
24
|
+
const create = () => {
|
|
25
|
+
if (name.trim() === '') return setError('Enter a project name');
|
|
26
|
+
toast({ title: `Project “${name.trim()}” created`, variant: 'success' });
|
|
27
|
+
setOpen(false);
|
|
28
|
+
setName('');
|
|
29
|
+
setError(undefined);
|
|
30
|
+
};
|
|
31
|
+
return (
|
|
32
|
+
<>
|
|
33
|
+
<Group title="Examples" description="Escape or a click outside closes; focus returns to the trigger." layout="grid" code={`<Dialog open={open} onOpenChange={(next) => { setOpen(next); if (!next) setError(undefined); }}>\n <DialogTrigger render={<Button variant="primary" />}><Icon name="plus" />New project</DialogTrigger>\n <DialogContent>\n <DialogHeader><DialogTitle>New project</DialogTitle><CloseButton /></DialogHeader>\n <DialogBody>\n <form className="ds-form ds-dialog-form" noValidate onSubmit={(event) => { event.preventDefault(); create(); }}>\n <Field invalid={error !== undefined}>\n <FieldLabel>Name</FieldLabel>\n <Input variant="outline" autoFocus placeholder="Website relaunch" value={name} onChange={(event) => { setName(event.currentTarget.value); setError(undefined); }} />\n <FieldError>{error}</FieldError>\n </Field>\n <Field>\n <FieldLabel>Description</FieldLabel>\n <Textarea variant="outline" placeholder="What is it for?" />\n <FieldDescription>Optional; shown on the project's page</FieldDescription>\n </Field>\n </form>\n </DialogBody>\n <DialogFooter className="ds-dialog-footer">\n <DialogClose render={<Button variant="ghost" />}>Cancel</DialogClose>\n <Button variant="primary" onClick={create}>Create project</Button>\n </DialogFooter>\n </DialogContent>\n</Dialog>\n<Dialog open={confirming} onOpenChange={setConfirming}>\n <DialogTrigger render={<Button variant="destructive" />}><Icon name="trash" />Delete workspace…</DialogTrigger>\n <DialogContent>\n <DialogHeader><DialogTitle>Delete “Northwind”?</DialogTitle><CloseButton /></DialogHeader>\n <DialogBody className="ds-dialog-body">\n <DialogDescription>Its 1,204 contacts, 86 organizations and every plugin's data go for good. This cannot be undone.</DialogDescription>\n </DialogBody>\n <DialogFooter className="ds-dialog-footer">\n <DialogClose render={<Button variant="ghost" />}>Keep it</DialogClose>\n <Button variant="destructive" onClick={() => { setConfirming(false); toast({ title: 'Workspace deleted', description: '(Not really: this is a story.)', variant: 'error' }); }}><Icon name="trash" />Delete for good</Button>\n </DialogFooter>\n </DialogContent>\n</Dialog>\n<Dialog>\n <DialogTrigger render={<Button variant="outline" />}><Icon name="dashboard" />Open the board</DialogTrigger>\n <DialogContent fullscreen>\n <DialogHeader><DialogTitle>Sprint board</DialogTitle><CloseButton /></DialogHeader>\n <DialogBody className="ds-dialog-body">\n <Section title="A large surface" description="For work that needs the room: a board, a document, a diff. Escape closes it." />\n </DialogBody>\n </DialogContent>\n</Dialog>\n<Dialog>\n <DialogTrigger render={<Button variant="outline" />}><Icon name="file-text" />Open document</DialogTrigger>\n <DialogContent maximizable>\n <DialogHeader>\n <DialogTitle>Release notes</DialogTitle>\n <DialogMaximize className={buttonVariants({ variant: 'ghost', size: 'icon-sm' })} />\n <CloseButton />\n </DialogHeader>\n <DialogBody className="ds-dialog-body">\n <Section title="0.4.2" description="Sidebar items under a plugin's screens; the item in the route; a Picker for detail cards; server-searched Combobox." />\n </DialogBody>\n </DialogContent>\n</Dialog>`}>
|
|
34
|
+
<Sample title="a form" description="Validates, then closes with a toast">
|
|
35
|
+
<Dialog open={open} onOpenChange={(next) => { setOpen(next); if (!next) setError(undefined); }}>
|
|
36
|
+
<DialogTrigger render={<Button variant="primary" />}><Icon name="plus" />New project</DialogTrigger>
|
|
37
|
+
<DialogContent>
|
|
38
|
+
<DialogHeader><DialogTitle>New project</DialogTitle><CloseButton /></DialogHeader>
|
|
39
|
+
<DialogBody>
|
|
40
|
+
<form className="ds-form ds-dialog-form" noValidate onSubmit={(event) => { event.preventDefault(); create(); }}>
|
|
41
|
+
<Field invalid={error !== undefined}>
|
|
42
|
+
<FieldLabel>Name</FieldLabel>
|
|
43
|
+
<Input variant="outline" autoFocus placeholder="Website relaunch" value={name} onChange={(event) => { setName(event.currentTarget.value); setError(undefined); }} />
|
|
44
|
+
<FieldError>{error}</FieldError>
|
|
45
|
+
</Field>
|
|
46
|
+
<Field>
|
|
47
|
+
<FieldLabel>Description</FieldLabel>
|
|
48
|
+
<Textarea variant="outline" placeholder="What is it for?" />
|
|
49
|
+
<FieldDescription>Optional; shown on the project's page</FieldDescription>
|
|
50
|
+
</Field>
|
|
51
|
+
</form>
|
|
52
|
+
</DialogBody>
|
|
53
|
+
<DialogFooter className="ds-dialog-footer">
|
|
54
|
+
<DialogClose render={<Button variant="ghost" />}>Cancel</DialogClose>
|
|
55
|
+
<Button variant="primary" onClick={create}>Create project</Button>
|
|
56
|
+
</DialogFooter>
|
|
57
|
+
</DialogContent>
|
|
58
|
+
</Dialog>
|
|
59
|
+
</Sample>
|
|
60
|
+
<Sample title="a confirmation" description="A destructive action, asked first">
|
|
61
|
+
<Dialog open={confirming} onOpenChange={setConfirming}>
|
|
62
|
+
<DialogTrigger render={<Button variant="destructive" />}><Icon name="trash" />Delete workspace…</DialogTrigger>
|
|
63
|
+
<DialogContent>
|
|
64
|
+
<DialogHeader><DialogTitle>Delete “Northwind”?</DialogTitle><CloseButton /></DialogHeader>
|
|
65
|
+
<DialogBody className="ds-dialog-body">
|
|
66
|
+
<DialogDescription>Its 1,204 contacts, 86 organizations and every plugin's data go for good. This cannot be undone.</DialogDescription>
|
|
67
|
+
</DialogBody>
|
|
68
|
+
<DialogFooter className="ds-dialog-footer">
|
|
69
|
+
<DialogClose render={<Button variant="ghost" />}>Keep it</DialogClose>
|
|
70
|
+
<Button variant="destructive" onClick={() => { setConfirming(false); toast({ title: 'Workspace deleted', description: '(Not really: this is a story.)', variant: 'error' }); }}><Icon name="trash" />Delete for good</Button>
|
|
71
|
+
</DialogFooter>
|
|
72
|
+
</DialogContent>
|
|
73
|
+
</Dialog>
|
|
74
|
+
</Sample>
|
|
75
|
+
<Sample title="fullscreen" description="fullscreen: 90% of the window">
|
|
76
|
+
<Dialog>
|
|
77
|
+
<DialogTrigger render={<Button variant="outline" />}><Icon name="dashboard" />Open the board</DialogTrigger>
|
|
78
|
+
<DialogContent fullscreen>
|
|
79
|
+
<DialogHeader><DialogTitle>Sprint board</DialogTitle><CloseButton /></DialogHeader>
|
|
80
|
+
<DialogBody className="ds-dialog-body">
|
|
81
|
+
<Section title="A large surface" description="For work that needs the room: a board, a document, a diff. Escape closes it." />
|
|
82
|
+
</DialogBody>
|
|
83
|
+
</DialogContent>
|
|
84
|
+
</Dialog>
|
|
85
|
+
</Sample>
|
|
86
|
+
<Sample title="maximizable" description="DialogMaximize toggles fullscreen">
|
|
87
|
+
<Dialog>
|
|
88
|
+
<DialogTrigger render={<Button variant="outline" />}><Icon name="file-text" />Open document</DialogTrigger>
|
|
89
|
+
<DialogContent maximizable>
|
|
90
|
+
<DialogHeader>
|
|
91
|
+
<DialogTitle>Release notes</DialogTitle>
|
|
92
|
+
<DialogMaximize className={buttonVariants({ variant: 'ghost', size: 'icon-sm' })} />
|
|
93
|
+
<CloseButton />
|
|
94
|
+
</DialogHeader>
|
|
95
|
+
<DialogBody className="ds-dialog-body">
|
|
96
|
+
<Section title="0.4.2" description="Sidebar items under a plugin's screens; the item in the route; a Picker for detail cards; server-searched Combobox." />
|
|
97
|
+
</DialogBody>
|
|
98
|
+
</DialogContent>
|
|
99
|
+
</Dialog>
|
|
100
|
+
</Sample>
|
|
101
|
+
</Group>
|
|
102
|
+
</>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function DropdownMenuStory() {
|
|
107
|
+
const { toast } = useToast();
|
|
108
|
+
const [sort, setSort] = React.useState('Updated');
|
|
109
|
+
const [archived, setArchived] = React.useState(false);
|
|
110
|
+
const act = (title: string) => () => toast({ title });
|
|
111
|
+
return (
|
|
112
|
+
<>
|
|
113
|
+
<Group title="Examples" description="↑ ↓ move, Enter picks, Escape closes; type a letter to jump." layout="columns" code={`<DropdownMenu>\n <Tip label="More actions">\n <DropdownMenuTrigger render={<Button variant="ghost" size="icon" aria-label="More actions" />}><Icon name="ellipsis" /></DropdownMenuTrigger>\n </Tip>\n <DropdownMenuContent align="start">\n <DropdownMenuItem onSelect={act('Edit')}><Icon name="square-pen" size={14} />Edit<DropdownMenuShortcut>E</DropdownMenuShortcut></DropdownMenuItem>\n <DropdownMenuItem onSelect={act('Duplicated')}><Icon name="copy" size={14} />Duplicate<DropdownMenuShortcut>⌘D</DropdownMenuShortcut></DropdownMenuItem>\n <DropdownMenuItem onSelect={act('Link copied')}><Icon name="link" size={14} />Copy link<DropdownMenuShortcut>⌘L</DropdownMenuShortcut></DropdownMenuItem>\n <DropdownMenuItem disabled><Icon name="git-branch" size={14} />Create branch</DropdownMenuItem>\n <DropdownMenuSeparator />\n <DropdownMenuItem onSelect={act('Archived')}><Icon name="archive" size={14} />Archive</DropdownMenuItem>\n <DropdownMenuItem variant="destructive" onSelect={act('Deleted')}><Icon name="trash" size={14} />Delete…<DropdownMenuShortcut>⌫</DropdownMenuShortcut></DropdownMenuItem>\n </DropdownMenuContent>\n</DropdownMenu>\n<DropdownMenu>\n <DropdownMenuTrigger render={<Button variant="outline" />}><Icon name="filter" />Display</DropdownMenuTrigger>\n <DropdownMenuContent>\n <DropdownMenuGroup>\n <DropdownMenuLabel>Sort by</DropdownMenuLabel>\n {['Updated', 'Created', 'Title', 'Priority'].map((each) => (\n <DropdownMenuItem key={each} onSelect={() => setSort(each)}><span className="ds-grow-text">{each}</span>{sort === each && <Icon name="check" size={14} />}</DropdownMenuItem>\n ))}\n </DropdownMenuGroup>\n <DropdownMenuSeparator />\n <DropdownMenuItem onSelect={() => setArchived((on) => !on)}><Icon name="archive" size={14} /><span className="ds-grow-text">Show archived</span>{archived && <Icon name="check" size={14} />}</DropdownMenuItem>\n </DropdownMenuContent>\n</DropdownMenu>\n<DropdownMenu>\n <DropdownMenuTrigger render={<Button variant="property" />}><Icon name="calendar" />Due Friday</DropdownMenuTrigger>\n <DropdownMenuContent side="top" align="end">\n <DropdownMenuLabel>Due date</DropdownMenuLabel>\n {['Today', 'Tomorrow', 'Friday', 'Next week'].map((each) => <DropdownMenuItem key={each} onSelect={act(\`Due \${each.toLowerCase()}\`)}>{each}</DropdownMenuItem>)}\n <DropdownMenuSeparator />\n <DropdownMenuItem variant="destructive" onSelect={act('Due date removed')}><Icon name="x" size={14} />Remove due date</DropdownMenuItem>\n </DropdownMenuContent>\n</DropdownMenu>\n<ContextMenu>\n <ContextMenuTrigger>\n <Card variant="outline" className="ds-context-area" tabIndex={0}>\n <Section size="sm" title="BRG-41 · Storyboard of the kit" description="Right-click for its actions" />\n </Card>\n </ContextMenuTrigger>\n <DropdownMenuContent>\n <DropdownMenuItem onSelect={act('Opened')}><Icon name="file-text" size={14} />Open</DropdownMenuItem>\n <DropdownMenuItem onSelect={act('Link copied')}><Icon name="link" size={14} />Copy link</DropdownMenuItem>\n <DropdownMenuSeparator />\n <DropdownMenuItem variant="destructive" onSelect={act('Deleted')}><Icon name="trash" size={14} />Delete</DropdownMenuItem>\n </DropdownMenuContent>\n</ContextMenu>`}>
|
|
114
|
+
<Sample title="actions" description="Icons, shortcuts, a destructive item">
|
|
115
|
+
<DropdownMenu>
|
|
116
|
+
<Tip label="More actions">
|
|
117
|
+
<DropdownMenuTrigger render={<Button variant="ghost" size="icon" aria-label="More actions" />}><Icon name="ellipsis" /></DropdownMenuTrigger>
|
|
118
|
+
</Tip>
|
|
119
|
+
<DropdownMenuContent align="start">
|
|
120
|
+
<DropdownMenuItem onSelect={act('Edit')}><Icon name="square-pen" size={14} />Edit<DropdownMenuShortcut>E</DropdownMenuShortcut></DropdownMenuItem>
|
|
121
|
+
<DropdownMenuItem onSelect={act('Duplicated')}><Icon name="copy" size={14} />Duplicate<DropdownMenuShortcut>⌘D</DropdownMenuShortcut></DropdownMenuItem>
|
|
122
|
+
<DropdownMenuItem onSelect={act('Link copied')}><Icon name="link" size={14} />Copy link<DropdownMenuShortcut>⌘L</DropdownMenuShortcut></DropdownMenuItem>
|
|
123
|
+
<DropdownMenuItem disabled><Icon name="git-branch" size={14} />Create branch</DropdownMenuItem>
|
|
124
|
+
<DropdownMenuSeparator />
|
|
125
|
+
<DropdownMenuItem onSelect={act('Archived')}><Icon name="archive" size={14} />Archive</DropdownMenuItem>
|
|
126
|
+
<DropdownMenuItem variant="destructive" onSelect={act('Deleted')}><Icon name="trash" size={14} />Delete…<DropdownMenuShortcut>⌫</DropdownMenuShortcut></DropdownMenuItem>
|
|
127
|
+
</DropdownMenuContent>
|
|
128
|
+
</DropdownMenu>
|
|
129
|
+
</Sample>
|
|
130
|
+
<Sample title="choices" description={`Sort: ${sort}${archived ? ', archived shown' : ''}`}>
|
|
131
|
+
<DropdownMenu>
|
|
132
|
+
<DropdownMenuTrigger render={<Button variant="outline" />}><Icon name="filter" />Display</DropdownMenuTrigger>
|
|
133
|
+
<DropdownMenuContent>
|
|
134
|
+
<DropdownMenuGroup>
|
|
135
|
+
<DropdownMenuLabel>Sort by</DropdownMenuLabel>
|
|
136
|
+
{['Updated', 'Created', 'Title', 'Priority'].map((each) => (
|
|
137
|
+
<DropdownMenuItem key={each} onSelect={() => setSort(each)}><span className="ds-grow-text">{each}</span>{sort === each && <Icon name="check" size={14} />}</DropdownMenuItem>
|
|
138
|
+
))}
|
|
139
|
+
</DropdownMenuGroup>
|
|
140
|
+
<DropdownMenuSeparator />
|
|
141
|
+
<DropdownMenuItem onSelect={() => setArchived((on) => !on)}><Icon name="archive" size={14} /><span className="ds-grow-text">Show archived</span>{archived && <Icon name="check" size={14} />}</DropdownMenuItem>
|
|
142
|
+
</DropdownMenuContent>
|
|
143
|
+
</DropdownMenu>
|
|
144
|
+
</Sample>
|
|
145
|
+
<Sample title="placement" description='side="top", align="end"'>
|
|
146
|
+
<DropdownMenu>
|
|
147
|
+
<DropdownMenuTrigger render={<Button variant="property" />}><Icon name="calendar" />Due Friday</DropdownMenuTrigger>
|
|
148
|
+
<DropdownMenuContent side="top" align="end">
|
|
149
|
+
<DropdownMenuLabel>Due date</DropdownMenuLabel>
|
|
150
|
+
{['Today', 'Tomorrow', 'Friday', 'Next week'].map((each) => <DropdownMenuItem key={each} onSelect={act(`Due ${each.toLowerCase()}`)}>{each}</DropdownMenuItem>)}
|
|
151
|
+
<DropdownMenuSeparator />
|
|
152
|
+
<DropdownMenuItem variant="destructive" onSelect={act('Due date removed')}><Icon name="x" size={14} />Remove due date</DropdownMenuItem>
|
|
153
|
+
</DropdownMenuContent>
|
|
154
|
+
</DropdownMenu>
|
|
155
|
+
</Sample>
|
|
156
|
+
<Sample title="context menu" description="Right-click the card (or Shift+F10)">
|
|
157
|
+
<ContextMenu>
|
|
158
|
+
<ContextMenuTrigger>
|
|
159
|
+
<Card variant="outline" className="ds-context-area" tabIndex={0}>
|
|
160
|
+
<Section size="sm" title="BRG-41 · Storyboard of the kit" description="Right-click for its actions" />
|
|
161
|
+
</Card>
|
|
162
|
+
</ContextMenuTrigger>
|
|
163
|
+
<DropdownMenuContent>
|
|
164
|
+
<DropdownMenuItem onSelect={act('Opened')}><Icon name="file-text" size={14} />Open</DropdownMenuItem>
|
|
165
|
+
<DropdownMenuItem onSelect={act('Link copied')}><Icon name="link" size={14} />Copy link</DropdownMenuItem>
|
|
166
|
+
<DropdownMenuSeparator />
|
|
167
|
+
<DropdownMenuItem variant="destructive" onSelect={act('Deleted')}><Icon name="trash" size={14} />Delete</DropdownMenuItem>
|
|
168
|
+
</DropdownMenuContent>
|
|
169
|
+
</ContextMenu>
|
|
170
|
+
</Sample>
|
|
171
|
+
</Group>
|
|
172
|
+
</>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function SnoozeMenuStory() {
|
|
177
|
+
const [until, setUntil] = React.useState<string | null>(null);
|
|
178
|
+
const [custom, setCustom] = React.useState(false);
|
|
179
|
+
return (
|
|
180
|
+
<>
|
|
181
|
+
<Group title="Examples" description="Snooze ▸ in an item's menu; Custom… opens the dialog, outside the menu." layout="columns" code={`<DropdownMenu>\n <DropdownMenuTrigger render={<Button variant="outline" />}><Icon name="ellipsis" />Actions</DropdownMenuTrigger>\n <DropdownMenuContent align="start">\n <SnoozeMenu onSnooze={setUntil} onCustom={() => setCustom(true)} />\n <DropdownMenuSeparator />\n <DropdownMenuItem disabled={!until} onSelect={() => setUntil(null)}><Icon name="x" size={14} />Unsnooze</DropdownMenuItem>\n </DropdownMenuContent>\n</DropdownMenu>\n<SnoozeDialog open={custom} onOpenChange={setCustom} subject="Fix the build" onSnooze={setUntil} />`}>
|
|
182
|
+
<Sample title="in a menu" description={until ? `Back in ${snoozeWakeLabel(until)}` : 'Not snoozed'}>
|
|
183
|
+
<DropdownMenu>
|
|
184
|
+
<DropdownMenuTrigger render={<Button variant="outline" />}><Icon name="ellipsis" />Actions</DropdownMenuTrigger>
|
|
185
|
+
<DropdownMenuContent align="start">
|
|
186
|
+
<SnoozeMenu onSnooze={setUntil} onCustom={() => setCustom(true)} />
|
|
187
|
+
<DropdownMenuSeparator />
|
|
188
|
+
<DropdownMenuItem disabled={!until} onSelect={() => setUntil(null)}><Icon name="x" size={14} />Unsnooze</DropdownMenuItem>
|
|
189
|
+
</DropdownMenuContent>
|
|
190
|
+
</DropdownMenu>
|
|
191
|
+
<SnoozeDialog open={custom} onOpenChange={setCustom} subject="Fix the build" onSnooze={setUntil} />
|
|
192
|
+
</Sample>
|
|
193
|
+
</Group>
|
|
194
|
+
</>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function TooltipStory() {
|
|
199
|
+
return (
|
|
200
|
+
<>
|
|
201
|
+
<Group title="Sides" description="Hover or focus a button; top by default." code={`{(['top', 'right', 'bottom', 'left'] as const).map((side) => (\n <Tooltip>\n <TooltipTrigger render={<Button variant="outline" size="icon" aria-label={\`Tooltip \${side}\`} />}><Icon name="star" /></TooltipTrigger>\n <TooltipContent side={side}>{\`On the \${side}\`}</TooltipContent>\n </Tooltip>\n))}`}>
|
|
202
|
+
{(['top', 'right', 'bottom', 'left'] as const).map((side) => (
|
|
203
|
+
<Sample key={side} title={side}>
|
|
204
|
+
<Tooltip>
|
|
205
|
+
<TooltipTrigger render={<Button variant="outline" size="icon" aria-label={`Tooltip ${side}`} />}><Icon name="star" /></TooltipTrigger>
|
|
206
|
+
<TooltipContent side={side}>{`On the ${side}`}</TooltipContent>
|
|
207
|
+
</Tooltip>
|
|
208
|
+
</Sample>
|
|
209
|
+
))}
|
|
210
|
+
</Group>
|
|
211
|
+
<Group title="Examples" description="Every icon-only control names itself with a tooltip." code={`<Tip label="Search"><Button variant="ghost" size="icon" aria-label="Search"><Icon name="search" /></Button></Tip>\n<Tip label="Filter"><Button variant="ghost" size="icon" aria-label="Filter"><Icon name="filter" /></Button></Tip>\n<Tip label="Settings"><Button variant="ghost" size="icon" aria-label="Settings"><Icon name="settings" /></Button></Tip>\n<Tip label="Delete"><Button variant="destructive" size="icon" aria-label="Delete"><Icon name="trash" /></Button></Tip>\n<Tip label="New issue (C)"><Button variant="primary" size="icon" aria-label="New issue"><Icon name="plus" /></Button></Tip>`}>
|
|
212
|
+
<Sample title="a toolbar">
|
|
213
|
+
<Tip label="Search"><Button variant="ghost" size="icon" aria-label="Search"><Icon name="search" /></Button></Tip>
|
|
214
|
+
<Tip label="Filter"><Button variant="ghost" size="icon" aria-label="Filter"><Icon name="filter" /></Button></Tip>
|
|
215
|
+
<Tip label="Settings"><Button variant="ghost" size="icon" aria-label="Settings"><Icon name="settings" /></Button></Tip>
|
|
216
|
+
<Tip label="Delete"><Button variant="destructive" size="icon" aria-label="Delete"><Icon name="trash" /></Button></Tip>
|
|
217
|
+
</Sample>
|
|
218
|
+
<Sample title="with a shortcut" description="Longer text wraps">
|
|
219
|
+
<Tip label="New issue (C)"><Button variant="primary" size="icon" aria-label="New issue"><Icon name="plus" /></Button></Tip>
|
|
220
|
+
</Sample>
|
|
221
|
+
</Group>
|
|
222
|
+
</>
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function PopoverStory() {
|
|
227
|
+
return (
|
|
228
|
+
<>
|
|
229
|
+
<Group title="Sides" description="Placed beside its trigger, flipped to fit; Escape or a click outside closes." layout="grid" code={`{(['bottom', 'top', 'right', 'left'] as const).map((side) => (\n <Popover>\n <PopoverTrigger render={<Button variant="outline" />}>Open</PopoverTrigger>\n <PopoverContent side={side}><Section size="sm" title="A panel" description={\`Opened on the \${side}.\`} /></PopoverContent>\n </Popover>\n))}`}>
|
|
230
|
+
{(['bottom', 'top', 'right', 'left'] as const).map((side) => (
|
|
231
|
+
<Sample key={side} title={side}>
|
|
232
|
+
<Popover>
|
|
233
|
+
<PopoverTrigger render={<Button variant="outline" />}>Open</PopoverTrigger>
|
|
234
|
+
<PopoverContent side={side}><Section size="sm" title="A panel" description={`Opened on the ${side}.`} /></PopoverContent>
|
|
235
|
+
</Popover>
|
|
236
|
+
</Sample>
|
|
237
|
+
))}
|
|
238
|
+
</Group>
|
|
239
|
+
<Group title="Examples" description="A small form beside its trigger; focus stays inside." layout="grid" code={`<Popover>\n <PopoverTrigger render={<Button variant="ghost" size="sm" />}><Icon name="filter" size={14} />Filter</PopoverTrigger>\n <PopoverContent align="start">\n <Field><FieldLabel>Name contains</FieldLabel><Input variant="outline" placeholder="Ada…" /></Field>\n </PopoverContent>\n</Popover>`}>
|
|
240
|
+
<Sample title="a filter">
|
|
241
|
+
<Popover>
|
|
242
|
+
<PopoverTrigger render={<Button variant="ghost" size="sm" />}><Icon name="filter" size={14} />Filter</PopoverTrigger>
|
|
243
|
+
<PopoverContent align="start">
|
|
244
|
+
<Field><FieldLabel>Name contains</FieldLabel><Input variant="outline" placeholder="Ada…" /></Field>
|
|
245
|
+
</PopoverContent>
|
|
246
|
+
</Popover>
|
|
247
|
+
</Sample>
|
|
248
|
+
</Group>
|
|
249
|
+
</>
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** The first step: a choice that goes on to the next step, as Bridge's own new project does. */
|
|
254
|
+
function Sources() {
|
|
255
|
+
const wizard = useWizard();
|
|
256
|
+
return (
|
|
257
|
+
<List aria-label="Sources" selectionMode="single" selectedKey="" onSelectionChange={(keys) => { if (keys[0]) wizard.go(keys[0]); }}>
|
|
258
|
+
<ListItem value="empty" textValue="Empty folder" leading={<Icon name="folder-plus" />} description="A new folder, nothing in it yet">Empty folder</ListItem>
|
|
259
|
+
<ListItem value="clone" textValue="Clone a repository" leading={<Icon name="git-branch" />} description="From a git URL">Clone a repository</ListItem>
|
|
260
|
+
</List>
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function WizardStory() {
|
|
265
|
+
const { toast } = useToast();
|
|
266
|
+
const [open, setOpen] = React.useState(false);
|
|
267
|
+
const [name, setName] = React.useState('');
|
|
268
|
+
const [url, setUrl] = React.useState('');
|
|
269
|
+
return (
|
|
270
|
+
<>
|
|
271
|
+
<Group title="Examples" description="One step at a time: a choice goes on, Back returns, the primary button is busy while its submit runs." layout="grid" code={`<Button variant="primary" onClick={() => setOpen(true)}><Icon name="plus" />New project</Button>\n<Wizard open={open} onOpenChange={setOpen} initial="source">\n <WizardStep id="source" title="New project" description="Where does it come from?">\n <Sources />\n </WizardStep>\n <WizardStep id="empty" title="Empty folder" submitLabel="Create" busyLabel="Creating…" canSubmit={name.trim() !== ''}\n onSubmit={() => { toast({ title: \`Project “\${name.trim()}” created\`, variant: 'success' }); setName(''); }}>\n <Field><FieldLabel>Name</FieldLabel><Input variant="outline" placeholder="Website relaunch" value={name} onChange={(event) => setName(event.currentTarget.value)} /></Field>\n </WizardStep>\n <WizardStep id="clone" title="Clone a repository" submitLabel="Clone" busyLabel="Cloning…" canSubmit={url.trim() !== ''}\n onSubmit={() => { throw new Error('This is a story: nothing is cloned. A failure stays in its step.'); }}>\n <Field><FieldLabel>Repository URL</FieldLabel><Input variant="outline" placeholder="https://github.com/…" value={url} onChange={(event) => setUrl(event.currentTarget.value)} /></Field>\n </WizardStep>\n</Wizard>`}>
|
|
272
|
+
<Sample title="a choice, then a form" description="The first choice decides the next step">
|
|
273
|
+
<Button variant="primary" onClick={() => setOpen(true)}><Icon name="plus" />New project</Button>
|
|
274
|
+
<Wizard open={open} onOpenChange={setOpen} initial="source">
|
|
275
|
+
<WizardStep id="source" title="New project" description="Where does it come from?">
|
|
276
|
+
<Sources />
|
|
277
|
+
</WizardStep>
|
|
278
|
+
<WizardStep id="empty" title="Empty folder" submitLabel="Create" busyLabel="Creating…" canSubmit={name.trim() !== ''}
|
|
279
|
+
onSubmit={() => { toast({ title: `Project “${name.trim()}” created`, variant: 'success' }); setName(''); }}>
|
|
280
|
+
<Field><FieldLabel>Name</FieldLabel><Input variant="outline" placeholder="Website relaunch" value={name} onChange={(event) => setName(event.currentTarget.value)} /></Field>
|
|
281
|
+
</WizardStep>
|
|
282
|
+
<WizardStep id="clone" title="Clone a repository" submitLabel="Clone" busyLabel="Cloning…" canSubmit={url.trim() !== ''}
|
|
283
|
+
onSubmit={() => { throw new Error('This is a story: nothing is cloned. A failure stays in its step.'); }}>
|
|
284
|
+
<Field><FieldLabel>Repository URL</FieldLabel><Input variant="outline" placeholder="https://github.com/…" value={url} onChange={(event) => setUrl(event.currentTarget.value)} /></Field>
|
|
285
|
+
</WizardStep>
|
|
286
|
+
</Wizard>
|
|
287
|
+
</Sample>
|
|
288
|
+
</Group>
|
|
289
|
+
</>
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export const overlay = { popover: PopoverStory, dialog: DialogStory, 'dropdown-menu': DropdownMenuStory, 'snooze-menu': SnoozeMenuStory, tooltip: TooltipStory, wizard: WizardStory };
|