@estiva-app/ui 0.99.0 → 0.100.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 (50) hide show
  1. package/README.md +3 -1
  2. package/dist/ConversationCard.d.ts +6 -0
  3. package/dist/ConversationCard.d.ts.map +1 -1
  4. package/dist/ConversationLayout.d.ts +1 -1
  5. package/dist/ConversationLayout.d.ts.map +1 -1
  6. package/dist/ConversationMenu.d.ts +5 -1
  7. package/dist/ConversationMenu.d.ts.map +1 -1
  8. package/dist/Menu.d.ts +11 -3
  9. package/dist/Menu.d.ts.map +1 -1
  10. package/dist/MoveDialog.d.ts +6 -3
  11. package/dist/MoveDialog.d.ts.map +1 -1
  12. package/dist/RepliesRow.d.ts +5 -3
  13. package/dist/RepliesRow.d.ts.map +1 -1
  14. package/dist/Thread.d.ts +1 -1
  15. package/dist/Thread.d.ts.map +1 -1
  16. package/dist/index.js +62 -35
  17. package/dist/index.js.map +2 -2
  18. package/package.json +1 -1
  19. package/registry.json +80 -12
  20. package/src/ConversationCard.mdx +4 -0
  21. package/src/ConversationCard.states.test.tsx +67 -0
  22. package/src/ConversationCard.stories.tsx +16 -0
  23. package/src/ConversationCard.tsx +14 -6
  24. package/src/ConversationLayout.mdx +4 -0
  25. package/src/ConversationLayout.stories.tsx +28 -0
  26. package/src/ConversationLayout.test.tsx +54 -0
  27. package/src/ConversationLayout.tsx +6 -2
  28. package/src/ConversationMenu.mdx +3 -0
  29. package/src/ConversationMenu.stories.tsx +12 -0
  30. package/src/ConversationMenu.test.tsx +17 -0
  31. package/src/ConversationMenu.tsx +7 -3
  32. package/src/Menu.test.tsx +80 -0
  33. package/src/Menu.tsx +35 -14
  34. package/src/MenuItem.mdx +12 -0
  35. package/src/MenuItem.stories.tsx +39 -1
  36. package/src/MoveDialog.mdx +12 -1
  37. package/src/MoveDialog.stories.tsx +13 -0
  38. package/src/MoveDialog.test.tsx +36 -0
  39. package/src/MoveDialog.tsx +6 -3
  40. package/src/RepliesRow.mdx +6 -3
  41. package/src/RepliesRow.stories.tsx +3 -0
  42. package/src/RepliesRow.test.tsx +24 -0
  43. package/src/RepliesRow.tsx +12 -6
  44. package/src/ReplyCard.mdx +5 -0
  45. package/src/ReplyCard.stories.tsx +26 -0
  46. package/src/Thread.mdx +3 -1
  47. package/src/Thread.stories.tsx +39 -0
  48. package/src/Thread.tsx +6 -4
  49. package/src/seenOnScreen.test.tsx +59 -0
  50. package/stories/Choosing.mdx +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/ui",
3
- "version": "0.99.0",
3
+ "version": "0.100.0",
4
4
  "description": "Estiva's design tokens (the contract) and a small set of primitives (a convenience) for every Estiva app.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/registry.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "kind": "package",
5
5
  "repo": "estiva-ui",
6
6
  "package": "@estiva-app/ui",
7
- "packageVersion": "0.99.0",
7
+ "packageVersion": "0.100.0",
8
8
  "exports": 243,
9
9
  "typeExports": 249,
10
10
  "files": null
@@ -2957,6 +2957,18 @@
2957
2957
  "required": false,
2958
2958
  "note": "Edit's words in the ⋯ menu: \"Edit\" by default; Peek's \"Edit message\"."
2959
2959
  },
2960
+ {
2961
+ "name": "deleteLabel",
2962
+ "takes": "text",
2963
+ "required": false,
2964
+ "note": "Delete's words in the ⋯ menu: \"Delete\" by default; Ship's \"Delete message\"."
2965
+ },
2966
+ {
2967
+ "name": "moreLabel",
2968
+ "takes": "text",
2969
+ "required": false,
2970
+ "note": "The ⋯ button's name and tooltip: \"More actions\" by default; Ship's \"Message actions\"."
2971
+ },
2960
2972
  {
2961
2973
  "name": "className",
2962
2974
  "takes": "text",
@@ -3029,7 +3041,7 @@
3029
3041
  "name": "below",
3030
3042
  "takes": "anything",
3031
3043
  "required": false,
3032
- "note": "Two columns: under the comments, inside their list, or under the empty line: a `ReactionHorizon`."
3044
+ "note": "Under the comments, inside their list, or under the empty line: a `ReactionHorizon`, or the app's own note."
3033
3045
  },
3034
3046
  {
3035
3047
  "name": "top",
@@ -3185,6 +3197,18 @@
3185
3197
  "required": false,
3186
3198
  "note": "Offered on your own only; the card asks before it deletes."
3187
3199
  },
3200
+ {
3201
+ "name": "deleteLabel",
3202
+ "takes": "text",
3203
+ "required": false,
3204
+ "note": "Delete's words: \"Delete\" by default; Ship's \"Delete message\"."
3205
+ },
3206
+ {
3207
+ "name": "moreLabel",
3208
+ "takes": "text",
3209
+ "required": false,
3210
+ "note": "Its own ⋯ button's name and tooltip, with no `trigger`: \"More actions\" by default; Ship's \"Message actions\"."
3211
+ },
3188
3212
  {
3189
3213
  "name": "open",
3190
3214
  "takes": "true/false",
@@ -4147,6 +4171,7 @@
4147
4171
  "docPage": null,
4148
4172
  "app": null,
4149
4173
  "looks": [
4174
+ "cursor-pointer rounded-lg text-left outline-none",
4150
4175
  "text-menu signal:font-mono signal:text-small signal:tracking-wider leaf:font-mono leaf:text-small leaf:tracking-wider"
4151
4176
  ]
4152
4177
  },
@@ -6651,7 +6676,9 @@
6651
6676
  "storyId": "menus-windows-menu--items",
6652
6677
  "docPage": "src/Menu.mdx",
6653
6678
  "app": null,
6654
- "looks": []
6679
+ "looks": [
6680
+ "cursor-pointer rounded-lg text-left outline-none"
6681
+ ]
6655
6682
  },
6656
6683
  {
6657
6684
  "name": "MenuItem",
@@ -6733,6 +6760,12 @@
6733
6760
  "takes": "true/false",
6734
6761
  "required": false,
6735
6762
  "note": "The row the menu currently points at (a submenu's chosen value)."
6763
+ },
6764
+ {
6765
+ "name": "disabledReason",
6766
+ "takes": "text",
6767
+ "required": false,
6768
+ "note": "Why it cannot be chosen right now: the row is shown, shut, in the disabled colour, with no fill, and says why under the pointer and when the arrow keys reach it, as `Button`'s does."
6736
6769
  }
6737
6770
  ],
6738
6771
  "variants": [
@@ -6760,7 +6793,9 @@
6760
6793
  "storyId": "menus-windows-menuitem--default",
6761
6794
  "docPage": "src/MenuItem.mdx",
6762
6795
  "app": null,
6763
- "looks": []
6796
+ "looks": [
6797
+ "cursor-pointer rounded-lg text-left outline-none"
6798
+ ]
6764
6799
  },
6765
6800
  {
6766
6801
  "name": "MenuPanel",
@@ -6787,7 +6822,8 @@
6787
6822
  "docPage": null,
6788
6823
  "app": null,
6789
6824
  "looks": [
6790
- "rounded-lg border border-border-default bg-bg-elevated shadow-lg"
6825
+ "rounded-lg border border-border-default bg-bg-elevated shadow-lg",
6826
+ "cursor-pointer rounded-lg text-left outline-none"
6791
6827
  ]
6792
6828
  },
6793
6829
  {
@@ -6820,7 +6856,9 @@
6820
6856
  "storyId": "menus-windows-menu--items",
6821
6857
  "docPage": null,
6822
6858
  "app": null,
6823
- "looks": []
6859
+ "looks": [
6860
+ "cursor-pointer rounded-lg text-left outline-none"
6861
+ ]
6824
6862
  },
6825
6863
  {
6826
6864
  "name": "MenuSection",
@@ -6867,7 +6905,9 @@
6867
6905
  "storyId": "menus-windows-menu--items",
6868
6906
  "docPage": null,
6869
6907
  "app": null,
6870
- "looks": []
6908
+ "looks": [
6909
+ "cursor-pointer rounded-lg text-left outline-none"
6910
+ ]
6871
6911
  },
6872
6912
  {
6873
6913
  "name": "MenuSeparator",
@@ -6886,7 +6926,9 @@
6886
6926
  "storyId": "menus-windows-menu--items",
6887
6927
  "docPage": null,
6888
6928
  "app": null,
6889
- "looks": []
6929
+ "looks": [
6930
+ "cursor-pointer rounded-lg text-left outline-none"
6931
+ ]
6890
6932
  },
6891
6933
  {
6892
6934
  "name": "MenuSub",
@@ -6945,7 +6987,9 @@
6945
6987
  "storyId": "menus-windows-menu--items",
6946
6988
  "docPage": null,
6947
6989
  "app": null,
6948
- "looks": []
6990
+ "looks": [
6991
+ "cursor-pointer rounded-lg text-left outline-none"
6992
+ ]
6949
6993
  },
6950
6994
  {
6951
6995
  "name": "MetaText",
@@ -7050,7 +7094,7 @@
7050
7094
  "name": "from",
7051
7095
  "takes": "text",
7052
7096
  "required": true,
7053
- "note": "The Folder it is in now."
7097
+ "note": "The Folder it is in now, not offered to a file that nests under nothing."
7054
7098
  },
7055
7099
  {
7056
7100
  "name": "folders",
@@ -9141,7 +9185,7 @@
9141
9185
  "kind": "component",
9142
9186
  "importPath": "@estiva-app/ui",
9143
9187
  "sourceFile": "src/RepliesRow.tsx",
9144
- "purpose": "The way into a thread, under its comment: who replied, \"2 replies\", the last reply's time, and \"1 new\" until it is read.",
9188
+ "purpose": "The way into a thread, under its comment: who replied, \"2 replies\", the last reply's time, and how many are new (\"2 new\") until they are read.",
9145
9189
  "purposeFrom": "page",
9146
9190
  "props": [
9147
9191
  {
@@ -9168,6 +9212,12 @@
9168
9212
  "required": false,
9169
9213
  "note": "\"1 new\": a reply you have not read."
9170
9214
  },
9215
+ {
9216
+ "name": "newCount",
9217
+ "takes": "number",
9218
+ "required": false,
9219
+ "note": "How many replies you have not read: \"2 new\", and the row's name says it too."
9220
+ },
9171
9221
  {
9172
9222
  "name": "urgent",
9173
9223
  "takes": "true/false",
@@ -9217,6 +9267,12 @@
9217
9267
  "required": false,
9218
9268
  "note": "Its id, on the card as `data-reply-id`: what a link to it shows (`showInConversation`), and what `Thread` watches to say it was seen."
9219
9269
  },
9270
+ {
9271
+ "name": "noun",
9272
+ "takes": "text",
9273
+ "required": false,
9274
+ "note": "What the reply is called in the delete question: \"Delete this reply?\" by default; Ship's `message`."
9275
+ },
9220
9276
  {
9221
9277
  "name": "author",
9222
9278
  "takes": "ConversationPerson",
@@ -9361,6 +9417,18 @@
9361
9417
  "required": false,
9362
9418
  "note": "Edit's words in the ⋯ menu: \"Edit\" by default; Peek's \"Edit message\"."
9363
9419
  },
9420
+ {
9421
+ "name": "deleteLabel",
9422
+ "takes": "text",
9423
+ "required": false,
9424
+ "note": "Delete's words in the ⋯ menu: \"Delete\" by default; Ship's \"Delete message\"."
9425
+ },
9426
+ {
9427
+ "name": "moreLabel",
9428
+ "takes": "text",
9429
+ "required": false,
9430
+ "note": "The ⋯ button's name and tooltip: \"More actions\" by default; Ship's \"Message actions\"."
9431
+ },
9364
9432
  {
9365
9433
  "name": "className",
9366
9434
  "takes": "text",
@@ -10988,7 +11056,7 @@
10988
11056
  "name": "seen",
10989
11057
  "takes": "SeenOnScreen",
10990
11058
  "required": false,
10991
- "note": "Beside: what `useSeenOnScreen` made for this thread: it watches its replies (each `ReplyCard`'s `id`), and says in it which were seen."
11059
+ "note": "What `useSeenOnScreen` made for this thread: it watches its replies (each `ReplyCard`'s `id`), beside or under its comment, and says in it which were seen."
10992
11060
  },
10993
11061
  {
10994
11062
  "name": "className",
@@ -15,8 +15,12 @@ One comment, the same in every app: who, when, the words, files, cards, reaction
15
15
  - `own` on yours: Edit (with `editor`) and Delete (with `onDelete`) in its menu. The card asks before it deletes.
16
16
  - `resolved`: "✓ Resolved" by the time, with who, when and the note on hover; "Person two → the note · time" above its replies row. Nothing of the comment is hidden: its words, cards, files and reactions stay.
17
17
  - `noun`: what the delete question calls it, "Delete this comment?" by default; a direct message says `message`.
18
+ - In the app's own words, the ⋯ menu: `menuLabel` heads its first rows, `editLabel` and `deleteLabel` are Edit's and Delete's words ("Edit message", "Delete message"), and `moreLabel` names the ⋯ button, its tooltip too ("Message actions"; "More actions" by default).
19
+
20
+ <Canvas of={Stories.InAnAppsWords} />
18
21
  - `about` on a comment on a part of the page: a **QuotedLine** under the name, above the words.
19
22
  - `isNew`, `urgent`: the dot or the urgent mark, and a hairline, until it is read.
23
+ - `replies.newCount`, how many replies under it are new: its replies row says "2 new", and the comment takes the hairline too. `replies.isNew` alone says "1 new".
20
24
  - `at`, its moment: the time says the exact date and time under the pointer, in the reader's own way. Give it on every comment.
21
25
 
22
26
  <Canvas of={Stories.Replies} />
@@ -195,6 +195,16 @@ describe('new and urgent (Peek: ConversationCard.urgent, the card’s part)', ()
195
195
  expect(screen.getByText('1 new')).toBeTruthy()
196
196
  })
197
197
 
198
+ it('replies under it new by count mark the comment too, and its row says how many (Ship, 2 November): "2 new"', () => {
199
+ const { container } = render(
200
+ <ConversationCard author={ONE} time="11:08 AM" replies={{ count: 3, newCount: 2 }}>
201
+ Words
202
+ </ConversationCard>,
203
+ )
204
+ expect(container.firstElementChild?.className).toMatch(/\bborder-accent-outline\b/)
205
+ expect(screen.getByText('2 new')).toBeTruthy()
206
+ })
207
+
198
208
  it('read, it draws neither mark nor edge', () => {
199
209
  const { container } = render(
200
210
  <ConversationCard author={ONE} time="11:08 AM">
@@ -348,3 +358,60 @@ describe('its files, what it is about, and how it was resolved', () => {
348
358
  expect(container.querySelector('[data-resolved="line"]')).toBeNull()
349
359
  })
350
360
  })
361
+
362
+ describe('an app’s own words and counts (Ship, 2 November: Ship takes the one conversation with its own words)', () => {
363
+ it('asks about a reply in the app’s noun, "Delete this message?", and as a reply by default', async () => {
364
+ render(
365
+ <ReplyCard author={ONE} time="11:40 AM" own onDelete={() => {}} noun="message">
366
+ A reply
367
+ </ReplyCard>,
368
+ )
369
+ point('A reply')
370
+ fireEvent.click(screen.getByRole('button', { name: 'More actions' }))
371
+ fireEvent.click(await screen.findByRole('menuitem', { name: 'Delete' }))
372
+ expect(await screen.findByText('Delete this message?')).toBeTruthy()
373
+ expect(screen.getByRole('button', { name: 'Delete message' })).toBeTruthy()
374
+ cleanup()
375
+ render(
376
+ <ReplyCard author={ONE} time="11:40 AM" own onDelete={() => {}}>
377
+ A reply
378
+ </ReplyCard>,
379
+ )
380
+ point('A reply')
381
+ fireEvent.click(screen.getByRole('button', { name: 'More actions' }))
382
+ fireEvent.click(await screen.findByRole('menuitem', { name: 'Delete' }))
383
+ expect(await screen.findByText('Delete this reply?')).toBeTruthy()
384
+ expect(screen.getByRole('button', { name: 'Delete reply' })).toBeTruthy()
385
+ })
386
+
387
+ it('names the ⋯ and its Delete row in the app’s words, "Message actions" and "Delete message", on a comment and a reply', async () => {
388
+ for (const Part of [ConversationCard, ReplyCard]) {
389
+ const onDelete = vi.fn()
390
+ render(
391
+ <Part author={ONE} time="11:08 AM" own onDelete={onDelete} noun="message" moreLabel="Message actions" deleteLabel="Delete message">
392
+ Words
393
+ </Part>,
394
+ )
395
+ point('Words')
396
+ expect(screen.queryByRole('button', { name: 'More actions' })).toBeNull()
397
+ fireEvent.click(screen.getByRole('button', { name: 'Message actions' }))
398
+ fireEvent.click(await screen.findByRole('menuitem', { name: 'Delete message' }))
399
+ expect(await screen.findByText('Delete this message?')).toBeTruthy()
400
+ fireEvent.click(screen.getByRole('button', { name: 'Delete message' }))
401
+ await vi.waitFor(() => expect(onDelete).toHaveBeenCalledOnce())
402
+ cleanup()
403
+ }
404
+ })
405
+
406
+ it('says the ⋯ button’s name as its tooltip too', async () => {
407
+ const user = userEvent.setup()
408
+ render(
409
+ <ReplyCard author={ONE} time="11:40 AM" own onDelete={() => {}} moreLabel="Message actions">
410
+ A reply
411
+ </ReplyCard>,
412
+ )
413
+ point('A reply')
414
+ await user.hover(screen.getByRole('button', { name: 'Message actions' }))
415
+ expect((await screen.findByRole('tooltip')).textContent).toBe('Message actions')
416
+ })
417
+ })
@@ -95,6 +95,9 @@ export const New: Story = { render: (args) => <Live {...args} isNew /> }
95
95
  /** A reply under it not read yet. */
96
96
  export const NewReply: Story = { name: 'New reply', render: (args) => <Live {...args} replies={{ count: 2, faces: [TWO, THREE], last: '12:02 PM', isNew: true }} onClick={() => {}} /> }
97
97
 
98
+ /** Replies under it not read yet, by count: the row says how many. */
99
+ export const NewReplies: Story = { name: 'New replies, how many', render: (args) => <Live {...args} replies={{ count: 3, faces: [TWO, THREE, YOU], last: '12:02 PM', newCount: 2 }} onClick={() => {}} /> }
100
+
98
101
  /** Urgent and not read yet. */
99
102
  export const Urgent: Story = { render: (args) => <Live {...args} isNew urgent replies={{ count: 1, faces: [TWO], last: '12:02 PM', isNew: true }} /> }
100
103
 
@@ -138,6 +141,19 @@ export const ReadOnly: Story = { name: 'Read-only', render: (args) => <Live {...
138
141
  /** A long comment, at its full height. */
139
142
  export const Long: Story = { render: (args) => <Live {...args}>{LONG}</Live> }
140
143
 
144
+ /**
145
+ * Yours, in an app's own words: the ⋯ named "Message actions", its Delete row "Delete message", and the question
146
+ * asking about a message (`noun`). The story points at it and opens the menu.
147
+ */
148
+ export const InAnAppsWords: Story = {
149
+ name: "In an app's words",
150
+ render: (args) => <Live {...args} author={YOU} own noun="message" deleteLabel="Delete message" moreLabel="Message actions" />,
151
+ play: async ({ canvasElement }) => {
152
+ await userEvent.hover(within(canvasElement).getByText(WORDS))
153
+ await userEvent.click(within(canvasElement).getByRole('button', { name: 'Message actions' }))
154
+ },
155
+ }
156
+
141
157
  /** The app's own rows in its ⋯ menu, between Resolve and Edit. */
142
158
  export const MoreRows: Story = {
143
159
  name: 'More rows',
@@ -78,6 +78,10 @@ export interface ConversationEntryProps {
78
78
  menuLabel?: string
79
79
  /** Edit's words in the ⋯ menu: "Edit" by default; Peek's "Edit message". */
80
80
  editLabel?: string
81
+ /** Delete's words in the ⋯ menu: "Delete" by default; Ship's "Delete message". The question's button says `noun`'s. */
82
+ deleteLabel?: string
83
+ /** The ⋯ button's name and tooltip: "More actions" by default; Ship's "Message actions". */
84
+ moreLabel?: string
81
85
  /** Placement only. */
82
86
  className?: string
83
87
  }
@@ -116,6 +120,8 @@ export interface ConversationCardProps extends ConversationEntryProps {
116
120
  export interface ReplyCardProps extends ConversationEntryProps {
117
121
  /** Its id, on the card as `data-reply-id`: what a link to it shows (`showInConversation`), and what `Thread` watches to say it was seen. */
118
122
  id?: string
123
+ /** What the reply is called in the delete question: "Delete this reply?" by default; Ship's `message`. */
124
+ noun?: string
119
125
  }
120
126
 
121
127
  /**
@@ -264,7 +270,7 @@ function useEditing(editing: boolean | undefined, onEditingChange: ((editing: bo
264
270
  * The same card in every app, each in its own colours (the record that makes one conversation). Peek's, moved.
265
271
  */
266
272
  export function ConversationCard(props: ConversationCardProps) {
267
- const { author, about, files, reactions, reactionRefused, isNew = false, urgent = false, own = false, editor, deleted = false, replies, onReply, resolved, noun = 'comment', onResolve, resolveHint, resolveRefused, onReopen, selected, onClick, onDelete, deleteNote, menu, menuAfter, menuLabel, editLabel, className, children } = props
273
+ const { author, about, files, reactions, reactionRefused, isNew = false, urgent = false, own = false, editor, deleted = false, replies, onReply, resolved, noun = 'comment', onResolve, resolveHint, resolveRefused, onReopen, selected, onClick, onDelete, deleteNote, menu, menuAfter, menuLabel, editLabel, deleteLabel, moreLabel = 'More actions', className, children } = props
268
274
  const readOnly = (props.readOnly ?? false) || deleted
269
275
  const inThreadCard = useContext(InThreadCard)
270
276
 
@@ -317,7 +323,7 @@ export function ConversationCard(props: ConversationCardProps) {
317
323
  hovered={hovered}
318
324
  selected={marked}
319
325
  active={isEditing}
320
- attention={attentionOf(isNew || !!replies?.isNew, urgent, inThreadCard)}
326
+ attention={attentionOf(isNew || (replies?.newCount ?? (replies?.isNew ? 1 : 0)) > 0, urgent, inThreadCard)}
321
327
  className={cn('relative', className)}
322
328
  // A press opens its thread, wherever it lands on the card but for what acts by itself (Card's `onPress`). Before,
323
329
  // the whole reactions row and the strip stopped every press, so a press beside the reactions did nothing
@@ -403,7 +409,7 @@ export function ConversationCard(props: ConversationCardProps) {
403
409
  offersMenu && (
404
410
  <ConversationMenu
405
411
  trigger={
406
- <ToolbarButton tooltip="More actions" aria-label="More actions">
412
+ <ToolbarButton tooltip={moreLabel} aria-label={moreLabel}>
407
413
  <IconDotsVertical size={16} stroke={1.5} />
408
414
  </ToolbarButton>
409
415
  }
@@ -421,6 +427,7 @@ export function ConversationCard(props: ConversationCardProps) {
421
427
  editLabel={editLabel}
422
428
  after={menuAfter}
423
429
  onDelete={own && onDelete ? () => setDeleting(true) : undefined}
430
+ deleteLabel={deleteLabel}
424
431
  >
425
432
  {menu}
426
433
  </ConversationMenu>
@@ -462,7 +469,7 @@ export function ConversationCard(props: ConversationCardProps) {
462
469
  * when it has one. Peek's, moved with the conversation.
463
470
  */
464
471
  export function ReplyCard(props: ReplyCardProps) {
465
- const { id, author, about, files, reactions, reactionRefused, isNew = false, urgent = false, own = false, editor, onDelete, deleteNote, menu, menuAfter, menuLabel, editLabel, className, children } = props
472
+ const { id, author, about, files, reactions, reactionRefused, isNew = false, urgent = false, own = false, editor, onDelete, deleteNote, menu, menuAfter, menuLabel, editLabel, deleteLabel, moreLabel = 'More actions', noun = 'reply', className, children } = props
466
473
  const readOnly = props.readOnly ?? false
467
474
  const [hovered, setHovered] = useState(false)
468
475
  const [menuOpen, setMenuOpen] = useState(false)
@@ -529,7 +536,7 @@ export function ReplyCard(props: ReplyCardProps) {
529
536
  offersMenu && (
530
537
  <ConversationMenu
531
538
  trigger={
532
- <ToolbarButton tooltip="More actions" aria-label="More actions">
539
+ <ToolbarButton tooltip={moreLabel} aria-label={moreLabel}>
533
540
  <IconDotsVertical size={16} stroke={1.5} />
534
541
  </ToolbarButton>
535
542
  }
@@ -543,6 +550,7 @@ export function ReplyCard(props: ReplyCardProps) {
543
550
  editLabel={editLabel}
544
551
  after={menuAfter}
545
552
  onDelete={own && onDelete ? () => setDeleting(true) : undefined}
553
+ deleteLabel={deleteLabel}
546
554
  >
547
555
  {menu}
548
556
  </ConversationMenu>
@@ -552,7 +560,7 @@ export function ReplyCard(props: ReplyCardProps) {
552
560
  )}
553
561
  </Card>
554
562
  {deleting && onDelete && (
555
- <ConfirmDialog title="Delete this reply?" confirmLabel="Delete reply" destructive onConfirm={onDelete} onClose={() => setDeleting(false)}>
563
+ <ConfirmDialog title={`Delete this ${noun}?`} confirmLabel={`Delete ${noun}`} destructive onConfirm={onDelete} onClose={() => setDeleting(false)}>
556
564
  {deleteNote === undefined ? <p>It is deleted for everyone.</p> : typeof deleteNote === 'string' ? <p>{deleteNote}</p> : deleteNote}
557
565
  </ConfirmDialog>
558
566
  )}
@@ -29,6 +29,10 @@ Where a conversation's cards sit: two columns, or one 384px column beside the pa
29
29
 
30
30
  <Canvas of={Stories.Apart} />
31
31
 
32
+ - With one column too, `below` is under the comments, after the groups: a **ReactionHorizon**, or the app's own note. It stands at the column's foot, so with few comments it sits on the box, as a short conversation's last line does with two columns; with many it comes after them and scrolls with them. The comments still start at the top. Not while the comments are read.
33
+
34
+ <Canvas of={Stories.OneColumnBelow} />
35
+
32
36
  ## When not
33
37
 
34
38
  - One thread on its own → **Thread**.
@@ -266,6 +266,34 @@ export const Apart: Story = {
266
266
  },
267
267
  }
268
268
 
269
+ /**
270
+ * One column, a note under the comments (`below`), here a `ReactionHorizon`: after the groups, at the column's foot, so
271
+ * with few comments it sits on the box. The comments stay at the top.
272
+ */
273
+ export const OneColumnBelow: Story = {
274
+ name: 'One column, a note under the comments',
275
+ render: function Render() {
276
+ const [open, setOpen] = useState<string | undefined>(undefined)
277
+ return (
278
+ <>
279
+ <div className="flex min-w-0 flex-1 flex-col">
280
+ <Page />
281
+ </div>
282
+ <div className="flex border-l border-border-subtle">
283
+ <ConversationLayout
284
+ threads="under"
285
+ items={useItems('under', open, setOpen, true, true)}
286
+ open={open}
287
+ onOpenChange={setOpen}
288
+ below={<ReactionHorizon limit={100} omitted={3} />}
289
+ box={<WriteBox label="Comment" />}
290
+ />
291
+ </div>
292
+ </>
293
+ )
294
+ },
295
+ }
296
+
269
297
  /** Nobody has commented yet. */
270
298
  export const Empty: Story = {
271
299
  render: () => (
@@ -417,3 +417,57 @@ describe('ConversationLayout, two columns, the right column', () => {
417
417
  expect(column()).toBeNull()
418
418
  })
419
419
  })
420
+
421
+ describe('ConversationLayout, one column, under the comments (below; Ship, 2 November)', () => {
422
+ it('draws `below` under the comments, the groups too, inside the column that scrolls and above the box', () => {
423
+ const resolved: ConversationItem = {
424
+ id: 'r',
425
+ resolved: true,
426
+ card: (
427
+ <ConversationCard author={ONE} time="12:15 PM">
428
+ Resolved one
429
+ </ConversationCard>
430
+ ),
431
+ }
432
+ render(<ConversationLayout threads="under" items={[...items('under'), resolved]} below={<p>Reactions note</p>} box={<p>The box</p>} />)
433
+ const note = screen.getByText('Reactions note')
434
+ const follows = (a: Node, b: Node) => !!(a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING)
435
+ expect(follows(screen.getByText('No replies yet'), note)).toBe(true)
436
+ expect(follows(screen.getByRole('button', { name: /Resolved/ }), note)).toBe(true)
437
+ expect(follows(note, screen.getByText('The box'))).toBe(true)
438
+ // In the comments' own box, the one that scrolls: not in the footer with the box.
439
+ expect(note.closest('[data-conversation-item]')).toBeNull()
440
+ expect(screen.getByText('The box').parentElement?.contains(note)).toBe(false)
441
+ })
442
+
443
+ it('under the empty line too, and not while the comments are read', () => {
444
+ render(<ConversationLayout threads="under" items={[]} below={<p>Reactions note</p>} />)
445
+ expect(screen.getByText('Reactions note')).toBeTruthy()
446
+ cleanup()
447
+ render(<ConversationLayout threads="under" items={[]} loading below={<p>Reactions note</p>} />)
448
+ expect(screen.queryByText('Reactions note')).toBeNull()
449
+ })
450
+ })
451
+
452
+ describe('ConversationLayout, one column, the note sits on the box (Katerina, 2 November: as in Peek)', () => {
453
+ it('pushes `below` to the foot of a column at least as tall as its room, the comments staying at the top', () => {
454
+ render(<ConversationLayout threads="under" items={items('under')} below={<p>Reactions note</p>} box={<p>The box</p>} />)
455
+ const pushed = screen.getByText('Reactions note').closest('.mt-auto')
456
+ expect(pushed).not.toBeNull()
457
+ const body = pushed!.parentElement!
458
+ // The scrolling box's content is at least the column's height, so the room a short conversation leaves is above the note.
459
+ expect(body.className.split(/\s+/)).toContain('min-h-full')
460
+ // Only the note moves: the comments are the body's first children, and none is pushed.
461
+ const first = document.querySelector('[data-conversation-item="a"]')!
462
+ expect(body.firstElementChild).toBe(first)
463
+ expect(document.querySelectorAll('[data-conversation-item].mt-auto, [data-conversation-item] .mt-auto').length).toBe(0)
464
+ })
465
+
466
+ it('pushes nothing while the comments are read, and with no note', () => {
467
+ const { container } = render(<ConversationLayout threads="under" items={[]} loading below={<p>Reactions note</p>} />)
468
+ expect(container.querySelector('.mt-auto')).toBeNull()
469
+ cleanup()
470
+ const again = render(<ConversationLayout threads="under" items={items('under')} />)
471
+ expect(again.container.querySelector('.mt-auto')).toBeNull()
472
+ })
473
+ })
@@ -53,7 +53,7 @@ export interface ConversationLayoutProps {
53
53
  box?: ReactNode
54
54
  /** Above the comments, inside their list: placeholders while older comments are read, a note. */
55
55
  above?: ReactNode
56
- /** Two columns: under the comments, inside their list, or under the empty line: a `ReactionHorizon`. Not while the comments are read. */
56
+ /** Under the comments, inside their list, or under the empty line: a `ReactionHorizon`, or the app's own note. One column: after "Resolved" too, at the column's foot, so with few comments it sits on the box. Not while the comments are read. */
57
57
  below?: ReactNode
58
58
  /** Two columns: at the top of the column however few the comments are, over the room a short conversation leaves: an `ArchivedNotice`. */
59
59
  top?: ReactNode
@@ -378,8 +378,12 @@ export function ConversationLayout({
378
378
  }))
379
379
  if (threads === 'under') {
380
380
  return (
381
- <Panel className={cn('w-[384px] flex-none', className)} title={title} actions={actions} bodyRef={setBody} bodyClassName="flex flex-col gap-2 p-3" footer={box && <div className="p-3">{box}</div>}>
381
+ // The body at least the column's height: the comments start at its top, and the note under them (`below`) is pushed
382
+ // to its foot, so with few comments it sits on the box, as a short conversation's last line does in Peek's two
383
+ // columns (Katerina, 2 November); with many it comes after them, and scrolls with them.
384
+ <Panel className={cn('w-[384px] flex-none', className)} title={title} actions={actions} bodyRef={setBody} bodyClassName="flex min-h-full flex-col gap-2 p-3" footer={box && <div className="p-3">{box}</div>}>
382
385
  <List items={items} open={open} under above={above} loading={loading} empty={empty} change={change} caret={caret} />
386
+ {!loading && below != null && below !== false && below !== '' && <div className="mt-auto flex flex-col gap-2">{below}</div>}
383
387
  </Panel>
384
388
  )
385
389
  }
@@ -14,9 +14,12 @@ The ⋯ menu of a comment or a reply: Resolve or Reopen and the app's own rows;
14
14
  - Inside **ConversationCard** and **ReplyCard**, which draw it for you.
15
15
  - Its `children` are the app's own rows, after Resolve; `after`, its rows after Edit.
16
16
  - In the app's own words: `label` heads the first rows, `resolveHint` stands beside Resolve, `editLabel` is Edit's word. Peek's menu reads as it did with them (Katerina, 1 November).
17
+ - `deleteLabel` is Delete's words ("Delete message"), and `moreLabel` names its own ⋯ button, its tooltip too, when no `trigger` is given ("More actions" by default; "Message actions"). Ship's menu reads as it did with them (2 November).
17
18
 
18
19
  <Canvas of={Stories.InAnAppsWords} />
19
20
 
21
+ <Canvas of={Stories.OwnButtonInAnAppsWords} />
22
+
20
23
  <Canvas of={Stories.Theirs} />
21
24
 
22
25
  <Canvas of={Stories.MoreRows} />
@@ -41,6 +41,18 @@ export const MoreRows: Story = {
41
41
  args: { onResolve: () => {}, onEdit: () => {}, onDelete: () => {}, children: <MenuItem label="Item one" onClick={() => {}} /> },
42
42
  }
43
43
 
44
+ /**
45
+ * Its own ⋯ button and its Delete row in an app's own words: the button named "Message actions", its tooltip too, and
46
+ * "Delete message". With no `trigger`, the menu draws its own ⋯; the story presses it.
47
+ */
48
+ export const OwnButtonInAnAppsWords: Story = {
49
+ name: "Its own button, in an app's words",
50
+ args: { trigger: undefined, moreLabel: 'Message actions', onEdit: () => {}, editLabel: 'Edit message', onDelete: () => {}, deleteLabel: 'Delete message' },
51
+ play: async ({ canvasElement }) => {
52
+ await userEvent.click(within(canvasElement).getByRole('button', { name: 'Message actions' }))
53
+ },
54
+ }
55
+
44
56
  /**
45
57
  * In an app's own words, as Peek's menu reads (Katerina, 1 November): a heading over the first rows, the key that
46
58
  * resolves from its box beside Resolve, its word for Edit, and a row of its own after Edit. Delete stays apart.
@@ -1,6 +1,7 @@
1
1
  // @vitest-environment jsdom
2
2
  import { afterEach, describe, expect, it, vi } from 'vitest'
3
3
  import { cleanup, fireEvent, render, screen } from '@testing-library/react'
4
+ import userEvent from '@testing-library/user-event'
4
5
  import { ConversationMenu } from './ConversationMenu'
5
6
  import { MenuItem } from './Menu'
6
7
 
@@ -58,3 +59,19 @@ describe('ConversationMenu', () => {
58
59
  expect(screen.getAllByRole('separator').length).toBe(2)
59
60
  })
60
61
  })
62
+
63
+ describe('ConversationMenu, in an app’s words (Ship, 2 November)', () => {
64
+ it('says Delete in the app’s words, and names its own ⋯ button so, its tooltip too', async () => {
65
+ const user = userEvent.setup()
66
+ const onDelete = vi.fn()
67
+ render(<ConversationMenu onEdit={() => {}} editLabel="Edit message" onDelete={onDelete} deleteLabel="Delete message" moreLabel="Message actions" />)
68
+ const more = screen.getByRole('button', { name: 'Message actions' })
69
+ await user.hover(more)
70
+ expect((await screen.findByRole('tooltip')).textContent).toBe('Message actions')
71
+ fireEvent.click(more)
72
+ await screen.findByRole('menu')
73
+ expect(names()).toEqual(['Edit message', 'Delete message'])
74
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Delete message' }))
75
+ expect(onDelete).toHaveBeenCalledOnce()
76
+ })
77
+ })