@estiva-app/ui 0.104.2 → 0.104.3
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/dist/ContainerHeader.d.ts.map +1 -1
- package/dist/ConversationCard.d.ts +8 -2
- package/dist/ConversationCard.d.ts.map +1 -1
- package/dist/ConversationLayout.d.ts +4 -1
- package/dist/ConversationLayout.d.ts.map +1 -1
- package/dist/index.js +69 -23
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/registry.json +2 -2
- package/src/ContainerHeader.mdx +2 -0
- package/src/ContainerHeader.test.tsx +6 -0
- package/src/ContainerHeader.tsx +3 -1
- package/src/ConversationCard.mdx +4 -2
- package/src/ConversationCard.stories.tsx +14 -0
- package/src/ConversationCard.test.tsx +130 -2
- package/src/ConversationCard.tsx +128 -56
- package/src/ConversationLayout.mdx +4 -0
- package/src/ConversationLayout.tsx +4 -1
- package/src/PageHeader.mdx +1 -0
- package/src/ReplyCard.mdx +1 -0
package/package.json
CHANGED
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.104.
|
|
7
|
+
"packageVersion": "0.104.3",
|
|
8
8
|
"exports": 245,
|
|
9
9
|
"typeExports": 254,
|
|
10
10
|
"files": null
|
|
@@ -3089,7 +3089,7 @@
|
|
|
3089
3089
|
"name": "bodyRef",
|
|
3090
3090
|
"takes": "Ref<HTMLDivElement>",
|
|
3091
3091
|
"required": false,
|
|
3092
|
-
"note": "
|
|
3092
|
+
"note": "The comments' scrolling box, in both layouts: two columns' list, and one column's Panel body."
|
|
3093
3093
|
},
|
|
3094
3094
|
{
|
|
3095
3095
|
"name": "onBodyScroll",
|
package/src/ContainerHeader.mdx
CHANGED
|
@@ -54,6 +54,8 @@ import { ContainerHeader, IconButton } from '@estiva-app/ui'
|
|
|
54
54
|
- A string title is one line in `body-2-strong` and keeps its width. Anything
|
|
55
55
|
else — an EditableText, a title over a caption — takes the room left and is
|
|
56
56
|
drawn as given.
|
|
57
|
+
- The title stops 12px before the buttons, so a title cut short never touches
|
|
58
|
+
them.
|
|
57
59
|
|
|
58
60
|
<Canvas of={ContainerHeaderStories.WithRichTitle} />
|
|
59
61
|
|
|
@@ -47,6 +47,12 @@ describe('ContainerHeader', () => {
|
|
|
47
47
|
expect(screen.getByRole('button', { name: 'New' }).closest('div')!.className).toContain('gap-1')
|
|
48
48
|
})
|
|
49
49
|
|
|
50
|
+
// A cut title, and a button after it, ran right up to the buttons: 0px apart (Leaf's adoption review, 4 November).
|
|
51
|
+
it('keeps 12px between the title and the buttons, the gap between the right group’s own parts', () => {
|
|
52
|
+
const { container } = render(<ContainerHeader title={<em>Plan</em>} actions={<button type="button">New</button>} />)
|
|
53
|
+
expect(container.firstElementChild!.className.split(' ')).toContain('gap-3')
|
|
54
|
+
})
|
|
55
|
+
|
|
50
56
|
it('a title with a menu is one button, and opens it', async () => {
|
|
51
57
|
render(<ContainerHeader title="View one" titleMenu={<MenuItem label="View two" />} />)
|
|
52
58
|
await userEvent.click(screen.getByRole('button', { name: 'View one' }))
|
package/src/ContainerHeader.tsx
CHANGED
|
@@ -48,7 +48,9 @@ export function ContainerHeader({ title, chevron = false, titleMenu, actions, cl
|
|
|
48
48
|
// (pl-2.5 + the button's px-1.5 = pl-4): the words stay where a title's
|
|
49
49
|
// are, and the fill is inside the bar — a negative margin had it clipped
|
|
50
50
|
// (Katerina, 5 October).
|
|
51
|
-
|
|
51
|
+
// 12px between the title and the buttons, as between the right group's own parts: a cut title, and a button
|
|
52
|
+
// after it, ran right up to them (Leaf's adoption review, 4 November). A bar whose title fits does not move.
|
|
53
|
+
<div className={cn('flex h-12 shrink-0 items-center justify-between gap-3 overflow-hidden border-b border-border-subtle py-2 pr-4', titleMenu != null ? 'pl-2.5' : 'pl-4', className)}>
|
|
52
54
|
<div className={cn('flex items-center gap-2 overflow-hidden', text ? 'shrink-0' : 'min-w-0 flex-1')}>
|
|
53
55
|
{titleMenu != null ? (
|
|
54
56
|
<Menu
|
package/src/ConversationCard.mdx
CHANGED
|
@@ -60,12 +60,13 @@ import { ConversationCard } from '@estiva-app/ui'
|
|
|
60
60
|
|
|
61
61
|
- **The words are yours to draw**: text, people named, links, attached cards and quoted blocks, with **RichText** and the link parts. The card gives them their size and colour.
|
|
62
62
|
- **Edit opens your box**: `editor` draws your **CommentBox** edit form; call `done` when it saves or cancels. To open it again after a refused save, hold `editing` yourself.
|
|
63
|
-
- **Resolve opens the dialog**: **ResolveDialog**, then `onResolve(note)`. Answer `false` when it was refused; the dialog stays.
|
|
63
|
+
- **Resolve opens the dialog**: **ResolveDialog**, then `onResolve(note)`. Answer `false` when it was refused, and pass `resolveRefused` (why, in plain words); the dialog stays and says it.
|
|
64
64
|
- **Delete asks first**: **ConfirmDialog**, then `onDelete()`. Answer `false` when it was refused, and pass `deleteRefused` (why, in plain words): the question stays and says it, as Resolve's does.
|
|
65
|
+
- **A refusal is said only in the question it answered.** Keep it in your own state and never clear it: a question opened again says nothing until its own press is refused.
|
|
65
66
|
- **Deleted** keeps its `about`: what it was on stays above "This comment was deleted.", for the replies under it.
|
|
66
67
|
- `time` is your words for it ("11:08 AM"); `at` is the moment (ms), from which the card says the exact date and time on hover. Never a tooltip of your own round `time`.
|
|
67
68
|
- A press on the card is `onClick` (its thread opens); a press on a button, a link or anything marked `data-interactive` inside it is not.
|
|
68
|
-
- The strip shows while the card is pointed at or has focus, and holds while its reactions or its menu are open.
|
|
69
|
+
- The strip shows while the card is pointed at or has focus, and holds while its reactions or its menu are open. A head long enough to reach it (a narrow card, a time in words, "(edited)") fades out 8px before it; nothing in the head moves.
|
|
69
70
|
|
|
70
71
|
## What it owns
|
|
71
72
|
|
|
@@ -74,6 +75,7 @@ import { ConversationCard } from '@estiva-app/ui'
|
|
|
74
75
|
| Shows its actions while pointed at, and holds them while a menu is open | hover state and an outside-click check | |
|
|
75
76
|
| A card that opens on a press is a Tab stop: reaching it shows its actions, Enter or Space opens it | a `tabIndex` and a key handler | |
|
|
76
77
|
| Asks before it deletes | a confirm dialog | |
|
|
78
|
+
| Says a refusal only in the question it answered | clearing it when the question closes | |
|
|
77
79
|
| Says the exact date and time under the pointer, from `at` | a tooltip round the time | |
|
|
78
80
|
| Opens the Resolve dialog, and closes it once resolved | a dialog and its open state | |
|
|
79
81
|
| Says it is resolved, with who and the note, and hides nothing of it | a resolved line or chip of your own | |
|
|
@@ -65,6 +65,20 @@ export const Yours: Story = { render: (args) => <Live {...args} author={YOU} own
|
|
|
65
65
|
/** Edited since it was sent: "(edited)", its time on hover. */
|
|
66
66
|
export const Edited: Story = { render: (args) => <Live {...args} edited="Edited 11:20 AM" /> }
|
|
67
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Leaf's card, 360px, with a time in words and "(edited)": the head runs to where the strip stands. While the strip
|
|
70
|
+
* shows, the head fades out 8px before it, and nothing in it moves. The story points at it.
|
|
71
|
+
*/
|
|
72
|
+
export const NarrowEdited: Story = {
|
|
73
|
+
name: 'Narrow, edited, a time in words',
|
|
74
|
+
// Leaf's card: its 384px column less 12px each side (Field's and FieldLine's stories write their 360px the same way).
|
|
75
|
+
decorators: [(Story) => <div className="w-[360px]"><Story /></div>],
|
|
76
|
+
render: (args) => <Live {...args} author={{ name: 'Marta' }} time="20 minutes ago" at={AT} edited="Edited 2 minutes ago" onReply={() => {}} />,
|
|
77
|
+
play: async ({ canvasElement }) => {
|
|
78
|
+
await userEvent.hover(within(canvasElement).getByText(WORDS))
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
|
|
68
82
|
/** Deleted: its replies stay under it. */
|
|
69
83
|
export const Deleted: Story = { render: (args) => <Live {...args} deleted replies={{ count: 2, faces: [TWO, THREE], last: '11:40 AM' }} /> }
|
|
70
84
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
2
|
import { useState } from 'react'
|
|
3
3
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
4
|
-
import { cleanup, fireEvent, render, screen, within } from '@testing-library/react'
|
|
4
|
+
import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'
|
|
5
5
|
import userEvent from '@testing-library/user-event'
|
|
6
6
|
import { ConversationCard, ReplyCard } from './ConversationCard'
|
|
7
7
|
import { PinnedComment } from './PinnedComment'
|
|
@@ -205,7 +205,135 @@ describe('ReplyCard', () => {
|
|
|
205
205
|
await point(user, 'A reply')
|
|
206
206
|
press('More actions')
|
|
207
207
|
await user.click(await screen.findByRole('menuitem', { name: 'Delete' }))
|
|
208
|
-
|
|
208
|
+
// Said once its Delete is refused, not as the question opens (Leaf's adoption review, 4 November).
|
|
209
|
+
const question = await screen.findByRole('alertdialog')
|
|
210
|
+
await user.click(within(question).getByRole('button', { name: 'Delete reply' }))
|
|
211
|
+
expect((await within(question).findByRole('alert')).textContent).toBe('Could not delete it. Try again.')
|
|
212
|
+
})
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* In Leaf's 360px cards a time in words and "(edited)" ran under the strip, which covered the end of "(edited)" (Leaf's
|
|
217
|
+
* adoption review, 4 November). jsdom draws nothing, so the boxes are given: the strip from x 232, the head's words to
|
|
218
|
+
* x 367, the last part of them ending at `end`.
|
|
219
|
+
*/
|
|
220
|
+
describe('the head keeps clear of the strip', () => {
|
|
221
|
+
function placed(end: number) {
|
|
222
|
+
return vi.spyOn(Element.prototype, 'getBoundingClientRect').mockImplementation(function (this: Element) {
|
|
223
|
+
const box = (left: number, right: number) => ({ left, right, x: left, y: 0, top: 0, bottom: 20, width: right - left, height: 20, toJSON: () => ({}) }) as DOMRect
|
|
224
|
+
if (this.matches('[data-head]')) return box(25, 367)
|
|
225
|
+
if (this.parentElement?.matches('[data-head]')) return this === this.parentElement.lastElementChild ? box(end - 40, end) : box(25, end - 48)
|
|
226
|
+
if (this.matches('.absolute.right-1.top-1')) return box(232, 372)
|
|
227
|
+
return box(0, 0)
|
|
228
|
+
})
|
|
229
|
+
}
|
|
230
|
+
const head = () => document.querySelector<HTMLElement>('[data-head]')!
|
|
231
|
+
|
|
232
|
+
for (const [what, card] of [
|
|
233
|
+
['a comment', (words: string) => <ConversationCard author={ONE} time="20 minutes ago" edited="Edited 2 minutes ago" onReply={() => {}} onResolve={() => {}}>{words}</ConversationCard>],
|
|
234
|
+
['a reply', (words: string) => <ReplyCard author={ONE} time="20 minutes ago" edited="Edited 2 minutes ago" own onDelete={() => {}}>{words}</ReplyCard>],
|
|
235
|
+
] as const) {
|
|
236
|
+
it(`${what}: while the strip shows, the words that reach it fade out 8px before it, and nothing in the head moves`, async () => {
|
|
237
|
+
const user = userEvent.setup()
|
|
238
|
+
const boxes = placed(238.4)
|
|
239
|
+
render(card('Words'))
|
|
240
|
+
const parts = Array.from(head().children, (part) => part.outerHTML)
|
|
241
|
+
expect(head().style.maskImage).toBe('')
|
|
242
|
+
await point(user, 'Words')
|
|
243
|
+
// Transparent from 8px before the strip (x 224, 199px into the head), after a 16px fade.
|
|
244
|
+
expect(head().style.maskImage).toBe('linear-gradient(to right, black 183px, transparent 199px)')
|
|
245
|
+
expect(Array.from(head().children, (part) => part.outerHTML)).toEqual(parts)
|
|
246
|
+
boxes.mockRestore()
|
|
247
|
+
})
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
it('words that end before the strip are left as they are', async () => {
|
|
251
|
+
const user = userEvent.setup()
|
|
252
|
+
const boxes = placed(200)
|
|
253
|
+
render(
|
|
254
|
+
<ConversationCard author={ONE} time="11:08 AM" onReply={() => {}}>
|
|
255
|
+
Words
|
|
256
|
+
</ConversationCard>,
|
|
257
|
+
)
|
|
258
|
+
await point(user, 'Words')
|
|
259
|
+
expect(screen.getByRole('button', { name: 'Reply' })).toBeTruthy()
|
|
260
|
+
expect(head().style.maskImage).toBe('')
|
|
261
|
+
boxes.mockRestore()
|
|
262
|
+
})
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* The app keeps the refusal in its own state, as the usage page asks, and is not told when the question closes. Before,
|
|
267
|
+
* the next Delete or Resolve opened already saying the last one's "Could not … Try again.", before anything was pressed
|
|
268
|
+
* (Leaf's adoption review, 4 November).
|
|
269
|
+
*/
|
|
270
|
+
describe('a refusal is said only in the question it answered', () => {
|
|
271
|
+
const REFUSED = 'Could not do it. Try again.'
|
|
272
|
+
|
|
273
|
+
/** An app that sets the refusal when it refuses, and never clears it. */
|
|
274
|
+
function Refusing({ reply = false }: { reply?: boolean }) {
|
|
275
|
+
const [refused, setRefused] = useState<string>()
|
|
276
|
+
const refuse = () => {
|
|
277
|
+
setRefused(REFUSED)
|
|
278
|
+
return false
|
|
279
|
+
}
|
|
280
|
+
return reply ? (
|
|
281
|
+
<ReplyCard author={ONE} time="11:40 AM" own onDelete={refuse} deleteRefused={refused}>
|
|
282
|
+
Words
|
|
283
|
+
</ReplyCard>
|
|
284
|
+
) : (
|
|
285
|
+
<ConversationCard author={ONE} time="11:08 AM" own onDelete={refuse} deleteRefused={refused} onResolve={refuse} resolveRefused={refused}>
|
|
286
|
+
Words
|
|
287
|
+
</ConversationCard>
|
|
288
|
+
)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
async function askToDelete(user: ReturnType<typeof userEvent.setup>) {
|
|
292
|
+
await point(user, 'Words')
|
|
293
|
+
press('More actions')
|
|
294
|
+
await user.click(await screen.findByRole('menuitem', { name: 'Delete' }))
|
|
295
|
+
return screen.findByRole('alertdialog')
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
async function askToResolve(user: ReturnType<typeof userEvent.setup>) {
|
|
299
|
+
await point(user, 'Words')
|
|
300
|
+
press('Resolve')
|
|
301
|
+
return screen.findByRole('dialog')
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
for (const [what, reply, button] of [
|
|
305
|
+
['a comment', false, 'Delete comment'],
|
|
306
|
+
['a reply', true, 'Delete reply'],
|
|
307
|
+
] as const) {
|
|
308
|
+
it(`deleting ${what}: refused, cancelled and asked again, the new question is clean until it is refused`, async () => {
|
|
309
|
+
const user = userEvent.setup()
|
|
310
|
+
render(<Refusing reply={reply} />)
|
|
311
|
+
let question = await askToDelete(user)
|
|
312
|
+
await user.click(within(question).getByRole('button', { name: button }))
|
|
313
|
+
expect((await within(question).findByRole('alert')).textContent).toBe(REFUSED)
|
|
314
|
+
await user.click(within(question).getByRole('button', { name: 'Cancel' }))
|
|
315
|
+
await waitFor(() => expect(screen.queryByRole('alertdialog')).toBeNull())
|
|
316
|
+
|
|
317
|
+
question = await askToDelete(user)
|
|
318
|
+
expect(within(question).queryByRole('alert')).toBeNull()
|
|
319
|
+
await user.click(within(question).getByRole('button', { name: button }))
|
|
320
|
+
expect((await within(question).findByRole('alert')).textContent).toBe(REFUSED)
|
|
321
|
+
})
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
it('resolving: refused, cancelled and asked again, the new dialog is clean until it is refused', async () => {
|
|
325
|
+
const user = userEvent.setup()
|
|
326
|
+
render(<Refusing />)
|
|
327
|
+
let dialog = await askToResolve(user)
|
|
328
|
+
await user.click(within(dialog).getByRole('button', { name: 'Resolve' }))
|
|
329
|
+
expect((await within(dialog).findByRole('alert')).textContent).toBe(REFUSED)
|
|
330
|
+
await user.click(within(dialog).getByRole('button', { name: 'Cancel' }))
|
|
331
|
+
await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull())
|
|
332
|
+
|
|
333
|
+
dialog = await askToResolve(user)
|
|
334
|
+
expect(within(dialog).queryByRole('alert')).toBeNull()
|
|
335
|
+
await user.click(within(dialog).getByRole('button', { name: 'Resolve' }))
|
|
336
|
+
expect((await within(dialog).findByRole('alert')).textContent).toBe(REFUSED)
|
|
209
337
|
})
|
|
210
338
|
})
|
|
211
339
|
|
package/src/ConversationCard.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useContext, useLayoutEffect, useRef, useState, type ReactNode } from 'react'
|
|
1
|
+
import { useContext, useLayoutEffect, useRef, useState, type ReactNode, type RefObject } from 'react'
|
|
2
2
|
import { IconArrowNarrowRight, IconCircleCheck, IconDotsVertical } from '@tabler/icons-react'
|
|
3
3
|
import { Avatar } from './Avatar'
|
|
4
4
|
import { Card } from './Card'
|
|
@@ -70,7 +70,10 @@ export interface ConversationEntryProps {
|
|
|
70
70
|
* everyone.", and on a comment how many replies stay. A string is one paragraph; a node is drawn as given.
|
|
71
71
|
*/
|
|
72
72
|
deleteNote?: ReactNode
|
|
73
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* Why the last delete was refused, in plain words: said under the question, while it stays open (`onDelete` answered
|
|
75
|
+
* `false`). Only in the question it answered: one opened again says nothing until its own Delete is refused.
|
|
76
|
+
*/
|
|
74
77
|
deleteRefused?: string
|
|
75
78
|
/** The app's own rows in the ⋯ menu, after Resolve: `MenuItem`s. */
|
|
76
79
|
menu?: ReactNode
|
|
@@ -110,7 +113,10 @@ export interface ConversationCardProps extends ConversationEntryProps {
|
|
|
110
113
|
resolveHint?: string
|
|
111
114
|
/** Resolve, with the note written in the dialog the card opens. Offered on the strip and in the menu. */
|
|
112
115
|
onResolve?: (note: string) => Promise<boolean | void> | boolean | void
|
|
113
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* Why the last resolve was refused, in plain words: said under the note, while the dialog stays open (`onResolve`
|
|
118
|
+
* answered `false`). Only in the dialog it answered: one opened again says nothing until its own Resolve is refused.
|
|
119
|
+
*/
|
|
114
120
|
resolveRefused?: string
|
|
115
121
|
onReopen?: () => void
|
|
116
122
|
/** The one open beside its thread. */
|
|
@@ -150,11 +156,38 @@ function When({ time, at: given, timeHref, timeLabel = 'Link to this' }: Pick<Co
|
|
|
150
156
|
return <MetaText className="shrink-0">{exact ? <WithTooltip label={exact}>{said}</WithTooltip> : time}</MetaText>
|
|
151
157
|
}
|
|
152
158
|
|
|
153
|
-
/** The
|
|
154
|
-
|
|
159
|
+
/** The head's words fade out over their last 16px before `end`: a mask on the words, as ShowMore's, so they end in whatever is behind. */
|
|
160
|
+
const fadeBefore = (end: number) => `linear-gradient(to right, black ${end - 16}px, transparent ${end}px)`
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* While the strip shows, where the head's words must end, in px from the head's start: 8px short of the strip,
|
|
164
|
+
* measured, as the strip's width follows the buttons the card offers; nothing when the words end before that. The head
|
|
165
|
+
* fades out there rather than giving way: giving way cut the name sooner and slid the time and "(edited)" left under
|
|
166
|
+
* the pointer. Before, the strip covered the end of "(edited)" in Leaf's 360px cards (Leaf's adoption review, 4 November).
|
|
167
|
+
*/
|
|
168
|
+
function useClearOfStrip(root: RefObject<HTMLDivElement | null>, strip: RefObject<HTMLDivElement | null>, shown: boolean) {
|
|
169
|
+
const [end, setEnd] = useState<number>()
|
|
170
|
+
useLayoutEffect(() => {
|
|
171
|
+
const words = root.current?.querySelector<HTMLElement>('[data-head]')
|
|
172
|
+
if (!shown || !words || !strip.current) {
|
|
173
|
+
setEnd(undefined)
|
|
174
|
+
return
|
|
175
|
+
}
|
|
176
|
+
const stop = strip.current.getBoundingClientRect().left - 8
|
|
177
|
+
const reach = Math.max(...Array.from(words.children, (part) => part.getBoundingClientRect().right))
|
|
178
|
+
setEnd(reach > stop ? stop - words.getBoundingClientRect().left : undefined)
|
|
179
|
+
}, [root, strip, shown])
|
|
180
|
+
return end
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* The face, the name, the time and "(edited)", with the new mark at the far right. `meta`: after "(edited)". `end`:
|
|
185
|
+
* the strip shows over the head, and its words fade out before this point (`useClearOfStrip`).
|
|
186
|
+
*/
|
|
187
|
+
function Head({ author, time, at, timeHref, timeLabel, edited, isNew, urgent, meta, end }: Pick<ConversationEntryProps, 'author' | 'time' | 'at' | 'timeHref' | 'timeLabel' | 'edited' | 'isNew' | 'urgent'> & { meta?: ReactNode; end?: number }) {
|
|
155
188
|
return (
|
|
156
189
|
<div className="flex w-full items-center gap-2">
|
|
157
|
-
<div className="flex min-w-0 flex-1 items-center gap-2">
|
|
190
|
+
<div data-head className="flex min-w-0 flex-1 items-center gap-2" style={end === undefined ? undefined : { maskImage: fadeBefore(end), WebkitMaskImage: fadeBefore(end) }}>
|
|
158
191
|
<span data-face className="relative flex shrink-0">
|
|
159
192
|
<Avatar size={24} src={author.picture} alt={author.name} bot={author.bot} />
|
|
160
193
|
</span>
|
|
@@ -255,6 +288,48 @@ function stillHere(root: HTMLElement | null) {
|
|
|
255
288
|
}
|
|
256
289
|
}
|
|
257
290
|
|
|
291
|
+
/**
|
|
292
|
+
* The card's questions, Delete and Resolve, each mounted only while it is open. The app's refusal is said only once
|
|
293
|
+
* this opening's own press was answered: the app keeps the refusal in its own state and is not told when a question
|
|
294
|
+
* closes, so the next one opened already saying the last one's "Could not … Try again." (Leaf's adoption review,
|
|
295
|
+
* 4 November).
|
|
296
|
+
*/
|
|
297
|
+
function DeleteQuestion({ noun, onDelete, refused, onClose, children }: { noun: string; onDelete: NonNullable<ConversationEntryProps['onDelete']>; refused?: string; onClose: () => void; children: ReactNode }) {
|
|
298
|
+
const [answered, setAnswered] = useState(false)
|
|
299
|
+
return (
|
|
300
|
+
<ConfirmDialog
|
|
301
|
+
title={`Delete this ${noun}?`}
|
|
302
|
+
confirmLabel={`Delete ${noun}`}
|
|
303
|
+
destructive
|
|
304
|
+
onConfirm={async () => {
|
|
305
|
+
const ok = await onDelete()
|
|
306
|
+
setAnswered(true)
|
|
307
|
+
return ok
|
|
308
|
+
}}
|
|
309
|
+
onClose={onClose}
|
|
310
|
+
refused={answered ? refused : undefined}
|
|
311
|
+
>
|
|
312
|
+
{children}
|
|
313
|
+
</ConfirmDialog>
|
|
314
|
+
)
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function ResolveQuestion({ onResolve, refused, onClose }: { onResolve: NonNullable<ConversationCardProps['onResolve']>; refused?: string; onClose: () => void }) {
|
|
318
|
+
const [answered, setAnswered] = useState(false)
|
|
319
|
+
return (
|
|
320
|
+
<ResolveDialog
|
|
321
|
+
refused={answered ? refused : undefined}
|
|
322
|
+
onCancel={onClose}
|
|
323
|
+
onResolve={async (note) => {
|
|
324
|
+
const ok = await onResolve(note)
|
|
325
|
+
setAnswered(true)
|
|
326
|
+
if (ok !== false) onClose()
|
|
327
|
+
return ok
|
|
328
|
+
}}
|
|
329
|
+
/>
|
|
330
|
+
)
|
|
331
|
+
}
|
|
332
|
+
|
|
258
333
|
/** The editing state, held by the card or by the app. */
|
|
259
334
|
function useEditing(editing: boolean | undefined, onEditingChange: ((editing: boolean) => void) | undefined) {
|
|
260
335
|
const [own, setOwn] = useState(false)
|
|
@@ -301,6 +376,8 @@ export function ConversationCard(props: ConversationCardProps) {
|
|
|
301
376
|
// The ⋯ menu only when it has a row to show: Resolve or Reopen, the app's rows, or Edit and Delete on your own.
|
|
302
377
|
const offersMenu = !!resolves || !!menu || !!menuAfter || (own && (!!editor || !!onDelete))
|
|
303
378
|
const showStrip = hovered && !isEditing && !readOnly
|
|
379
|
+
const strip = useRef<HTMLDivElement>(null)
|
|
380
|
+
const wordsEnd = useClearOfStrip(root, strip, showStrip)
|
|
304
381
|
const react = reactions?.onToggle
|
|
305
382
|
// Read-only with no replies, there is nothing to open: no box to write in, no thread to read (Peek's way, Katerina, 1 November).
|
|
306
383
|
const press = onClick ?? (readOnly && !replies?.count ? undefined : item?.toggle)
|
|
@@ -368,6 +445,7 @@ export function ConversationCard(props: ConversationCardProps) {
|
|
|
368
445
|
isNew={isNew}
|
|
369
446
|
urgent={urgent}
|
|
370
447
|
meta={resolved && <ResolvedCheck by={resolved.by} note={resolved.note} at={resolved.at} />}
|
|
448
|
+
end={wordsEnd}
|
|
371
449
|
/>
|
|
372
450
|
{!!about && (
|
|
373
451
|
// Under the name, above the words (Katerina, 1 November).
|
|
@@ -399,7 +477,7 @@ export function ConversationCard(props: ConversationCardProps) {
|
|
|
399
477
|
<span aria-hidden className="pointer-events-none absolute left-[19px] w-0.5 bg-border-default" style={{ top: dotLine.top, height: dotLine.height }} />
|
|
400
478
|
)}
|
|
401
479
|
{showStrip && (
|
|
402
|
-
<div className="absolute right-1 top-1 z-10">
|
|
480
|
+
<div ref={strip} className="absolute right-1 top-1 z-10">
|
|
403
481
|
<ConversationActions
|
|
404
482
|
options={reactions?.options}
|
|
405
483
|
onReact={react}
|
|
@@ -444,7 +522,7 @@ export function ConversationCard(props: ConversationCardProps) {
|
|
|
444
522
|
)}
|
|
445
523
|
</Card>
|
|
446
524
|
{deleting && onDelete && (
|
|
447
|
-
<
|
|
525
|
+
<DeleteQuestion noun={noun} onDelete={onDelete} refused={deleteRefused} onClose={() => setDeleting(false)}>
|
|
448
526
|
{deleteNote !== undefined ? (
|
|
449
527
|
typeof deleteNote === 'string' ? <p>{deleteNote}</p> : deleteNote
|
|
450
528
|
) : (
|
|
@@ -453,19 +531,9 @@ export function ConversationCard(props: ConversationCardProps) {
|
|
|
453
531
|
{replies && replies.count > 0 && <p>Its {replies.count === 1 ? 'reply stays' : `${replies.count} replies stay`}.</p>}
|
|
454
532
|
</>
|
|
455
533
|
)}
|
|
456
|
-
</
|
|
457
|
-
)}
|
|
458
|
-
{resolving && onResolve && (
|
|
459
|
-
<ResolveDialog
|
|
460
|
-
refused={resolveRefused}
|
|
461
|
-
onCancel={() => setResolving(false)}
|
|
462
|
-
onResolve={async (note) => {
|
|
463
|
-
const ok = await onResolve(note)
|
|
464
|
-
if (ok !== false) setResolving(false)
|
|
465
|
-
return ok
|
|
466
|
-
}}
|
|
467
|
-
/>
|
|
534
|
+
</DeleteQuestion>
|
|
468
535
|
)}
|
|
536
|
+
{resolving && onResolve && <ResolveQuestion onResolve={onResolve} refused={resolveRefused} onClose={() => setResolving(false)} />}
|
|
469
537
|
</>
|
|
470
538
|
)
|
|
471
539
|
}
|
|
@@ -486,6 +554,8 @@ export function ReplyCard(props: ReplyCardProps) {
|
|
|
486
554
|
const offersMenu = !!menu || !!menuAfter || (own && (!!editor || !!onDelete))
|
|
487
555
|
const showStrip = hovered && !isEditing && !readOnly && (offersMenu || !!reactions?.onToggle)
|
|
488
556
|
const root = useRef<HTMLDivElement>(null)
|
|
557
|
+
const strip = useRef<HTMLDivElement>(null)
|
|
558
|
+
const wordsEnd = useClearOfStrip(root, strip, showStrip)
|
|
489
559
|
const settle = () => requestAnimationFrame(() => setHovered(stillHere(root.current)))
|
|
490
560
|
// In a Thread beside, a reply counts itself as it is first drawn: a new one takes the thread to its newest.
|
|
491
561
|
const drawn = useContext(repliesDrawn)
|
|
@@ -521,7 +591,7 @@ export function ReplyCard(props: ReplyCardProps) {
|
|
|
521
591
|
<Editing author={author}>{editor(() => setEditing(false))}</Editing>
|
|
522
592
|
) : (
|
|
523
593
|
<div className="flex flex-col items-start px-2 pt-2">
|
|
524
|
-
<Head author={author} time={props.time} at={props.at} timeHref={props.timeHref} timeLabel={props.timeLabel} edited={props.edited} isNew={isNew} urgent={urgent} />
|
|
594
|
+
<Head author={author} time={props.time} at={props.at} timeHref={props.timeHref} timeLabel={props.timeLabel} edited={props.edited} isNew={isNew} urgent={urgent} end={wordsEnd} />
|
|
525
595
|
{/* As on a comment: under the name, above the words. */}
|
|
526
596
|
{about && <div className="w-full pl-8 pr-2 pt-0.5">{about}</div>}
|
|
527
597
|
<Words>{children}</Words>
|
|
@@ -530,45 +600,47 @@ export function ReplyCard(props: ReplyCardProps) {
|
|
|
530
600
|
</div>
|
|
531
601
|
)}
|
|
532
602
|
{showStrip && (
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
<
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
603
|
+
// In a box of its own, as a comment's: the box is what the head measures to keep clear of.
|
|
604
|
+
<div ref={strip} className="absolute right-1 top-1 z-10">
|
|
605
|
+
<ConversationActions
|
|
606
|
+
options={reactions?.options}
|
|
607
|
+
onReact={reactions?.onToggle}
|
|
608
|
+
onPickerOpenChange={(open) => {
|
|
609
|
+
setPicking(open)
|
|
610
|
+
if (!open) settle()
|
|
611
|
+
}}
|
|
612
|
+
more={
|
|
613
|
+
offersMenu && (
|
|
614
|
+
<ConversationMenu
|
|
615
|
+
trigger={
|
|
616
|
+
<ToolbarButton tooltip={moreLabel} aria-label={moreLabel}>
|
|
617
|
+
<IconDotsVertical size={16} stroke={1.5} />
|
|
618
|
+
</ToolbarButton>
|
|
619
|
+
}
|
|
620
|
+
open={menuOpen}
|
|
621
|
+
onOpenChange={(next) => {
|
|
622
|
+
setMenuOpen(next)
|
|
623
|
+
if (!next) settle()
|
|
624
|
+
}}
|
|
625
|
+
label={menuLabel}
|
|
626
|
+
onEdit={own && editor ? () => setEditing(true) : undefined}
|
|
627
|
+
editLabel={editLabel}
|
|
628
|
+
after={menuAfter}
|
|
629
|
+
onDelete={own && onDelete ? () => setDeleting(true) : undefined}
|
|
630
|
+
deleteLabel={deleteLabel}
|
|
631
|
+
>
|
|
632
|
+
{menu}
|
|
633
|
+
</ConversationMenu>
|
|
634
|
+
)
|
|
635
|
+
}
|
|
636
|
+
/>
|
|
637
|
+
</div>
|
|
566
638
|
)}
|
|
567
639
|
</Card>
|
|
568
640
|
{deleting && onDelete && (
|
|
569
|
-
<
|
|
641
|
+
<DeleteQuestion noun={noun} onDelete={onDelete} refused={deleteRefused} onClose={() => setDeleting(false)}>
|
|
570
642
|
{deleteNote === undefined ? <p>It is deleted for everyone.</p> : typeof deleteNote === 'string' ? <p>{deleteNote}</p> : deleteNote}
|
|
571
|
-
</
|
|
643
|
+
</DeleteQuestion>
|
|
572
644
|
)}
|
|
573
645
|
</>
|
|
574
646
|
)
|
|
@@ -48,6 +48,8 @@ import { ConversationLayout } from '@estiva-app/ui'
|
|
|
48
48
|
|
|
49
49
|
- Which layout is the app's: where a conversation sits is its own.
|
|
50
50
|
- The right column is 384px in every app.
|
|
51
|
+
- To fill a page's height inside an app's frame, one column needs a `flex flex-col` parent and `className="min-h-0 flex-1"`
|
|
52
|
+
on the layout. Ship and Leaf both do this.
|
|
51
53
|
- The app keeps `open`; the layout says when it changes, with `onOpenChange`. Give every comment a `thread`, a
|
|
52
54
|
**Thread** with its box, even one with no replies yet: pressing it opens it to its box. An app that builds only the
|
|
53
55
|
open thread gives a function, `thread: () => threadOf(comment)`: it is called only while that one is open.
|
|
@@ -62,6 +64,8 @@ import { ConversationLayout } from '@estiva-app/ui'
|
|
|
62
64
|
pictures fill in. Give the conversation its name, `rememberAs` (its address), and going back to it lands where it was
|
|
63
65
|
left, in this tab. `useLeftAt(name)` says when the reader left it away from the newest, for your "New" line in
|
|
64
66
|
`before` over the first comment written since. Keep no place of your own: `bodyRef` and `onBodyScroll` only read the box.
|
|
67
|
+
- `bodyRef` lends the comments' scrolling box in both layouts: two columns' list, and one column's body under its
|
|
68
|
+
header. `onBodyScroll` is two columns only.
|
|
65
69
|
|
|
66
70
|
<Canvas of={Stories.TwoColumnsLong} />
|
|
67
71
|
|
|
@@ -67,7 +67,10 @@ export interface ConversationLayoutProps {
|
|
|
67
67
|
* it, it opens at the newest each time it is drawn. `useLeftAt` with the same name says when it was left, for a "New" line.
|
|
68
68
|
*/
|
|
69
69
|
rememberAs?: string
|
|
70
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* The comments' scrolling box, in both layouts: two columns' list, and one column's Panel body. Two columns, where it
|
|
72
|
+
* scrolls is the layout's: an app reads it, and keeps no place of its own in it.
|
|
73
|
+
*/
|
|
71
74
|
bodyRef?: Ref<HTMLDivElement>
|
|
72
75
|
/** Two columns: the comments' box scrolled. */
|
|
73
76
|
onBodyScroll?: UIEventHandler<HTMLDivElement>
|
package/src/PageHeader.mdx
CHANGED
|
@@ -87,6 +87,7 @@ import { MembersPill, PageHeader, Toolbar, ToolbarButton } from '@estiva-app/ui'
|
|
|
87
87
|
- A string `title` is one line and is cut short with an ellipsis when the
|
|
88
88
|
room runs out; everything at the right keeps its size. A node — a
|
|
89
89
|
`Breadcrumb`, an `InlineText` — is drawn as given, and cuts itself short.
|
|
90
|
+
Cut short, the title and what is `after` it stop 12px before the right group.
|
|
90
91
|
|
|
91
92
|
<Canvas of={PageHeaderStories.LongTitle} />
|
|
92
93
|
|
package/src/ReplyCard.mdx
CHANGED
|
@@ -51,6 +51,7 @@ import { ReplyCard, Thread } from '@estiva-app/ui'
|
|
|
51
51
|
|---|---|---|
|
|
52
52
|
| Shows its actions while pointed at, and holds them while a menu is open | hover state and an outside-click check | |
|
|
53
53
|
| Asks before it deletes | a confirm dialog | |
|
|
54
|
+
| Says a refusal (`deleteRefused`) only in the question it answered | clearing it when the question closes | |
|
|
54
55
|
| Says the exact date and time under the pointer, from `at` | a tooltip round the time | |
|
|
55
56
|
|
|
56
57
|
## Props
|