oneslash-design-system 2.23.1 → 2.25.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 +20 -5
- 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 +248 -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 +551 -0
- package/dist/cases/billing-page/self-serve.jsx +4 -4
- package/dist/cases/billing-page/trial.d.ts +1 -0
- package/dist/cases/billing-page/trial.jsx +115 -0
- package/dist/cases/billing-page.md +166 -5
- 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/collapsible-search/popover.jsx +1 -1
- package/dist/cases/collapsible-search.md +2 -2
- 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/cookie-choice/banner.d.ts +1 -0
- package/dist/cases/cookie-choice/banner.jsx +82 -0
- package/dist/cases/cookie-choice/settings.d.ts +1 -0
- package/dist/cases/cookie-choice/settings.jsx +75 -0
- package/dist/cases/cookie-choice.md +234 -0
- package/dist/cases/dashboard/numbers-first.jsx +63 -2
- package/dist/cases/dashboard/work-first.jsx +1 -1
- package/dist/cases/dashboard.md +77 -5
- package/dist/cases/data-table-page/all-rows.jsx +1 -1
- package/dist/cases/data-table-page/paged.jsx +1 -1
- package/dist/cases/data-table-page.md +2 -2
- package/dist/cases/invoice-list/table.jsx +21 -9
- package/dist/cases/invoice-list.md +27 -12
- 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/message-reactions/picker.jsx +1 -1
- package/dist/cases/message-reactions.md +2 -2
- package/dist/cases/message-row.md +2 -1
- package/dist/cases/newsletter-signup/inline.d.ts +1 -0
- package/dist/cases/newsletter-signup/inline.jsx +72 -0
- package/dist/cases/newsletter-signup/section.d.ts +1 -0
- package/dist/cases/newsletter-signup/section.jsx +72 -0
- package/dist/cases/newsletter-signup.md +234 -0
- package/dist/cases/number-format.md +9 -3
- 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/people-row/stack.jsx +1 -1
- package/dist/cases/people-row.md +2 -2
- package/dist/cases/plan-comparison/table.d.ts +1 -0
- package/dist/cases/plan-comparison/table.jsx +47 -0
- package/dist/cases/plan-comparison.md +94 -0
- package/dist/cases/plan-picker.md +1 -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/pricing-section.md +1 -1
- package/dist/cases/site-footer/columns.jsx +2 -1
- package/dist/cases/site-footer.md +3 -1
- package/dist/cases/stat-row/tiles.jsx +2 -1
- package/dist/cases/stat-row.md +5 -2
- 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 +883 -30
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +5 -5
- package/dist/components/barChart.d.ts +35 -0
- package/dist/components/barChart.jsx +92 -0
- package/dist/components/dateField.jsx +1 -1
- package/dist/components/formatNumber.d.ts +10 -2
- package/dist/components/formatNumber.js +44 -9
- package/dist/components/heading.d.ts +2 -2
- package/dist/components/heading.jsx +5 -3
- package/dist/components/layout.d.ts +4 -2
- package/dist/components/layout.jsx +13 -2
- package/dist/components/lineChart.d.ts +39 -0
- package/dist/components/lineChart.jsx +128 -0
- package/dist/components/markdown.d.ts +24 -0
- package/dist/components/markdown.jsx +81 -0
- package/dist/components/pageShell.d.ts +3 -3
- package/dist/components/pageShell.jsx +6 -5
- package/dist/components/popover.d.ts +5 -1
- package/dist/components/popover.jsx +3 -2
- package/dist/components/progress.jsx +1 -1
- package/dist/components/select.jsx +5 -2
- package/dist/components/statTile.d.ts +1 -1
- package/dist/components/statTile.jsx +7 -2
- package/dist/components/tableCell.d.ts +4 -3
- package/dist/components/tableCell.jsx +2 -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/components/toaster.jsx +81 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- 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/internal/markdown.d.ts +40 -0
- package/dist/internal/markdown.js +577 -0
- package/dist/internal/toaster.d.ts +2 -0
- package/dist/internal/toaster.js +8 -0
- package/dist/native-mapping.json +28 -4
- 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 +22 -0
- package/dist/stories/Cases.generated.stories.jsx +44 -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/Markdown.stories.d.ts +9 -0
- package/dist/stories/Markdown.stories.jsx +66 -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 +2 -0
- package/dist/stories/Popover.stories.jsx +33 -0
- package/dist/stories/StatTile.stories.d.ts +4 -0
- package/dist/stories/StatTile.stories.jsx +47 -2
- 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/dist/stories/Toaster.stories.d.ts +4 -0
- package/dist/stories/Toaster.stories.jsx +30 -0
- package/package.json +1 -1
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# Chart
|
|
2
|
+
|
|
3
|
+
A dashboard shows how a count moved over its range, day by day or week by week.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the rule 'A number shows its unit and never shows 0 for unknown'. The axis shows a number from 10,000 up in its short form, and the readout and the table show it exact.
|
|
8
|
+
- Put the chart in a `SettingsSection` under the stat row, and count it over the dashboard's one range, as the case 'Range switch' says. Name the range in the section's title: 'Comments this week'.
|
|
9
|
+
- Use `BarChart` for one count per day or week, and `LineChart` for one or two trends.
|
|
10
|
+
- Write the `summary` as one sentence that says what changed, from the same data: 'Comments rose from 40 on Nov 10 to 72 on Nov 16.'
|
|
11
|
+
- Pass the `unit` the chart counts, such as 'comments', so the readout says '58 comments'.
|
|
12
|
+
- Count by week when the range is long, and pass `labelHeader` 'Week of' for the table.
|
|
13
|
+
- Keep one unit per chart. Two series share it, such as 'opened' and 'done' threads.
|
|
14
|
+
- Pass `loading` while the range changes, so the plot holds its place. Pass `null` for a day with no data: it draws nothing and reads 'No data'.
|
|
15
|
+
- Keep 'Show Table' under every chart, so the exact values are one press away.
|
|
16
|
+
- Pass `emptyText` in the person's words when the range has no data at all, such as 'No comments this week'. Keep the section.
|
|
17
|
+
- Show a chart that could not load as the case 'Load failure' says: an inline error `Alert` 'Could not load comments' with 'Try Again' in its place. Keep the rest of the dashboard.
|
|
18
|
+
- Write the summary from the days with data. Leave out a day with no data, and never read it as 0.
|
|
19
|
+
|
|
20
|
+
## Don't
|
|
21
|
+
|
|
22
|
+
- Do not draw a pie, a donut, or a stacked or grouped bar. Show a split as the case 'Breakdown of a total' says.
|
|
23
|
+
- Do not put two units or two y scales in one chart.
|
|
24
|
+
- Do not add a third series. Split it into a second chart.
|
|
25
|
+
- Do not print a value on every bar. The readout and the table give each one.
|
|
26
|
+
- Do not use color to mean good or bad. More is not good or bad by itself.
|
|
27
|
+
- Do not draw a chart for one number. Use a `StatTile`, as the case 'Stat row' says.
|
|
28
|
+
|
|
29
|
+
## Option: Bars
|
|
30
|
+
|
|
31
|
+
Use when: One count per day or week over the range, such as comments per day.
|
|
32
|
+
|
|
33
|
+
Uses: `BarChart`, `Center`, `SegmentedControl`, `SettingsSection`, `Stack`, `TitleBar`, `formatCount`
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
'use client';
|
|
37
|
+
import { useEffect, useRef, useState } from 'react';
|
|
38
|
+
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
39
|
+
import SegmentedControl from 'oneslash-design-system/components/segmentedControl';
|
|
40
|
+
import SettingsSection from 'oneslash-design-system/components/settingsSection';
|
|
41
|
+
import BarChart from 'oneslash-design-system/components/barChart';
|
|
42
|
+
import { formatCount } from 'oneslash-design-system/components/formatNumber';
|
|
43
|
+
import { Center, Stack } from 'oneslash-design-system/components/layout';
|
|
44
|
+
|
|
45
|
+
type Range = 'week' | 'month' | 'quarter';
|
|
46
|
+
type Point = { label: string; value: number | null };
|
|
47
|
+
|
|
48
|
+
const ranges = [
|
|
49
|
+
{ value: 'week', label: 'Week' },
|
|
50
|
+
{ value: 'month', label: 'Month' },
|
|
51
|
+
{ value: 'quarter', label: 'Quarter' },
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
55
|
+
// 'Nov 14' for the day `back` days before Nov 16, 2026. Written from UTC, so the server and the browser agree.
|
|
56
|
+
function day(back: number) {
|
|
57
|
+
const d = new Date(Date.UTC(2026, 10, 16 - back));
|
|
58
|
+
return `${months[d.getUTCMonth()]} ${d.getUTCDate()}`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// A real app counts these on the server. The last seven days are the week.
|
|
62
|
+
const week = [40, 46, 38, 52, 58, 61, 72];
|
|
63
|
+
const month = [...Array.from({ length: 23 }, (_, i) => 28 + Math.round(i * 0.8) + ((i * 7) % 5) * 3), ...week];
|
|
64
|
+
// The quarter is counted by week: 13 weeks, the last from Nov 10 to Nov 16.
|
|
65
|
+
const quarter = [236, 251, 228, 262, 270, 249, 281, 290, 276, 302, 311, 334, 367];
|
|
66
|
+
|
|
67
|
+
const data: Record<Range, Point[]> = {
|
|
68
|
+
week: week.map((value, i) => ({ label: day(6 - i), value })),
|
|
69
|
+
month: month.map((value, i) => ({ label: day(29 - i), value })),
|
|
70
|
+
quarter: quarter.map((value, i) => ({ label: day(6 + (12 - i) * 7), value })),
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const noun: Record<Range, string> = { week: 'this week', month: 'this month', quarter: 'this quarter' };
|
|
74
|
+
|
|
75
|
+
// The summary says what changed, written from the same data the chart draws. A day with no data (null)
|
|
76
|
+
// is left out, never read as 0: the summary runs from the first day with data to the last.
|
|
77
|
+
function summary(points: Point[], range: Range) {
|
|
78
|
+
const known = points.filter((p): p is { label: string; value: number } => p.value !== null);
|
|
79
|
+
if (known.length === 0) return `No comments were counted ${noun[range]}.`;
|
|
80
|
+
const first = known[0];
|
|
81
|
+
const last = known[known.length - 1];
|
|
82
|
+
const when = (p: Point) => (range === 'quarter' ? `in the week of ${p.label}` : `on ${p.label}`);
|
|
83
|
+
if (known.length === 1) return `Comments were counted only ${when(first)}: ${formatCount(first.value)}.`;
|
|
84
|
+
const move = last.value > first.value ? 'rose' : last.value < first.value ? 'fell' : 'stayed';
|
|
85
|
+
return move === 'stayed'
|
|
86
|
+
? `Comments stayed at ${formatCount(first.value)} from ${first.label} to ${last.label}.`
|
|
87
|
+
: `Comments ${move} from ${formatCount(first.value)} ${when(first)} to ${formatCount(last.value)} ${when(last)}.`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default function ChartBars() {
|
|
91
|
+
const [range, setRange] = useState<Range>('week');
|
|
92
|
+
// The numbers load again when the range changes.
|
|
93
|
+
const [loading, setLoading] = useState(false);
|
|
94
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
95
|
+
|
|
96
|
+
// Stops the request if the example goes away before it ends.
|
|
97
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
98
|
+
|
|
99
|
+
function changeRange(next: string) {
|
|
100
|
+
clearTimeout(timer.current);
|
|
101
|
+
setRange(next as Range);
|
|
102
|
+
setLoading(true);
|
|
103
|
+
// Stands in for the request to the server.
|
|
104
|
+
timer.current = setTimeout(() => setLoading(false), 600);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const points = data[range];
|
|
108
|
+
// The total adds the days with data, and says so when a day has none.
|
|
109
|
+
const total = points.reduce((sum, p) => sum + (p.value ?? 0), 0);
|
|
110
|
+
const gap = points.some((p) => p.value === null);
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<Center width="page">
|
|
114
|
+
<Stack gap="xlarge">
|
|
115
|
+
{/* The dashboard's one range drives the chart too. Below md the switch takes its own line under the title. */}
|
|
116
|
+
<TitleBar
|
|
117
|
+
title="Dashboard"
|
|
118
|
+
actionsBelow
|
|
119
|
+
actions={<SegmentedControl size="small" width="fit" aria-label="Range" options={ranges} value={range} onChange={changeRange} />}
|
|
120
|
+
/>
|
|
121
|
+
<SettingsSection
|
|
122
|
+
title={`Comments ${noun[range]}`}
|
|
123
|
+
description={`${formatCount(total)} comments ${gap ? 'on the days with data ' : ''}from ${points[0].label} to Nov 16, 2026`}
|
|
124
|
+
id="chart-bars-comments"
|
|
125
|
+
>
|
|
126
|
+
<BarChart
|
|
127
|
+
id="chart-bars-per-day"
|
|
128
|
+
title={range === 'quarter' ? 'Comments per week' : 'Comments per day'}
|
|
129
|
+
summary={summary(points, range)}
|
|
130
|
+
data={points}
|
|
131
|
+
unit="comments"
|
|
132
|
+
labelHeader={range === 'quarter' ? 'Week of' : 'Date'}
|
|
133
|
+
loading={loading}
|
|
134
|
+
emptyText={`No comments ${noun[range]}`}
|
|
135
|
+
/>
|
|
136
|
+
</SettingsSection>
|
|
137
|
+
</Stack>
|
|
138
|
+
</Center>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Option: Lines
|
|
144
|
+
|
|
145
|
+
Use when: A trend over the range, one or two series in the same unit, such as threads opened and done.
|
|
146
|
+
|
|
147
|
+
Uses: `Center`, `LineChart`, `SegmentedControl`, `SettingsSection`, `Stack`, `TitleBar`, `formatCount`
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
'use client';
|
|
151
|
+
import { useEffect, useRef, useState } from 'react';
|
|
152
|
+
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
153
|
+
import SegmentedControl from 'oneslash-design-system/components/segmentedControl';
|
|
154
|
+
import SettingsSection from 'oneslash-design-system/components/settingsSection';
|
|
155
|
+
import LineChart from 'oneslash-design-system/components/lineChart';
|
|
156
|
+
import { formatCount } from 'oneslash-design-system/components/formatNumber';
|
|
157
|
+
import { Center, Stack } from 'oneslash-design-system/components/layout';
|
|
158
|
+
|
|
159
|
+
type Range = 'week' | 'month' | 'quarter';
|
|
160
|
+
type Counts = { labels: string[]; opened: number[]; done: number[] };
|
|
161
|
+
|
|
162
|
+
const ranges = [
|
|
163
|
+
{ value: 'week', label: 'Week' },
|
|
164
|
+
{ value: 'month', label: 'Month' },
|
|
165
|
+
{ value: 'quarter', label: 'Quarter' },
|
|
166
|
+
];
|
|
167
|
+
|
|
168
|
+
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
169
|
+
// 'Nov 14' for the day `back` days before Nov 16, 2026. Written from UTC, so the server and the browser agree.
|
|
170
|
+
function day(back: number) {
|
|
171
|
+
const d = new Date(Date.UTC(2026, 10, 16 - back));
|
|
172
|
+
return `${months[d.getUTCMonth()]} ${d.getUTCDate()}`;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// A real app counts these on the server. Both lines count threads, so they share one unit and one scale.
|
|
176
|
+
const openedMonth = Array.from({ length: 30 }, (_, i) => 18 + Math.round(i * 0.9) + ((i * 5) % 7));
|
|
177
|
+
const doneMonth = Array.from({ length: 30 }, (_, i) => 12 + Math.round(i * 0.8) + ((i * 3) % 5));
|
|
178
|
+
|
|
179
|
+
const data: Record<Range, Counts> = {
|
|
180
|
+
week: { labels: Array.from({ length: 7 }, (_, i) => day(6 - i)), opened: openedMonth.slice(23), done: doneMonth.slice(23) },
|
|
181
|
+
month: { labels: Array.from({ length: 30 }, (_, i) => day(29 - i)), opened: openedMonth, done: doneMonth },
|
|
182
|
+
// The quarter is counted by week: 13 weeks, the last from Nov 10 to Nov 16.
|
|
183
|
+
quarter: {
|
|
184
|
+
labels: Array.from({ length: 13 }, (_, i) => day(6 + (12 - i) * 7)),
|
|
185
|
+
opened: [150, 162, 158, 171, 166, 180, 177, 189, 196, 204, 199, 221, 238],
|
|
186
|
+
done: [131, 140, 149, 152, 160, 158, 169, 171, 180, 186, 192, 201, 214],
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const noun: Record<Range, string> = { week: 'this week', month: 'this month', quarter: 'this quarter' };
|
|
191
|
+
|
|
192
|
+
// The summary says what changed, written from the same data the chart draws.
|
|
193
|
+
function summary({ labels, opened, done }: Counts, range: Range) {
|
|
194
|
+
const when = (i: number) => (range === 'quarter' ? `in the week of ${labels[i]}` : `on ${labels[i]}`);
|
|
195
|
+
const last = labels.length - 1;
|
|
196
|
+
const move = (list: number[]) => (list[last] > list[0] ? 'rose' : list[last] < list[0] ? 'fell' : 'stayed');
|
|
197
|
+
return `Threads opened ${move(opened)} from ${formatCount(opened[0])} ${when(0)} to ${formatCount(opened[last])} ${when(last)}, and threads done ${move(done)} from ${formatCount(done[0])} to ${formatCount(done[last])}.`;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export default function ChartLines() {
|
|
201
|
+
// A trend needs more than a few points, so this chart opens on the month.
|
|
202
|
+
const [range, setRange] = useState<Range>('month');
|
|
203
|
+
// The numbers load again when the range changes.
|
|
204
|
+
const [loading, setLoading] = useState(false);
|
|
205
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
206
|
+
|
|
207
|
+
// Stops the request if the example goes away before it ends.
|
|
208
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
209
|
+
|
|
210
|
+
function changeRange(next: string) {
|
|
211
|
+
clearTimeout(timer.current);
|
|
212
|
+
setRange(next as Range);
|
|
213
|
+
setLoading(true);
|
|
214
|
+
// Stands in for the request to the server.
|
|
215
|
+
timer.current = setTimeout(() => setLoading(false), 600);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const counts = data[range];
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
<Center width="page">
|
|
222
|
+
<Stack gap="xlarge">
|
|
223
|
+
{/* The dashboard's one range drives the chart too. Below md the switch takes its own line under the title. */}
|
|
224
|
+
<TitleBar
|
|
225
|
+
title="Dashboard"
|
|
226
|
+
actionsBelow
|
|
227
|
+
actions={<SegmentedControl size="small" width="fit" aria-label="Range" options={ranges} value={range} onChange={changeRange} />}
|
|
228
|
+
/>
|
|
229
|
+
<SettingsSection
|
|
230
|
+
title={`Threads ${noun[range]}`}
|
|
231
|
+
description={`Opened and marked done, ${range === 'quarter' ? 'per week' : 'per day'}, from ${counts.labels[0]} to Nov 16, 2026`}
|
|
232
|
+
id="chart-lines-threads"
|
|
233
|
+
>
|
|
234
|
+
{/* Two series in one unit. A third would go in a chart of its own. */}
|
|
235
|
+
<LineChart
|
|
236
|
+
id="chart-lines-opened-done"
|
|
237
|
+
title={`Opened and done ${noun[range]}`}
|
|
238
|
+
summary={summary(counts, range)}
|
|
239
|
+
labels={counts.labels}
|
|
240
|
+
series={[
|
|
241
|
+
{ name: 'opened', values: counts.opened },
|
|
242
|
+
{ name: 'done', values: counts.done },
|
|
243
|
+
]}
|
|
244
|
+
unit="threads"
|
|
245
|
+
labelHeader={range === 'quarter' ? 'Week of' : 'Date'}
|
|
246
|
+
loading={loading}
|
|
247
|
+
emptyText={`No threads opened or done ${noun[range]}`}
|
|
248
|
+
/>
|
|
249
|
+
</SettingsSection>
|
|
250
|
+
</Stack>
|
|
251
|
+
</Center>
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Native
|
|
257
|
+
|
|
258
|
+
On Apple use Swift Charts: `BarMark` or `LineMark`, a dashed `lineStyle` for the second series, an `accessibilityLabel` and `accessibilityValue` per mark, and an audio graph through `AXChartDescriptor`. On Android, which has no system chart, draw on a `Canvas` with `semantics` per point, or show the table.
|
|
@@ -64,7 +64,7 @@ export default function CollapsibleSearchPopover() {
|
|
|
64
64
|
<EmptyBox size="large" icon="Search" text={"No invoices match \"".concat(words, "\"")} secondText="Check the spelling, or search for fewer words." action={<Button size="medium" type="secondary" state="enabled" label="Clear Search" onClickButton={clearSearch}/>}/>
|
|
65
65
|
</Surface>)}
|
|
66
66
|
</Stack>
|
|
67
|
-
<Popover open={open} anchorEl={anchor} onClose={function () { return setOpen(false); }} returnFocus>
|
|
67
|
+
<Popover open={open} anchorEl={anchor} onClose={function () { return setOpen(false); }} returnFocus aria-label="Search">
|
|
68
68
|
{/* Menu gives the Popover its surface and a width. It holds a field here, not items. */}
|
|
69
69
|
<Menu width={288}>
|
|
70
70
|
<TextField id="collapsible-search-query" type="search" size="small" autoFocus aria-label="Search invoices" placeholder="Search invoices" value={query} onChange={function (e) { return setQuery(e.target.value); }} onKeyDown={keyDown}/>
|
|
@@ -4,7 +4,7 @@ A person filters a list by a word, and the list should keep its room when they a
|
|
|
4
4
|
|
|
5
5
|
## Do
|
|
6
6
|
|
|
7
|
-
- Use an `IconButton` with `iconName="Search"` beside the list's heading, and open a `<Popover returnFocus>` with a search `TextField` from it.
|
|
7
|
+
- Use an `IconButton` with `iconName="Search"` beside the list's heading, and open a `<Popover returnFocus aria-label="Search">` with a search `TextField` from it.
|
|
8
8
|
- Keep the words in the page, not in the Popover. The list stays filtered while the Popover is closed.
|
|
9
9
|
- Show that a search is on: `color="secondary"` on the button, and a line such as '2 of 5 invoices match "north".'.
|
|
10
10
|
- Say the current search in the button's `ariaLabel`: 'Search: north'. It is plain 'Search' when no search is on.
|
|
@@ -117,7 +117,7 @@ export default function CollapsibleSearchPopover() {
|
|
|
117
117
|
</Surface>
|
|
118
118
|
)}
|
|
119
119
|
</Stack>
|
|
120
|
-
<Popover open={open} anchorEl={anchor} onClose={() => setOpen(false)} returnFocus>
|
|
120
|
+
<Popover open={open} anchorEl={anchor} onClose={() => setOpen(false)} returnFocus aria-label="Search">
|
|
121
121
|
{/* Menu gives the Popover its surface and a width. It holds a field here, not items. */}
|
|
122
122
|
<Menu width={288}>
|
|
123
123
|
<TextField
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function CommentThreadCard(): import("react").JSX.Element;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
import { useState } from 'react';
|
|
14
|
+
import Message from '../../components/message';
|
|
15
|
+
import UserImage from '../../components/userImage';
|
|
16
|
+
import Tag from '../../components/tag';
|
|
17
|
+
import Heading from '../../components/heading';
|
|
18
|
+
import Paragraph from '../../components/paragraph';
|
|
19
|
+
import Link from '../../components/link';
|
|
20
|
+
import IconButton from '../../components/iconButton';
|
|
21
|
+
import Tooltip from '../../components/tooltip';
|
|
22
|
+
import Popover from '../../components/popover';
|
|
23
|
+
import Alert from '../../components/alert';
|
|
24
|
+
import Menu from '../../components/menu';
|
|
25
|
+
import MenuItem from '../../components/menuItem';
|
|
26
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
27
|
+
var firstComments = [
|
|
28
|
+
{
|
|
29
|
+
id: 'c1',
|
|
30
|
+
from: 'Ben Carter',
|
|
31
|
+
when: 'Nov 16, 2026, 2:40 PM',
|
|
32
|
+
text: 'The headline wraps to three lines on a phone, and the sign-up button drops below the fold. Can we cut the headline to one line there, or make the type a size smaller? I would rather keep the button in view than keep every word.',
|
|
33
|
+
place: 'Homepage design, frame Hero',
|
|
34
|
+
replies: 2,
|
|
35
|
+
unread: true,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 'c2',
|
|
39
|
+
from: 'Omar Reyes',
|
|
40
|
+
when: 'Nov 16, 2026, 11:15 AM',
|
|
41
|
+
text: 'The Team plan should read $25 per seat, not $25.',
|
|
42
|
+
place: 'Homepage design, frame Pricing',
|
|
43
|
+
replies: 1,
|
|
44
|
+
done: true,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'c3',
|
|
48
|
+
from: 'Mia Park',
|
|
49
|
+
when: 'Nov 15, 2026, 4:30 PM',
|
|
50
|
+
text: 'The footer links need more room between them on a phone.',
|
|
51
|
+
place: 'Homepage design, frame Footer',
|
|
52
|
+
replies: 0,
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
// The card shows about three lines. The caller cuts the text at a word, and the thread shows it in full.
|
|
56
|
+
function excerpt(text, max) {
|
|
57
|
+
if (max === void 0) { max = 160; }
|
|
58
|
+
if (text.length <= max)
|
|
59
|
+
return text;
|
|
60
|
+
return "".concat(text.slice(0, text.lastIndexOf(' ', max)), "\u2026");
|
|
61
|
+
}
|
|
62
|
+
function repliesLine(n) {
|
|
63
|
+
if (n === 0)
|
|
64
|
+
return 'No replies yet';
|
|
65
|
+
return "".concat(n, " ").concat(n === 1 ? 'reply' : 'replies');
|
|
66
|
+
}
|
|
67
|
+
export default function CommentThreadCard() {
|
|
68
|
+
var _a = useState(firstComments), comments = _a[0], setComments = _a[1];
|
|
69
|
+
// The comment whose menu is open, and the More button it opens from. Both stay set while the menu fades out.
|
|
70
|
+
var _b = useState(null), menuId = _b[0], setMenuId = _b[1];
|
|
71
|
+
var _c = useState(null), menuAnchor = _c[0], setMenuAnchor = _c[1];
|
|
72
|
+
var _d = useState(false), menuOpen = _d[0], setMenuOpen = _d[1];
|
|
73
|
+
// What the polite line says after Mark Done or Reopen. The count gives each change a fresh line, so it is read again.
|
|
74
|
+
var _e = useState(null), said = _e[0], setSaid = _e[1];
|
|
75
|
+
var menuComment = comments.find(function (c) { return c.id === menuId; });
|
|
76
|
+
function openMenu(c, anchor) {
|
|
77
|
+
if (menuOpen && menuId === c.id) {
|
|
78
|
+
setMenuOpen(false);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
setMenuId(c.id);
|
|
82
|
+
setMenuAnchor(anchor);
|
|
83
|
+
setMenuOpen(true);
|
|
84
|
+
}
|
|
85
|
+
// Every item closes the menu, and the Popover gives focus back to More. The change shows on the card.
|
|
86
|
+
function choose(change) {
|
|
87
|
+
var id = menuId;
|
|
88
|
+
setMenuOpen(false);
|
|
89
|
+
// A real app sends the change to the server here.
|
|
90
|
+
setComments(function (list) { return list.map(function (c) { return (c.id === id ? __assign(__assign({}, c), change(c)) : c); }); });
|
|
91
|
+
}
|
|
92
|
+
// Focus goes back to More, whose name does not change, so the polite line says what happened.
|
|
93
|
+
function toggleDone() {
|
|
94
|
+
var wasDone = !!(menuComment === null || menuComment === void 0 ? void 0 : menuComment.done);
|
|
95
|
+
choose(function (c) { return ({ done: !c.done }); });
|
|
96
|
+
setSaid(function (s) { var _a; return ({ text: wasDone ? 'Reopened.' : 'Marked done.', n: ((_a = s === null || s === void 0 ? void 0 : s.n) !== null && _a !== void 0 ? _a : 0) + 1 }); });
|
|
97
|
+
}
|
|
98
|
+
return (<Center width="page">
|
|
99
|
+
<Stack gap="large">
|
|
100
|
+
<Heading level={1} size="h5">Comments</Heading>
|
|
101
|
+
{said && (
|
|
102
|
+
// An inline Alert is a polite status. It leaves after 5 seconds; the card's Tag still shows the state.
|
|
103
|
+
<Alert key={said.n} variant="inline" type="success" message={said.text} onClose={function () { return setSaid(null); }}/>)}
|
|
104
|
+
{/* A real app gives the list that holds the cards role="feed". */}
|
|
105
|
+
<Stack gap="medium">
|
|
106
|
+
{comments.map(function (c) { return (<Message key={c.id} aria-label={c.unread ? "Unread comment from ".concat(c.from) : "Comment from ".concat(c.from)} avatar={<UserImage userHandle={c.from} decorative/>} name={c.from} meta={<>
|
|
107
|
+
{/* Cards span days, so each says its date and time in full, written by the app. */}
|
|
108
|
+
<Paragraph size="caption" tone="secondary" measure="none">{c.when}</Paragraph>
|
|
109
|
+
{c.unread && <Tag variant="dot" size="small" color="info" label="Unread"/>}
|
|
110
|
+
{c.done && <Tag variant="textOnly" size="small" label="Done"/>}
|
|
111
|
+
{c.saved && <Tag variant="textOnly" size="small" label="Saved"/>}
|
|
112
|
+
</>} footer={<Stack gap="small">
|
|
113
|
+
<Paragraph size="body2" tone="secondary" measure="none">{c.place}</Paragraph>
|
|
114
|
+
{c.reacted && (<Cluster>
|
|
115
|
+
<Tag variant="contained" size="small" state="selected" label="👍 1" aria-label="Thumbs up, 1 reaction"/>
|
|
116
|
+
</Cluster>)}
|
|
117
|
+
{/* The link opens the thread. The card itself is not a button. */}
|
|
118
|
+
<Cluster gap="small">
|
|
119
|
+
<Link href={"/comments/".concat(c.id)} size="body2">Open thread from {c.from}</Link>
|
|
120
|
+
<Paragraph size="body2" tone="secondary" measure="none">{repliesLine(c.replies)}</Paragraph>
|
|
121
|
+
</Cluster>
|
|
122
|
+
</Stack>}
|
|
123
|
+
// One More button, in the tab order. It stays on screen while its menu is open.
|
|
124
|
+
actionsVisible={menuOpen && menuId === c.id} actions={<Tooltip title="More">
|
|
125
|
+
<IconButton color="iconOnly" state={menuOpen && menuId === c.id ? 'selected' : 'enabled'} size="small" iconName="Ellipsis" ariaLabel={"More actions for comment from ".concat(c.from)} aria-haspopup="menu" aria-expanded={menuOpen && menuId === c.id} onClick={function (e) { return openMenu(c, e.currentTarget); }}/>
|
|
126
|
+
</Tooltip>}>
|
|
127
|
+
<Paragraph measure="none">{excerpt(c.text)}</Paragraph>
|
|
128
|
+
</Message>); })}
|
|
129
|
+
</Stack>
|
|
130
|
+
</Stack>
|
|
131
|
+
{/* A navigable Menu focuses its first item and takes the arrow keys, Home, End and letters. */}
|
|
132
|
+
<Popover open={menuOpen} anchorEl={menuAnchor} onClose={function () { return setMenuOpen(false); }} returnFocus>
|
|
133
|
+
<Menu navigable aria-label="Comment actions" width={200}>
|
|
134
|
+
<MenuItem size="small" iconName="SmilePlus" label={(menuComment === null || menuComment === void 0 ? void 0 : menuComment.reacted) ? 'Remove Reaction' : 'Add Reaction'} onClick={function () { return choose(function (c) { return ({ reacted: !c.reacted }); }); }}/>
|
|
135
|
+
<MenuItem size="small" iconName="Bookmark" label={(menuComment === null || menuComment === void 0 ? void 0 : menuComment.saved) ? 'Remove from Saved' : 'Save'} onClick={function () { return choose(function (c) { return ({ saved: !c.saved }); }); }}/>
|
|
136
|
+
<MenuItem size="small" iconName="Check" label={(menuComment === null || menuComment === void 0 ? void 0 : menuComment.done) ? 'Reopen' : 'Mark Done'} onClick={toggleDone}/>
|
|
137
|
+
{(menuComment === null || menuComment === void 0 ? void 0 : menuComment.unread) && <MenuItem size="small" iconName="MailOpen" label="Mark as Read" onClick={function () { return choose(function () { return ({ unread: false }); }); }}/>}
|
|
138
|
+
</Menu>
|
|
139
|
+
</Popover>
|
|
140
|
+
</Center>);
|
|
141
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function CommentThreadThread(): import("react").JSX.Element;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
import { useState } from 'react';
|
|
12
|
+
import Message from '../../components/message';
|
|
13
|
+
import UserImage from '../../components/userImage';
|
|
14
|
+
import Tag from '../../components/tag';
|
|
15
|
+
import TimeStamp from '../../components/timeStamp';
|
|
16
|
+
import Heading from '../../components/heading';
|
|
17
|
+
import Paragraph from '../../components/paragraph';
|
|
18
|
+
import TitleBar from '../../components/titleBar';
|
|
19
|
+
import Button from '../../components/button';
|
|
20
|
+
import Composer from '../../components/composer';
|
|
21
|
+
import Alert from '../../components/alert';
|
|
22
|
+
import { Center, Stack } from '../../components/layout';
|
|
23
|
+
// A real app reads this from the session.
|
|
24
|
+
var me = 'Dana Lee';
|
|
25
|
+
var comment = {
|
|
26
|
+
from: 'Ben Carter',
|
|
27
|
+
at: new Date('2026-11-16T14:40:00Z'),
|
|
28
|
+
text: 'The headline wraps to three lines on a phone, and the sign-up button drops below the fold. Can we cut the headline to one line there, or make the type a size smaller? I would rather keep the button in view than keep every word.',
|
|
29
|
+
place: 'Homepage design, frame Hero',
|
|
30
|
+
};
|
|
31
|
+
var firstReplies = [
|
|
32
|
+
{ id: 'r1', from: 'Omar Reyes', at: new Date('2026-11-16T14:52:00Z'), text: 'I can cut it to "Plan your launch in one place." That fits on one line on a phone.' },
|
|
33
|
+
{ id: 'r2', from: 'Ben Carter', at: new Date('2026-11-16T15:01:00Z'), text: 'That works for me.' },
|
|
34
|
+
{ id: 'r3', from: 'Ben Carter', at: new Date('2026-11-16T15:02:00Z'), text: 'Keep the type size as it is, then.' },
|
|
35
|
+
];
|
|
36
|
+
// A reply is compact when the one above is from the same person, on the same day and less than 5 minutes older.
|
|
37
|
+
function isFollowOn(list, i) {
|
|
38
|
+
var above = list[i - 1];
|
|
39
|
+
if (!above || above.from !== list[i].from)
|
|
40
|
+
return false;
|
|
41
|
+
var sameDay = above.at.toDateString() === list[i].at.toDateString();
|
|
42
|
+
return sameDay && list[i].at.getTime() - above.at.getTime() < 5 * 60 * 1000;
|
|
43
|
+
}
|
|
44
|
+
export default function CommentThreadThread() {
|
|
45
|
+
var _a = useState(firstReplies), replies = _a[0], setReplies = _a[1];
|
|
46
|
+
var _b = useState(''), text = _b[0], setText = _b[1];
|
|
47
|
+
var _c = useState(false), done = _c[0], setDone = _c[1];
|
|
48
|
+
// What the polite line says after the last press. The count gives each press a fresh line, so it is read again.
|
|
49
|
+
var _d = useState(null), said = _d[0], setSaid = _d[1];
|
|
50
|
+
// A real app sends the change to the server here. The Button keeps focus as its label changes,
|
|
51
|
+
// and a screen reader may not read that new name, so the polite line says it.
|
|
52
|
+
function toggleDone() {
|
|
53
|
+
setDone(!done);
|
|
54
|
+
setSaid(function (s) { var _a; return ({ text: done ? 'Reopened.' : 'Marked done.', n: ((_a = s === null || s === void 0 ? void 0 : s.n) !== null && _a !== void 0 ? _a : 0) + 1 }); });
|
|
55
|
+
}
|
|
56
|
+
function send() {
|
|
57
|
+
// A real app sends the reply to the server here and shows it at once.
|
|
58
|
+
setReplies(function (list) { return __spreadArray(__spreadArray([], list, true), [{ id: "r".concat(list.length + 1), from: me, at: new Date('2026-11-16T15:10:00Z'), text: text.trim() }], false); });
|
|
59
|
+
setText('');
|
|
60
|
+
}
|
|
61
|
+
return (<Center width="page">
|
|
62
|
+
<Stack gap="large">
|
|
63
|
+
<Heading level={1} size="h5">Comments</Heading>
|
|
64
|
+
{/* On a phone the thread takes the screen, so Back goes to the list. From md a real app shows the list beside it and leaves Back out. */}
|
|
65
|
+
<TitleBar level={2} title="Thread" back={<Button size="small" type="tertiary" state="enabled" decoIcon="ChevronLeft" label="Back to Comments"/>} meta={<>
|
|
66
|
+
{comment.place}
|
|
67
|
+
{done && <Tag variant="textOnly" size="small" label="Done"/>}
|
|
68
|
+
</>} actions={<Button size="small" type="secondary" state="enabled" label={done ? 'Reopen' : 'Mark Done'} onClickButton={toggleDone}/>}/>
|
|
69
|
+
{said && (
|
|
70
|
+
// An inline Alert is a polite status. It leaves after 5 seconds; the Tag and the Button still show the state.
|
|
71
|
+
<Alert key={said.n} variant="inline" type="success" message={said.text} onClose={function () { return setSaid(null); }}/>)}
|
|
72
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
73
|
+
<Stack gap="small">
|
|
74
|
+
<Message aria-label={comment.from} avatar={<UserImage userHandle={comment.from} decorative/>} name={comment.from} meta={<TimeStamp createdAt={comment.at} dateFormat="absolute" data="time"/>}>
|
|
75
|
+
<Paragraph measure="none">{comment.text}</Paragraph>
|
|
76
|
+
</Message>
|
|
77
|
+
{replies.map(function (r, i) {
|
|
78
|
+
var compact = isFollowOn(replies, i);
|
|
79
|
+
return (<Message key={r.id} compact={compact} aria-label={r.from} avatar={compact ? undefined : <UserImage userHandle={r.from} decorative/>} name={compact ? undefined : r.from} meta={compact ? undefined : <TimeStamp createdAt={r.at} dateFormat="absolute" data="time"/>}>
|
|
80
|
+
<Paragraph measure="none">{r.text}</Paragraph>
|
|
81
|
+
</Message>);
|
|
82
|
+
})}
|
|
83
|
+
</Stack>
|
|
84
|
+
<Composer id="comment-thread-reply" aria-label={"Reply to ".concat(comment.from)} placeholder={"Reply to ".concat(comment.from)} value={text} onChange={setText} onSubmit={send}/>
|
|
85
|
+
</Stack>
|
|
86
|
+
</Center>);
|
|
87
|
+
}
|