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,349 @@
|
|
|
1
|
+
# Comment and thread
|
|
2
|
+
|
|
3
|
+
A person reads comments left on a piece of work, opens one, and reads and answers its thread.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the cases 'Message row' and 'Message composer'.
|
|
8
|
+
- Show each comment as a `Message`: the face, the name, then the time and any state in `meta`, such as a text `Tag` 'Done'.
|
|
9
|
+
- Write a card's date and time in full, such as 'Nov 16, 2026, 2:40 PM', since a list of cards spans days.
|
|
10
|
+
- Say where the comment is, in a secondary line under the text: 'Homepage design, frame Hero'.
|
|
11
|
+
- Cut a long comment to about three lines in the text you pass, and show it in full in the thread.
|
|
12
|
+
- Open the thread from a link in the card, named for whose it is: 'Open thread from Ben Carter'. Say how many replies it has beside it.
|
|
13
|
+
- Put the card's actions in a More menu, as the case 'Message actions' says: `<Popover returnFocus>` around `<Menu navigable aria-label="Comment actions">`. The More button is in the tab order, so a keyboard always reaches it.
|
|
14
|
+
- Mark an unread comment with a dot `Tag` 'Unread' in `info`, as the case 'Admin inbox' does, and say it in the row's `aria-label`: 'Unread comment from Ben Carter'.
|
|
15
|
+
- Title the open thread with `TitleBar level={2}` 'Thread' under the page's level 1 heading. On a phone, where it takes the screen, pass `back` 'Back to Comments'.
|
|
16
|
+
- Give the thread a secondary 'Mark Done'. Once done it reads 'Reopen', and a text `Tag` 'Done' shows in the `meta` line.
|
|
17
|
+
- Announce the change politely: the app says 'Marked done.' or 'Reopened.' in a polite live region, since a screen reader may not read a Button's new name while it has focus. Do the same when the change comes from the card's menu. Show no toast, since the change is in view.
|
|
18
|
+
- Show the first comment in full, then the replies in order. Make a reply `compact` when the reply above is from the same person, as the case 'Message row' says.
|
|
19
|
+
- Put a `Composer` under the replies, named for who reads it: 'Reply to Ben Carter'. Add the reply to the thread at once and empty the box.
|
|
20
|
+
|
|
21
|
+
## Don't
|
|
22
|
+
|
|
23
|
+
- Do not show the actions on pointer hover only. A keyboard and a touch screen must reach them too.
|
|
24
|
+
- Do not make the whole card one clickable box. Its link opens the thread, and its buttons stay their own.
|
|
25
|
+
- Do not mark unread with bold text alone. Show the word.
|
|
26
|
+
- Do not leave out where the comment is. A comment about a frame means little without it.
|
|
27
|
+
- Do not group replies from two people into one row.
|
|
28
|
+
|
|
29
|
+
## Option: Comment cards
|
|
30
|
+
|
|
31
|
+
Use when: Comments show in a list or a feed, and each one opens its thread.
|
|
32
|
+
|
|
33
|
+
Uses: `Alert`, `Center`, `Cluster`, `Heading`, `IconButton`, `Link`, `Menu`, `MenuItem`, `Message`, `Paragraph`, `Popover`, `Stack`, `Tag`, `Tooltip`, `UserImage`
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
'use client';
|
|
37
|
+
import { useState } from 'react';
|
|
38
|
+
import Message from 'oneslash-design-system/components/message';
|
|
39
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
40
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
41
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
42
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
43
|
+
import Link from 'oneslash-design-system/components/link';
|
|
44
|
+
import IconButton from 'oneslash-design-system/components/iconButton';
|
|
45
|
+
import Tooltip from 'oneslash-design-system/components/tooltip';
|
|
46
|
+
import Popover from 'oneslash-design-system/components/popover';
|
|
47
|
+
import Alert from 'oneslash-design-system/components/alert';
|
|
48
|
+
import Menu from 'oneslash-design-system/components/menu';
|
|
49
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
50
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
51
|
+
|
|
52
|
+
type Comment = {
|
|
53
|
+
id: string;
|
|
54
|
+
from: string;
|
|
55
|
+
when: string;
|
|
56
|
+
text: string;
|
|
57
|
+
place: string;
|
|
58
|
+
replies: number;
|
|
59
|
+
unread?: boolean;
|
|
60
|
+
done?: boolean;
|
|
61
|
+
saved?: boolean;
|
|
62
|
+
reacted?: boolean;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const firstComments: Comment[] = [
|
|
66
|
+
{
|
|
67
|
+
id: 'c1',
|
|
68
|
+
from: 'Ben Carter',
|
|
69
|
+
when: 'Nov 16, 2026, 2:40 PM',
|
|
70
|
+
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.',
|
|
71
|
+
place: 'Homepage design, frame Hero',
|
|
72
|
+
replies: 2,
|
|
73
|
+
unread: true,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: 'c2',
|
|
77
|
+
from: 'Omar Reyes',
|
|
78
|
+
when: 'Nov 16, 2026, 11:15 AM',
|
|
79
|
+
text: 'The Team plan should read $25 per seat, not $25.',
|
|
80
|
+
place: 'Homepage design, frame Pricing',
|
|
81
|
+
replies: 1,
|
|
82
|
+
done: true,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: 'c3',
|
|
86
|
+
from: 'Mia Park',
|
|
87
|
+
when: 'Nov 15, 2026, 4:30 PM',
|
|
88
|
+
text: 'The footer links need more room between them on a phone.',
|
|
89
|
+
place: 'Homepage design, frame Footer',
|
|
90
|
+
replies: 0,
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
|
|
94
|
+
// The card shows about three lines. The caller cuts the text at a word, and the thread shows it in full.
|
|
95
|
+
function excerpt(text: string, max = 160) {
|
|
96
|
+
if (text.length <= max) return text;
|
|
97
|
+
return `${text.slice(0, text.lastIndexOf(' ', max))}…`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function repliesLine(n: number) {
|
|
101
|
+
if (n === 0) return 'No replies yet';
|
|
102
|
+
return `${n} ${n === 1 ? 'reply' : 'replies'}`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export default function CommentThreadCard() {
|
|
106
|
+
const [comments, setComments] = useState(firstComments);
|
|
107
|
+
// The comment whose menu is open, and the More button it opens from. Both stay set while the menu fades out.
|
|
108
|
+
const [menuId, setMenuId] = useState<string | null>(null);
|
|
109
|
+
const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null);
|
|
110
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
111
|
+
// What the polite line says after Mark Done or Reopen. The count gives each change a fresh line, so it is read again.
|
|
112
|
+
const [said, setSaid] = useState<{ text: string; n: number } | null>(null);
|
|
113
|
+
|
|
114
|
+
const menuComment = comments.find((c) => c.id === menuId);
|
|
115
|
+
|
|
116
|
+
function openMenu(c: Comment, anchor: HTMLElement) {
|
|
117
|
+
if (menuOpen && menuId === c.id) {
|
|
118
|
+
setMenuOpen(false);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
setMenuId(c.id);
|
|
122
|
+
setMenuAnchor(anchor);
|
|
123
|
+
setMenuOpen(true);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Every item closes the menu, and the Popover gives focus back to More. The change shows on the card.
|
|
127
|
+
function choose(change: (c: Comment) => Partial<Comment>) {
|
|
128
|
+
const id = menuId;
|
|
129
|
+
setMenuOpen(false);
|
|
130
|
+
// A real app sends the change to the server here.
|
|
131
|
+
setComments((list) => list.map((c) => (c.id === id ? { ...c, ...change(c) } : c)));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Focus goes back to More, whose name does not change, so the polite line says what happened.
|
|
135
|
+
function toggleDone() {
|
|
136
|
+
const wasDone = !!menuComment?.done;
|
|
137
|
+
choose((c) => ({ done: !c.done }));
|
|
138
|
+
setSaid((s) => ({ text: wasDone ? 'Reopened.' : 'Marked done.', n: (s?.n ?? 0) + 1 }));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<Center width="page">
|
|
143
|
+
<Stack gap="large">
|
|
144
|
+
<Heading level={1} size="h5">Comments</Heading>
|
|
145
|
+
{said && (
|
|
146
|
+
// An inline Alert is a polite status. It leaves after 5 seconds; the card's Tag still shows the state.
|
|
147
|
+
<Alert key={said.n} variant="inline" type="success" message={said.text} onClose={() => setSaid(null)} />
|
|
148
|
+
)}
|
|
149
|
+
{/* A real app gives the list that holds the cards role="feed". */}
|
|
150
|
+
<Stack gap="medium">
|
|
151
|
+
{comments.map((c) => (
|
|
152
|
+
<Message
|
|
153
|
+
key={c.id}
|
|
154
|
+
aria-label={c.unread ? `Unread comment from ${c.from}` : `Comment from ${c.from}`}
|
|
155
|
+
avatar={<UserImage userHandle={c.from} decorative />}
|
|
156
|
+
name={c.from}
|
|
157
|
+
meta={
|
|
158
|
+
<>
|
|
159
|
+
{/* Cards span days, so each says its date and time in full, written by the app. */}
|
|
160
|
+
<Paragraph size="caption" tone="secondary" measure="none">{c.when}</Paragraph>
|
|
161
|
+
{c.unread && <Tag variant="dot" size="small" color="info" label="Unread" />}
|
|
162
|
+
{c.done && <Tag variant="textOnly" size="small" label="Done" />}
|
|
163
|
+
{c.saved && <Tag variant="textOnly" size="small" label="Saved" />}
|
|
164
|
+
</>
|
|
165
|
+
}
|
|
166
|
+
footer={
|
|
167
|
+
<Stack gap="small">
|
|
168
|
+
<Paragraph size="body2" tone="secondary" measure="none">{c.place}</Paragraph>
|
|
169
|
+
{c.reacted && (
|
|
170
|
+
<Cluster>
|
|
171
|
+
<Tag variant="contained" size="small" state="selected" label="👍 1" aria-label="Thumbs up, 1 reaction" />
|
|
172
|
+
</Cluster>
|
|
173
|
+
)}
|
|
174
|
+
{/* The link opens the thread. The card itself is not a button. */}
|
|
175
|
+
<Cluster gap="small">
|
|
176
|
+
<Link href={`/comments/${c.id}`} size="body2">Open thread from {c.from}</Link>
|
|
177
|
+
<Paragraph size="body2" tone="secondary" measure="none">{repliesLine(c.replies)}</Paragraph>
|
|
178
|
+
</Cluster>
|
|
179
|
+
</Stack>
|
|
180
|
+
}
|
|
181
|
+
// One More button, in the tab order. It stays on screen while its menu is open.
|
|
182
|
+
actionsVisible={menuOpen && menuId === c.id}
|
|
183
|
+
actions={
|
|
184
|
+
<Tooltip title="More">
|
|
185
|
+
<IconButton
|
|
186
|
+
color="iconOnly"
|
|
187
|
+
state={menuOpen && menuId === c.id ? 'selected' : 'enabled'}
|
|
188
|
+
size="small"
|
|
189
|
+
iconName="Ellipsis"
|
|
190
|
+
ariaLabel={`More actions for comment from ${c.from}`}
|
|
191
|
+
aria-haspopup="menu"
|
|
192
|
+
aria-expanded={menuOpen && menuId === c.id}
|
|
193
|
+
onClick={(e: { currentTarget: HTMLElement }) => openMenu(c, e.currentTarget)}
|
|
194
|
+
/>
|
|
195
|
+
</Tooltip>
|
|
196
|
+
}
|
|
197
|
+
>
|
|
198
|
+
<Paragraph measure="none">{excerpt(c.text)}</Paragraph>
|
|
199
|
+
</Message>
|
|
200
|
+
))}
|
|
201
|
+
</Stack>
|
|
202
|
+
</Stack>
|
|
203
|
+
{/* A navigable Menu focuses its first item and takes the arrow keys, Home, End and letters. */}
|
|
204
|
+
<Popover open={menuOpen} anchorEl={menuAnchor} onClose={() => setMenuOpen(false)} returnFocus>
|
|
205
|
+
<Menu navigable aria-label="Comment actions" width={200}>
|
|
206
|
+
<MenuItem size="small" iconName="SmilePlus" label={menuComment?.reacted ? 'Remove Reaction' : 'Add Reaction'} onClick={() => choose((c) => ({ reacted: !c.reacted }))} />
|
|
207
|
+
<MenuItem size="small" iconName="Bookmark" label={menuComment?.saved ? 'Remove from Saved' : 'Save'} onClick={() => choose((c) => ({ saved: !c.saved }))} />
|
|
208
|
+
<MenuItem size="small" iconName="Check" label={menuComment?.done ? 'Reopen' : 'Mark Done'} onClick={toggleDone} />
|
|
209
|
+
{menuComment?.unread && <MenuItem size="small" iconName="MailOpen" label="Mark as Read" onClick={() => choose(() => ({ unread: false }))} />}
|
|
210
|
+
</Menu>
|
|
211
|
+
</Popover>
|
|
212
|
+
</Center>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Option: Open thread
|
|
218
|
+
|
|
219
|
+
Use when: One thread is open, with its replies and a reply box.
|
|
220
|
+
|
|
221
|
+
Uses: `Alert`, `Button`, `Center`, `Composer`, `Heading`, `Message`, `Paragraph`, `Stack`, `Tag`, `TimeStamp`, `TitleBar`, `UserImage`
|
|
222
|
+
|
|
223
|
+
```tsx
|
|
224
|
+
'use client';
|
|
225
|
+
import { useState } from 'react';
|
|
226
|
+
import Message from 'oneslash-design-system/components/message';
|
|
227
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
228
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
229
|
+
import TimeStamp from 'oneslash-design-system/components/timeStamp';
|
|
230
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
231
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
232
|
+
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
233
|
+
import Button from 'oneslash-design-system/components/button';
|
|
234
|
+
import Composer from 'oneslash-design-system/components/composer';
|
|
235
|
+
import Alert from 'oneslash-design-system/components/alert';
|
|
236
|
+
import { Center, Stack } from 'oneslash-design-system/components/layout';
|
|
237
|
+
|
|
238
|
+
// A real app reads this from the session.
|
|
239
|
+
const me = 'Dana Lee';
|
|
240
|
+
|
|
241
|
+
type Reply = { id: string; from: string; at: Date; text: string };
|
|
242
|
+
|
|
243
|
+
const comment = {
|
|
244
|
+
from: 'Ben Carter',
|
|
245
|
+
at: new Date('2026-11-16T14:40:00Z'),
|
|
246
|
+
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.',
|
|
247
|
+
place: 'Homepage design, frame Hero',
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const firstReplies: Reply[] = [
|
|
251
|
+
{ 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.' },
|
|
252
|
+
{ id: 'r2', from: 'Ben Carter', at: new Date('2026-11-16T15:01:00Z'), text: 'That works for me.' },
|
|
253
|
+
{ id: 'r3', from: 'Ben Carter', at: new Date('2026-11-16T15:02:00Z'), text: 'Keep the type size as it is, then.' },
|
|
254
|
+
];
|
|
255
|
+
|
|
256
|
+
// A reply is compact when the one above is from the same person, on the same day and less than 5 minutes older.
|
|
257
|
+
function isFollowOn(list: Reply[], i: number) {
|
|
258
|
+
const above = list[i - 1];
|
|
259
|
+
if (!above || above.from !== list[i].from) return false;
|
|
260
|
+
const sameDay = above.at.toDateString() === list[i].at.toDateString();
|
|
261
|
+
return sameDay && list[i].at.getTime() - above.at.getTime() < 5 * 60 * 1000;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export default function CommentThreadThread() {
|
|
265
|
+
const [replies, setReplies] = useState(firstReplies);
|
|
266
|
+
const [text, setText] = useState('');
|
|
267
|
+
const [done, setDone] = useState(false);
|
|
268
|
+
// What the polite line says after the last press. The count gives each press a fresh line, so it is read again.
|
|
269
|
+
const [said, setSaid] = useState<{ text: string; n: number } | null>(null);
|
|
270
|
+
|
|
271
|
+
// A real app sends the change to the server here. The Button keeps focus as its label changes,
|
|
272
|
+
// and a screen reader may not read that new name, so the polite line says it.
|
|
273
|
+
function toggleDone() {
|
|
274
|
+
setDone(!done);
|
|
275
|
+
setSaid((s) => ({ text: done ? 'Reopened.' : 'Marked done.', n: (s?.n ?? 0) + 1 }));
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function send() {
|
|
279
|
+
// A real app sends the reply to the server here and shows it at once.
|
|
280
|
+
setReplies((list) => [...list, { id: `r${list.length + 1}`, from: me, at: new Date('2026-11-16T15:10:00Z'), text: text.trim() }]);
|
|
281
|
+
setText('');
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return (
|
|
285
|
+
<Center width="page">
|
|
286
|
+
<Stack gap="large">
|
|
287
|
+
<Heading level={1} size="h5">Comments</Heading>
|
|
288
|
+
{/* 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. */}
|
|
289
|
+
<TitleBar
|
|
290
|
+
level={2}
|
|
291
|
+
title="Thread"
|
|
292
|
+
back={<Button size="small" type="tertiary" state="enabled" decoIcon="ChevronLeft" label="Back to Comments" />}
|
|
293
|
+
meta={
|
|
294
|
+
<>
|
|
295
|
+
{comment.place}
|
|
296
|
+
{done && <Tag variant="textOnly" size="small" label="Done" />}
|
|
297
|
+
</>
|
|
298
|
+
}
|
|
299
|
+
actions={
|
|
300
|
+
<Button size="small" type="secondary" state="enabled" label={done ? 'Reopen' : 'Mark Done'} onClickButton={toggleDone} />
|
|
301
|
+
}
|
|
302
|
+
/>
|
|
303
|
+
{said && (
|
|
304
|
+
// An inline Alert is a polite status. It leaves after 5 seconds; the Tag and the Button still show the state.
|
|
305
|
+
<Alert key={said.n} variant="inline" type="success" message={said.text} onClose={() => setSaid(null)} />
|
|
306
|
+
)}
|
|
307
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
308
|
+
<Stack gap="small">
|
|
309
|
+
<Message
|
|
310
|
+
aria-label={comment.from}
|
|
311
|
+
avatar={<UserImage userHandle={comment.from} decorative />}
|
|
312
|
+
name={comment.from}
|
|
313
|
+
meta={<TimeStamp createdAt={comment.at} dateFormat="absolute" data="time" />}
|
|
314
|
+
>
|
|
315
|
+
<Paragraph measure="none">{comment.text}</Paragraph>
|
|
316
|
+
</Message>
|
|
317
|
+
{replies.map((r, i) => {
|
|
318
|
+
const compact = isFollowOn(replies, i);
|
|
319
|
+
return (
|
|
320
|
+
<Message
|
|
321
|
+
key={r.id}
|
|
322
|
+
compact={compact}
|
|
323
|
+
aria-label={r.from}
|
|
324
|
+
avatar={compact ? undefined : <UserImage userHandle={r.from} decorative />}
|
|
325
|
+
name={compact ? undefined : r.from}
|
|
326
|
+
meta={compact ? undefined : <TimeStamp createdAt={r.at} dateFormat="absolute" data="time" />}
|
|
327
|
+
>
|
|
328
|
+
<Paragraph measure="none">{r.text}</Paragraph>
|
|
329
|
+
</Message>
|
|
330
|
+
);
|
|
331
|
+
})}
|
|
332
|
+
</Stack>
|
|
333
|
+
<Composer
|
|
334
|
+
id="comment-thread-reply"
|
|
335
|
+
aria-label={`Reply to ${comment.from}`}
|
|
336
|
+
placeholder={`Reply to ${comment.from}`}
|
|
337
|
+
value={text}
|
|
338
|
+
onChange={setText}
|
|
339
|
+
onSubmit={send}
|
|
340
|
+
/>
|
|
341
|
+
</Stack>
|
|
342
|
+
</Center>
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
## Native
|
|
348
|
+
|
|
349
|
+
On Apple show the comments in a `List` with a `NavigationLink` per comment, its actions in a `contextMenu` and `swipeActions`, and the thread as a pushed view with a text field in a bottom bar. On Android use a `LazyColumn` of cards that each have a clickable title, a dropdown menu for the actions, and a thread screen.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function CookieChoiceBanner(): import("react").JSX.Element;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Surface from '../../components/surface';
|
|
4
|
+
import Heading from '../../components/heading';
|
|
5
|
+
import Paragraph from '../../components/paragraph';
|
|
6
|
+
import Button from '../../components/button';
|
|
7
|
+
import Modal from '../../components/modal';
|
|
8
|
+
import Switch from '../../components/switch';
|
|
9
|
+
import SiteHeader from '../../components/siteHeader';
|
|
10
|
+
import PageShell from '../../components/pageShell';
|
|
11
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
12
|
+
var links = [
|
|
13
|
+
{ label: 'Features', href: '#features' },
|
|
14
|
+
{ label: 'Pricing', href: '#pricing' },
|
|
15
|
+
{ label: 'Docs', href: '#docs' },
|
|
16
|
+
];
|
|
17
|
+
export default function CookieChoiceBanner() {
|
|
18
|
+
var _a = useState(false), chosen = _a[0], setChosen = _a[1];
|
|
19
|
+
var _b = useState(false), choosing = _b[0], setChoosing = _b[1];
|
|
20
|
+
// Every optional cookie starts off. Only the visitor turns one on.
|
|
21
|
+
var _c = useState(false), visits = _c[0], setVisits = _c[1];
|
|
22
|
+
var _d = useState(false), marketing = _d[0], setMarketing = _d[1];
|
|
23
|
+
var main = useRef(null);
|
|
24
|
+
// The banner is gone, so focus moves to the page the visitor came to read.
|
|
25
|
+
// This runs after the Modal has tried to give focus back to 'Choose Cookies', which is gone too.
|
|
26
|
+
useEffect(function () {
|
|
27
|
+
var _a;
|
|
28
|
+
if (chosen)
|
|
29
|
+
(_a = main.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
|
|
30
|
+
}, [chosen]);
|
|
31
|
+
// A real site keeps the choice in the browser, and sets a visit count or marketing cookie only when it is on.
|
|
32
|
+
function choose(next) {
|
|
33
|
+
setVisits(next.visits);
|
|
34
|
+
setMarketing(next.marketing);
|
|
35
|
+
setChoosing(false);
|
|
36
|
+
setChosen(true);
|
|
37
|
+
}
|
|
38
|
+
// Cancel puts every switch back off. The banner stays until the visitor chooses.
|
|
39
|
+
function handleCancel() {
|
|
40
|
+
setVisits(false);
|
|
41
|
+
setMarketing(false);
|
|
42
|
+
setChoosing(false);
|
|
43
|
+
}
|
|
44
|
+
return (<>
|
|
45
|
+
{/* In the page flow, before the header, so Tab reaches it first. It never covers the page, and the page stays usable. */}
|
|
46
|
+
{!chosen && (<Center width="page">
|
|
47
|
+
<Surface padding="small">
|
|
48
|
+
<Stack gap="medium">
|
|
49
|
+
<Stack gap="small">
|
|
50
|
+
<Heading level={2} size="h6">Cookies on Acme</Heading>
|
|
51
|
+
<Paragraph size="body2" measure="none">Acme uses cookies to keep you logged in. Accept All also allows cookies that count visits and cookies for marketing. Reject All turns both off.</Paragraph>
|
|
52
|
+
</Stack>
|
|
53
|
+
{/* Accept and Reject have the same weight, side by side. Neither is the page's main action. */}
|
|
54
|
+
<Cluster gap="small">
|
|
55
|
+
<Button size="medium" type="secondary" state="enabled" label="Accept All" onClickButton={function () { return choose({ visits: true, marketing: true }); }}/>
|
|
56
|
+
<Button size="medium" type="secondary" state="enabled" label="Reject All" onClickButton={function () { return choose({ visits: false, marketing: false }); }}/>
|
|
57
|
+
<Button size="medium" type="tertiary" state="enabled" label="Choose Cookies" onClickButton={function () { return setChoosing(true); }}/>
|
|
58
|
+
</Cluster>
|
|
59
|
+
</Stack>
|
|
60
|
+
</Surface>
|
|
61
|
+
</Center>)}
|
|
62
|
+
<SiteHeader brand={{ href: '#top', name: 'Acme' }} links={links} actions={<Button size="medium" type="tertiary" state="enabled" label="Log In" href="#log-in"/>} phoneAction={<Button size="medium" type="primary" state="enabled" label="Sign Up" href="#sign-up"/>} mainId="cookie-choice-banner-main"/>
|
|
63
|
+
{/* tabIndex -1 lets the skip link and the banner move focus here. */}
|
|
64
|
+
<PageShell ref={main} id="cookie-choice-banner-main" tabIndex={-1}>
|
|
65
|
+
<Stack gap="large">
|
|
66
|
+
<Heading level={1} size="h5">Share files and decide together</Heading>
|
|
67
|
+
<Paragraph tone="secondary" measure="none">Acme keeps a small team's files, notes and decisions in one place.</Paragraph>
|
|
68
|
+
</Stack>
|
|
69
|
+
</PageShell>
|
|
70
|
+
<Modal isOpen={choosing} size="small" title="Cookie Settings" onClose={handleCancel} actions={<>
|
|
71
|
+
<Button size="small" type="tertiary" state="enabled" label="Cancel" onClickButton={handleCancel}/>
|
|
72
|
+
{/* No choice is saved yet, so Save is enabled at once: saving every switch off is a choice. */}
|
|
73
|
+
<Button size="small" type="primary" state="enabled" label="Save Choices" onClickButton={function () { return choose({ visits: visits, marketing: marketing }); }}/>
|
|
74
|
+
</>}>
|
|
75
|
+
<Stack gap="medium">
|
|
76
|
+
<Switch id="cookie-choice-banner-needed" label="Needed to run the site" description="Keeps you logged in. Always on." checked disabled onChange={function () { }}/>
|
|
77
|
+
<Switch id="cookie-choice-banner-visits" label="Visit counts" checked={visits} onChange={setVisits}/>
|
|
78
|
+
<Switch id="cookie-choice-banner-marketing" label="Marketing" checked={marketing} onChange={setMarketing}/>
|
|
79
|
+
</Stack>
|
|
80
|
+
</Modal>
|
|
81
|
+
</>);
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function CookieChoiceSettings(): import("react").JSX.Element;
|
|
@@ -0,0 +1,75 @@
|
|
|
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 { useEffect, useRef, useState } from 'react';
|
|
14
|
+
import Modal from '../../components/modal';
|
|
15
|
+
import Switch from '../../components/switch';
|
|
16
|
+
import Button from '../../components/button';
|
|
17
|
+
import Heading from '../../components/heading';
|
|
18
|
+
import Paragraph from '../../components/paragraph';
|
|
19
|
+
import SiteFooter from '../../components/siteFooter';
|
|
20
|
+
import { Center, Stack } from '../../components/layout';
|
|
21
|
+
export default function CookieChoiceSettings() {
|
|
22
|
+
// Opens on the Modal, as if the visitor just chose 'Cookie Settings' in the footer.
|
|
23
|
+
var _a = useState(true), open = _a[0], setOpen = _a[1];
|
|
24
|
+
// The visitor's last choice, kept in the browser. Here they chose Reject All, so every optional cookie is off.
|
|
25
|
+
var _b = useState({ visits: false, marketing: false }), saved = _b[0], setSaved = _b[1];
|
|
26
|
+
var _c = useState(saved), draft = _c[0], setDraft = _c[1];
|
|
27
|
+
var _d = useState(false), justSaved = _d[0], setJustSaved = _d[1];
|
|
28
|
+
var savedTimer = useRef();
|
|
29
|
+
// Save is disabled while the switches match what was saved, and while 'Saved' shows it stays enabled.
|
|
30
|
+
var changed = draft.visits !== saved.visits || draft.marketing !== saved.marketing;
|
|
31
|
+
// Stops the 'Saved' timer if the example goes away before it ends.
|
|
32
|
+
useEffect(function () { return function () { return clearTimeout(savedTimer.current); }; }, []);
|
|
33
|
+
// One Save for the group. The choice is kept in the browser, so it saves at once, and 'Saved' shows for 2 seconds.
|
|
34
|
+
// A press while 'Saved' shows and nothing changed does nothing.
|
|
35
|
+
function handleSave() {
|
|
36
|
+
if (!changed)
|
|
37
|
+
return;
|
|
38
|
+
setSaved(draft);
|
|
39
|
+
setJustSaved(true);
|
|
40
|
+
clearTimeout(savedTimer.current);
|
|
41
|
+
savedTimer.current = setTimeout(function () { return setJustSaved(false); }, 2000);
|
|
42
|
+
}
|
|
43
|
+
// Cancel, Escape and a click outside drop what was not saved.
|
|
44
|
+
function handleClose() {
|
|
45
|
+
setDraft(saved);
|
|
46
|
+
setJustSaved(false);
|
|
47
|
+
setOpen(false);
|
|
48
|
+
}
|
|
49
|
+
return (<>
|
|
50
|
+
<Stack gap="huge">
|
|
51
|
+
<Center width="page">
|
|
52
|
+
<Stack gap="large">
|
|
53
|
+
<Heading level={1} size="h5">Privacy</Heading>
|
|
54
|
+
<Paragraph tone="secondary" measure="none">Acme uses cookies to keep you logged in. Visit counts and marketing stay off until you turn them on.</Paragraph>
|
|
55
|
+
</Stack>
|
|
56
|
+
</Center>
|
|
57
|
+
{/* The footer's 'Cookie Settings' link comes to this page, which opens the Modal. The visitor can change the choice at any time. */}
|
|
58
|
+
<SiteFooter brand={{ href: '#top', name: 'Acme' }} links={[
|
|
59
|
+
{ label: 'Terms', href: '#terms' },
|
|
60
|
+
{ label: 'Privacy', href: '#privacy' },
|
|
61
|
+
{ label: 'Cookie Settings', href: '#cookie-settings' },
|
|
62
|
+
]} legal="© 2026 Acme. All rights reserved."/>
|
|
63
|
+
</Stack>
|
|
64
|
+
<Modal isOpen={open} size="small" title="Cookie Settings" onClose={handleClose} actions={<>
|
|
65
|
+
<Button size="small" type="tertiary" state="enabled" label="Cancel" onClickButton={handleClose}/>
|
|
66
|
+
<Button size="small" type="primary" state={changed || justSaved ? 'enabled' : 'disabled'} label={justSaved ? 'Saved' : 'Save Choices'} onClickButton={handleSave}/>
|
|
67
|
+
</>}>
|
|
68
|
+
<Stack gap="medium">
|
|
69
|
+
<Switch id="cookie-choice-settings-needed" label="Needed to run the site" description="Keeps you logged in. Always on." checked disabled onChange={function () { }}/>
|
|
70
|
+
<Switch id="cookie-choice-settings-visits" label="Visit counts" checked={draft.visits} onChange={function (visits) { return setDraft(function (d) { return (__assign(__assign({}, d), { visits: visits })); }); }}/>
|
|
71
|
+
<Switch id="cookie-choice-settings-marketing" label="Marketing" checked={draft.marketing} onChange={function (marketing) { return setDraft(function (d) { return (__assign(__assign({}, d), { marketing: marketing })); }); }}/>
|
|
72
|
+
</Stack>
|
|
73
|
+
</Modal>
|
|
74
|
+
</>);
|
|
75
|
+
}
|