@bridgebrew/design-system 0.0.0-stage → 0.1.10-next.79

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.
@@ -0,0 +1,76 @@
1
+ // Interaction: reordering by drag, in a list, a row, and across a board's columns.
2
+ import * as React from 'react';
3
+ import {
4
+ Avatar, Badge, Card, DragHandle, Label, Section, SortableBoard, SortableItem, SortableList, StatusIcon,
5
+ type MoveEvent, type StatusIconStatus,
6
+ } from '@bridge/ui';
7
+ import { Group, Sample } from './parts.tsx';
8
+
9
+ const tasks: Record<string, { title: string; status: StatusIconStatus; owner: string }> = {
10
+ t1: { title: 'Write the release notes', status: 'todo', owner: 'Ada Lindqvist' },
11
+ t2: { title: 'Review the Picker PR', status: 'in-review', owner: 'Bruno Okafor' },
12
+ t3: { title: 'Fix the tooltip flicker', status: 'in-progress', owner: 'Chloé Martin' },
13
+ t4: { title: 'Plan the Q4 offsite', status: 'backlog', owner: 'Dmitri Volkov' },
14
+ t5: { title: 'Ship the storyboard', status: 'done', owner: 'Elif Şahin' },
15
+ t6: { title: 'Migrate contacts v2', status: 'todo', owner: 'Farah Haddad' },
16
+ t7: { title: 'Trigram index benchmark', status: 'in-progress', owner: 'Gustavo Reyes' },
17
+ };
18
+
19
+ const TaskCard = ({ id, handle }: { id: string; handle?: boolean }) => {
20
+ const task = tasks[id]!;
21
+ return (
22
+ <Card variant="outline" size="sm" className="ds-task">
23
+ {handle && <DragHandle aria-label={`Move ${task.title}`} />}
24
+ <StatusIcon status={task.status} />
25
+ <Section size="sm" title={task.title} className="ds-grow-text" />
26
+ <Avatar name={task.owner} size="sm" tint />
27
+ </Card>
28
+ );
29
+ };
30
+
31
+ const columns = [{ id: 'todo', title: 'Todo', status: 'todo' }, { id: 'doing', title: 'In progress', status: 'in-progress' }, { id: 'done', title: 'Done', status: 'done' }] as const;
32
+
33
+ function SortableStory() {
34
+ const [order, setOrder] = React.useState(['t1', 't2', 't3', 't4']);
35
+ const [labels, setLabels] = React.useState(['Design', 'Frontend', 'Research', 'Ops']);
36
+ const [board, setBoard] = React.useState<Record<string, string[]>>({ todo: ['t1', 't6'], doing: ['t3', 't7'], done: ['t5'] });
37
+ const move = ({ itemId, fromContainerId, toContainerId, toIndex }: MoveEvent) => setBoard((current) => {
38
+ const next = { ...current, [fromContainerId]: current[fromContainerId]!.filter((each) => each !== itemId) };
39
+ const target = [...next[toContainerId]!];
40
+ target.splice(Math.min(toIndex, target.length), 0, itemId);
41
+ return { ...next, [toContainerId]: target };
42
+ });
43
+ return (
44
+ <>
45
+ <Group title="Examples" description="Drag by the handle (or the whole item), or focus a handle and use Space, the arrows, Space." layout="stack" code={`<Sample title="a list, by its handles" description={\`Order: \${order.map((id) => tasks[id]!.title.split(' ')[0]).join(' → ')}\`} wide>\n <div className="ds-control-wide">\n <SortableList id="tasks" items={order} onReorder={setOrder} className="ds-sortable">\n {order.map((id) => <SortableItem key={id} id={id}><TaskCard id={id} handle /></SortableItem>)}\n </SortableList>\n </div>\n <SortableList id="labels" orientation="horizontal" items={labels} onReorder={setLabels} className="ds-sortable-row">\n {labels.map((label) => <SortableItem key={label} id={label} dragFullItem><Label variant="feature">{label}</Label></SortableItem>)}\n </SortableList>`}>
46
+ <Sample title="a list, by its handles" description={`Order: ${order.map((id) => tasks[id]!.title.split(' ')[0]).join(' → ')}`} wide>
47
+ <div className="ds-control-wide">
48
+ <SortableList id="tasks" items={order} onReorder={setOrder} className="ds-sortable">
49
+ {order.map((id) => <SortableItem key={id} id={id}><TaskCard id={id} handle /></SortableItem>)}
50
+ </SortableList>
51
+ </div>
52
+ </Sample>
53
+ <Sample title="a row, whole items" description="orientation horizontal, dragFullItem" wide>
54
+ <SortableList id="labels" orientation="horizontal" items={labels} onReorder={setLabels} className="ds-sortable-row">
55
+ {labels.map((label) => <SortableItem key={label} id={label} dragFullItem><Label variant="feature">{label}</Label></SortableItem>)}
56
+ </SortableList>
57
+ </Sample>
58
+ </Group>
59
+ <Group title="Board" description="Move cards within and across columns; the dragged card swings, then settles." layout="fill" code={`<SortableBoard onMove={move} renderOverlay={(id) => <TaskCard id={id} />} className="ds-board">\n {columns.map((column) => (\n <Card key={column.id} variant="ghost" size="sm" className="ds-column">\n <Section size="sm" title={<span className="ds-column-title"><StatusIcon status={column.status} />{column.title}<Badge>{board[column.id]!.length}</Badge></span>}>\n <SortableList id={column.id} items={board[column.id]!} onReorder={(ids) => setBoard((current) => ({ ...current, [column.id]: ids }))} className="ds-sortable">\n {board[column.id]!.map((id) => <SortableItem key={id} id={id} dragFullItem><TaskCard id={id} /></SortableItem>)}\n </SortableList>\n </Section>\n </Card>\n ))}\n</SortableBoard>`}>
60
+ <SortableBoard onMove={move} renderOverlay={(id) => <TaskCard id={id} />} className="ds-board">
61
+ {columns.map((column) => (
62
+ <Card key={column.id} variant="ghost" size="sm" className="ds-column">
63
+ <Section size="sm" title={<span className="ds-column-title"><StatusIcon status={column.status} />{column.title}<Badge>{board[column.id]!.length}</Badge></span>}>
64
+ <SortableList id={column.id} items={board[column.id]!} onReorder={(ids) => setBoard((current) => ({ ...current, [column.id]: ids }))} className="ds-sortable">
65
+ {board[column.id]!.map((id) => <SortableItem key={id} id={id} dragFullItem><TaskCard id={id} /></SortableItem>)}
66
+ </SortableList>
67
+ </Section>
68
+ </Card>
69
+ ))}
70
+ </SortableBoard>
71
+ </Group>
72
+ </>
73
+ );
74
+ }
75
+
76
+ export const interaction = { sortable: SortableStory };
@@ -0,0 +1,510 @@
1
+ // Layout: the page frame, surfaces, split panes, scrolling, and titled sections.
2
+ import * as React from 'react';
3
+ import {
4
+ AppShell, Avatar, Badge, Breadcrumb, Button, Card, CardHeader, Cluster, Detail, DetailHeader, DetailHint, DetailSubtitle,
5
+ DetailTitle, EditableField, Kbd, Pane, PaneBody, PaneFooter, PaneHeader, PaneNote, MultiPane, SinglePane, MainContent, AddressBookTemplate, MailTemplate, Icon, Label, List, ListItem, ResizableHandle,
6
+ ResizablePanel, ResizablePanelGroup, ScrollArea, Section, Sidebar, SidebarContent, SidebarItem, SidebarSection,
7
+ Input, Properties, PropertyRow, StatusIcon,
8
+ SplitHandle, SplitPane, SplitView,
9
+ } from '@bridge/ui';
10
+ import { Tip } from './action.tsx';
11
+ import { Devices, FullscreenLink, Group, PhoneFlow, PhonePreview, Sample, Screen, Wide, people } from './parts.tsx';
12
+
13
+ function AppShellStory() {
14
+ const [page, setPage] = React.useState('Issues');
15
+ return (
16
+ <>
17
+ <Group title="Examples" description="A global header over a sidebar and a scrolling main area (Bridge's own frame)." layout="fill">
18
+ <Wide><div className="ds-shell-frame">
19
+ <AppShell
20
+ className="ds-shell"
21
+ header={(
22
+ <div className="ds-shell-header">
23
+ <Avatar name="Northwind" size="lg" shape="square" tint />
24
+ <Breadcrumb items={[{ label: 'Northwind', onClick: () => setPage('Issues') }, { label: page }]} />
25
+ <span className="ds-grow-text" />
26
+ <Tip label="Search"><Button variant="ghost" size="icon-sm" aria-label="Search"><Icon name="search" size={14} /></Button></Tip>
27
+ <Avatar name="Ada Lindqvist" size="lg" tint />
28
+ </div>
29
+ )}
30
+ sidebar={(
31
+ <Sidebar aria-label="Shell navigation" className="ds-shell-sidebar">
32
+ <SidebarContent>
33
+ {['Inbox', 'Issues', 'Projects'].map((each) => (
34
+ <SidebarItem key={each} active={page === each} icon={<Icon name={each === 'Inbox' ? 'inbox' : each === 'Issues' ? 'list' : 'folder'} />} onClick={() => setPage(each)}>{each}</SidebarItem>
35
+ ))}
36
+ <SidebarSection>Teams</SidebarSection>
37
+ <SidebarItem teamDot="oklch(65% 0.15 250)">Design</SidebarItem>
38
+ <SidebarItem teamDot="oklch(70% 0.15 150)">Engineering</SidebarItem>
39
+ </SidebarContent>
40
+ </Sidebar>
41
+ )}
42
+ >
43
+ <div className="ds-shell-main">
44
+ <Section title={page} description="The main area scrolls on its own; the header and the sidebar stay.">
45
+ <List aria-label={page} className="ds-list">
46
+ {people.slice(0, 12).map((name, index) => (
47
+ <ListItem key={name} leading={<StatusIcon status={index % 3 === 0 ? 'done' : index % 3 === 1 ? 'in-progress' : 'todo'} />} trailing={<Avatar name={name} size="sm" tint />}>{`BRG-${50 - index} · Follow up with ${name.split(' ')[0]}`}</ListItem>
48
+ ))}
49
+ </List>
50
+ </Section>
51
+ </div>
52
+ </AppShell>
53
+ </div></Wide>
54
+ </Group>
55
+ </>
56
+ );
57
+ }
58
+
59
+ function CardStory() {
60
+ const [picked, setPicked] = React.useState<string>();
61
+ const content = (title: string) => <Section size="sm" title={title} description="Grouped content with the kit's padding and radius." />;
62
+ return (
63
+ <>
64
+ <Group title="Variants" layout="grid" code={`<Card variant="outline">{content('Sprint progress')}</Card>\n<Card variant="elevated">{content('Sprint progress')}</Card>\n<Card variant="ghost">{content('Sprint progress')}</Card>`}>
65
+ <Sample title="outline" description="Border, the default"><Card variant="outline">{content('Sprint progress')}</Card></Sample>
66
+ <Sample title="elevated" description="Shadow, for floating cards"><Card variant="elevated">{content('Sprint progress')}</Card></Sample>
67
+ <Sample title="ghost" description="No chrome"><Card variant="ghost">{content('Sprint progress')}</Card></Sample>
68
+ </Group>
69
+ <Group title="Sizes" description="Padding of 8, 12 or 16px." layout="grid" code={`{(['sm', 'default', 'lg'] as const).map((size) => <Sample key={size} title={size}><Card size={size}>{content(\`Size \${size}\`)}</Card></Sample>)}`}>
70
+ {(['sm', 'default', 'lg'] as const).map((size) => <Sample key={size} title={size}><Card size={size}>{content(`Size ${size}`)}</Card></Sample>)}
71
+ </Group>
72
+ <Group title="Examples" description="Interactive cards: hover, focus, Enter or a click picks." layout="grid" code={`{[{ id: 'BRG-41', title: 'Storyboard of the kit', label: 'feature', status: 'in-progress' }, { id: 'BRG-38', title: 'Picker keyboard digits', label: 'improvement', status: 'in-review' }, { id: 'BRG-36', title: 'Tooltip flicker on scroll', label: 'bug', status: 'todo' }].map((issue) => (\n <Card\n interactive\n role="button"\n tabIndex={0}\n aria-pressed={picked === issue.id}\n onClick={() => setPicked(issue.id)}\n onKeyDown={(event) => { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); setPicked(issue.id); } }}\n >\n <CardHeader>\n <Badge>{issue.id}</Badge>\n <StatusIcon status={issue.status as 'todo'} />\n </CardHeader>\n <Section size="sm" title={issue.title} />\n <CardHeader className="ds-card-foot">\n <Label variant={issue.label as 'bug'}>{issue.label}</Label>\n <Avatar name="Ada Lindqvist" size="sm" tint />\n </CardHeader>\n </Card>\n))}`}>
73
+ {[{ id: 'BRG-41', title: 'Storyboard of the kit', label: 'feature', status: 'in-progress' }, { id: 'BRG-38', title: 'Picker keyboard digits', label: 'improvement', status: 'in-review' }, { id: 'BRG-36', title: 'Tooltip flicker on scroll', label: 'bug', status: 'todo' }].map((issue) => (
74
+ <Sample key={issue.id} title={picked === issue.id ? 'picked' : 'interactive'}>
75
+ <Card
76
+ interactive
77
+ role="button"
78
+ tabIndex={0}
79
+ aria-pressed={picked === issue.id}
80
+ onClick={() => setPicked(issue.id)}
81
+ onKeyDown={(event) => { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); setPicked(issue.id); } }}
82
+ >
83
+ <CardHeader>
84
+ <Badge>{issue.id}</Badge>
85
+ <StatusIcon status={issue.status as 'todo'} />
86
+ </CardHeader>
87
+ <Section size="sm" title={issue.title} />
88
+ <CardHeader className="ds-card-foot">
89
+ <Label variant={issue.label as 'bug'}>{issue.label}</Label>
90
+ <Avatar name="Ada Lindqvist" size="sm" tint />
91
+ </CardHeader>
92
+ </Card>
93
+ </Sample>
94
+ ))}
95
+ </Group>
96
+ </>
97
+ );
98
+ }
99
+
100
+ function ResizableStory() {
101
+ return (
102
+ <>
103
+ <Group title="Orientations" description="Drag a handle, or focus it and use the arrow keys." layout="columns" code={`<Card variant="outline" className="ds-split">\n <ResizablePanelGroup orientation="horizontal">\n <ResizablePanel defaultSize="40%" minSize="20%"><div className="ds-pane-pad"><Section size="sm" title="List" description="40% by default" /></div></ResizablePanel>\n <ResizableHandle />\n <ResizablePanel minSize="30%"><div className="ds-pane-pad"><Section size="sm" title="Detail" description="Takes the rest" /></div></ResizablePanel>\n </ResizablePanelGroup>\n</Card>\n<Card variant="outline" className="ds-split">\n <ResizablePanelGroup orientation="vertical">\n <ResizablePanel defaultSize="55%" minSize="20%"><div className="ds-pane-pad"><Section size="sm" title="Editor" /></div></ResizablePanel>\n <ResizableHandle withHandle />\n <ResizablePanel minSize="20%"><div className="ds-pane-pad"><Section size="sm" title="Terminal" /></div></ResizablePanel>\n </ResizablePanelGroup>\n</Card>`}>
104
+ <Sample title="horizontal">
105
+ <Card variant="outline" className="ds-split">
106
+ <ResizablePanelGroup orientation="horizontal">
107
+ <ResizablePanel defaultSize="40%" minSize="20%"><div className="ds-pane-pad"><Section size="sm" title="List" description="40% by default" /></div></ResizablePanel>
108
+ <ResizableHandle />
109
+ <ResizablePanel minSize="30%"><div className="ds-pane-pad"><Section size="sm" title="Detail" description="Takes the rest" /></div></ResizablePanel>
110
+ </ResizablePanelGroup>
111
+ </Card>
112
+ </Sample>
113
+ <Sample title="vertical, with a grip" description="withHandle shows a grip">
114
+ <Card variant="outline" className="ds-split">
115
+ <ResizablePanelGroup orientation="vertical">
116
+ <ResizablePanel defaultSize="55%" minSize="20%"><div className="ds-pane-pad"><Section size="sm" title="Editor" /></div></ResizablePanel>
117
+ <ResizableHandle withHandle />
118
+ <ResizablePanel minSize="20%"><div className="ds-pane-pad"><Section size="sm" title="Terminal" /></div></ResizablePanel>
119
+ </ResizablePanelGroup>
120
+ </Card>
121
+ </Sample>
122
+ </Group>
123
+ <Group title="Examples" description="Three panes with grips, as a mail client." layout="fill" code={`<Card variant="outline" className="ds-split ds-split-tall">\n <ResizablePanelGroup orientation="horizontal">\n <ResizablePanel defaultSize="22%" minSize="15%"><div className="ds-pane-pad"><Section size="sm" title="Folders" description="Inbox, Sent, Archive" /></div></ResizablePanel>\n <ResizableHandle withHandle />\n <ResizablePanel defaultSize="33%" minSize="20%"><div className="ds-pane-pad"><Section size="sm" title="Messages" description="12 unread" /></div></ResizablePanel>\n <ResizableHandle withHandle />\n <ResizablePanel minSize="25%"><div className="ds-pane-pad"><Section size="sm" title="Reading pane" description="The selected message" /></div></ResizablePanel>\n </ResizablePanelGroup>\n</Card>`}>
124
+ <Card variant="outline" className="ds-split ds-split-tall">
125
+ <ResizablePanelGroup orientation="horizontal">
126
+ <ResizablePanel defaultSize="22%" minSize="15%"><div className="ds-pane-pad"><Section size="sm" title="Folders" description="Inbox, Sent, Archive" /></div></ResizablePanel>
127
+ <ResizableHandle withHandle />
128
+ <ResizablePanel defaultSize="33%" minSize="20%"><div className="ds-pane-pad"><Section size="sm" title="Messages" description="12 unread" /></div></ResizablePanel>
129
+ <ResizableHandle withHandle />
130
+ <ResizablePanel minSize="25%"><div className="ds-pane-pad"><Section size="sm" title="Reading pane" description="The selected message" /></div></ResizablePanel>
131
+ </ResizablePanelGroup>
132
+ </Card>
133
+ </Group>
134
+ </>
135
+ );
136
+ }
137
+
138
+ function ScrollAreaStory() {
139
+ return (
140
+ <Group title="Orientations" description="The thin scrollbar shows while hovering or scrolling." layout="columns" code={`<Card variant="outline" className="ds-scroll-box">\n <ScrollArea className="ds-fill">\n <List aria-label="People">{people.map((name) => <ListItem key={name} size="sm" leading={<Avatar name={name} size="sm" tint />}>{name}</ListItem>)}</List>\n </ScrollArea>\n</Card>\n<Card variant="outline" className="ds-scroll-box ds-scroll-short">\n <ScrollArea orientation="horizontal" className="ds-fill">\n <div className="ds-scroll-row">{people.map((name) => <Card key={name} variant="outline" size="sm" className="ds-scroll-chip"><Avatar name={name} size="lg" tint /><Section size="sm" title={name.split(' ')[0]!} /></Card>)}</div>\n </ScrollArea>\n</Card>\n<Card variant="outline" className="ds-scroll-box">\n <ScrollArea orientation="both" className="ds-fill">\n <div className="ds-scroll-wide">\n {people.slice(0, 16).map((name) => <Section key={name} size="sm" title={\`\${name} — \${name.toLowerCase().replace(/\\s+/g, '.')}@northwind.example — Lyon, France\`} />)}\n </div>\n </ScrollArea>\n</Card>`}>
141
+ <Sample title="vertical">
142
+ <Card variant="outline" className="ds-scroll-box">
143
+ <ScrollArea className="ds-fill">
144
+ <List aria-label="People">{people.map((name) => <ListItem key={name} size="sm" leading={<Avatar name={name} size="sm" tint />}>{name}</ListItem>)}</List>
145
+ </ScrollArea>
146
+ </Card>
147
+ </Sample>
148
+ <Sample title="horizontal">
149
+ <Card variant="outline" className="ds-scroll-box ds-scroll-short">
150
+ <ScrollArea orientation="horizontal" className="ds-fill">
151
+ <div className="ds-scroll-row">{people.map((name) => <Card key={name} variant="outline" size="sm" className="ds-scroll-chip"><Avatar name={name} size="lg" tint /><Section size="sm" title={name.split(' ')[0]!} /></Card>)}</div>
152
+ </ScrollArea>
153
+ </Card>
154
+ </Sample>
155
+ <Sample title="both">
156
+ <Card variant="outline" className="ds-scroll-box">
157
+ <ScrollArea orientation="both" className="ds-fill">
158
+ <div className="ds-scroll-wide">
159
+ {people.slice(0, 16).map((name) => <Section key={name} size="sm" title={`${name} — ${name.toLowerCase().replace(/\s+/g, '.')}@northwind.example — Lyon, France`} />)}
160
+ </div>
161
+ </ScrollArea>
162
+ </Card>
163
+ </Sample>
164
+ </Group>
165
+ );
166
+ }
167
+
168
+ function SectionStory() {
169
+ return (
170
+ <>
171
+ <Group title="Sizes" description="lg titles a page (h2), default a section (h3), sm a caption (h4)." layout="stack" code={`<Section size="lg" title="Organizations" description="The workspace's companies, each with its people." />\n<Section title="Contact details" description="Emails, phones and the address." />\n<Section size="sm" title="--bg-surface" description="oklch(1 0 0)" />`}>
172
+ <Sample title="lg" wide><Section size="lg" title="Organizations" description="The workspace's companies, each with its people." /></Sample>
173
+ <Sample title="default" wide><Section title="Contact details" description="Emails, phones and the address." /></Sample>
174
+ <Sample title="sm" wide><Section size="sm" title="--bg-surface" description="oklch(1 0 0)" /></Sample>
175
+ </Group>
176
+ <Group title="Options" layout="stack" code={`<Section title="Members" />\n<div className="ds-control-wide"><Section title="Members" description="4 people" actions={<><Button variant="ghost" size="sm"><Icon name="filter" size={14} />Filter</Button><Button variant="outline" size="sm"><Icon name="user-plus" size={14} />Invite</Button></>} /></div>\n<div className="ds-control-wide"><Section title="A section title far too long to fit on one line of this narrow column" description="The description wraps instead, across as many lines as it needs to say what it says." /></div>`}>
177
+ <Sample title="title only" wide><Section title="Members" /></Sample>
178
+ <Sample title="with actions" description="At the header's end" wide>
179
+ <div className="ds-control-wide"><Section title="Members" description="4 people" actions={<><Button variant="ghost" size="sm"><Icon name="filter" size={14} />Filter</Button><Button variant="outline" size="sm"><Icon name="user-plus" size={14} />Invite</Button></>} /></div>
180
+ </Sample>
181
+ <Sample title="long title" description="Truncates on one line" wide>
182
+ <div className="ds-control-wide"><Section title="A section title far too long to fit on one line of this narrow column" description="The description wraps instead, across as many lines as it needs to say what it says." /></div>
183
+ </Sample>
184
+ </Group>
185
+ </>
186
+ );
187
+ }
188
+
189
+ function ClusterStory() {
190
+ return (
191
+ <>
192
+ <Group title="Examples" layout="stack" code={`<Cluster><Button variant="outline" size="sm">Owner</Button><Badge>3</Badge></Cluster>\n<div style={{ width: 220 }}><Cluster>{people.slice(0, 6).map((name) => <Label key={name}>{name.split(' ')[0]}</Label>)}</Cluster></div>`}>
193
+ <Sample title="a control and its badge" wide><Cluster><Button variant="outline" size="sm">Owner</Button><Badge>3</Badge></Cluster></Sample>
194
+ <Sample title="wraps when it must" description="8px apart" wide>
195
+ <div style={{ width: 220 }}><Cluster>{people.slice(0, 6).map((name) => <Label key={name}>{name.split(' ')[0]}</Label>)}</Cluster></div>
196
+ </Sample>
197
+ </Group>
198
+ </>
199
+ );
200
+ }
201
+
202
+ function DetailStory() {
203
+ const [name, setName] = React.useState('Ada Lindqvist');
204
+ return (
205
+ <>
206
+ <Group title="Examples" description="A record's page: it scrolls in its pane, the header over its rows." layout="fill" code={`<div style={{ height: 380 }}>\n <Detail aria-label="Ada Lindqvist">\n <DetailHeader>\n <Avatar name="Ada Lindqvist" size="3xl" tint />\n <DetailTitle>\n <EditableField variant="title" aria-label="Name" value={name} onChange={setName} />\n <DetailSubtitle>2 organizations</DetailSubtitle>\n </DetailTitle>\n <Button variant="ghost" size="icon-sm" aria-label="More"><Icon name="ellipsis" size={14} /></Button>\n </DetailHeader>\n <Properties>\n <PropertyRow label="Email">ada@northwind.example</PropertyRow>\n <PropertyRow label="Phone">+33 1 23 45 67 89</PropertyRow>\n <PropertyRow label="Company">Northwind</PropertyRow>\n </Properties>\n <DetailHint>Edit any value in place: <Kbd>Enter</Kbd> saves, <Kbd>Esc</Kbd> reverts.</DetailHint>\n </Detail>\n</div>`}>
207
+ <div style={{ height: 380 }}>
208
+ <Detail aria-label="Ada Lindqvist">
209
+ <DetailHeader>
210
+ <Avatar name="Ada Lindqvist" size="3xl" tint />
211
+ <DetailTitle>
212
+ <EditableField variant="title" aria-label="Name" value={name} onChange={setName} />
213
+ <DetailSubtitle>2 organizations</DetailSubtitle>
214
+ </DetailTitle>
215
+ <Button variant="ghost" size="icon-sm" aria-label="More"><Icon name="ellipsis" size={14} /></Button>
216
+ </DetailHeader>
217
+ <Properties>
218
+ <PropertyRow label="Email">ada@northwind.example</PropertyRow>
219
+ <PropertyRow label="Phone">+33 1 23 45 67 89</PropertyRow>
220
+ <PropertyRow label="Company">Northwind</PropertyRow>
221
+ </Properties>
222
+ <DetailHint>Edit any value in place: <Kbd>Enter</Kbd> saves, <Kbd>Esc</Kbd> reverts.</DetailHint>
223
+ </Detail>
224
+ </div>
225
+ </Group>
226
+ </>
227
+ );
228
+ }
229
+
230
+ function PaneStory() {
231
+ return (
232
+ <>
233
+ <Group title="Examples" description="A list's column: toolbar, scrolling body, footer; a note closes the list." layout="fill" code={`<div style={{ height: 340, maxWidth: 360 }}>\n <Pane aria-label="Contacts">\n <PaneHeader>\n <Input aria-label="Search" placeholder="Search…" variant="outline" />\n <Button variant="ghost" size="icon-sm" aria-label="New contact"><Icon name="plus" size={14} /></Button>\n </PaneHeader>\n <PaneBody>\n <List aria-label="Contacts">\n {people.slice(0, 14).map((name) => <ListItem key={name} leading={<Avatar name={name} size="sm" tint />}>{name}</ListItem>)}\n </List>\n <PaneNote>Loading…</PaneNote>\n </PaneBody>\n <PaneFooter><span><strong>14</strong> contacts</span></PaneFooter>\n </Pane>\n</div>`}>
234
+ <div style={{ height: 340, maxWidth: 360 }}>
235
+ <Pane aria-label="Contacts">
236
+ <PaneHeader>
237
+ <Input aria-label="Search" placeholder="Search…" variant="outline" />
238
+ <Button variant="ghost" size="icon-sm" aria-label="New contact"><Icon name="plus" size={14} /></Button>
239
+ </PaneHeader>
240
+ <PaneBody>
241
+ <List aria-label="Contacts">
242
+ {people.slice(0, 14).map((name) => <ListItem key={name} leading={<Avatar name={name} size="sm" tint />}>{name}</ListItem>)}
243
+ </List>
244
+ <PaneNote>Loading…</PaneNote>
245
+ </PaneBody>
246
+ <PaneFooter><span><strong>14</strong> contacts</span></PaneFooter>
247
+ </Pane>
248
+ </div>
249
+ </Group>
250
+ </>
251
+ );
252
+ }
253
+
254
+ /** A pane's shape: a grey block named after it (a layout shows nothing but its shape). */
255
+ const block = (name: string) => <div className="ds-block">{name}</div>;
256
+
257
+ function MultiPaneStory() {
258
+ const nav = block('nav'), main = block('main'), aside = block('aside');
259
+ const shapes: [string, string, { nav?: React.ReactNode; aside?: React.ReactNode }][] = [
260
+ ['nav + main', 'A list beside its record (Contacts). Under 640px wide, nav alone.', { nav }],
261
+ ['nav + main + aside', '25 % / 50 % / 25 %, each edge dragged. Under 800px wide the aside leaves; under 640px, nav alone.', { nav, aside }],
262
+ ['main + aside', 'A table beside the row it opened (Orders). Nothing open: main alone.', { aside }],
263
+ ];
264
+ const codeOf = (panes: { nav?: React.ReactNode; aside?: React.ReactNode }) => [
265
+ '<MultiPane',
266
+ ...(panes.nav ? [' nav={<Pane aria-label="People">…</Pane>}'] : []),
267
+ ' main={<Detail aria-label={person.name}>…</Detail>}',
268
+ ...(panes.aside ? [' aside={<Pane aria-label="Properties">…</Pane>}'] : []),
269
+ '/>',
270
+ ].join('\n');
271
+ return (
272
+ <Devices>
273
+ {(device) => device === 'desktop' ? (
274
+ <>
275
+ {shapes.map(([title, description, panes]) => <Group key={title} title={title} description={description} layout="bleed" code={codeOf(panes)}><Screen device="desktop"><MultiPane {...panes} main={main} /></Screen></Group>)}
276
+ </>
277
+ ) : (
278
+ shapes.map(([title, , panes]) => {
279
+ const order = (['nav', 'main', 'aside'] as const).filter((id) => id === 'main' || panes[id] !== undefined);
280
+ return (
281
+ <Group key={title} title={title} description="One pane at a time: a tap pushes the next, Back returns." layout="bleed" code={codeOf(panes)}>
282
+ <PhoneFlow steps={order.map((id, i) => ({ label: i === 0 ? id : `${id}, Back returns`, screen: <MultiPane mode={id} {...panes} main={main} /> }))} />
283
+ </Group>
284
+ );
285
+ })
286
+ )}
287
+ </Devices>
288
+ );
289
+ }
290
+
291
+ function MainContentStory() {
292
+ const content = <div className="ds-block" style={{ height: 240, margin: 0 }}>content</div>;
293
+ const widths = [
294
+ ['read', 'The default: a centred column, 720px at most. A record, settings, a document.'],
295
+ ['wide', 'A wider column, 1040px at most: a page of samples, settings in two columns.'],
296
+ ['full', 'The whole width: a large table, a dashboard.'],
297
+ ] as const;
298
+ return (
299
+ <Devices>
300
+ {(device) => (
301
+ <>
302
+ {widths.map(([width, description]) => (
303
+ <Group key={width} title={width} description={description} layout="bleed" code={`<MainContent${width === 'read' ? '' : ` width="${width}"`}>\n …\n</MainContent>`}>
304
+ <Screen device={device}><MainContent width={width}>{content}</MainContent></Screen>
305
+ </Group>
306
+ ))}
307
+ </>
308
+ )}
309
+ </Devices>
310
+ );
311
+ }
312
+
313
+ function SinglePaneStory() {
314
+ const content = <div className="ds-block" style={{ height: 1200, margin: 0 }}>content</div>;
315
+ return (
316
+ <Devices>
317
+ {(device) => (
318
+ <>
319
+ <Group title="read" description="Centred, 720px at most: settings, a record, a document. scroll: it scrolls in the pane." layout="bleed" code={'<SinglePane scroll>\n <Section size="lg" title="General" />\n …\n</SinglePane>'}><Screen device={device}><SinglePane scroll>{content}</SinglePane></Screen></Group>
320
+ <Group title="full" description="The whole width: a large table, a dashboard." layout="bleed" code={'<SinglePane width="full">\n <Table>…</Table>\n</SinglePane>'}><Screen device={device}><SinglePane scroll width="full">{content}</SinglePane></Screen></Group>
321
+ </>
322
+ )}
323
+ </Devices>
324
+ );
325
+ }
326
+
327
+ /** How Address book is put together: the kit's parts, its data made up (packages/ui/…/address-book-template.tsx). */
328
+ const addressBookCode = `<MultiPane
329
+ defaultNavSize="320px"
330
+ nav={
331
+ <Pane aria-label="People">
332
+ <PaneHeader>
333
+ <Input variant="outline" type="search" placeholder="Search" value={query} onChange={search} />
334
+ </PaneHeader>
335
+ <PaneBody>
336
+ <List variant="records" aria-label="People" openKey={openId} onOpen={open}>
337
+ {shown.map((person) => (
338
+ <ListItem
339
+ key={person.id}
340
+ value={person.id}
341
+ leading={<Avatar name={person.name} size="sm" tint />}
342
+ trailing={<span className="text-xs text-muted">{person.company}</span>}
343
+ >
344
+ {person.name}
345
+ </ListItem>
346
+ ))}
347
+ </List>
348
+ </PaneBody>
349
+ <PaneFooter><span><strong>{shown.length}</strong> people</span></PaneFooter>
350
+ </Pane>
351
+ }
352
+ main={
353
+ <Detail aria-label={person.name}>
354
+ <DetailHeader>
355
+ <Avatar name={person.name} size="3xl" tint />
356
+ <DetailTitle><Section size="lg" title={person.name} description={person.company} /></DetailTitle>
357
+ </DetailHeader>
358
+ <Properties>
359
+ <PropertyRow label="Email">{person.email}</PropertyRow>
360
+ <PropertyRow label="Phone">{person.phone}</PropertyRow>
361
+ <PropertyRow label="Company">{person.company}</PropertyRow>
362
+ </Properties>
363
+ </Detail>
364
+ }
365
+ />`;
366
+
367
+ function AddressBookTemplateStory() {
368
+ return (
369
+ <Devices>
370
+ {(device) => (
371
+ device === 'desktop'
372
+ ? <Group title="screen" actions={<FullscreenLink template="address-book-template" />} description="Sample people, nothing behind them: a row opens its record, the search filters the list." layout="bleed" code={addressBookCode}><Screen device="desktop"><AddressBookTemplate /></Screen></Group>
373
+ : <Group title="phone" description="In Bridge's phone shell: the list alone; a row opens its record, Back returns; the text size is the phone's." layout="bleed" code={addressBookCode}><PhonePreview title="Address book on a phone" template="address-book-template" /></Group>
374
+ )}
375
+ </Devices>
376
+ );
377
+ }
378
+
379
+ /** How Mail is put together: the kit's parts, its data made up (packages/ui/…/mail-template.tsx). */
380
+ const mailCode = `<MultiPane
381
+ defaultNavSize="360px"
382
+ nav={
383
+ <Pane aria-label="Inbox" className="relative">
384
+ <PaneHeader>
385
+ <Input variant="outline" type="search" placeholder="Search mail" value={query} onChange={search} />
386
+ </PaneHeader>
387
+ <PaneBody>
388
+ {shown.length === 0 ? (
389
+ <EmptyState fill title={'No mail matches “' + query + '”'}>
390
+ <Button variant="outline" size="sm" onClick={() => setQuery('')}>Clear search</Button>
391
+ </EmptyState>
392
+ ) : (
393
+ <List variant="records" aria-label="Inbox" openKey={openId} onOpen={open} openFollowsCursor={!narrow} selectedKeys={selected} onSelectionChange={setSelected}>
394
+ {groups.map(([day, mails]) => ( // Object.groupBy(shown, (mail) => groupOf(mail.when)): Today, Yesterday…
395
+ <ListGroup key={day} label={day} variant="records">
396
+ {mails.map((mail) => (
397
+ <ListItem key={mail.id} value={mail.id} size="auto" marker={flagged(mail) ? <Icon name="flag" size={12} className="fill-current text-destructive" /> : unread(mail) ? <span className="size-2 rounded-full bg-accent" /> : undefined}>
398
+ <div className="flex min-w-0 flex-1 flex-col gap-0.5">
399
+ <div className="flex items-baseline gap-2">
400
+ <span className={cn('min-w-0 flex-1 truncate', unread(mail) && 'font-semibold')}>{mail.from}</span>
401
+ <span className={cn('shrink-0 text-xs', unread(mail) ? 'font-semibold text-foreground' : 'text-muted')}>{mail.when}</span>
402
+ </div>
403
+ <span className={cn('truncate', unread(mail) && 'font-semibold')}>{mail.subject}</span>
404
+ <span className="truncate text-xs text-muted">{mail.preview}</span>
405
+ </div>
406
+ </ListItem>
407
+ ))}
408
+ </ListGroup>
409
+ ))}
410
+ </List>
411
+ )}
412
+ </PaneBody>
413
+ <BulkBar floating count={selected.length} onClear={() => setSelected([])}>
414
+ <BulkAction onClick={() => archive(selected)}>Archive</BulkAction>
415
+ <BulkAction onClick={() => archive(selected, 'spam')}>Spam</BulkAction>
416
+ <BulkAction onClick={() => mark(selected, true)}>Mark read</BulkAction>
417
+ <BulkAction onClick={() => mark(selected, false)}>Mark unread</BulkAction>
418
+ <BulkAction onClick={() => flag(selected, true)}>Flag</BulkAction>
419
+ </BulkBar>
420
+ <PaneFooter><span><strong>{shown.length}</strong> mails, <strong>{unreadCount}</strong> unread</span></PaneFooter>
421
+ </Pane>
422
+ }
423
+ main={
424
+ <div className="h-full bg-hover">
425
+ <Detail aria-label={mail.subject}>
426
+ <Card variant="outline" size="lg" className="flex flex-col gap-5">
427
+ <DetailHeader>
428
+ <DetailTitle><Section size="lg" title={mail.subject} /></DetailTitle>
429
+ <div className="ml-auto flex shrink-0 gap-1">
430
+ <Tip label="Archive"><Button variant="ghost" size="icon" aria-label="Archive" onClick={() => archive([mail.id])}><Icon name="archive" size={16} /></Button></Tip>
431
+ <Tip label={flagged(mail) ? 'Unflag' : 'Flag'}><Button variant="ghost" size="icon" aria-label={flagged(mail) ? 'Unflag' : 'Flag'} aria-pressed={flagged(mail)} onClick={() => flag([mail.id], !flagged(mail))}><Icon name="flag" size={16} className={flagged(mail) ? 'fill-current text-destructive' : undefined} /></Button></Tip>
432
+ <Tip label={unread(mail) ? 'Mark read' : 'Mark unread'}><Button variant="ghost" size="icon" aria-label={unread(mail) ? 'Mark read' : 'Mark unread'} onClick={() => mark([mail.id], unread(mail))}><Icon name={unread(mail) ? 'mail' : 'mail-open'} size={16} /></Button></Tip>
433
+ </div>
434
+ </DetailHeader>
435
+ <div className="flex min-w-0 flex-col gap-0.5">
436
+ <div className="flex items-baseline gap-2">
437
+ <span className="min-w-0 flex-1 truncate text-sm font-semibold">{mail.from}</span>
438
+ <time title={mail.date} className="shrink-0 text-xs text-muted">{shortDate(mail.date)}</time>
439
+ </div>
440
+ <span className="truncate text-xs text-muted">{mail.email} · to You</span>
441
+ </div>
442
+ <div className="flex flex-col gap-3 text-[14px] leading-relaxed">
443
+ {mail.body.map((paragraph, i) => <p key={i} className="m-0 whitespace-pre-line">{paragraph}</p>)}
444
+ </div>
445
+ <ReplyBox key={mail.id} to={mail.from} onSend={() => toast({ title: 'Reply sent', variant: 'success' })} />
446
+ </Card>
447
+ </Detail>
448
+ </div>
449
+ }
450
+ />`;
451
+
452
+ function MailTemplateStory() {
453
+ return (
454
+ <Devices>
455
+ {(device) => (
456
+ device === 'desktop'
457
+ ? <Group title="screen" actions={<FullscreenLink template="mail-template" />} description="Sample mails, nothing behind them: a row (or J, ↓) opens its mail and marks it read, the search filters the inbox; an unread mail has a dot, an important one a flag, its checkbox on hover; Archive (with Undo), Flag, Mark unread, the bar over the rows selected and Reply change the sample only." layout="bleed" code={mailCode}><Screen device="desktop"><MailTemplate /></Screen></Group>
458
+ : <Group title="phone" description="In Bridge's phone shell: the inbox alone; a row opens its mail, Back returns; the text size is the phone's." layout="bleed" code={mailCode}><PhonePreview title="Mail on a phone" template="mail-template" /></Group>
459
+ )}
460
+ </Devices>
461
+ );
462
+ }
463
+
464
+ function SplitViewStory() {
465
+ const pane = (title: string, description?: string) => <div className="ds-pane-pad"><Section size="sm" title={title} description={description} /></div>;
466
+ return (
467
+ <>
468
+ <Group title="Orientations" description="Place a SplitHandle between two panes; drag it, or focus it and use the arrow keys." layout="columns" code={`<Card variant="outline" className="ds-split">\n <SplitView>\n <SplitPane defaultSize="35%" minSize="20%">{pane('Tools', '35% by default')}</SplitPane>\n <SplitHandle withHandle />\n <SplitPane>{pane('Canvas', 'Takes the rest')}</SplitPane>\n </SplitView>\n</Card>\n<Card variant="outline" className="ds-split">\n <SplitView orientation="vertical">\n <SplitPane minSize="20%">{pane('Canvas')}</SplitPane>\n <SplitHandle />\n <SplitPane defaultSize="40%" minSize="20%">{pane('Console')}</SplitPane>\n </SplitView>\n</Card>`}>
469
+ <Sample title="horizontal">
470
+ <Card variant="outline" className="ds-split">
471
+ <SplitView>
472
+ <SplitPane defaultSize="35%" minSize="20%">{pane('Tools', '35% by default')}</SplitPane>
473
+ <SplitHandle withHandle />
474
+ <SplitPane>{pane('Canvas', 'Takes the rest')}</SplitPane>
475
+ </SplitView>
476
+ </Card>
477
+ </Sample>
478
+ <Sample title="vertical">
479
+ <Card variant="outline" className="ds-split">
480
+ <SplitView orientation="vertical">
481
+ <SplitPane minSize="20%">{pane('Canvas')}</SplitPane>
482
+ <SplitHandle />
483
+ <SplitPane defaultSize="40%" minSize="20%">{pane('Console')}</SplitPane>
484
+ </SplitView>
485
+ </Card>
486
+ </Sample>
487
+ </Group>
488
+ <Group title="Examples" description="A fixed grid (resizable={false}): an editor over its console, beside a preview." layout="fill" code={`<Card variant="outline" className="ds-split ds-split-tall">\n <SplitView resizable={false}>\n <SplitPane defaultSize="50%">\n <SplitView orientation="vertical" resizable={false}>\n <SplitPane>{pane('Editor')}</SplitPane>\n <SplitHandle />\n <SplitPane defaultSize="100px">{pane('Console')}</SplitPane>\n </SplitView>\n </SplitPane>\n <SplitHandle />\n <SplitPane>{pane('Preview')}</SplitPane>\n </SplitView>\n</Card>`}>
489
+ <Card variant="outline" className="ds-split ds-split-tall">
490
+ <SplitView resizable={false}>
491
+ <SplitPane defaultSize="50%">
492
+ <SplitView orientation="vertical" resizable={false}>
493
+ <SplitPane>{pane('Editor')}</SplitPane>
494
+ <SplitHandle />
495
+ <SplitPane defaultSize="100px">{pane('Console')}</SplitPane>
496
+ </SplitView>
497
+ </SplitPane>
498
+ <SplitHandle />
499
+ <SplitPane>{pane('Preview')}</SplitPane>
500
+ </SplitView>
501
+ </Card>
502
+ </Group>
503
+ </>
504
+ );
505
+ }
506
+
507
+ export const layout = { 'split-view': SplitViewStory,
508
+ 'app-shell': AppShellStory, card: CardStory, cluster: ClusterStory, detail: DetailStory, pane: PaneStory, resizable: ResizableStory,
509
+ 'scroll-area': ScrollAreaStory, section: SectionStory, 'main-content': MainContentStory, 'multi-pane': MultiPaneStory, 'single-pane': SinglePaneStory, 'address-book-template': AddressBookTemplateStory, 'mail-template': MailTemplateStory,
510
+ };