oneslash-design-system 2.23.0 → 2.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/DESIGN.md +13 -2
- package/dist/cases/activity-timeline/activity.d.ts +1 -0
- package/dist/cases/activity-timeline/activity.jsx +43 -0
- package/dist/cases/activity-timeline/versions.d.ts +1 -0
- package/dist/cases/activity-timeline/versions.jsx +130 -0
- package/dist/cases/activity-timeline.md +315 -0
- package/dist/cases/agent-plan-proposal.md +1 -0
- package/dist/cases/ask-page/answered.d.ts +1 -0
- package/dist/cases/ask-page/answered.jsx +240 -0
- package/dist/cases/ask-page/first-visit.d.ts +1 -0
- package/dist/cases/ask-page/first-visit.jsx +118 -0
- package/dist/cases/ask-page.md +542 -0
- package/dist/cases/chart/bars.d.ts +1 -0
- package/dist/cases/chart/bars.jsx +83 -0
- package/dist/cases/chart/lines.d.ts +1 -0
- package/dist/cases/chart/lines.jsx +71 -0
- package/dist/cases/chart.md +258 -0
- package/dist/cases/comment-thread/card.d.ts +1 -0
- package/dist/cases/comment-thread/card.jsx +141 -0
- package/dist/cases/comment-thread/thread.d.ts +1 -0
- package/dist/cases/comment-thread/thread.jsx +87 -0
- package/dist/cases/comment-thread.md +349 -0
- package/dist/cases/dashboard/numbers-first.jsx +62 -1
- package/dist/cases/dashboard.md +75 -3
- package/dist/cases/leaderboard/ranked.d.ts +1 -0
- package/dist/cases/leaderboard/ranked.jsx +44 -0
- package/dist/cases/leaderboard/table.d.ts +1 -0
- package/dist/cases/leaderboard/table.jsx +87 -0
- package/dist/cases/leaderboard.md +177 -0
- package/dist/cases/number-format.md +4 -2
- package/dist/cases/onboarding/checklist.d.ts +1 -0
- package/dist/cases/onboarding/checklist.jsx +92 -0
- package/dist/cases/onboarding/steps.d.ts +3 -0
- package/dist/cases/onboarding/steps.jsx +177 -0
- package/dist/cases/onboarding.md +368 -0
- package/dist/cases/plan-sign-off/one-approver.d.ts +1 -0
- package/dist/cases/plan-sign-off/one-approver.jsx +129 -0
- package/dist/cases/plan-sign-off/team.d.ts +1 -0
- package/dist/cases/plan-sign-off/team.jsx +213 -0
- package/dist/cases/plan-sign-off.md +541 -0
- package/dist/cases/stat-row.md +1 -1
- package/dist/cases/task-header/agent-sets-status.d.ts +1 -0
- package/dist/cases/task-header/agent-sets-status.jsx +164 -0
- package/dist/cases/task-header/people-change-status.d.ts +1 -0
- package/dist/cases/task-header/people-change-status.jsx +175 -0
- package/dist/cases/task-header.md +576 -0
- package/dist/cases.json +645 -7
- package/dist/components/barChart.d.ts +35 -0
- package/dist/components/barChart.jsx +90 -0
- package/dist/components/heading.d.ts +2 -2
- package/dist/components/heading.jsx +5 -3
- package/dist/components/lineChart.d.ts +39 -0
- package/dist/components/lineChart.jsx +128 -0
- package/dist/components/popover.jsx +7 -2
- package/dist/components/timeline.d.ts +32 -0
- package/dist/components/timeline.jsx +54 -0
- package/dist/components/titleBar.d.ts +3 -1
- package/dist/components/titleBar.jsx +9 -4
- package/dist/internal/chart.d.ts +39 -0
- package/dist/internal/chart.js +110 -0
- package/dist/internal/chartFrame.d.ts +29 -0
- package/dist/internal/chartFrame.jsx +57 -0
- package/dist/native-mapping.json +19 -1
- package/dist/stories/BarChart.stories.d.ts +10 -0
- package/dist/stories/BarChart.stories.jsx +104 -0
- package/dist/stories/Cases.generated.stories.d.ts +16 -0
- package/dist/stories/Cases.generated.stories.jsx +32 -0
- package/dist/stories/Heading.stories.d.ts +1 -0
- package/dist/stories/Heading.stories.jsx +17 -0
- package/dist/stories/LineChart.stories.d.ts +9 -0
- package/dist/stories/LineChart.stories.jsx +34 -0
- package/dist/stories/Onboarding.probe.stories.d.ts +6 -0
- package/dist/stories/Onboarding.probe.stories.jsx +12 -0
- package/dist/stories/Popover.stories.d.ts +1 -0
- package/dist/stories/Popover.stories.jsx +17 -0
- package/dist/stories/Timeline.stories.d.ts +8 -0
- package/dist/stories/Timeline.stories.jsx +49 -0
- package/dist/stories/TitleBar.stories.d.ts +1 -0
- package/dist/stories/TitleBar.stories.jsx +13 -0
- package/package.json +1 -1
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
# Task header
|
|
2
|
+
|
|
3
|
+
A task page shows its name, its state, who is on it and when it is due, with the panes and actions for it.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the case 'Page header with actions': `TitleBar` with the task's name as the one level 1 heading.
|
|
8
|
+
- Put the state, the people and the due date in the `meta` line under the title: a `Tag variant="dot" size="small"` such as 'In progress', an `AvatarStack`, then 'Due Nov 20, 2026'.
|
|
9
|
+
- Write the state in sentence case, as the case 'Status in a row' says: 'In progress', not 'IN PROGRESS'.
|
|
10
|
+
- Show the people as the case 'People on an item' says: one `AvatarStack` that opens a list of every name and role.
|
|
11
|
+
- Let people change the state from a secondary small Button that names it: 'Status: In Progress'. Give it `aria-haspopup="menu"` and `aria-expanded`. A row keeps the change in its More menu, as the case 'Status in a row' says. A task page has room for the Button.
|
|
12
|
+
- Open `<Popover returnFocus>` around `<Menu navigable aria-label="Task status">` from that Button, with the current state `isSelected`.
|
|
13
|
+
- Show a new state in the `meta` Tag and on the Button at once, and close the menu. Focus goes back to the Button.
|
|
14
|
+
- Show the Tag alone when the agent or a check sets the state. Say who sets it near the header, such as 'Acme Agent sets the status as the work moves.'
|
|
15
|
+
- Open the plan and the history as panes, as the case 'Side pane' says: an `IconButton` each, with `aria-expanded` and `state="selected"` while its pane is open.
|
|
16
|
+
- Name each pane button for its pane and the task: 'Show the plan for Launch checklist'.
|
|
17
|
+
- Put a More menu last, as the case 'More menu' says: 'More actions for Launch checklist' with Rename and Archive, then a `Line` and a danger 'Delete Task'.
|
|
18
|
+
- Confirm 'Delete Task' in a small Modal, as the case 'Delete confirm' says: 'Delete Task', 'Cancel', then a danger 'Delete'.
|
|
19
|
+
- Pass `phoneActions` with the Plan button and More when the row holds only icon buttons. Below `md` the History button folds into More, first and before a `Line`.
|
|
20
|
+
- Pass `actionsBelow` instead when the row holds the status Button. It is too wide to sit beside the title on a phone, so below `md` the actions take their own line under it.
|
|
21
|
+
|
|
22
|
+
## Don't
|
|
23
|
+
|
|
24
|
+
- Do not make the status Tag a button. A state people change opens from its own Button.
|
|
25
|
+
- Do not put a `Tooltip` on each face. Use the stack and its list.
|
|
26
|
+
- Do not put Delete in the row as an icon button. It goes last in the More menu.
|
|
27
|
+
- Do not write the state in the Tag in upper case or Title Case. The Button and the menu items use Title Case: 'Status: In Progress'.
|
|
28
|
+
- Do not use a small heading size for the task name. It is the page's level 1 heading in `TitleBar`.
|
|
29
|
+
|
|
30
|
+
## Option: People change the status
|
|
31
|
+
|
|
32
|
+
Use when: People move the task through its states.
|
|
33
|
+
|
|
34
|
+
Uses: `AppShell`, `AvatarStack`, `Button`, `IconButton`, `Line`, `List`, `Menu`, `MenuItem`, `Modal`, `Navigation`, `Paragraph`, `Popover`, `SidePane`, `Stack`, `Tag`, `Timeline`, `TitleBar`, `Toaster`, `Tooltip`, `dismissToast`, `toast`
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
'use client';
|
|
38
|
+
import { useEffect, useRef, useState } from 'react';
|
|
39
|
+
import AppShell from 'oneslash-design-system/components/appShell';
|
|
40
|
+
import SidePane, { type SidePaneHandle } from 'oneslash-design-system/components/sidePane';
|
|
41
|
+
import Navigation from 'oneslash-design-system/components/navigation';
|
|
42
|
+
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
43
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
44
|
+
import AvatarStack from 'oneslash-design-system/components/avatarStack';
|
|
45
|
+
import Button from 'oneslash-design-system/components/button';
|
|
46
|
+
import IconButton from 'oneslash-design-system/components/iconButton';
|
|
47
|
+
import Tooltip from 'oneslash-design-system/components/tooltip';
|
|
48
|
+
import Popover from 'oneslash-design-system/components/popover';
|
|
49
|
+
import Menu from 'oneslash-design-system/components/menu';
|
|
50
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
51
|
+
import Line from 'oneslash-design-system/components/line';
|
|
52
|
+
import List from 'oneslash-design-system/components/list';
|
|
53
|
+
import Modal from 'oneslash-design-system/components/modal';
|
|
54
|
+
import Timeline from 'oneslash-design-system/components/timeline';
|
|
55
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
56
|
+
import Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';
|
|
57
|
+
import { Stack } from 'oneslash-design-system/components/layout';
|
|
58
|
+
|
|
59
|
+
type PaneId = 'plan' | 'history';
|
|
60
|
+
type Focusable = HTMLButtonElement | HTMLAnchorElement | null;
|
|
61
|
+
|
|
62
|
+
const task = 'Launch checklist';
|
|
63
|
+
|
|
64
|
+
// A Button and a menu item say the state in Title Case. The Tag says it in sentence case.
|
|
65
|
+
const statuses = [
|
|
66
|
+
{ id: 'to-do', label: 'To Do', tag: 'To do' },
|
|
67
|
+
{ id: 'in-progress', label: 'In Progress', tag: 'In progress' },
|
|
68
|
+
{ id: 'in-review', label: 'In Review', tag: 'In review' },
|
|
69
|
+
{ id: 'done', label: 'Done', tag: 'Done' },
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
// The person who started the task comes first, here and in every list of these people.
|
|
73
|
+
const people = [
|
|
74
|
+
{ name: 'Ben Carter', role: 'Admin' },
|
|
75
|
+
{ name: 'Dana Lee', role: 'Member' },
|
|
76
|
+
{ name: 'Omar Reyes', role: 'Member' },
|
|
77
|
+
{ name: 'Mia Park', role: 'Member' },
|
|
78
|
+
{ name: 'Leo Grant', role: 'Guest' },
|
|
79
|
+
{ name: 'Ana Silva', role: 'Guest' },
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
const history = [
|
|
83
|
+
{ id: 'h3', title: 'Dana Lee approved the plan', when: 'Nov 16, 2026, 2:52 PM', dateTime: '2026-11-16T14:52', actor: { name: 'Dana Lee' } },
|
|
84
|
+
{ id: 'h2', title: 'Acme Agent wrote the plan', when: 'Nov 16, 2026, 2:40 PM', dateTime: '2026-11-16T14:40', actor: { name: 'Acme Agent', agent: true } },
|
|
85
|
+
{ id: 'h1', title: 'Ben Carter created the task', when: 'Nov 15, 2026, 4:02 PM', dateTime: '2026-11-15T16:02', actor: { name: 'Ben Carter' } },
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
// The places. A real app lets each link go to its page.
|
|
89
|
+
const sidebar = (
|
|
90
|
+
<Navigation aria-label="Main">
|
|
91
|
+
<MenuItem
|
|
92
|
+
size="small"
|
|
93
|
+
label="Tasks"
|
|
94
|
+
iconName="ListChecks"
|
|
95
|
+
href="/tasks"
|
|
96
|
+
isSelected
|
|
97
|
+
aria-current="page"
|
|
98
|
+
onClick={(event: { preventDefault: () => void }) => event.preventDefault()}
|
|
99
|
+
/>
|
|
100
|
+
</Navigation>
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
export default function TaskHeaderPeopleChangeStatus() {
|
|
104
|
+
const [navOpen, setNavOpen] = useState(false);
|
|
105
|
+
const [status, setStatus] = useState('in-progress');
|
|
106
|
+
const [statusAnchor, setStatusAnchor] = useState<HTMLElement | null>(null);
|
|
107
|
+
const [peopleAnchor, setPeopleAnchor] = useState<HTMLElement | null>(null);
|
|
108
|
+
const [moreAnchor, setMoreAnchor] = useState<HTMLElement | null>(null);
|
|
109
|
+
const [moreOpen, setMoreOpen] = useState(false);
|
|
110
|
+
// One pane at a time. Opening another replaces it.
|
|
111
|
+
const [pane, setPane] = useState<PaneId | null>(null);
|
|
112
|
+
const [confirming, setConfirming] = useState(false);
|
|
113
|
+
const [deleting, setDeleting] = useState(false);
|
|
114
|
+
const paneRef = useRef<SidePaneHandle>(null);
|
|
115
|
+
const moreButton = useRef<Focusable>(null);
|
|
116
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
117
|
+
const toastIds = useRef<string[]>([]);
|
|
118
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
119
|
+
const focusNext = useRef<() => void>();
|
|
120
|
+
|
|
121
|
+
// On unmount it stops the request and closes every toast it opened.
|
|
122
|
+
useEffect(() => () => {
|
|
123
|
+
clearTimeout(timer.current);
|
|
124
|
+
toastIds.current.forEach((id) => dismissToast(id));
|
|
125
|
+
toastIds.current = [];
|
|
126
|
+
}, []);
|
|
127
|
+
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
const move = focusNext.current;
|
|
130
|
+
focusNext.current = undefined;
|
|
131
|
+
move?.();
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const current = statuses.find((s) => s.id === status) ?? statuses[0];
|
|
135
|
+
|
|
136
|
+
// The new state shows in the Tag and on the Button at once. The Popover gives focus back to the Button.
|
|
137
|
+
function chooseStatus(id: string) {
|
|
138
|
+
setStatusAnchor(null);
|
|
139
|
+
// A real app sends the new state to the server here.
|
|
140
|
+
setStatus(id);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Pressed again while its pane is open, the button brings the pane forward instead of opening a second one.
|
|
144
|
+
function togglePane(id: PaneId) {
|
|
145
|
+
if (pane === id) paneRef.current?.focus();
|
|
146
|
+
else setPane(id);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function openMore(el: HTMLElement) {
|
|
150
|
+
setMoreAnchor(el);
|
|
151
|
+
setMoreOpen((o) => !o);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Every item closes the menu. The Popover gives focus back to More.
|
|
155
|
+
function choose(action: () => void) {
|
|
156
|
+
setMoreOpen(false);
|
|
157
|
+
action();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// The Modal opens while the menu fades, so it cannot take focus back from the menu item: 'Cancel' sends it to More.
|
|
161
|
+
function keepTask() {
|
|
162
|
+
if (deleting) return;
|
|
163
|
+
setConfirming(false);
|
|
164
|
+
focusNext.current = () => moreButton.current?.focus({ preventScroll: true });
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function confirmDelete() {
|
|
168
|
+
if (deleting) return;
|
|
169
|
+
setDeleting(true);
|
|
170
|
+
// Stands in for the request to the server. A real app then goes back to the task list.
|
|
171
|
+
timer.current = setTimeout(() => {
|
|
172
|
+
setDeleting(false);
|
|
173
|
+
setConfirming(false);
|
|
174
|
+
toastIds.current.push(toast({ type: 'success', message: `${task} deleted.` }));
|
|
175
|
+
}, 1200);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const statusButton = (
|
|
179
|
+
<Button
|
|
180
|
+
size="small"
|
|
181
|
+
type="secondary"
|
|
182
|
+
state="enabled"
|
|
183
|
+
label={`Status: ${current.label}`}
|
|
184
|
+
aria-haspopup="menu"
|
|
185
|
+
aria-expanded={statusAnchor !== null}
|
|
186
|
+
onClickButton={(e: { currentTarget: HTMLElement }) => setStatusAnchor(statusAnchor ? null : e.currentTarget)}
|
|
187
|
+
/>
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
const paneButton = (id: PaneId) => (
|
|
191
|
+
<Tooltip title={id === 'plan' ? 'Plan' : 'History'}>
|
|
192
|
+
<IconButton
|
|
193
|
+
color="iconOnly"
|
|
194
|
+
state={pane === id ? 'selected' : 'enabled'}
|
|
195
|
+
size="medium"
|
|
196
|
+
iconName={id === 'plan' ? 'FileText' : 'History'}
|
|
197
|
+
ariaLabel={id === 'plan' ? `Show the plan for ${task}` : `Show the history of ${task}`}
|
|
198
|
+
aria-expanded={pane === id}
|
|
199
|
+
onClick={() => togglePane(id)}
|
|
200
|
+
/>
|
|
201
|
+
</Tooltip>
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
const more = (
|
|
205
|
+
<Tooltip title="More">
|
|
206
|
+
<IconButton
|
|
207
|
+
ref={moreButton}
|
|
208
|
+
color="iconOnly"
|
|
209
|
+
state={moreOpen ? 'selected' : 'enabled'}
|
|
210
|
+
size="medium"
|
|
211
|
+
iconName="Ellipsis"
|
|
212
|
+
ariaLabel={`More actions for ${task}`}
|
|
213
|
+
aria-haspopup="menu"
|
|
214
|
+
aria-expanded={moreOpen}
|
|
215
|
+
onClick={(e: { currentTarget: HTMLElement }) => openMore(e.currentTarget)}
|
|
216
|
+
/>
|
|
217
|
+
</Tooltip>
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
<AppShell
|
|
222
|
+
title="Tasks"
|
|
223
|
+
navOpen={navOpen}
|
|
224
|
+
onNavOpenChange={setNavOpen}
|
|
225
|
+
sidebar={sidebar}
|
|
226
|
+
pane={
|
|
227
|
+
pane && (
|
|
228
|
+
<SidePane key={pane} ref={paneRef} title={pane === 'plan' ? 'Plan' : 'History'} onClose={() => setPane(null)}>
|
|
229
|
+
{pane === 'plan' ? (
|
|
230
|
+
<Stack gap="medium">
|
|
231
|
+
<Paragraph measure="none">Ship the new home page on Nov 20, 2026. Omar Reyes writes the copy and Mia Park checks the screens.</Paragraph>
|
|
232
|
+
<Paragraph tone="secondary" size="body2" measure="none">Written by Acme Agent, Nov 16, 2026, 2:40 PM</Paragraph>
|
|
233
|
+
</Stack>
|
|
234
|
+
) : (
|
|
235
|
+
<Timeline id="task-header-history" aria-label="History" items={history} />
|
|
236
|
+
)}
|
|
237
|
+
</SidePane>
|
|
238
|
+
)
|
|
239
|
+
}
|
|
240
|
+
>
|
|
241
|
+
{/* A real app mounts one Toaster near its root. */}
|
|
242
|
+
<Toaster />
|
|
243
|
+
<Stack gap="large">
|
|
244
|
+
<TitleBar
|
|
245
|
+
title={task}
|
|
246
|
+
meta={
|
|
247
|
+
<>
|
|
248
|
+
<Tag variant="dot" size="small" label={current.tag} />
|
|
249
|
+
<AvatarStack
|
|
250
|
+
people={people}
|
|
251
|
+
aria-label={`Show the ${people.length} people on ${task}`}
|
|
252
|
+
aria-haspopup="dialog"
|
|
253
|
+
aria-expanded={peopleAnchor !== null}
|
|
254
|
+
onClick={(event) => setPeopleAnchor(peopleAnchor ? null : event.currentTarget)}
|
|
255
|
+
/>
|
|
256
|
+
Due Nov 20, 2026
|
|
257
|
+
</>
|
|
258
|
+
}
|
|
259
|
+
// The status Button is too wide to sit beside the title on a phone, so below md the actions take their own line.
|
|
260
|
+
actions={
|
|
261
|
+
<>
|
|
262
|
+
{statusButton}
|
|
263
|
+
{paneButton('plan')}
|
|
264
|
+
{paneButton('history')}
|
|
265
|
+
{more}
|
|
266
|
+
</>
|
|
267
|
+
}
|
|
268
|
+
actionsBelow
|
|
269
|
+
/>
|
|
270
|
+
<Paragraph tone="secondary" measure="none">Acme Agent is updating the home page. Omar Reyes is writing the copy.</Paragraph>
|
|
271
|
+
</Stack>
|
|
272
|
+
<Popover id="task-header-status" open={statusAnchor !== null} anchorEl={statusAnchor} onClose={() => setStatusAnchor(null)} returnFocus>
|
|
273
|
+
<Menu navigable aria-label="Task status" width={200}>
|
|
274
|
+
{statuses.map((s) => (
|
|
275
|
+
<MenuItem key={s.id} size="small" label={s.label} isSelected={s.id === status} onClick={() => chooseStatus(s.id)} />
|
|
276
|
+
))}
|
|
277
|
+
</Menu>
|
|
278
|
+
</Popover>
|
|
279
|
+
<Popover id="task-header-people" open={peopleAnchor !== null} anchorEl={peopleAnchor} onClose={() => setPeopleAnchor(null)} returnFocus>
|
|
280
|
+
<List items={people.map((p) => `${p.name}, ${p.role}`)} />
|
|
281
|
+
</Popover>
|
|
282
|
+
<Popover id="task-header-more" open={moreOpen} anchorEl={moreAnchor} onClose={() => setMoreOpen(false)} returnFocus>
|
|
283
|
+
<Menu navigable aria-label={`Actions for ${task}`} width={200}>
|
|
284
|
+
{/* A real app opens the Rename Modal of the case 'Rename', and archives the task with a toast. */}
|
|
285
|
+
<MenuItem size="small" iconName="Pencil" label="Rename" onClick={() => choose(() => {})} />
|
|
286
|
+
<MenuItem size="small" iconName="Archive" label="Archive" onClick={() => choose(() => {})} />
|
|
287
|
+
<Line />
|
|
288
|
+
{/* Delete is last, and danger. */}
|
|
289
|
+
<MenuItem size="small" color="danger" iconName="Trash2" label="Delete Task" onClick={() => choose(() => setConfirming(true))} />
|
|
290
|
+
</Menu>
|
|
291
|
+
</Popover>
|
|
292
|
+
{/* The task is a page, not a row in a list, so the confirm is a small Modal, as the case 'Delete confirm' says. */}
|
|
293
|
+
<Modal
|
|
294
|
+
isOpen={confirming}
|
|
295
|
+
size="small"
|
|
296
|
+
title="Delete Task"
|
|
297
|
+
onClose={keepTask}
|
|
298
|
+
actions={
|
|
299
|
+
<>
|
|
300
|
+
<Button size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={keepTask} />
|
|
301
|
+
<Button size="small" type="primary" color="danger" state="enabled" label="Delete" loading={deleting} onClickButton={confirmDelete} />
|
|
302
|
+
</>
|
|
303
|
+
}
|
|
304
|
+
>
|
|
305
|
+
<Paragraph measure="none">This deletes '{task}', its plan and its history.</Paragraph>
|
|
306
|
+
</Modal>
|
|
307
|
+
</AppShell>
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## Option: The agent sets the status
|
|
313
|
+
|
|
314
|
+
Use when: The agent or a check sets the state, and people only read it.
|
|
315
|
+
|
|
316
|
+
Uses: `AppShell`, `AvatarStack`, `Button`, `IconButton`, `Line`, `List`, `Menu`, `MenuItem`, `Modal`, `Navigation`, `Paragraph`, `Popover`, `SidePane`, `Stack`, `Tag`, `Timeline`, `TitleBar`, `Toaster`, `Tooltip`, `dismissToast`, `toast`
|
|
317
|
+
|
|
318
|
+
```tsx
|
|
319
|
+
'use client';
|
|
320
|
+
import { useEffect, useRef, useState } from 'react';
|
|
321
|
+
import AppShell from 'oneslash-design-system/components/appShell';
|
|
322
|
+
import SidePane, { type SidePaneHandle } from 'oneslash-design-system/components/sidePane';
|
|
323
|
+
import Navigation from 'oneslash-design-system/components/navigation';
|
|
324
|
+
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
325
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
326
|
+
import AvatarStack from 'oneslash-design-system/components/avatarStack';
|
|
327
|
+
import Button from 'oneslash-design-system/components/button';
|
|
328
|
+
import IconButton from 'oneslash-design-system/components/iconButton';
|
|
329
|
+
import Tooltip from 'oneslash-design-system/components/tooltip';
|
|
330
|
+
import Popover from 'oneslash-design-system/components/popover';
|
|
331
|
+
import Menu from 'oneslash-design-system/components/menu';
|
|
332
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
333
|
+
import Line from 'oneslash-design-system/components/line';
|
|
334
|
+
import List from 'oneslash-design-system/components/list';
|
|
335
|
+
import Modal from 'oneslash-design-system/components/modal';
|
|
336
|
+
import Timeline from 'oneslash-design-system/components/timeline';
|
|
337
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
338
|
+
import Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';
|
|
339
|
+
import { Stack } from 'oneslash-design-system/components/layout';
|
|
340
|
+
|
|
341
|
+
type PaneId = 'plan' | 'history';
|
|
342
|
+
type Width = 'wide' | 'phone';
|
|
343
|
+
type Focusable = HTMLButtonElement | HTMLAnchorElement | null;
|
|
344
|
+
|
|
345
|
+
const task = 'Launch checklist';
|
|
346
|
+
|
|
347
|
+
// The person who started the task comes first, here and in every list of these people.
|
|
348
|
+
const people = [
|
|
349
|
+
{ name: 'Ben Carter', role: 'Admin' },
|
|
350
|
+
{ name: 'Dana Lee', role: 'Member' },
|
|
351
|
+
{ name: 'Omar Reyes', role: 'Member' },
|
|
352
|
+
{ name: 'Mia Park', role: 'Member' },
|
|
353
|
+
{ name: 'Leo Grant', role: 'Guest' },
|
|
354
|
+
{ name: 'Ana Silva', role: 'Guest' },
|
|
355
|
+
];
|
|
356
|
+
|
|
357
|
+
const history = [
|
|
358
|
+
{ id: 'h3', title: 'Dana Lee approved the plan', when: 'Nov 16, 2026, 2:52 PM', dateTime: '2026-11-16T14:52', actor: { name: 'Dana Lee' } },
|
|
359
|
+
{ id: 'h2', title: 'Acme Agent wrote the plan', when: 'Nov 16, 2026, 2:40 PM', dateTime: '2026-11-16T14:40', actor: { name: 'Acme Agent', agent: true } },
|
|
360
|
+
{ id: 'h1', title: 'Ben Carter created the task', when: 'Nov 15, 2026, 4:02 PM', dateTime: '2026-11-15T16:02', actor: { name: 'Ben Carter' } },
|
|
361
|
+
];
|
|
362
|
+
|
|
363
|
+
// The places. A real app lets each link go to its page.
|
|
364
|
+
const sidebar = (
|
|
365
|
+
<Navigation aria-label="Main">
|
|
366
|
+
<MenuItem
|
|
367
|
+
size="small"
|
|
368
|
+
label="Tasks"
|
|
369
|
+
iconName="ListChecks"
|
|
370
|
+
href="/tasks"
|
|
371
|
+
isSelected
|
|
372
|
+
aria-current="page"
|
|
373
|
+
onClick={(event: { preventDefault: () => void }) => event.preventDefault()}
|
|
374
|
+
/>
|
|
375
|
+
</Navigation>
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
export default function TaskHeaderAgentSetsStatus() {
|
|
379
|
+
const [navOpen, setNavOpen] = useState(false);
|
|
380
|
+
const [peopleAnchor, setPeopleAnchor] = useState<HTMLElement | null>(null);
|
|
381
|
+
// Which More button opened the menu: on a phone the menu also holds History. It stays set while the menu fades out.
|
|
382
|
+
const [moreFrom, setMoreFrom] = useState<Width>('wide');
|
|
383
|
+
const [moreAnchor, setMoreAnchor] = useState<HTMLElement | null>(null);
|
|
384
|
+
const [moreOpen, setMoreOpen] = useState(false);
|
|
385
|
+
// One pane at a time. Opening another replaces it.
|
|
386
|
+
const [pane, setPane] = useState<PaneId | null>(null);
|
|
387
|
+
const [confirming, setConfirming] = useState(false);
|
|
388
|
+
const [deleting, setDeleting] = useState(false);
|
|
389
|
+
const paneRef = useRef<SidePaneHandle>(null);
|
|
390
|
+
const moreButtons = useRef<Record<Width, Focusable>>({ wide: null, phone: null });
|
|
391
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
392
|
+
const toastIds = useRef<string[]>([]);
|
|
393
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
394
|
+
const focusNext = useRef<() => void>();
|
|
395
|
+
|
|
396
|
+
// On unmount it stops the request and closes every toast it opened.
|
|
397
|
+
useEffect(() => () => {
|
|
398
|
+
clearTimeout(timer.current);
|
|
399
|
+
toastIds.current.forEach((id) => dismissToast(id));
|
|
400
|
+
toastIds.current = [];
|
|
401
|
+
}, []);
|
|
402
|
+
|
|
403
|
+
useEffect(() => {
|
|
404
|
+
const move = focusNext.current;
|
|
405
|
+
focusNext.current = undefined;
|
|
406
|
+
move?.();
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
// Pressed again while its pane is open, the button brings the pane forward instead of opening a second one.
|
|
410
|
+
function togglePane(id: PaneId) {
|
|
411
|
+
if (pane === id) paneRef.current?.focus();
|
|
412
|
+
else setPane(id);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function openMore(from: Width, el: HTMLElement) {
|
|
416
|
+
if (moreOpen && moreFrom === from) {
|
|
417
|
+
setMoreOpen(false);
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
setMoreFrom(from);
|
|
421
|
+
setMoreAnchor(el);
|
|
422
|
+
setMoreOpen(true);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// Every item closes the menu. The Popover gives focus back to More.
|
|
426
|
+
function choose(action: () => void) {
|
|
427
|
+
setMoreOpen(false);
|
|
428
|
+
action();
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// The Modal opens while the menu fades, so it cannot take focus back from the menu item: 'Cancel' sends it to More.
|
|
432
|
+
function keepTask() {
|
|
433
|
+
if (deleting) return;
|
|
434
|
+
setConfirming(false);
|
|
435
|
+
focusNext.current = () => moreButtons.current[moreFrom]?.focus({ preventScroll: true });
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
function confirmDelete() {
|
|
439
|
+
if (deleting) return;
|
|
440
|
+
setDeleting(true);
|
|
441
|
+
// Stands in for the request to the server. A real app then goes back to the task list.
|
|
442
|
+
timer.current = setTimeout(() => {
|
|
443
|
+
setDeleting(false);
|
|
444
|
+
setConfirming(false);
|
|
445
|
+
toastIds.current.push(toast({ type: 'success', message: `${task} deleted.` }));
|
|
446
|
+
}, 1200);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
const paneButton = (id: PaneId) => (
|
|
450
|
+
<Tooltip title={id === 'plan' ? 'Plan' : 'History'}>
|
|
451
|
+
<IconButton
|
|
452
|
+
color="iconOnly"
|
|
453
|
+
state={pane === id ? 'selected' : 'enabled'}
|
|
454
|
+
size="medium"
|
|
455
|
+
iconName={id === 'plan' ? 'FileText' : 'History'}
|
|
456
|
+
ariaLabel={id === 'plan' ? `Show the plan for ${task}` : `Show the history of ${task}`}
|
|
457
|
+
aria-expanded={pane === id}
|
|
458
|
+
onClick={() => togglePane(id)}
|
|
459
|
+
/>
|
|
460
|
+
</Tooltip>
|
|
461
|
+
);
|
|
462
|
+
|
|
463
|
+
const more = (from: Width) => (
|
|
464
|
+
<Tooltip title="More">
|
|
465
|
+
<IconButton
|
|
466
|
+
ref={(el) => { moreButtons.current[from] = el; }}
|
|
467
|
+
color="iconOnly"
|
|
468
|
+
state={moreOpen && moreFrom === from ? 'selected' : 'enabled'}
|
|
469
|
+
size="medium"
|
|
470
|
+
iconName="Ellipsis"
|
|
471
|
+
ariaLabel={`More actions for ${task}`}
|
|
472
|
+
aria-haspopup="menu"
|
|
473
|
+
aria-expanded={moreOpen && moreFrom === from}
|
|
474
|
+
onClick={(e: { currentTarget: HTMLElement }) => openMore(from, e.currentTarget)}
|
|
475
|
+
/>
|
|
476
|
+
</Tooltip>
|
|
477
|
+
);
|
|
478
|
+
|
|
479
|
+
return (
|
|
480
|
+
<AppShell
|
|
481
|
+
title="Tasks"
|
|
482
|
+
navOpen={navOpen}
|
|
483
|
+
onNavOpenChange={setNavOpen}
|
|
484
|
+
sidebar={sidebar}
|
|
485
|
+
pane={
|
|
486
|
+
pane && (
|
|
487
|
+
<SidePane key={pane} ref={paneRef} title={pane === 'plan' ? 'Plan' : 'History'} onClose={() => setPane(null)}>
|
|
488
|
+
{pane === 'plan' ? (
|
|
489
|
+
<Stack gap="medium">
|
|
490
|
+
<Paragraph measure="none">Ship the new home page on Nov 20, 2026. Omar Reyes writes the copy and Mia Park checks the screens.</Paragraph>
|
|
491
|
+
<Paragraph tone="secondary" size="body2" measure="none">Written by Acme Agent, Nov 16, 2026, 2:40 PM</Paragraph>
|
|
492
|
+
</Stack>
|
|
493
|
+
) : (
|
|
494
|
+
<Timeline id="task-header-agent-history" aria-label="History" items={history} />
|
|
495
|
+
)}
|
|
496
|
+
</SidePane>
|
|
497
|
+
)
|
|
498
|
+
}
|
|
499
|
+
>
|
|
500
|
+
{/* A real app mounts one Toaster near its root. */}
|
|
501
|
+
<Toaster />
|
|
502
|
+
<Stack gap="large">
|
|
503
|
+
<TitleBar
|
|
504
|
+
title={task}
|
|
505
|
+
meta={
|
|
506
|
+
<>
|
|
507
|
+
{/* Acme Agent and the checks set the state. People read it here and do not change it. */}
|
|
508
|
+
<Tag variant="dot" size="small" label="In progress" />
|
|
509
|
+
<AvatarStack
|
|
510
|
+
people={people}
|
|
511
|
+
aria-label={`Show the ${people.length} people on ${task}`}
|
|
512
|
+
aria-haspopup="dialog"
|
|
513
|
+
aria-expanded={peopleAnchor !== null}
|
|
514
|
+
onClick={(event) => setPeopleAnchor(peopleAnchor ? null : event.currentTarget)}
|
|
515
|
+
/>
|
|
516
|
+
Due Nov 20, 2026
|
|
517
|
+
</>
|
|
518
|
+
}
|
|
519
|
+
actions={
|
|
520
|
+
<>
|
|
521
|
+
{paneButton('plan')}
|
|
522
|
+
{paneButton('history')}
|
|
523
|
+
{more('wide')}
|
|
524
|
+
</>
|
|
525
|
+
}
|
|
526
|
+
phoneActions={
|
|
527
|
+
<>
|
|
528
|
+
{paneButton('plan')}
|
|
529
|
+
{more('phone')}
|
|
530
|
+
</>
|
|
531
|
+
}
|
|
532
|
+
/>
|
|
533
|
+
<Paragraph tone="secondary" measure="none">Acme Agent sets the status as the work moves. It is updating the home page, and Omar Reyes is writing the copy.</Paragraph>
|
|
534
|
+
</Stack>
|
|
535
|
+
<Popover id="task-header-agent-people" open={peopleAnchor !== null} anchorEl={peopleAnchor} onClose={() => setPeopleAnchor(null)} returnFocus>
|
|
536
|
+
<List items={people.map((p) => `${p.name}, ${p.role}`)} />
|
|
537
|
+
</Popover>
|
|
538
|
+
<Popover id="task-header-agent-more" open={moreOpen} anchorEl={moreAnchor} onClose={() => setMoreOpen(false)} returnFocus>
|
|
539
|
+
<Menu navigable aria-label={`Actions for ${task}`} width={200}>
|
|
540
|
+
{moreFrom === 'phone' && (
|
|
541
|
+
<>
|
|
542
|
+
<MenuItem size="small" iconName="History" label="History" onClick={() => choose(() => togglePane('history'))} />
|
|
543
|
+
<Line />
|
|
544
|
+
</>
|
|
545
|
+
)}
|
|
546
|
+
{/* A real app opens the Rename Modal of the case 'Rename', and archives the task with a toast. */}
|
|
547
|
+
<MenuItem size="small" iconName="Pencil" label="Rename" onClick={() => choose(() => {})} />
|
|
548
|
+
<MenuItem size="small" iconName="Archive" label="Archive" onClick={() => choose(() => {})} />
|
|
549
|
+
<Line />
|
|
550
|
+
{/* Delete is last, and danger. */}
|
|
551
|
+
<MenuItem size="small" color="danger" iconName="Trash2" label="Delete Task" onClick={() => choose(() => setConfirming(true))} />
|
|
552
|
+
</Menu>
|
|
553
|
+
</Popover>
|
|
554
|
+
{/* The task is a page, not a row in a list, so the confirm is a small Modal, as the case 'Delete confirm' says. */}
|
|
555
|
+
<Modal
|
|
556
|
+
isOpen={confirming}
|
|
557
|
+
size="small"
|
|
558
|
+
title="Delete Task"
|
|
559
|
+
onClose={keepTask}
|
|
560
|
+
actions={
|
|
561
|
+
<>
|
|
562
|
+
<Button size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={keepTask} />
|
|
563
|
+
<Button size="small" type="primary" color="danger" state="enabled" label="Delete" loading={deleting} onClickButton={confirmDelete} />
|
|
564
|
+
</>
|
|
565
|
+
}
|
|
566
|
+
>
|
|
567
|
+
<Paragraph measure="none">This deletes '{task}', its plan and its history.</Paragraph>
|
|
568
|
+
</Modal>
|
|
569
|
+
</AppShell>
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
## Native
|
|
575
|
+
|
|
576
|
+
On Apple put the name in the navigation title, the state and the people in a `.navigationSubtitle` on Mac and a toolbar `principal` item on iPhone, the status in a `Menu` with a `Picker`, and the panes as an inspector. On Android use a `TopAppBar` with a dropdown menu for the status and the rest.
|