oneslash-design-system 2.22.0 → 2.23.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.
Files changed (88) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +12 -1
  3. package/dist/cases/admin-inbox/split.jsx +22 -10
  4. package/dist/cases/admin-inbox.md +28 -23
  5. package/dist/cases/api-keys.md +1 -1
  6. package/dist/cases/breadcrumb/back-link.d.ts +1 -0
  7. package/dist/cases/breadcrumb/back-link.jsx +23 -0
  8. package/dist/cases/breadcrumb/trail.d.ts +1 -0
  9. package/dist/cases/breadcrumb/trail.jsx +28 -0
  10. package/dist/cases/breadcrumb.md +105 -0
  11. package/dist/cases/date-field/calendar.d.ts +1 -0
  12. package/dist/cases/date-field/calendar.jsx +80 -0
  13. package/dist/cases/date-field/typed.d.ts +1 -0
  14. package/dist/cases/date-field/typed.jsx +58 -0
  15. package/dist/cases/date-field.md +232 -0
  16. package/dist/cases/docs-component-page/reference.jsx +11 -1
  17. package/dist/cases/docs-component-page.md +19 -8
  18. package/dist/cases/file-upload/files.d.ts +1 -0
  19. package/dist/cases/file-upload/files.jsx +118 -0
  20. package/dist/cases/file-upload/picture.d.ts +1 -0
  21. package/dist/cases/file-upload/picture.jsx +50 -0
  22. package/dist/cases/file-upload.md +270 -0
  23. package/dist/cases/filter-menu.md +1 -1
  24. package/dist/cases/image-viewer/with-video.d.ts +1 -0
  25. package/dist/cases/image-viewer/with-video.jsx +42 -0
  26. package/dist/cases/image-viewer.md +72 -4
  27. package/dist/cases/master-detail/split.jsx +17 -10
  28. package/dist/cases/master-detail.md +26 -24
  29. package/dist/cases/message-reactions/picker.d.ts +1 -0
  30. package/dist/cases/message-reactions/picker.jsx +145 -0
  31. package/dist/cases/message-reactions/quick-pick.jsx +1 -1
  32. package/dist/cases/message-reactions.md +184 -3
  33. package/dist/cases/page-header.md +1 -1
  34. package/dist/cases/people-row/names.d.ts +1 -0
  35. package/dist/cases/people-row/names.jsx +20 -0
  36. package/dist/cases/people-row/stack.d.ts +1 -0
  37. package/dist/cases/people-row/stack.jsx +33 -0
  38. package/dist/cases/people-row.md +110 -0
  39. package/dist/cases/profile-form/form.jsx +21 -10
  40. package/dist/cases/profile-form.md +38 -9
  41. package/dist/cases.json +306 -25
  42. package/dist/components/avatarStack.d.ts +22 -0
  43. package/dist/components/avatarStack.jsx +32 -0
  44. package/dist/components/breadcrumb.d.ts +12 -0
  45. package/dist/components/breadcrumb.jsx +24 -0
  46. package/dist/components/calendar.d.ts +19 -0
  47. package/dist/components/calendar.jsx +126 -0
  48. package/dist/components/dateField.d.ts +35 -0
  49. package/dist/components/dateField.jsx +76 -0
  50. package/dist/components/dropZone.d.ts +53 -0
  51. package/dist/components/dropZone.jsx +136 -0
  52. package/dist/components/emojiPicker.d.ts +22 -0
  53. package/dist/components/emojiPicker.jsx +161 -0
  54. package/dist/components/itemList.d.ts +31 -0
  55. package/dist/components/itemList.jsx +81 -0
  56. package/dist/components/lightbox.d.ts +33 -9
  57. package/dist/components/lightbox.jsx +58 -27
  58. package/dist/components/menuItem.d.ts +1 -1
  59. package/dist/components/menuItem.jsx +3 -3
  60. package/dist/internal/date.d.ts +35 -0
  61. package/dist/internal/date.js +122 -0
  62. package/dist/internal/dropZone.d.ts +28 -0
  63. package/dist/internal/dropZone.js +42 -0
  64. package/dist/internal/emoji.d.ts +13 -0
  65. package/dist/internal/emoji.js +182 -0
  66. package/dist/internal/overlayStack.js +1 -1
  67. package/dist/internal/people.d.ts +1 -0
  68. package/dist/internal/people.js +12 -0
  69. package/dist/native-mapping.json +45 -3
  70. package/dist/stories/AvatarStack.stories.d.ts +7 -0
  71. package/dist/stories/AvatarStack.stories.jsx +46 -0
  72. package/dist/stories/Breadcrumb.stories.d.ts +7 -0
  73. package/dist/stories/Breadcrumb.stories.jsx +26 -0
  74. package/dist/stories/Calendar.stories.d.ts +6 -0
  75. package/dist/stories/Calendar.stories.jsx +15 -0
  76. package/dist/stories/Cases.generated.stories.d.ts +10 -0
  77. package/dist/stories/Cases.generated.stories.jsx +20 -0
  78. package/dist/stories/DateField.stories.d.ts +10 -0
  79. package/dist/stories/DateField.stories.jsx +132 -0
  80. package/dist/stories/DropZone.stories.d.ts +12 -0
  81. package/dist/stories/DropZone.stories.jsx +151 -0
  82. package/dist/stories/EmojiPicker.stories.d.ts +6 -0
  83. package/dist/stories/EmojiPicker.stories.jsx +92 -0
  84. package/dist/stories/ItemList.stories.d.ts +9 -0
  85. package/dist/stories/ItemList.stories.jsx +86 -0
  86. package/dist/stories/Lightbox.stories.d.ts +4 -0
  87. package/dist/stories/Lightbox.stories.jsx +44 -0
  88. package/package.json +3 -2
@@ -0,0 +1,145 @@
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
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
+ if (ar || !(i in from)) {
16
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
+ ar[i] = from[i];
18
+ }
19
+ }
20
+ return to.concat(ar || Array.prototype.slice.call(from));
21
+ };
22
+ import { useEffect, useRef, useState } from 'react';
23
+ import Message from '../../components/message';
24
+ import UserImage from '../../components/userImage';
25
+ import TimeStamp from '../../components/timeStamp';
26
+ import Heading from '../../components/heading';
27
+ import Paragraph from '../../components/paragraph';
28
+ import Tag from '../../components/tag';
29
+ import IconButton from '../../components/iconButton';
30
+ import Tooltip from '../../components/tooltip';
31
+ import Popover from '../../components/popover';
32
+ import EmojiPicker from '../../components/emojiPicker';
33
+ import { Center, Cluster, Stack } from '../../components/layout';
34
+ // A real app reads this from the session.
35
+ var me = 'Dana Lee';
36
+ var firstThread = [
37
+ {
38
+ id: 'm1',
39
+ from: 'Ben Carter',
40
+ at: new Date('2025-01-15T11:40:00Z'),
41
+ text: 'The pricing page is live.',
42
+ reactions: [
43
+ { emoji: '👍', name: 'Thumbs up', by: ['Omar Reyes', me] },
44
+ { emoji: '🙌', name: 'Raised hands', by: ['Omar Reyes'] },
45
+ ],
46
+ },
47
+ { id: 'm2', from: 'Omar Reyes', at: new Date('2025-01-15T11:42:00Z'), text: 'Nice work. I will share it with the sales team.', reactions: [] },
48
+ ];
49
+ var firstName = function (name) { return name.split(' ')[0]; };
50
+ // 'Omar and you': other people by first name, the person last.
51
+ function whoReacted(by) {
52
+ var names = __spreadArray(__spreadArray([], by.filter(function (n) { return n !== me; }).map(firstName), true), (by.includes(me) ? ['you'] : []), true);
53
+ if (names.length === 1)
54
+ return names[0] === 'you' ? 'You' : names[0];
55
+ return "".concat(names.slice(0, -1).join(', '), " and ").concat(names[names.length - 1]);
56
+ }
57
+ // 'Thumbs up, 3 reactions'. The chip's aria-pressed says whether the person reacted.
58
+ function chipName(r) {
59
+ var count = "".concat(r.by.length, " ").concat(r.by.length === 1 ? 'reaction' : 'reactions');
60
+ return "".concat(r.name, ", ").concat(count);
61
+ }
62
+ export default function MessageReactionsPicker() {
63
+ var _a = useState(firstThread), thread = _a[0], setThread = _a[1];
64
+ // Each row's 'Add reaction' button by row id. When the chip that had focus goes away, focus goes there.
65
+ var addButtons = useRef({});
66
+ var focusAdd = useRef(null);
67
+ useEffect(function () {
68
+ var _a;
69
+ if (!focusAdd.current)
70
+ return;
71
+ (_a = addButtons.current[focusAdd.current]) === null || _a === void 0 ? void 0 : _a.focus();
72
+ focusAdd.current = null;
73
+ });
74
+ // The row whose picker is open, and the button it opens from. Both stay set while it fades out.
75
+ var _b = useState(null), pickRow = _b[0], setPickRow = _b[1];
76
+ var _c = useState(null), pickAnchor = _c[0], setPickAnchor = _c[1];
77
+ var _d = useState(false), pickOpen = _d[0], setPickOpen = _d[1];
78
+ // The count changes at once. A real app sends the change to the server and puts it back if that fails.
79
+ function toggle(rowId, emoji, name) {
80
+ var row = thread.find(function (m) { return m.id === rowId; });
81
+ var chip = row === null || row === void 0 ? void 0 : row.reactions.find(function (r) { return r.emoji === emoji; });
82
+ // The person's reaction was the last one, so the chip goes away.
83
+ if (chip && chip.by.length === 1 && chip.by[0] === me)
84
+ focusAdd.current = rowId;
85
+ setThread(function (rows) {
86
+ return rows.map(function (m) {
87
+ if (m.id !== rowId)
88
+ return m;
89
+ var has = m.reactions.find(function (r) { return r.emoji === emoji; });
90
+ var reactions = has
91
+ ? m.reactions.map(function (r) {
92
+ return r.emoji !== emoji ? r : __assign(__assign({}, r), { by: r.by.includes(me) ? r.by.filter(function (n) { return n !== me; }) : __spreadArray(__spreadArray([], r.by, true), [me], false) });
93
+ })
94
+ : __spreadArray(__spreadArray([], m.reactions, true), [{ emoji: emoji, name: name, by: [me] }], false);
95
+ // A chip with no reactions left goes away.
96
+ return __assign(__assign({}, m), { reactions: reactions.filter(function (r) { return r.by.length > 0; }) });
97
+ });
98
+ });
99
+ }
100
+ function openPick(m, anchor) {
101
+ if (pickOpen && (pickRow === null || pickRow === void 0 ? void 0 : pickRow.id) === m.id) {
102
+ setPickOpen(false);
103
+ return;
104
+ }
105
+ setPickRow(m);
106
+ setPickAnchor(anchor);
107
+ setPickOpen(true);
108
+ }
109
+ // Escape, a click outside and a pick close it. Popover's returnFocus gives focus back to 'Add reaction'.
110
+ function closePick() {
111
+ setPickOpen(false);
112
+ }
113
+ // The open row, read from the thread so the picker shows its reactions as they are now.
114
+ var openRow = thread.find(function (m) { return m.id === (pickRow === null || pickRow === void 0 ? void 0 : pickRow.id); });
115
+ var mine = openRow ? openRow.reactions.filter(function (r) { return r.by.includes(me); }).map(function (r) { return r.emoji; }) : [];
116
+ return (<Center width="page">
117
+ <Stack gap="large">
118
+ <Heading level={1} size="h5">Launch plan</Heading>
119
+ {/* A real app gives the list that holds the rows role="log". */}
120
+ <Stack gap="small">
121
+ {thread.map(function (m) { return (<Message key={m.id} aria-label={m.from} avatar={<UserImage userHandle={m.from} decorative/>} name={m.from} meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time"/>} footer={<Cluster gap="small">
122
+ {m.reactions.map(function (r) { return (<Tooltip key={r.emoji} title={whoReacted(r.by)}>
123
+ <Tag variant="contained" size="small" state={r.by.includes(me) ? 'selected' : 'enabled'} label={"".concat(r.emoji, " ").concat(r.by.length)} aria-label={chipName(r)} onClick={function () { return toggle(m.id, r.emoji, r.name); }}/>
124
+ </Tooltip>); })}
125
+ <Tooltip title="Add reaction">
126
+ <IconButton color="iconOnly" state={pickOpen && (pickRow === null || pickRow === void 0 ? void 0 : pickRow.id) === m.id ? 'selected' : 'enabled'} size="small" ref={function (el) { addButtons.current[m.id] = el; }} iconName="SmilePlus" ariaLabel={"Add reaction to message from ".concat(m.from)} aria-haspopup="dialog" aria-expanded={pickOpen && (pickRow === null || pickRow === void 0 ? void 0 : pickRow.id) === m.id} onClick={function (e) { return openPick(m, e.currentTarget); }}/>
127
+ </Tooltip>
128
+ </Cluster>}>
129
+ <Paragraph measure="none">{m.text}</Paragraph>
130
+ </Message>); })}
131
+ </Stack>
132
+ </Stack>
133
+ {/* The picker focuses its search. ArrowDown enters the grid; Tab and Shift+Tab move between the search and the grid. */}
134
+ <Popover open={pickOpen} anchorEl={pickAnchor} onClose={closePick} returnFocus>
135
+ <EmojiPicker id="message-reactions-picker" aria-label="Add reaction"
136
+ // The emoji the person already used show pressed. Picking one again removes it.
137
+ selected={mine} onPick={function (emoji) {
138
+ if (!pickRow)
139
+ return;
140
+ closePick();
141
+ toggle(pickRow.id, emoji.char, emoji.name);
142
+ }}/>
143
+ </Popover>
144
+ </Center>);
145
+ }
@@ -34,7 +34,7 @@ import MenuItem from '../../components/menuItem';
34
34
  import { Center, Cluster, Stack } from '../../components/layout';
35
35
  // A real app reads this from the session.
36
36
  var me = 'Dana Lee';
37
- // The six emoji people use most, each named in words. ODS has no full emoji picker yet.
37
+ // The six emoji people use most, each named in words.
38
38
  var quickEmoji = [
39
39
  { emoji: '👍', name: 'Thumbs up' },
40
40
  { emoji: '❤️', name: 'Heart' },
@@ -14,7 +14,8 @@ People answer a message with an emoji instead of a reply.
14
14
  - Mark the emoji the person already used with an 'Added' tag. Picking it again removes it.
15
15
  - Close the quick pick when an emoji is picked. Focus goes back to the button that opened it.
16
16
  - Move focus to the 'Add reaction' button when the chip that had it disappears, because its count reached 0.
17
- - Offer the six emoji for now: ODS has no full emoji picker yet.
17
+ - Use `quick-pick` when six emoji cover most reactions, and `picker` when people use many. Both name each emoji in words.
18
+ - Open the picker from 'Add reaction' in a `<Popover returnFocus>` around `EmojiPicker`. Pass the person's emoji as `selected`, so they show pressed. A pick adds or removes the reaction and closes the Popover.
18
19
 
19
20
  ## Don't
20
21
 
@@ -192,7 +193,7 @@ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout
192
193
  // A real app reads this from the session.
193
194
  const me = 'Dana Lee';
194
195
 
195
- // The six emoji people use most, each named in words. ODS has no full emoji picker yet.
196
+ // The six emoji people use most, each named in words.
196
197
  const quickEmoji = [
197
198
  { emoji: '👍', name: 'Thumbs up' },
198
199
  { emoji: '❤️', name: 'Heart' },
@@ -362,6 +363,186 @@ export default function MessageReactionsQuickPick() {
362
363
  }
363
364
  ```
364
365
 
366
+ ## Option: Emoji picker
367
+
368
+ Use when: People react with more than the usual six emoji.
369
+
370
+ Uses: `Center`, `Cluster`, `EmojiPicker`, `Heading`, `IconButton`, `Message`, `Paragraph`, `Popover`, `Stack`, `Tag`, `TimeStamp`, `Tooltip`, `UserImage`
371
+
372
+ ```tsx
373
+ 'use client';
374
+ import { useEffect, useRef, useState } from 'react';
375
+ import Message from 'oneslash-design-system/components/message';
376
+ import UserImage from 'oneslash-design-system/components/userImage';
377
+ import TimeStamp from 'oneslash-design-system/components/timeStamp';
378
+ import Heading from 'oneslash-design-system/components/heading';
379
+ import Paragraph from 'oneslash-design-system/components/paragraph';
380
+ import Tag from 'oneslash-design-system/components/tag';
381
+ import IconButton from 'oneslash-design-system/components/iconButton';
382
+ import Tooltip from 'oneslash-design-system/components/tooltip';
383
+ import Popover from 'oneslash-design-system/components/popover';
384
+ import EmojiPicker from 'oneslash-design-system/components/emojiPicker';
385
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
386
+
387
+ // A real app reads this from the session.
388
+ const me = 'Dana Lee';
389
+
390
+ // Each reaction keeps the emoji's name in words, from the picker, for its chip's aria-label.
391
+ type Reaction = { emoji: string; name: string; by: string[] };
392
+ type Row = { id: string; from: string; at: Date; text: string; reactions: Reaction[] };
393
+
394
+ const firstThread: Row[] = [
395
+ {
396
+ id: 'm1',
397
+ from: 'Ben Carter',
398
+ at: new Date('2025-01-15T11:40:00Z'),
399
+ text: 'The pricing page is live.',
400
+ reactions: [
401
+ { emoji: '👍', name: 'Thumbs up', by: ['Omar Reyes', me] },
402
+ { emoji: '🙌', name: 'Raised hands', by: ['Omar Reyes'] },
403
+ ],
404
+ },
405
+ { id: 'm2', from: 'Omar Reyes', at: new Date('2025-01-15T11:42:00Z'), text: 'Nice work. I will share it with the sales team.', reactions: [] },
406
+ ];
407
+
408
+ const firstName = (name: string) => name.split(' ')[0];
409
+
410
+ // 'Omar and you': other people by first name, the person last.
411
+ function whoReacted(by: string[]) {
412
+ const names = [...by.filter((n) => n !== me).map(firstName), ...(by.includes(me) ? ['you'] : [])];
413
+ if (names.length === 1) return names[0] === 'you' ? 'You' : names[0];
414
+ return `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}`;
415
+ }
416
+
417
+ // 'Thumbs up, 3 reactions'. The chip's aria-pressed says whether the person reacted.
418
+ function chipName(r: Reaction) {
419
+ const count = `${r.by.length} ${r.by.length === 1 ? 'reaction' : 'reactions'}`;
420
+ return `${r.name}, ${count}`;
421
+ }
422
+
423
+ export default function MessageReactionsPicker() {
424
+ const [thread, setThread] = useState(firstThread);
425
+ // Each row's 'Add reaction' button by row id. When the chip that had focus goes away, focus goes there.
426
+ const addButtons = useRef<Record<string, HTMLButtonElement | HTMLAnchorElement | null>>({});
427
+ const focusAdd = useRef<string | null>(null);
428
+
429
+ useEffect(() => {
430
+ if (!focusAdd.current) return;
431
+ addButtons.current[focusAdd.current]?.focus();
432
+ focusAdd.current = null;
433
+ });
434
+ // The row whose picker is open, and the button it opens from. Both stay set while it fades out.
435
+ const [pickRow, setPickRow] = useState<Row | null>(null);
436
+ const [pickAnchor, setPickAnchor] = useState<HTMLElement | null>(null);
437
+ const [pickOpen, setPickOpen] = useState(false);
438
+
439
+ // The count changes at once. A real app sends the change to the server and puts it back if that fails.
440
+ function toggle(rowId: string, emoji: string, name: string) {
441
+ const row = thread.find((m) => m.id === rowId);
442
+ const chip = row?.reactions.find((r) => r.emoji === emoji);
443
+ // The person's reaction was the last one, so the chip goes away.
444
+ if (chip && chip.by.length === 1 && chip.by[0] === me) focusAdd.current = rowId;
445
+ setThread((rows) =>
446
+ rows.map((m) => {
447
+ if (m.id !== rowId) return m;
448
+ const has = m.reactions.find((r) => r.emoji === emoji);
449
+ const reactions = has
450
+ ? m.reactions.map((r) =>
451
+ r.emoji !== emoji ? r : { ...r, by: r.by.includes(me) ? r.by.filter((n) => n !== me) : [...r.by, me] },
452
+ )
453
+ : [...m.reactions, { emoji, name, by: [me] }];
454
+ // A chip with no reactions left goes away.
455
+ return { ...m, reactions: reactions.filter((r) => r.by.length > 0) };
456
+ }),
457
+ );
458
+ }
459
+
460
+ function openPick(m: Row, anchor: HTMLElement) {
461
+ if (pickOpen && pickRow?.id === m.id) {
462
+ setPickOpen(false);
463
+ return;
464
+ }
465
+ setPickRow(m);
466
+ setPickAnchor(anchor);
467
+ setPickOpen(true);
468
+ }
469
+
470
+ // Escape, a click outside and a pick close it. Popover's returnFocus gives focus back to 'Add reaction'.
471
+ function closePick() {
472
+ setPickOpen(false);
473
+ }
474
+
475
+ // The open row, read from the thread so the picker shows its reactions as they are now.
476
+ const openRow = thread.find((m) => m.id === pickRow?.id);
477
+ const mine = openRow ? openRow.reactions.filter((r) => r.by.includes(me)).map((r) => r.emoji) : [];
478
+
479
+ return (
480
+ <Center width="page">
481
+ <Stack gap="large">
482
+ <Heading level={1} size="h5">Launch plan</Heading>
483
+ {/* A real app gives the list that holds the rows role="log". */}
484
+ <Stack gap="small">
485
+ {thread.map((m) => (
486
+ <Message
487
+ key={m.id}
488
+ aria-label={m.from}
489
+ avatar={<UserImage userHandle={m.from} decorative />}
490
+ name={m.from}
491
+ meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time" />}
492
+ footer={
493
+ <Cluster gap="small">
494
+ {m.reactions.map((r) => (
495
+ <Tooltip key={r.emoji} title={whoReacted(r.by)}>
496
+ <Tag
497
+ variant="contained"
498
+ size="small"
499
+ state={r.by.includes(me) ? 'selected' : 'enabled'}
500
+ label={`${r.emoji} ${r.by.length}`}
501
+ aria-label={chipName(r)}
502
+ onClick={() => toggle(m.id, r.emoji, r.name)}
503
+ />
504
+ </Tooltip>
505
+ ))}
506
+ <Tooltip title="Add reaction">
507
+ <IconButton
508
+ color="iconOnly"
509
+ state={pickOpen && pickRow?.id === m.id ? 'selected' : 'enabled'}
510
+ size="small"
511
+ ref={(el) => { addButtons.current[m.id] = el; }}
512
+ iconName="SmilePlus"
513
+ ariaLabel={`Add reaction to message from ${m.from}`}
514
+ aria-haspopup="dialog"
515
+ aria-expanded={pickOpen && pickRow?.id === m.id}
516
+ onClick={(e: { currentTarget: HTMLElement }) => openPick(m, e.currentTarget)}
517
+ />
518
+ </Tooltip>
519
+ </Cluster>
520
+ }
521
+ >
522
+ <Paragraph measure="none">{m.text}</Paragraph>
523
+ </Message>
524
+ ))}
525
+ </Stack>
526
+ </Stack>
527
+ {/* The picker focuses its search. ArrowDown enters the grid; Tab and Shift+Tab move between the search and the grid. */}
528
+ <Popover open={pickOpen} anchorEl={pickAnchor} onClose={closePick} returnFocus>
529
+ <EmojiPicker
530
+ id="message-reactions-picker"
531
+ aria-label="Add reaction"
532
+ // The emoji the person already used show pressed. Picking one again removes it.
533
+ selected={mine}
534
+ onPick={(emoji) => {
535
+ if (!pickRow) return;
536
+ closePick();
537
+ toggle(pickRow.id, emoji.char, emoji.name);
538
+ }}
539
+ />
540
+ </Popover>
541
+ </Center>
542
+ );
543
+ }
544
+ ```
545
+
365
546
  ## Native
366
547
 
367
- On Apple a reaction is added from the row's `contextMenu`, with Add Reaction.
548
+ On Apple a reaction is added from the row's `contextMenu`, with Add Reaction, offering a few presets. For any emoji, use the system emoji keyboard (Apple) or `EmojiPickerView` (Android).
@@ -16,7 +16,7 @@ A page names itself at the top and offers what the person can do with it.
16
16
 
17
17
  ## Don't
18
18
 
19
- - Do not add a breadcrumb. Back goes one step up, and the title says where the person is.
19
+ - Do not add a breadcrumb to an app page. Back goes one step up. A docs or help page three levels deep follows the case 'Breadcrumb'.
20
20
  - Do not show two primary Buttons.
21
21
  - Do not name an icon button only by its icon, or More only by the word.
22
22
  - Do not leave an action out on a phone without a way to reach it.
@@ -0,0 +1 @@
1
+ export default function PeopleRowNames(): import("react").JSX.Element;
@@ -0,0 +1,20 @@
1
+ 'use client';
2
+ import Heading from '../../components/heading';
3
+ import Paragraph from '../../components/paragraph';
4
+ import UserImage from '../../components/userImage';
5
+ import { Cluster, Stack } from '../../components/layout';
6
+ // The person who started the task comes first, here and everywhere these people are listed.
7
+ var people = ['Dana Lee', 'Ben Carter', 'Omar Reyes'];
8
+ export default function PeopleRowNames() {
9
+ return (<Stack gap="small">
10
+ <Heading level={1} size="h5">Fix the sign-up email</Heading>
11
+ <Cluster gap="small">
12
+ {/* The names say who is there, so the faces are decorative */}
13
+ <Cluster gap="small">
14
+ {people.map(function (name) { return (<UserImage key={name} userHandle={name} size={24} decorative/>); })}
15
+ </Cluster>
16
+ {/* The same words as the people in the array, in the wording AvatarStack names a group with: 'A, B and C' */}
17
+ <Paragraph tone="secondary" size="body2" measure="none">Dana Lee, Ben Carter and Omar Reyes</Paragraph>
18
+ </Cluster>
19
+ </Stack>);
20
+ }
@@ -0,0 +1 @@
1
+ export default function PeopleRowStack(): import("react").JSX.Element;
@@ -0,0 +1,33 @@
1
+ 'use client';
2
+ import { useState } from 'react';
3
+ import Heading from '../../components/heading';
4
+ import Paragraph from '../../components/paragraph';
5
+ import AvatarStack from '../../components/avatarStack';
6
+ import Popover from '../../components/popover';
7
+ import List from '../../components/list';
8
+ import { Cluster, Stack } from '../../components/layout';
9
+ // The person who started the thread comes first, here and everywhere these people are listed.
10
+ var people = [
11
+ { name: 'Ben Carter', role: 'Admin' },
12
+ { name: 'Dana Lee', role: 'Member' },
13
+ { name: 'Omar Reyes', role: 'Member' },
14
+ { name: 'Mia Park', role: 'Member' },
15
+ { name: 'Leo Grant', role: 'Guest' },
16
+ { name: 'Ana Silva', role: 'Guest' },
17
+ ];
18
+ export default function PeopleRowStack() {
19
+ // The open list is anchored on the stack's button, and focus goes back to it on close.
20
+ var _a = useState(null), anchor = _a[0], setAnchor = _a[1];
21
+ return (<Stack gap="large">
22
+ <Cluster justify="between">
23
+ <Stack gap="small">
24
+ <Heading level={1} size="h5">Launch checklist</Heading>
25
+ <Paragraph tone="secondary" size="body2" measure="none">Started by Ben Carter on Nov 12, 2026</Paragraph>
26
+ </Stack>
27
+ <AvatarStack people={people} aria-label={"Show the ".concat(people.length, " people in this thread")} aria-haspopup="dialog" aria-expanded={anchor !== null} onClick={function (event) { return setAnchor(anchor ? null : event.currentTarget); }}/>
28
+ </Cluster>
29
+ <Popover id="people-row-people" open={anchor !== null} anchorEl={anchor} onClose={function () { return setAnchor(null); }} returnFocus>
30
+ <List items={people.map(function (p) { return "".concat(p.name, ", ").concat(p.role); })}/>
31
+ </Popover>
32
+ </Stack>);
33
+ }
@@ -0,0 +1,110 @@
1
+ # People on an item
2
+
3
+ A thread or a task shows who is on it, and the person can find out who they all are.
4
+
5
+ ## Do
6
+
7
+ - Use `AvatarStack` for four or more people. Past `max` its last circle counts the rest, such as '+3'.
8
+ - Make the stack one button with `onClick`, and name it for what it opens: 'Show the 6 people in this thread'.
9
+ - Open a `<Popover returnFocus>` from the stack with a `List` of every name and role, such as 'Ben Carter, Admin'. Escape or a click outside closes it, and Escape puts focus back on the stack.
10
+ - Show one to three people as faces and their names: 'Dana Lee, Ben Carter and Omar Reyes'. Make each face `UserImage decorative`, because the names say who is there.
11
+ - Keep the same order everywhere, the person who started the item first.
12
+ - Use the person's name as `userHandle`, so a person with no picture shows their initial.
13
+
14
+ ## Don't
15
+
16
+ - Do not put a `Tooltip` on each face. A face is not focusable, so a keyboard or touch cannot reach it.
17
+ - Do not make a face the only way to know who is there. Name everyone in the list or in text.
18
+ - Do not list everyone as faces when the row would wrap. Use the stack and its count.
19
+ - Do not make each face its own button that does something else, such as removing the person.
20
+
21
+ ## Option: Overlapping faces that open a list
22
+
23
+ Use when: Four or more people are on a thread or a task, shown in its header.
24
+
25
+ Uses: `AvatarStack`, `Cluster`, `Heading`, `List`, `Paragraph`, `Popover`, `Stack`
26
+
27
+ ```tsx
28
+ 'use client';
29
+ import { useState } from 'react';
30
+ import Heading from 'oneslash-design-system/components/heading';
31
+ import Paragraph from 'oneslash-design-system/components/paragraph';
32
+ import AvatarStack from 'oneslash-design-system/components/avatarStack';
33
+ import Popover from 'oneslash-design-system/components/popover';
34
+ import List from 'oneslash-design-system/components/list';
35
+ import { Cluster, Stack } from 'oneslash-design-system/components/layout';
36
+
37
+ // The person who started the thread comes first, here and everywhere these people are listed.
38
+ const people = [
39
+ { name: 'Ben Carter', role: 'Admin' },
40
+ { name: 'Dana Lee', role: 'Member' },
41
+ { name: 'Omar Reyes', role: 'Member' },
42
+ { name: 'Mia Park', role: 'Member' },
43
+ { name: 'Leo Grant', role: 'Guest' },
44
+ { name: 'Ana Silva', role: 'Guest' },
45
+ ];
46
+
47
+ export default function PeopleRowStack() {
48
+ // The open list is anchored on the stack's button, and focus goes back to it on close.
49
+ const [anchor, setAnchor] = useState<HTMLElement | null>(null);
50
+ return (
51
+ <Stack gap="large">
52
+ <Cluster justify="between">
53
+ <Stack gap="small">
54
+ <Heading level={1} size="h5">Launch checklist</Heading>
55
+ <Paragraph tone="secondary" size="body2" measure="none">Started by Ben Carter on Nov 12, 2026</Paragraph>
56
+ </Stack>
57
+ <AvatarStack
58
+ people={people}
59
+ aria-label={`Show the ${people.length} people in this thread`}
60
+ aria-haspopup="dialog"
61
+ aria-expanded={anchor !== null}
62
+ onClick={(event) => setAnchor(anchor ? null : event.currentTarget)}
63
+ />
64
+ </Cluster>
65
+ <Popover id="people-row-people" open={anchor !== null} anchorEl={anchor} onClose={() => setAnchor(null)} returnFocus>
66
+ <List items={people.map((p) => `${p.name}, ${p.role}`)} />
67
+ </Popover>
68
+ </Stack>
69
+ );
70
+ }
71
+ ```
72
+
73
+ ## Option: Faces beside the names
74
+
75
+ Use when: One to three people are on it, and their names fit.
76
+
77
+ Uses: `Cluster`, `Heading`, `Paragraph`, `Stack`, `UserImage`
78
+
79
+ ```tsx
80
+ 'use client';
81
+ import Heading from 'oneslash-design-system/components/heading';
82
+ import Paragraph from 'oneslash-design-system/components/paragraph';
83
+ import UserImage from 'oneslash-design-system/components/userImage';
84
+ import { Cluster, Stack } from 'oneslash-design-system/components/layout';
85
+
86
+ // The person who started the task comes first, here and everywhere these people are listed.
87
+ const people = ['Dana Lee', 'Ben Carter', 'Omar Reyes'];
88
+
89
+ export default function PeopleRowNames() {
90
+ return (
91
+ <Stack gap="small">
92
+ <Heading level={1} size="h5">Fix the sign-up email</Heading>
93
+ <Cluster gap="small">
94
+ {/* The names say who is there, so the faces are decorative */}
95
+ <Cluster gap="small">
96
+ {people.map((name) => (
97
+ <UserImage key={name} userHandle={name} size={24} decorative />
98
+ ))}
99
+ </Cluster>
100
+ {/* The same words as the people in the array, in the wording AvatarStack names a group with: 'A, B and C' */}
101
+ <Paragraph tone="secondary" size="body2" measure="none">Dana Lee, Ben Carter and Omar Reyes</Paragraph>
102
+ </Cluster>
103
+ </Stack>
104
+ );
105
+ }
106
+ ```
107
+
108
+ ## Native
109
+
110
+ On Apple show overlapping images in an `HStack` with negative spacing, as one accessibility element with the names, and a `Menu` or popover that lists everyone. On Android use the same in a `Row`, with a dropdown menu.
@@ -5,12 +5,24 @@ import Form from '../../components/form';
5
5
  import FormField from '../../components/formField';
6
6
  import TextField from '../../components/textField';
7
7
  import Button from '../../components/button';
8
- import Alert from '../../components/alert';
9
8
  import UserImage from '../../components/userImage';
9
+ import DropZone from '../../components/dropZone';
10
+ import { formatBytes } from '../../components/formatNumber';
10
11
  import SettingsSection from '../../components/settingsSection';
11
12
  import { Center, Cluster, Stack } from '../../components/layout';
12
13
  // A picture the person chose. A real app uploads the file and gets a URL back.
13
14
  var chosenPicture = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' fill='%232f6b4f'/%3E%3Ccircle cx='32' cy='25' r='11' fill='%23fff'/%3E%3Cpath d='M10 64c2-15 11-22 22-22s20 7 22 22z' fill='%23fff'/%3E%3C/svg%3E";
15
+ // 5 MB as formatBytes counts it (base 1024), so the words and the check agree
16
+ var maxPictureBytes = 5 * 1024 * 1024;
17
+ // The zone reports a reason. The words are this page's, shown under the picture.
18
+ function sayRejected(rejections) {
19
+ var reason = rejections[0].reason;
20
+ if (reason === 'type')
21
+ return 'Choose a JPG, PNG or WebP picture.';
22
+ if (reason === 'size')
23
+ return "Choose a picture under ".concat(formatBytes(maxPictureBytes), ".");
24
+ return 'Choose one picture.';
25
+ }
14
26
  var minPasswordLength = 8;
15
27
  // Stands in for the server's check. In this example every current password is right except this one.
16
28
  var wrongCurrentPassword = 'incorrect';
@@ -112,16 +124,15 @@ export default function ProfileForm() {
112
124
  <Heading level={1} size="h5">Profile</Heading>
113
125
 
114
126
  <SettingsSection title="Picture" description="Shown beside your name in Acme.">
115
- <Cluster gap="large">
116
- <UserImage userHandle={savedName} userImgUrl={picture} size={64}/>
117
- <Stack gap="small">
118
- <Cluster gap="small">
119
- <Button size="small" type="secondary" state={savingPicture === 'remove' ? 'disabled' : 'enabled'} label="Change Picture" loading={savingPicture === 'change'} onClickButton={function () { return savePicture(chosenPicture, 'change'); }}/>
127
+ {/* The error shows under the picture and its Buttons, and is read with the zone. */}
128
+ <FormField id="profile-form-picture" label="New picture" error={pictureError}>
129
+ {function (f) { return (<Cluster gap="small">
130
+ <DropZone id={f.id} size="compact" label="Drop a picture here" buttonLabel="Change Picture" hint={"JPG, PNG or WebP, up to ".concat(formatBytes(maxPictureBytes))} accept={['image/jpeg', 'image/png', 'image/webp']} maxBytes={maxPictureBytes} loading={savingPicture === 'change'} disabled={savingPicture === 'remove'} aria-describedby={f['aria-describedby']} aria-invalid={f['aria-invalid']} status={pictureError || undefined} onFiles={function () { return savePicture(chosenPicture, 'change'); }} onReject={function (rejections) { return setPictureError(sayRejected(rejections)); }}>
131
+ <UserImage userHandle={savedName} userImgUrl={picture} size={64}/>
132
+ </DropZone>
120
133
  {picture && <Button size="small" type="tertiary" state={savingPicture === 'change' ? 'disabled' : 'enabled'} label="Remove" aria-label="Remove picture" loading={savingPicture === 'remove'} onClickButton={function () { return savePicture(undefined, 'remove'); }}/>}
121
- </Cluster>
122
- {pictureError && <Alert type="error" variant="inline" autoDismiss={false} message={pictureError}/>}
123
- </Stack>
124
- </Cluster>
134
+ </Cluster>); }}
135
+ </FormField>
125
136
  </SettingsSection>
126
137
 
127
138
  <SettingsSection title="Name" description="How people see you in messages and on tasks.">