oneslash-design-system 2.23.1 → 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/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/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,541 @@
|
|
|
1
|
+
# Plan sign-off
|
|
2
|
+
|
|
3
|
+
The agent wrote a plan for a task, and people approve it before the agent starts the work.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the rule 'An agent asks before a risky action': the agent starts nothing until every required person has said yes.
|
|
8
|
+
- Show the plan in a `SidePane` titled 'Plan' beside the task, as the case 'Side pane' says. A plan in a chat message stays a card, as the case 'Plan proposal' says.
|
|
9
|
+
- Write the plan as headed sections: a `Heading`, then a `Paragraph` or a `List` for each.
|
|
10
|
+
- Say who wrote the plan and when: 'Written by Acme Agent, Nov 16, 2026, 2:40 PM'.
|
|
11
|
+
- Put the sign-off at the end of the pane, after the whole plan.
|
|
12
|
+
- Give one approver 'Cancel', 'Request Changes', then 'Approve' as the primary Button, as the changes card of the case 'Plan proposal' does. 'Cancel' marks the plan Cancelled, and the agent does nothing. 'Request Changes' opens a `Textarea` labelled 'What should change?' with 'Discard' and 'Send', with the same focus rules.
|
|
13
|
+
- Show a team's count as `<Progress kind="share" label="Signed off">` with `valueText` such as '2 of 3 people'.
|
|
14
|
+
- List who signed and when in a `List`: 'Ben Carter, Nov 16, 2026'. Keep the list as the record once all have signed.
|
|
15
|
+
- Say by name who has not signed: 'Waiting for Dana Lee.'
|
|
16
|
+
- Show how long the plan waits, as the rule 'An agent cancels and reports when nobody answers' says: 'Waits until Nov 19, 2026, then cancels.' Notify each person who has not signed.
|
|
17
|
+
- Give a person who has not signed 'Request Changes' and 'Sign Off' as the primary Button. Give one who has signed a tertiary 'Withdraw Sign-Off'.
|
|
18
|
+
- Clear the sign-offs when the agent rewrites the plan after a request, and say so in the warning `Alert`.
|
|
19
|
+
- Show the gaps in an inline warning `Alert` when the agent finds some before a sign-off, with 'Review Plan' and 'Sign Off Anyway'. 'Review Plan' moves focus to the plan's first heading.
|
|
20
|
+
- Make the pressed Button `loading` and keep its label while the request runs.
|
|
21
|
+
- Remove the sign-offs when the plan changes, and say so in an inline warning `Alert`: 'The plan changed, so the 2 sign-offs were removed. Each person signs off again.'
|
|
22
|
+
- Show 'Signed off by everyone. Acme Agent starts the work.' in an inline success `Alert` once the last person signs, and remove the Buttons. The Alert is a polite status, so a screen reader hears it.
|
|
23
|
+
- Move focus to the pane's title when the Buttons go away and nothing takes their place.
|
|
24
|
+
- Give every inline `Alert` here `autoDismiss={false}`, so it stays until the state changes.
|
|
25
|
+
|
|
26
|
+
## Don't
|
|
27
|
+
|
|
28
|
+
- Do not let the agent start before every required person has signed off.
|
|
29
|
+
- Do not offer an override that skips the sign-offs, such as a commit for an admin.
|
|
30
|
+
- Do not change a Button's label while it is loading, such as to 'Checking...'.
|
|
31
|
+
- Do not title a confirm 'Sure?'. Name the action, as the rule 'A confirm says exactly what will happen' says.
|
|
32
|
+
- Do not show only faces for who signed. Write the names and the dates.
|
|
33
|
+
|
|
34
|
+
## Option: One person approves
|
|
35
|
+
|
|
36
|
+
Use when: One person approves the agent's plan before it starts.
|
|
37
|
+
|
|
38
|
+
Uses: `Alert`, `AppShell`, `Button`, `Cluster`, `Heading`, `IconButton`, `Line`, `List`, `MenuItem`, `Navigation`, `Paragraph`, `SidePane`, `Stack`, `Textarea`, `TitleBar`, `Tooltip`
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
'use client';
|
|
42
|
+
import { useEffect, useRef, useState } from 'react';
|
|
43
|
+
import AppShell from 'oneslash-design-system/components/appShell';
|
|
44
|
+
import SidePane, { type SidePaneHandle } from 'oneslash-design-system/components/sidePane';
|
|
45
|
+
import Navigation from 'oneslash-design-system/components/navigation';
|
|
46
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
47
|
+
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
48
|
+
import IconButton from 'oneslash-design-system/components/iconButton';
|
|
49
|
+
import Tooltip from 'oneslash-design-system/components/tooltip';
|
|
50
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
51
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
52
|
+
import List from 'oneslash-design-system/components/list';
|
|
53
|
+
import Line from 'oneslash-design-system/components/line';
|
|
54
|
+
import Button from 'oneslash-design-system/components/button';
|
|
55
|
+
import Textarea from 'oneslash-design-system/components/textarea';
|
|
56
|
+
import Alert from 'oneslash-design-system/components/alert';
|
|
57
|
+
import { Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
58
|
+
|
|
59
|
+
type Status = 'open' | 'requesting' | 'redoing' | 'approved' | 'cancelled';
|
|
60
|
+
type Focusable = HTMLButtonElement | HTMLAnchorElement | null;
|
|
61
|
+
|
|
62
|
+
const task = 'Launch checklist';
|
|
63
|
+
|
|
64
|
+
// The plan Acme Agent wrote, as headed sections.
|
|
65
|
+
const steps = [
|
|
66
|
+
'Acme Agent updates the home page and its tests.',
|
|
67
|
+
'Omar Reyes writes the new copy.',
|
|
68
|
+
'Mia Park checks the screens on a phone.',
|
|
69
|
+
'Ben Carter merges the pull request.',
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
// The places. A real app lets each link go to its page.
|
|
73
|
+
const sidebar = (
|
|
74
|
+
<Navigation aria-label="Main">
|
|
75
|
+
<MenuItem
|
|
76
|
+
size="small"
|
|
77
|
+
label="Tasks"
|
|
78
|
+
iconName="ListChecks"
|
|
79
|
+
href="/tasks"
|
|
80
|
+
isSelected
|
|
81
|
+
aria-current="page"
|
|
82
|
+
onClick={(event: { preventDefault: () => void }) => event.preventDefault()}
|
|
83
|
+
/>
|
|
84
|
+
</Navigation>
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
export default function PlanSignOffOneApprover() {
|
|
88
|
+
const [navOpen, setNavOpen] = useState(false);
|
|
89
|
+
// The person opened the plan from the task header. The example starts with the pane open.
|
|
90
|
+
const [open, setOpen] = useState(true);
|
|
91
|
+
const [status, setStatus] = useState<Status>('open');
|
|
92
|
+
const [pending, setPending] = useState<'approve' | 'cancel' | 'send' | null>(null);
|
|
93
|
+
const [draft, setDraft] = useState('');
|
|
94
|
+
const pane = useRef<SidePaneHandle>(null);
|
|
95
|
+
const requestButton = useRef<Focusable>(null);
|
|
96
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
97
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
98
|
+
const focusNext = useRef<() => void>();
|
|
99
|
+
|
|
100
|
+
// On unmount it stops the request.
|
|
101
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
102
|
+
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
const move = focusNext.current;
|
|
105
|
+
focusNext.current = undefined;
|
|
106
|
+
move?.();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Acme Agent starts only after 'Approve'. 'Cancel' marks the plan Cancelled, and the agent does nothing.
|
|
110
|
+
// Either way the Buttons go, and nothing takes their place, so focus goes to the pane's title.
|
|
111
|
+
function decide(action: 'approve' | 'cancel') {
|
|
112
|
+
if (pending || status !== 'open') return;
|
|
113
|
+
setPending(action);
|
|
114
|
+
// Stands in for the request to the server.
|
|
115
|
+
timer.current = setTimeout(() => {
|
|
116
|
+
setPending(null);
|
|
117
|
+
setStatus(action === 'cancel' ? 'cancelled' : 'approved');
|
|
118
|
+
focusNext.current = () => pane.current?.focus();
|
|
119
|
+
}, 1200);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function startRequest() {
|
|
123
|
+
if (pending) return;
|
|
124
|
+
setDraft('');
|
|
125
|
+
setStatus('requesting');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 'Discard' leaves the field and keeps the plan waiting. Focus goes back to 'Request Changes'.
|
|
129
|
+
function discard() {
|
|
130
|
+
setStatus('open');
|
|
131
|
+
focusNext.current = () => requestButton.current?.focus({ preventScroll: true });
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const empty = draft.trim() === '';
|
|
135
|
+
|
|
136
|
+
// 'Send' gives the agent what should change. The Buttons go, and the agent rewrites the plan.
|
|
137
|
+
function send() {
|
|
138
|
+
if (pending || empty) return;
|
|
139
|
+
setPending('send');
|
|
140
|
+
// Stands in for the request to the server.
|
|
141
|
+
timer.current = setTimeout(() => {
|
|
142
|
+
setPending(null);
|
|
143
|
+
setStatus('redoing');
|
|
144
|
+
focusNext.current = () => pane.current?.focus();
|
|
145
|
+
}, 1200);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<AppShell
|
|
150
|
+
title="Tasks"
|
|
151
|
+
navOpen={navOpen}
|
|
152
|
+
onNavOpenChange={setNavOpen}
|
|
153
|
+
sidebar={sidebar}
|
|
154
|
+
pane={
|
|
155
|
+
open && (
|
|
156
|
+
<SidePane ref={pane} title="Plan" onClose={() => setOpen(false)}>
|
|
157
|
+
<Stack gap="large">
|
|
158
|
+
<Stack gap="small">
|
|
159
|
+
<Heading level={3} size="subtitle1">Goal</Heading>
|
|
160
|
+
<Paragraph measure="none">Ship the new home page on Nov 20, 2026, with the sign-up form above the pricing table.</Paragraph>
|
|
161
|
+
</Stack>
|
|
162
|
+
<Stack gap="small">
|
|
163
|
+
<Heading level={3} size="subtitle1">Steps</Heading>
|
|
164
|
+
<List marker="number" items={steps} />
|
|
165
|
+
</Stack>
|
|
166
|
+
<Stack gap="small">
|
|
167
|
+
<Heading level={3} size="subtitle1">Out of scope</Heading>
|
|
168
|
+
<Paragraph measure="none">The pricing page stays as it is.</Paragraph>
|
|
169
|
+
</Stack>
|
|
170
|
+
<Paragraph size="caption" tone="secondary" measure="none">Written by Acme Agent, Nov 16, 2026, 2:40 PM</Paragraph>
|
|
171
|
+
<Line />
|
|
172
|
+
{/* The approval comes last, after the whole plan. */}
|
|
173
|
+
<Stack gap="medium">
|
|
174
|
+
<Heading level={3} size="subtitle1">Approval</Heading>
|
|
175
|
+
{status === 'approved' ? (
|
|
176
|
+
// An inline Alert is a polite status, so a screen reader hears it.
|
|
177
|
+
<Alert variant="inline" type="success" autoDismiss={false} message="Approved by Dana Lee, Nov 16, 2026, 2:52 PM. Acme Agent starts the work." />
|
|
178
|
+
) : status === 'cancelled' ? (
|
|
179
|
+
<Alert variant="inline" type="info" autoDismiss={false} message="Cancelled. Nothing was changed." />
|
|
180
|
+
) : status === 'redoing' ? (
|
|
181
|
+
<Alert variant="inline" type="info" autoDismiss={false} message="Acme Agent is rewriting the plan. The new plan shows here when it is ready." />
|
|
182
|
+
) : (
|
|
183
|
+
<Paragraph measure="none">Acme Agent starts once Dana Lee approves this plan.</Paragraph>
|
|
184
|
+
)}
|
|
185
|
+
{status === 'requesting' && (
|
|
186
|
+
<Textarea
|
|
187
|
+
id="plan-sign-off-change-request"
|
|
188
|
+
label="What should change?"
|
|
189
|
+
value={draft}
|
|
190
|
+
onChange={(e) => setDraft(e.target.value)}
|
|
191
|
+
onSubmit={send}
|
|
192
|
+
autoFocus
|
|
193
|
+
disabled={pending === 'send'}
|
|
194
|
+
/>
|
|
195
|
+
)}
|
|
196
|
+
{status === 'open' && (
|
|
197
|
+
<Cluster gap="small">
|
|
198
|
+
<Button size="small" type="tertiary" state={pending === 'approve' ? 'disabled' : 'enabled'} label="Cancel" loading={pending === 'cancel'} onClickButton={() => decide('cancel')} />
|
|
199
|
+
<Button ref={requestButton} size="small" type="secondary" state={pending ? 'disabled' : 'enabled'} label="Request Changes" onClickButton={startRequest} />
|
|
200
|
+
{/* The product writes this label, never the agent. */}
|
|
201
|
+
<Button size="small" type="primary" state={pending === 'cancel' ? 'disabled' : 'enabled'} label="Approve" loading={pending === 'approve'} onClickButton={() => decide('approve')} />
|
|
202
|
+
</Cluster>
|
|
203
|
+
)}
|
|
204
|
+
{status === 'requesting' && (
|
|
205
|
+
<Cluster gap="small">
|
|
206
|
+
<Button size="small" type="tertiary" state={pending === 'send' ? 'disabled' : 'enabled'} label="Discard" onClickButton={discard} />
|
|
207
|
+
<Button size="small" type="primary" state={empty ? 'disabled' : 'enabled'} label="Send" loading={pending === 'send'} onClickButton={send} />
|
|
208
|
+
</Cluster>
|
|
209
|
+
)}
|
|
210
|
+
</Stack>
|
|
211
|
+
</Stack>
|
|
212
|
+
</SidePane>
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
>
|
|
216
|
+
<Stack gap="large">
|
|
217
|
+
<TitleBar
|
|
218
|
+
title={task}
|
|
219
|
+
actions={
|
|
220
|
+
<Tooltip title="Plan">
|
|
221
|
+
<IconButton
|
|
222
|
+
color="iconOnly"
|
|
223
|
+
state={open ? 'selected' : 'enabled'}
|
|
224
|
+
size="medium"
|
|
225
|
+
iconName="FileText"
|
|
226
|
+
ariaLabel={`Show the plan for ${task}`}
|
|
227
|
+
aria-expanded={open}
|
|
228
|
+
onClick={() => (open ? pane.current?.focus() : setOpen(true))}
|
|
229
|
+
/>
|
|
230
|
+
</Tooltip>
|
|
231
|
+
}
|
|
232
|
+
/>
|
|
233
|
+
<Paragraph tone="secondary" measure="none">Acme Agent wrote a plan for this task. It waits for Dana Lee to approve it.</Paragraph>
|
|
234
|
+
</Stack>
|
|
235
|
+
</AppShell>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Option: Everyone signs off
|
|
241
|
+
|
|
242
|
+
Use when: Every member of the task signs off a shared plan, and work starts when all have.
|
|
243
|
+
|
|
244
|
+
Uses: `Alert`, `AppShell`, `Button`, `Cluster`, `Heading`, `IconButton`, `Line`, `List`, `MenuItem`, `Navigation`, `Paragraph`, `Progress`, `SidePane`, `Stack`, `Textarea`, `TitleBar`, `Tooltip`
|
|
245
|
+
|
|
246
|
+
```tsx
|
|
247
|
+
'use client';
|
|
248
|
+
import { useEffect, useRef, useState } from 'react';
|
|
249
|
+
import AppShell from 'oneslash-design-system/components/appShell';
|
|
250
|
+
import SidePane, { type SidePaneHandle } from 'oneslash-design-system/components/sidePane';
|
|
251
|
+
import Navigation from 'oneslash-design-system/components/navigation';
|
|
252
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
253
|
+
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
254
|
+
import IconButton from 'oneslash-design-system/components/iconButton';
|
|
255
|
+
import Tooltip from 'oneslash-design-system/components/tooltip';
|
|
256
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
257
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
258
|
+
import List from 'oneslash-design-system/components/list';
|
|
259
|
+
import Line from 'oneslash-design-system/components/line';
|
|
260
|
+
import Button from 'oneslash-design-system/components/button';
|
|
261
|
+
import Progress from 'oneslash-design-system/components/progress';
|
|
262
|
+
import Textarea from 'oneslash-design-system/components/textarea';
|
|
263
|
+
import Alert from 'oneslash-design-system/components/alert';
|
|
264
|
+
import { Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
265
|
+
|
|
266
|
+
type Step = 'waiting' | 'requesting' | 'gaps' | 'signed' | 'done';
|
|
267
|
+
type Focusable = HTMLButtonElement | HTMLAnchorElement | null;
|
|
268
|
+
|
|
269
|
+
const task = 'Launch checklist';
|
|
270
|
+
// A real app reads this from the session.
|
|
271
|
+
const me = 'Dana Lee';
|
|
272
|
+
|
|
273
|
+
// Everyone on the task signs off. Acme Agent starts only when all have.
|
|
274
|
+
const members = ['Ben Carter', 'Omar Reyes', me];
|
|
275
|
+
|
|
276
|
+
const steps = [
|
|
277
|
+
'Acme Agent updates the home page and its tests.',
|
|
278
|
+
'Omar Reyes writes the new copy.',
|
|
279
|
+
'Dana Lee checks the screens on a phone.',
|
|
280
|
+
'Ben Carter merges the pull request.',
|
|
281
|
+
];
|
|
282
|
+
|
|
283
|
+
// The places. A real app lets each link go to its page.
|
|
284
|
+
const sidebar = (
|
|
285
|
+
<Navigation aria-label="Main">
|
|
286
|
+
<MenuItem
|
|
287
|
+
size="small"
|
|
288
|
+
label="Tasks"
|
|
289
|
+
iconName="ListChecks"
|
|
290
|
+
href="/tasks"
|
|
291
|
+
isSelected
|
|
292
|
+
aria-current="page"
|
|
293
|
+
onClick={(event: { preventDefault: () => void }) => event.preventDefault()}
|
|
294
|
+
/>
|
|
295
|
+
</Navigation>
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
export default function PlanSignOffTeam() {
|
|
299
|
+
const [navOpen, setNavOpen] = useState(false);
|
|
300
|
+
// The person opened the plan from the task header. The example starts with the pane open.
|
|
301
|
+
const [open, setOpen] = useState(true);
|
|
302
|
+
// Who signed and when, kept as the record.
|
|
303
|
+
const [signers, setSigners] = useState([
|
|
304
|
+
{ name: 'Ben Carter', on: 'Nov 16, 2026' },
|
|
305
|
+
{ name: 'Omar Reyes', on: 'Nov 16, 2026' },
|
|
306
|
+
]);
|
|
307
|
+
const [step, setStep] = useState<Step>('waiting');
|
|
308
|
+
const [pending, setPending] = useState<'check' | 'sign' | 'send' | 'withdraw' | null>(null);
|
|
309
|
+
const [draft, setDraft] = useState('');
|
|
310
|
+
// After a rewrite: how many sign-offs it removed. The rewrite also closed the gaps the agent found.
|
|
311
|
+
const [cleared, setCleared] = useState<number | null>(null);
|
|
312
|
+
const pane = useRef<SidePaneHandle>(null);
|
|
313
|
+
const firstHeading = useRef<HTMLHeadingElement>(null);
|
|
314
|
+
const reviewButton = useRef<Focusable>(null);
|
|
315
|
+
const requestButton = useRef<Focusable>(null);
|
|
316
|
+
const signOffButton = useRef<Focusable>(null);
|
|
317
|
+
const withdrawButton = useRef<Focusable>(null);
|
|
318
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
319
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
320
|
+
const focusNext = useRef<() => void>();
|
|
321
|
+
|
|
322
|
+
// On unmount it stops the request.
|
|
323
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
324
|
+
|
|
325
|
+
useEffect(() => {
|
|
326
|
+
const move = focusNext.current;
|
|
327
|
+
focusNext.current = undefined;
|
|
328
|
+
move?.();
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
const waitingFor = members.filter((m) => !signers.some((s) => s.name === m));
|
|
332
|
+
const waitingLine = waitingFor.length === 1 ? waitingFor[0] : `${waitingFor.slice(0, -1).join(', ')} and ${waitingFor[waitingFor.length - 1]}`;
|
|
333
|
+
|
|
334
|
+
// Dana's sign-off is in. When it was the last, Acme Agent starts: the Buttons go and focus goes to the pane's title.
|
|
335
|
+
// Otherwise 'Withdraw Sign-Off' takes the place of 'Sign Off' and takes focus.
|
|
336
|
+
function addMySignOff() {
|
|
337
|
+
const next = [...signers, { name: me, on: 'Nov 16, 2026' }];
|
|
338
|
+
setSigners(next);
|
|
339
|
+
if (next.length === members.length) {
|
|
340
|
+
setStep('done');
|
|
341
|
+
focusNext.current = () => pane.current?.focus();
|
|
342
|
+
} else {
|
|
343
|
+
setStep('signed');
|
|
344
|
+
focusNext.current = () => withdrawButton.current?.focus({ preventScroll: true });
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Acme Agent checks the plan for gaps first. 'Sign Off' keeps its label while it checks.
|
|
349
|
+
// The first plan has two, so 'Sign Off' gives way to 'Review Plan' and 'Sign Off Anyway', and focus goes to the first.
|
|
350
|
+
function signOff() {
|
|
351
|
+
if (pending) return;
|
|
352
|
+
setPending('check');
|
|
353
|
+
// Stands in for the request to the server.
|
|
354
|
+
timer.current = setTimeout(() => {
|
|
355
|
+
setPending(null);
|
|
356
|
+
if (cleared !== null) {
|
|
357
|
+
addMySignOff();
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
setStep('gaps');
|
|
361
|
+
focusNext.current = () => reviewButton.current?.focus({ preventScroll: true });
|
|
362
|
+
}, 1200);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function startRequest() {
|
|
366
|
+
if (pending) return;
|
|
367
|
+
setDraft('');
|
|
368
|
+
setStep('requesting');
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// 'Discard' leaves the field and keeps the plan as it is. Focus goes back to 'Request Changes'.
|
|
372
|
+
function discard() {
|
|
373
|
+
setStep('waiting');
|
|
374
|
+
focusNext.current = () => requestButton.current?.focus({ preventScroll: true });
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
const empty = draft.trim() === '';
|
|
378
|
+
|
|
379
|
+
// 'Send' gives the agent what should change. The rewritten plan clears every sign-off, and the warning says so.
|
|
380
|
+
// Focus goes to the pane's title, so the person reads the new plan from the top.
|
|
381
|
+
function send() {
|
|
382
|
+
if (pending || empty) return;
|
|
383
|
+
setPending('send');
|
|
384
|
+
// Stands in for the agent rewriting the plan.
|
|
385
|
+
timer.current = setTimeout(() => {
|
|
386
|
+
setPending(null);
|
|
387
|
+
setCleared(signers.length);
|
|
388
|
+
setSigners([]);
|
|
389
|
+
setStep('waiting');
|
|
390
|
+
focusNext.current = () => pane.current?.focus();
|
|
391
|
+
}, 1200);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// Withdrawing puts Dana back on the waiting list, and 'Sign Off' comes back with focus.
|
|
395
|
+
function withdraw() {
|
|
396
|
+
if (pending) return;
|
|
397
|
+
setPending('withdraw');
|
|
398
|
+
// Stands in for the request to the server.
|
|
399
|
+
timer.current = setTimeout(() => {
|
|
400
|
+
setPending(null);
|
|
401
|
+
setSigners((list) => list.filter((s) => s.name !== me));
|
|
402
|
+
setStep('waiting');
|
|
403
|
+
focusNext.current = () => signOffButton.current?.focus({ preventScroll: true });
|
|
404
|
+
}, 1200);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// The person goes back to read the plan. The warning and its Buttons stay.
|
|
408
|
+
function reviewPlan() {
|
|
409
|
+
firstHeading.current?.focus();
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function signOffAnyway() {
|
|
413
|
+
if (pending) return;
|
|
414
|
+
setPending('sign');
|
|
415
|
+
// Stands in for the request to the server.
|
|
416
|
+
timer.current = setTimeout(() => {
|
|
417
|
+
setPending(null);
|
|
418
|
+
addMySignOff();
|
|
419
|
+
}, 1200);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
return (
|
|
423
|
+
<AppShell
|
|
424
|
+
title="Tasks"
|
|
425
|
+
navOpen={navOpen}
|
|
426
|
+
onNavOpenChange={setNavOpen}
|
|
427
|
+
sidebar={sidebar}
|
|
428
|
+
pane={
|
|
429
|
+
open && (
|
|
430
|
+
<SidePane ref={pane} title="Plan" onClose={() => setOpen(false)}>
|
|
431
|
+
<Stack gap="large">
|
|
432
|
+
<Stack gap="small">
|
|
433
|
+
<Heading ref={firstHeading} tabIndex={-1} level={3} size="subtitle1">Goal</Heading>
|
|
434
|
+
<Paragraph measure="none">Ship the new home page on Nov 20, 2026, with the sign-up form above the pricing table.</Paragraph>
|
|
435
|
+
</Stack>
|
|
436
|
+
<Stack gap="small">
|
|
437
|
+
<Heading level={3} size="subtitle1">Steps</Heading>
|
|
438
|
+
<List marker="number" items={steps} />
|
|
439
|
+
</Stack>
|
|
440
|
+
<Stack gap="small">
|
|
441
|
+
<Heading level={3} size="subtitle1">Out of scope</Heading>
|
|
442
|
+
<Paragraph measure="none">The pricing page stays as it is.</Paragraph>
|
|
443
|
+
</Stack>
|
|
444
|
+
<Paragraph size="caption" tone="secondary" measure="none">{cleared === null ? 'Written by Acme Agent, Nov 16, 2026, 2:40 PM' : 'Rewritten by Acme Agent, Nov 16, 2026, 3:10 PM'}</Paragraph>
|
|
445
|
+
<Line />
|
|
446
|
+
{/* The sign-off comes last, after the whole plan. */}
|
|
447
|
+
<Stack gap="medium">
|
|
448
|
+
<Heading level={3} size="subtitle1">Sign-off</Heading>
|
|
449
|
+
<Progress
|
|
450
|
+
kind="share"
|
|
451
|
+
label="Signed off"
|
|
452
|
+
value={signers.length}
|
|
453
|
+
max={members.length}
|
|
454
|
+
valueText={`${signers.length} of ${members.length} people`}
|
|
455
|
+
/>
|
|
456
|
+
{signers.length > 0 && <List items={signers.map((s) => `${s.name}, ${s.on}`)} />}
|
|
457
|
+
{cleared !== null && step !== 'done' && (
|
|
458
|
+
<Alert variant="inline" type="warning" autoDismiss={false} message={`The plan changed, so the ${cleared} sign-offs were removed. Each person signs off again.`} />
|
|
459
|
+
)}
|
|
460
|
+
{step === 'done' ? (
|
|
461
|
+
// An inline Alert is a polite status, so a screen reader hears it.
|
|
462
|
+
<Alert variant="inline" type="success" autoDismiss={false} message="Signed off by everyone. Acme Agent starts the work." />
|
|
463
|
+
) : (
|
|
464
|
+
<Paragraph measure="none">Waiting for {waitingLine}.</Paragraph>
|
|
465
|
+
)}
|
|
466
|
+
{step === 'requesting' && (
|
|
467
|
+
<Textarea
|
|
468
|
+
id="plan-sign-off-team-change-request"
|
|
469
|
+
label="What should change?"
|
|
470
|
+
value={draft}
|
|
471
|
+
onChange={(e) => setDraft(e.target.value)}
|
|
472
|
+
onSubmit={send}
|
|
473
|
+
autoFocus
|
|
474
|
+
disabled={pending === 'send'}
|
|
475
|
+
/>
|
|
476
|
+
)}
|
|
477
|
+
{step === 'gaps' && (
|
|
478
|
+
<Alert
|
|
479
|
+
variant="inline"
|
|
480
|
+
type="warning"
|
|
481
|
+
autoDismiss={false}
|
|
482
|
+
message="Acme Agent found 2 gaps in the plan."
|
|
483
|
+
secondMessage="No one owns the press kit. The support hand-off has no date."
|
|
484
|
+
/>
|
|
485
|
+
)}
|
|
486
|
+
{step === 'waiting' && (
|
|
487
|
+
<Cluster gap="small">
|
|
488
|
+
<Button ref={requestButton} size="small" type="secondary" state={pending ? 'disabled' : 'enabled'} label="Request Changes" onClickButton={startRequest} />
|
|
489
|
+
<Button ref={signOffButton} size="small" type="primary" state="enabled" label="Sign Off" loading={pending === 'check'} onClickButton={signOff} />
|
|
490
|
+
</Cluster>
|
|
491
|
+
)}
|
|
492
|
+
{step === 'requesting' && (
|
|
493
|
+
<Cluster gap="small">
|
|
494
|
+
<Button size="small" type="tertiary" state={pending === 'send' ? 'disabled' : 'enabled'} label="Discard" onClickButton={discard} />
|
|
495
|
+
<Button size="small" type="primary" state={empty ? 'disabled' : 'enabled'} label="Send" loading={pending === 'send'} onClickButton={send} />
|
|
496
|
+
</Cluster>
|
|
497
|
+
)}
|
|
498
|
+
{step === 'signed' && (
|
|
499
|
+
<Cluster gap="small">
|
|
500
|
+
<Button ref={withdrawButton} size="small" type="tertiary" state="enabled" label="Withdraw Sign-Off" loading={pending === 'withdraw'} onClickButton={withdraw} />
|
|
501
|
+
</Cluster>
|
|
502
|
+
)}
|
|
503
|
+
{step === 'gaps' && (
|
|
504
|
+
<Cluster gap="small">
|
|
505
|
+
<Button ref={reviewButton} size="small" type="secondary" state={pending ? 'disabled' : 'enabled'} label="Review Plan" onClickButton={reviewPlan} />
|
|
506
|
+
<Button size="small" type="primary" state="enabled" label="Sign Off Anyway" loading={pending === 'sign'} onClickButton={signOffAnyway} />
|
|
507
|
+
</Cluster>
|
|
508
|
+
)}
|
|
509
|
+
</Stack>
|
|
510
|
+
</Stack>
|
|
511
|
+
</SidePane>
|
|
512
|
+
)
|
|
513
|
+
}
|
|
514
|
+
>
|
|
515
|
+
<Stack gap="large">
|
|
516
|
+
<TitleBar
|
|
517
|
+
title={task}
|
|
518
|
+
actions={
|
|
519
|
+
<Tooltip title="Plan">
|
|
520
|
+
<IconButton
|
|
521
|
+
color="iconOnly"
|
|
522
|
+
state={open ? 'selected' : 'enabled'}
|
|
523
|
+
size="medium"
|
|
524
|
+
iconName="FileText"
|
|
525
|
+
ariaLabel={`Show the plan for ${task}`}
|
|
526
|
+
aria-expanded={open}
|
|
527
|
+
onClick={() => (open ? pane.current?.focus() : setOpen(true))}
|
|
528
|
+
/>
|
|
529
|
+
</Tooltip>
|
|
530
|
+
}
|
|
531
|
+
/>
|
|
532
|
+
<Paragraph tone="secondary" measure="none">Acme Agent wrote a plan for this task. Everyone on the task signs it off before the work starts.</Paragraph>
|
|
533
|
+
</Stack>
|
|
534
|
+
</AppShell>
|
|
535
|
+
);
|
|
536
|
+
}
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
## Native
|
|
540
|
+
|
|
541
|
+
On Apple show the plan in an inspector or a sheet, the count as a `ProgressView` with a value label, and the sign-off Buttons in a bottom bar. On Android use a side sheet or a bottom sheet with a `LinearProgressIndicator`.
|
package/dist/cases/stat-row.md
CHANGED
|
@@ -19,7 +19,7 @@ A page opens with the few numbers that say how things are going, counted over on
|
|
|
19
19
|
- Do not show 0 while a number loads or when it is missing.
|
|
20
20
|
- Do not color a change green or red. More is not good or bad by itself.
|
|
21
21
|
- Do not put more than four tiles in a row, or two things in one tile.
|
|
22
|
-
- Do not draw a chart or a sparkline in a tile. A trend
|
|
22
|
+
- Do not draw a chart or a sparkline in a tile. A trend over the range goes in a chart under the row, as the case 'Chart' says.
|
|
23
23
|
- Do not box each tile in a card. The row sits on the page.
|
|
24
24
|
|
|
25
25
|
## Option: Tiles of equal weight
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function TaskHeaderAgentSetsStatus(): import("react").JSX.Element;
|