@estiva-app/ui 0.95.0 → 0.96.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AppShell.d.ts +25 -7
- package/dist/AppShell.d.ts.map +1 -1
- package/dist/ArchivedNotice.d.ts +28 -0
- package/dist/ArchivedNotice.d.ts.map +1 -0
- package/dist/Button.d.ts +4 -3
- package/dist/Button.d.ts.map +1 -1
- package/dist/Card.d.ts.map +1 -1
- package/dist/CommentBox.d.ts.map +1 -1
- package/dist/ConversationActions.d.ts +24 -0
- package/dist/ConversationActions.d.ts.map +1 -0
- package/dist/ConversationCard.d.ts +88 -0
- package/dist/ConversationCard.d.ts.map +1 -0
- package/dist/ConversationLayout.d.ts +50 -0
- package/dist/ConversationLayout.d.ts.map +1 -0
- package/dist/ConversationMenu.d.ts +24 -0
- package/dist/ConversationMenu.d.ts.map +1 -0
- package/dist/Divider.d.ts +23 -4
- package/dist/Divider.d.ts.map +1 -1
- package/dist/EditedMarker.d.ts +11 -0
- package/dist/EditedMarker.d.ts.map +1 -0
- package/dist/IconButton.d.ts +3 -3
- package/dist/IconButton.d.ts.map +1 -1
- package/dist/LinkParts.d.ts +3 -1
- package/dist/LinkParts.d.ts.map +1 -1
- package/dist/ListColumn.d.ts +3 -1
- package/dist/ListColumn.d.ts.map +1 -1
- package/dist/MetaText.d.ts +22 -0
- package/dist/MetaText.d.ts.map +1 -0
- package/dist/NavItem.d.ts.map +1 -1
- package/dist/PageHeader.d.ts +50 -0
- package/dist/PageHeader.d.ts.map +1 -0
- package/dist/Panel.d.ts +6 -0
- package/dist/Panel.d.ts.map +1 -1
- package/dist/PinnedComment.d.ts +17 -0
- package/dist/PinnedComment.d.ts.map +1 -0
- package/dist/QuotedLine.d.ts +16 -0
- package/dist/QuotedLine.d.ts.map +1 -0
- package/dist/ReactionHorizon.d.ts +14 -0
- package/dist/ReactionHorizon.d.ts.map +1 -0
- package/dist/RepliesRow.d.ts +26 -0
- package/dist/RepliesRow.d.ts.map +1 -0
- package/dist/ResolveDialog.d.ts +13 -0
- package/dist/ResolveDialog.d.ts.map +1 -0
- package/dist/Select.d.ts +1 -1
- package/dist/Select.d.ts.map +1 -1
- package/dist/Skeleton.d.ts +8 -4
- package/dist/Skeleton.d.ts.map +1 -1
- package/dist/Thread.d.ts +38 -0
- package/dist/Thread.d.ts.map +1 -0
- package/dist/TopBar.d.ts +3 -2
- package/dist/TopBar.d.ts.map +1 -1
- package/dist/UrgentMark.d.ts +6 -0
- package/dist/UrgentMark.d.ts.map +1 -0
- package/dist/commentBoxFrame.d.ts +3 -1
- package/dist/commentBoxFrame.d.ts.map +1 -1
- package/dist/conversation.examples.d.ts +52 -0
- package/dist/conversation.examples.d.ts.map +1 -0
- package/dist/editor.js +32 -24
- package/dist/editor.js.map +2 -2
- package/dist/eslint/index.js +2 -1
- package/dist/eslint/index.js.map +2 -2
- package/dist/eslint/no-native-title.d.ts +1 -1
- package/dist/eslint/no-native-title.d.ts.map +1 -1
- package/dist/eslint/no-restyled-part.d.ts.map +1 -1
- package/dist/index.d.ts +18 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1376 -433
- package/dist/index.js.map +4 -4
- package/dist/looks.d.ts +13 -1
- package/dist/looks.d.ts.map +1 -1
- package/dist/threadCard.d.ts +46 -0
- package/dist/threadCard.d.ts.map +1 -0
- package/package.json +1 -1
- package/registry.json +1873 -546
- package/src/AppShell.mdx +24 -10
- package/src/AppShell.stories.tsx +65 -31
- package/src/AppShell.test.tsx +92 -10
- package/src/AppShell.tsx +108 -18
- package/src/ArchivedNotice.mdx +46 -0
- package/src/ArchivedNotice.stories.tsx +52 -0
- package/src/ArchivedNotice.test.tsx +42 -0
- package/src/ArchivedNotice.tsx +71 -0
- package/src/Button.mdx +2 -2
- package/src/Button.tsx +8 -6
- package/src/Card.test.tsx +4 -4
- package/src/Card.tsx +6 -2
- package/src/CommentBox.test.tsx +2 -1
- package/src/CommentBox.tsx +14 -7
- package/src/ConfirmDialog.stories.tsx +12 -0
- package/src/ConversationActions.mdx +47 -0
- package/src/ConversationActions.stories.tsx +39 -0
- package/src/ConversationActions.tsx +96 -0
- package/src/ConversationCard.mdx +72 -0
- package/src/ConversationCard.states.test.tsx +330 -0
- package/src/ConversationCard.stories.tsx +135 -0
- package/src/ConversationCard.test.tsx +159 -0
- package/src/ConversationCard.tsx +522 -0
- package/src/ConversationLayout.mdx +61 -0
- package/src/ConversationLayout.stories.tsx +161 -0
- package/src/ConversationLayout.test.tsx +240 -0
- package/src/ConversationLayout.tsx +233 -0
- package/src/ConversationMenu.mdx +47 -0
- package/src/ConversationMenu.stories.tsx +42 -0
- package/src/ConversationMenu.test.tsx +47 -0
- package/src/ConversationMenu.tsx +57 -0
- package/src/Divider.mdx +36 -1
- package/src/Divider.stories.tsx +57 -0
- package/src/Divider.test.tsx +24 -1
- package/src/Divider.tsx +49 -9
- package/src/EditedMarker.mdx +36 -0
- package/src/EditedMarker.stories.tsx +24 -0
- package/src/EditedMarker.tsx +20 -0
- package/src/IconButton.mdx +2 -1
- package/src/IconButton.tsx +8 -5
- package/src/LinkParts.mdx +4 -0
- package/src/LinkParts.stories.tsx +10 -0
- package/src/LinkParts.tsx +5 -1
- package/src/ListColumn.tsx +9 -3
- package/src/MetaText.mdx +41 -0
- package/src/MetaText.stories.tsx +29 -0
- package/src/MetaText.tsx +38 -0
- package/src/NavItem.tsx +2 -11
- package/src/PageHeader.mdx +123 -0
- package/src/PageHeader.stories.tsx +174 -0
- package/src/PageHeader.test.tsx +99 -0
- package/src/PageHeader.tsx +105 -0
- package/src/Panel.mdx +12 -0
- package/src/Panel.stories.tsx +47 -5
- package/src/Panel.test.tsx +40 -0
- package/src/Panel.tsx +8 -2
- package/src/PinnedComment.mdx +40 -0
- package/src/PinnedComment.stories.tsx +21 -0
- package/src/PinnedComment.tsx +40 -0
- package/src/QuotedLine.mdx +44 -0
- package/src/QuotedLine.stories.tsx +30 -0
- package/src/QuotedLine.test.tsx +34 -0
- package/src/QuotedLine.tsx +33 -0
- package/src/ReactionHorizon.mdx +36 -0
- package/src/ReactionHorizon.stories.tsx +27 -0
- package/src/ReactionHorizon.tsx +27 -0
- package/src/RepliesRow.mdx +45 -0
- package/src/RepliesRow.stories.tsx +33 -0
- package/src/RepliesRow.test.tsx +47 -0
- package/src/RepliesRow.tsx +86 -0
- package/src/ReplyCard.mdx +50 -0
- package/src/ReplyCard.stories.tsx +68 -0
- package/src/ResolveDialog.mdx +44 -0
- package/src/ResolveDialog.stories.tsx +23 -0
- package/src/ResolveDialog.test.tsx +53 -0
- package/src/ResolveDialog.tsx +58 -0
- package/src/Select.tsx +12 -2
- package/src/Skeleton.stories.tsx +4 -1
- package/src/Skeleton.tsx +33 -4
- package/src/Thread.mdx +53 -0
- package/src/Thread.stories.tsx +167 -0
- package/src/Thread.test.tsx +83 -0
- package/src/Thread.tsx +113 -0
- package/src/TopBar.mdx +8 -6
- package/src/TopBar.stories.tsx +4 -3
- package/src/TopBar.tsx +8 -3
- package/src/UrgentMark.mdx +37 -0
- package/src/UrgentMark.stories.tsx +27 -0
- package/src/UrgentMark.tsx +15 -0
- package/src/commentBoxFrame.tsx +8 -4
- package/src/conversation.examples.tsx +135 -0
- package/src/eslint/no-native-title.ts +1 -1
- package/src/eslint/no-restyled-part.ts +1 -0
- package/src/index.ts +19 -2
- package/src/looks.ts +18 -2
- package/src/registry/registry.test.ts +7 -6
- package/src/threadCard.ts +84 -0
- package/stories/Choosing.mdx +21 -1
- package/tokens.css +14 -10
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
3
|
+
import { cleanup, render, screen } from '@testing-library/react'
|
|
4
|
+
import userEvent from '@testing-library/user-event'
|
|
5
|
+
import { ArchivedNotice } from './ArchivedNotice'
|
|
6
|
+
|
|
7
|
+
afterEach(cleanup)
|
|
8
|
+
|
|
9
|
+
describe('ArchivedNotice', () => {
|
|
10
|
+
it('says who archived it and when, the resolution, and offers Unarchive', () => {
|
|
11
|
+
render(<ArchivedNotice by="Person two" when="Today" resolution="Shipped." onUnarchive={() => {}} />)
|
|
12
|
+
expect(screen.getByText('Archived by Person two · Today')).toBeTruthy()
|
|
13
|
+
expect(screen.getByText('Shipped.')).toBeTruthy()
|
|
14
|
+
expect(screen.getByRole('button', { name: 'Unarchive' })).toBeTruthy()
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('archived with a project above it, names that project and opens it instead of unarchiving', async () => {
|
|
18
|
+
const open = vi.fn()
|
|
19
|
+
render(<ArchivedNotice by="Person two" when="Today" withWhat="project" withTitle="October release" onUnarchive={() => {}} onOpenParent={open} />)
|
|
20
|
+
expect(screen.getByText('Archived with its project “October release” by Person two · Today')).toBeTruthy()
|
|
21
|
+
expect(screen.queryByRole('button', { name: 'Unarchive' })).toBeNull()
|
|
22
|
+
await userEvent.click(screen.getByRole('button', { name: 'Open project' }))
|
|
23
|
+
expect(open).toHaveBeenCalledOnce()
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('unarchives once while the first press is still being written', async () => {
|
|
27
|
+
let finish = () => {}
|
|
28
|
+
const unarchive = vi.fn(() => new Promise<void>((resolve) => (finish = resolve)))
|
|
29
|
+
render(<ArchivedNotice by="Person two" when="Today" onUnarchive={unarchive} />)
|
|
30
|
+
const button = screen.getByRole('button', { name: 'Unarchive' })
|
|
31
|
+
await userEvent.click(button)
|
|
32
|
+
await userEvent.click(button)
|
|
33
|
+
expect(unarchive).toHaveBeenCalledOnce()
|
|
34
|
+
finish()
|
|
35
|
+
await vi.waitFor(() => expect((button as HTMLButtonElement).disabled).toBe(false))
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('offers nothing to a reader who cannot restore it', () => {
|
|
39
|
+
render(<ArchivedNotice by="Person two" when="Today" />)
|
|
40
|
+
expect(screen.queryByRole('button')).toBeNull()
|
|
41
|
+
})
|
|
42
|
+
})
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { IconArchive } from '@tabler/icons-react'
|
|
3
|
+
import { Button } from './Button'
|
|
4
|
+
import { Card } from './Card'
|
|
5
|
+
|
|
6
|
+
export interface ArchivedNoticeProps {
|
|
7
|
+
/** Who archived it, in the app's words: "You", a name. */
|
|
8
|
+
by: string
|
|
9
|
+
/** When, in the app's words, with its day: "Today", "Tue, Oct 28". */
|
|
10
|
+
when: string
|
|
11
|
+
/** What they wrote when they archived it. */
|
|
12
|
+
resolution?: string
|
|
13
|
+
/** Archived with the closest archived one above it: what that is, "project", "page", "Folder". */
|
|
14
|
+
withWhat?: string
|
|
15
|
+
/** The title of the one it is archived with, named in quotes. */
|
|
16
|
+
withTitle?: string
|
|
17
|
+
/** Restore it; the button waits for it. Absent when it is archived with one above it, or cannot be restored here. */
|
|
18
|
+
onUnarchive?: () => void | Promise<unknown>
|
|
19
|
+
/** Open the one it is archived with. Absent while that is still being read. */
|
|
20
|
+
onOpenParent?: () => void
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The first thing an archived file shows: who archived it and when, the resolution they gave, and the way back
|
|
25
|
+
* (FOL-46). A link still opens an archived file, so this is what stops it reading as live work. A quiet grey card,
|
|
26
|
+
* not a banner: archived is a state the file is in, not news. Peek's, Ship's and Leaf's card, moved here so the three
|
|
27
|
+
* say it in the same words and order (Katerina, 31 October).
|
|
28
|
+
*
|
|
29
|
+
* One archived by itself offers Unarchive; one archived with a file above it is restored there, so it opens that one.
|
|
30
|
+
*
|
|
31
|
+
* why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-file-is-archived-with-the-closest-archived-file-above-it.md
|
|
32
|
+
*/
|
|
33
|
+
export function ArchivedNotice({ by, when, resolution, withWhat, withTitle, onUnarchive, onOpenParent }: ArchivedNoticeProps) {
|
|
34
|
+
const [unarchiving, setUnarchiving] = useState(false)
|
|
35
|
+
const parent = withWhat ?? (withTitle ? 'parent' : undefined)
|
|
36
|
+
const named = withTitle ? ` “${withTitle}”` : ''
|
|
37
|
+
const line = parent ? `Archived with its ${parent}${named} by ${by} · ${when}` : `Archived by ${by} · ${when}`
|
|
38
|
+
return (
|
|
39
|
+
<Card fill="inset" className="flex items-start gap-3 px-4 py-3">
|
|
40
|
+
<IconArchive size={16} stroke={1.5} className="mt-0.5 shrink-0 text-text-muted" />
|
|
41
|
+
<div className="flex min-w-0 flex-1 flex-col gap-1">
|
|
42
|
+
<span className="text-body-2-strong text-text-primary">{line}</span>
|
|
43
|
+
{resolution && <p className="whitespace-pre-wrap text-caption text-text-secondary">{resolution}</p>}
|
|
44
|
+
</div>
|
|
45
|
+
{parent
|
|
46
|
+
? onOpenParent && (
|
|
47
|
+
<Button variant="outlined" size="small" className="shrink-0" onClick={onOpenParent}>
|
|
48
|
+
{`Open ${parent}`}
|
|
49
|
+
</Button>
|
|
50
|
+
)
|
|
51
|
+
: onUnarchive && (
|
|
52
|
+
<Button
|
|
53
|
+
variant="outlined"
|
|
54
|
+
size="small"
|
|
55
|
+
className="shrink-0"
|
|
56
|
+
disabled={unarchiving}
|
|
57
|
+
onClick={() => {
|
|
58
|
+
// One unarchive at a time: a second press while the first is written would write it twice.
|
|
59
|
+
setUnarchiving(true)
|
|
60
|
+
// A press that throws at once counts as done too: the button never stays shut (the review, 1 November).
|
|
61
|
+
void Promise.resolve()
|
|
62
|
+
.then(onUnarchive)
|
|
63
|
+
.finally(() => setUnarchiving(false))
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
Unarchive
|
|
67
|
+
</Button>
|
|
68
|
+
)}
|
|
69
|
+
</Card>
|
|
70
|
+
)
|
|
71
|
+
}
|
package/src/Button.mdx
CHANGED
|
@@ -84,8 +84,8 @@ import { IconExternalLink } from '@tabler/icons-react'
|
|
|
84
84
|
|
|
85
85
|
<Canvas of={ButtonStories.OpensAnotherApp} />
|
|
86
86
|
|
|
87
|
-
- `variant="resolve"` is
|
|
88
|
-
|
|
87
|
+
- `variant="resolve"` is outlined at rest and green when pointed at, in every
|
|
88
|
+
theme — the Resolve button. `IconButton`
|
|
89
89
|
has the same look.
|
|
90
90
|
- **Placed from outside, never restyled.** `className` takes space, size,
|
|
91
91
|
flex and grid, and position; a colour, a text size, a border, a corner or a
|
package/src/Button.tsx
CHANGED
|
@@ -26,9 +26,10 @@ import { TooltipTrigger } from './Tooltip'
|
|
|
26
26
|
* hover. Ship wrote that wrapper by hand six times.
|
|
27
27
|
*/
|
|
28
28
|
/**
|
|
29
|
-
* `resolve` is
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* `resolve` is outlined at rest and green when pointed at, in every theme —
|
|
30
|
+
* Peek's Resolve (UIG-9, 17 September; Peek passed it as classes before),
|
|
31
|
+
* Signal's look, and Ship's and Leaf's since Katerina's call (31 October): they
|
|
32
|
+
* drew it as the filled primary. `IconButton` has the same look.
|
|
32
33
|
*/
|
|
33
34
|
export type ButtonVariant = 'primary' | 'outlined' | 'muted' | 'destructive' | 'resolve'
|
|
34
35
|
export type ButtonSize = 'default' | 'small'
|
|
@@ -108,7 +109,8 @@ export function Button({
|
|
|
108
109
|
// Extra right padding beside a leading icon, for optical balance.
|
|
109
110
|
size === 'default' && (hasLeadingIcon ? 'pl-2 pr-3' : 'px-2'),
|
|
110
111
|
size === 'small' && (hasLeadingIcon ? 'pl-1.5 pr-2' : 'px-1.5'),
|
|
111
|
-
!off &&
|
|
112
|
+
!off && variant === 'primary' && 'bg-accent-primary hover:bg-accent-hover text-text-inverse cursor-pointer signal:font-semibold',
|
|
113
|
+
!off && variant === 'resolve' && 'cursor-pointer signal:font-semibold',
|
|
112
114
|
// @estiva-escape(no-copied-look): W2 (Katerina, 24 September: leave alone): an outlined button shares four words with Reaction's pill by coincidence
|
|
113
115
|
!off && variant === 'outlined' && 'border border-border-default hover:bg-bg-hover text-text-primary cursor-pointer',
|
|
114
116
|
!off && variant === 'muted' && 'hover:bg-bg-hover text-text-primary cursor-pointer',
|
|
@@ -121,9 +123,9 @@ export function Button({
|
|
|
121
123
|
// and a prevented `onClick`), so nothing else needs it.
|
|
122
124
|
off && !disabledReason && 'pointer-events-none',
|
|
123
125
|
off && variant === 'outlined' && 'border border-border-default',
|
|
124
|
-
// Disabled too, as it always drew.
|
|
126
|
+
// Disabled too, as it always drew; in every theme, as Signal drew it (Katerina, 31 October).
|
|
125
127
|
variant === 'resolve' &&
|
|
126
|
-
'
|
|
128
|
+
'border border-border-default bg-transparent text-text-primary shadow-none transition-colors hover:border-success-outline hover:bg-success-muted hover:text-success-default',
|
|
127
129
|
className,
|
|
128
130
|
)
|
|
129
131
|
const button =
|
package/src/Card.test.tsx
CHANGED
|
@@ -80,7 +80,7 @@ describe('Card', () => {
|
|
|
80
80
|
cleanup()
|
|
81
81
|
const active = classesOf(card(<Card hover="fill" active attention="accent">Item one</Card>))
|
|
82
82
|
expect(active).toContain('border-accent-primary')
|
|
83
|
-
expect(active).not.toContain('border-accent-
|
|
83
|
+
expect(active).not.toContain('border-accent-outline')
|
|
84
84
|
expect(active.some((c) => c.startsWith('hover:'))).toBe(false)
|
|
85
85
|
})
|
|
86
86
|
|
|
@@ -115,7 +115,7 @@ describe('Card', () => {
|
|
|
115
115
|
cleanup()
|
|
116
116
|
const urgent = classesOf(card(<Card hover="fill" quietUntilHover hovered attention="warning">Item one</Card>))
|
|
117
117
|
expect(urgent).toContain('bg-bg-hover')
|
|
118
|
-
expect(urgent).toContain('border-warning-
|
|
118
|
+
expect(urgent).toContain('border-warning-outline')
|
|
119
119
|
expect(urgent).not.toContain('border-border-default')
|
|
120
120
|
})
|
|
121
121
|
|
|
@@ -127,8 +127,8 @@ describe('Card', () => {
|
|
|
127
127
|
|
|
128
128
|
it('attention recolours the hairline, at rest and on hover', () => {
|
|
129
129
|
const classes = classesOf(card(<Card hover="fill" quietUntilHover attention="warning">Item one</Card>))
|
|
130
|
-
expect(classes).toContain('border-warning-
|
|
131
|
-
expect(classes).toContain('hover:border-warning-
|
|
130
|
+
expect(classes).toContain('border-warning-outline')
|
|
131
|
+
expect(classes).toContain('hover:border-warning-outline')
|
|
132
132
|
expect(classes).not.toContain('border-transparent')
|
|
133
133
|
})
|
|
134
134
|
|
package/src/Card.tsx
CHANGED
|
@@ -55,9 +55,13 @@ const HAIRLINE_HELD_CLASSES: Record<CardFill, string> = {
|
|
|
55
55
|
none: 'border-border-default',
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Each theme's own edge colours, the accent and the warning at 30% (Katerina, 31 October): the `-muted` fills read
|
|
60
|
+
* near black in Signal and not at all in Ship, whose accent-muted is its inset fill.
|
|
61
|
+
*/
|
|
58
62
|
const ATTENTION_CLASSES: Record<CardAttention, string> = {
|
|
59
|
-
accent: 'border-accent-
|
|
60
|
-
warning: 'border-warning-
|
|
63
|
+
accent: 'border-accent-outline hover:border-accent-outline',
|
|
64
|
+
warning: 'border-warning-outline hover:border-warning-outline',
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
export interface CardProps extends ComponentPropsWithRef<'div'> {
|
package/src/CommentBox.test.tsx
CHANGED
|
@@ -143,7 +143,8 @@ describe('editing', () => {
|
|
|
143
143
|
const onCancel = vi.fn()
|
|
144
144
|
render(<Box edit={{ body, onSave, onCancel }} />)
|
|
145
145
|
expect(editorOf().getText()).toBe('Said before')
|
|
146
|
-
|
|
146
|
+
// No keys written under it (Katerina, 1 November): Cancel and Save say it.
|
|
147
|
+
expect(screen.queryByText(/to cancel/)).toBeNull()
|
|
147
148
|
await type(', and now')
|
|
148
149
|
await press('Enter')
|
|
149
150
|
expect(textOf(onSave.mock.calls[0][0])).toBe('Said before, and now')
|
package/src/CommentBox.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fragment, useCallback, useEffect, useLayoutEffect, useRef, useState, type ComponentType, type DragEvent, type ReactNode } from 'react'
|
|
1
|
+
import { Fragment, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState, type ComponentType, type DragEvent, type ReactNode } from 'react'
|
|
2
2
|
import { Extension, nodePasteRule, type AnyExtension, type EditorOptions } from '@tiptap/core'
|
|
3
3
|
import { Editor, type JSONContent } from '@tiptap/react'
|
|
4
4
|
import { IconLock, IconPaperclip, IconSquareRounded } from '@tabler/icons-react'
|
|
@@ -25,7 +25,6 @@ import {
|
|
|
25
25
|
} from './ComposerTriggers'
|
|
26
26
|
import { FieldLine } from './Field'
|
|
27
27
|
import { FilePicker } from './FilePicker'
|
|
28
|
-
import { Kbd } from './Kbd'
|
|
29
28
|
import { inTheBox } from './linked'
|
|
30
29
|
import { LinkedIcon } from './LinkParts'
|
|
31
30
|
import { linkedKindOfReference } from './LinkPlaces'
|
|
@@ -34,6 +33,7 @@ import { PastedImages } from './PastedImages'
|
|
|
34
33
|
import { KeptSelection } from './SelectionToolbar'
|
|
35
34
|
import { isSuggestionOpen } from './suggestionPopup'
|
|
36
35
|
import { ToolbarButton } from './Toolbar'
|
|
36
|
+
import { caretOnOpen } from './threadCard'
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* The one box every app writes a comment, a reply and a chat line in, from the
|
|
@@ -575,6 +575,14 @@ export function CommentBox({
|
|
|
575
575
|
// Once, as the box opens.
|
|
576
576
|
}, [editor])
|
|
577
577
|
|
|
578
|
+
// At a thread's foot in a ConversationLayout: the caret, each time the thread opens, with no scroll to it.
|
|
579
|
+
const caret = useContext(caretOnOpen)
|
|
580
|
+
useEffect(() => {
|
|
581
|
+
if (!editor || !caret) return
|
|
582
|
+
const frame = requestAnimationFrame(() => editor.commands.focus('end', { scrollIntoView: false }))
|
|
583
|
+
return () => cancelAnimationFrame(frame)
|
|
584
|
+
}, [editor, caret])
|
|
585
|
+
|
|
578
586
|
// `/` → File asks for a file the way the paperclip does.
|
|
579
587
|
useEffect(() => {
|
|
580
588
|
const box = root.current
|
|
@@ -748,14 +756,13 @@ export function CommentBox({
|
|
|
748
756
|
marked={marking}
|
|
749
757
|
// The same strip as the send box: writing and editing work the same way (Katerina, 21 Oct).
|
|
750
758
|
selection={{ link: true }}
|
|
759
|
+
ring={false}
|
|
751
760
|
attachments={attached}
|
|
752
761
|
className={cn(sending && '[&_.ProseMirror]:text-text-muted')}
|
|
753
762
|
footer={
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
</span>
|
|
758
|
-
<div className="flex items-center gap-2">
|
|
763
|
+
// No keys written under the edit box: Cancel and Save say it (Katerina, 1 November).
|
|
764
|
+
<div className="flex items-center justify-end gap-2">
|
|
765
|
+
<div className="flex shrink-0 items-center gap-2">
|
|
759
766
|
<Button variant="outlined" size="small" onClick={edit.onCancel}>
|
|
760
767
|
Cancel
|
|
761
768
|
</Button>
|
|
@@ -61,3 +61,15 @@ export const RefusalKeepsItOpen: Story = {
|
|
|
61
61
|
)
|
|
62
62
|
},
|
|
63
63
|
}
|
|
64
|
+
|
|
65
|
+
/** Before a comment is deleted: its replies stay. The question a `ConversationCard` asks. */
|
|
66
|
+
export const DeleteAComment: Story = {
|
|
67
|
+
name: 'Delete a comment',
|
|
68
|
+
args: { title: 'Delete this comment?', confirmLabel: 'Delete comment', children: 'Its 2 replies stay.' },
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Before a reply is deleted. The question a `ReplyCard` asks. */
|
|
72
|
+
export const DeleteAReply: Story = {
|
|
73
|
+
name: 'Delete a reply',
|
|
74
|
+
args: { title: 'Delete this reply?', confirmLabel: 'Delete reply', children: 'It goes from the thread for everyone.' },
|
|
75
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks'
|
|
2
|
+
import * as Stories from './ConversationActions.stories'
|
|
3
|
+
|
|
4
|
+
<Meta of={Stories} />
|
|
5
|
+
|
|
6
|
+
# ConversationActions
|
|
7
|
+
|
|
8
|
+
The strip on a comment or a reply while it is pointed at: React, Reply, Resolve or Reopen, and ⋯, each drawn only when offered.
|
|
9
|
+
|
|
10
|
+
<Canvas of={Stories.Comment} />
|
|
11
|
+
|
|
12
|
+
## When
|
|
13
|
+
|
|
14
|
+
- Inside **ConversationCard** and **ReplyCard**, which draw it for you.
|
|
15
|
+
- On its own only where a card of your own needs the same strip.
|
|
16
|
+
|
|
17
|
+
<Canvas of={Stories.Resolved} />
|
|
18
|
+
|
|
19
|
+
<Canvas of={Stories.Reply} />
|
|
20
|
+
|
|
21
|
+
## When not
|
|
22
|
+
|
|
23
|
+
- The ⋯ menu itself → **ConversationMenu**, passed as `more`.
|
|
24
|
+
- A row of buttons anywhere else → **Toolbar**.
|
|
25
|
+
|
|
26
|
+
## How
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { ConversationActions, ConversationMenu } from '@estiva-app/ui'
|
|
30
|
+
|
|
31
|
+
<ConversationActions options={options} onReact={react} onReply={reply} onResolve={resolve} more={<ConversationMenu onResolve={resolve} />} />
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
- One Tab stop: the arrow keys walk the buttons.
|
|
35
|
+
- `onPickerOpenChange` tells a card the reactions are open, so it keeps the strip.
|
|
36
|
+
|
|
37
|
+
## What it owns
|
|
38
|
+
|
|
39
|
+
| It does | So you never write | Refused when written by hand |
|
|
40
|
+
|---|---|---|
|
|
41
|
+
| Draws only the buttons the card offers | a check per button | |
|
|
42
|
+
| Opens the reactions over the whole strip, and closes on a pick | a popover and its open state | |
|
|
43
|
+
| Offers Reopen in place of Resolve once resolved | the swap | |
|
|
44
|
+
|
|
45
|
+
## Props
|
|
46
|
+
|
|
47
|
+
<Controls />
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
+
import { IconDotsVertical } from '@tabler/icons-react'
|
|
3
|
+
import { ConversationActions } from './ConversationActions'
|
|
4
|
+
import { ConversationMenu } from './ConversationMenu'
|
|
5
|
+
import { OPTIONS } from './conversation.examples'
|
|
6
|
+
import { ToolbarButton } from './Toolbar'
|
|
7
|
+
|
|
8
|
+
/** The strip on a comment or a reply while it is pointed at. Each button is drawn only when the card offers it. */
|
|
9
|
+
const meta = {
|
|
10
|
+
title: 'Conversation/ConversationActions',
|
|
11
|
+
component: ConversationActions,
|
|
12
|
+
parameters: { layout: 'padded' },
|
|
13
|
+
decorators: [(Story) => <div className="pt-16">{Story()}</div>],
|
|
14
|
+
} satisfies Meta<typeof ConversationActions>
|
|
15
|
+
|
|
16
|
+
export default meta
|
|
17
|
+
type Story = StoryObj<typeof meta>
|
|
18
|
+
|
|
19
|
+
const more = (
|
|
20
|
+
<ConversationMenu
|
|
21
|
+
trigger={
|
|
22
|
+
<ToolbarButton tooltip="More actions" aria-label="More actions">
|
|
23
|
+
<IconDotsVertical size={16} stroke={1.5} />
|
|
24
|
+
</ToolbarButton>
|
|
25
|
+
}
|
|
26
|
+
onResolve={() => {}}
|
|
27
|
+
onEdit={() => {}}
|
|
28
|
+
onDelete={() => {}}
|
|
29
|
+
/>
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
/** On a comment: React, Reply, Resolve and ⋯. */
|
|
33
|
+
export const Comment: Story = { args: { options: OPTIONS, onReact: () => {}, onReply: () => {}, onResolve: () => {}, more } }
|
|
34
|
+
|
|
35
|
+
/** On a resolved comment: Reopen in place of Resolve. */
|
|
36
|
+
export const Resolved: Story = { args: { options: OPTIONS, onReact: () => {}, onReply: () => {}, resolved: true, onReopen: () => {}, more } }
|
|
37
|
+
|
|
38
|
+
/** On a reply: React and ⋯. */
|
|
39
|
+
export const Reply: Story = { args: { options: OPTIONS, onReact: () => {}, more } }
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { useState, type ReactNode } from 'react'
|
|
2
|
+
import { IconCircleCheck, IconCircleDashed, IconMessage2, IconMoodPlus } from '@tabler/icons-react'
|
|
3
|
+
import { cn } from './cn'
|
|
4
|
+
import { Popover } from './Popover'
|
|
5
|
+
import { ReactionPicker, type ReactionOption } from './ReactionPicker'
|
|
6
|
+
import { Toolbar, ToolbarButton, ToolbarSeparator } from './Toolbar'
|
|
7
|
+
|
|
8
|
+
export interface ConversationActionsProps {
|
|
9
|
+
/** The reactions on offer: with `onReact`, "React" opens them over the strip. */
|
|
10
|
+
options?: readonly ReactionOption[]
|
|
11
|
+
onReact?: (emoji: string) => void
|
|
12
|
+
onReply?: () => void
|
|
13
|
+
/** Resolved: the strip offers Reopen in place of Resolve. */
|
|
14
|
+
resolved?: boolean
|
|
15
|
+
onResolve?: () => void
|
|
16
|
+
onReopen?: () => void
|
|
17
|
+
/** Told when the reactions open and close, so a card can keep its strip while they are up. */
|
|
18
|
+
onPickerOpenChange?: (open: boolean) => void
|
|
19
|
+
/** The ⋯ menu: a `ConversationMenu` whose trigger is a `ToolbarButton`, so the strip stays one Tab stop. */
|
|
20
|
+
more?: ReactNode
|
|
21
|
+
/** Placement only: `absolute right-1 top-1`. */
|
|
22
|
+
className?: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The strip on a comment or a reply while it is pointed at: React · Reply · Resolve or Reopen · ⋯, each drawn only
|
|
27
|
+
* when the card offers it, a line only between two groups that are both there. One Tab stop; the arrow keys walk the buttons. Peek's, moved with the conversation.
|
|
28
|
+
*/
|
|
29
|
+
export function ConversationActions({ options, onReact, onReply, resolved = false, onResolve, onReopen, onPickerOpenChange, more, className }: ConversationActionsProps) {
|
|
30
|
+
const [picking, setPicking] = useState(false)
|
|
31
|
+
// The reactions hang from the whole strip, right-aligned, not from their own button.
|
|
32
|
+
const [strip, setStrip] = useState<HTMLDivElement | null>(null)
|
|
33
|
+
const setOpen = (open: boolean) => {
|
|
34
|
+
setPicking(open)
|
|
35
|
+
onPickerOpenChange?.(open)
|
|
36
|
+
}
|
|
37
|
+
const resolves = resolved ? onReopen : onResolve
|
|
38
|
+
const answers = (!!onReact && !!options) || !!onReply
|
|
39
|
+
return (
|
|
40
|
+
<div ref={setStrip} className={cn('inline-flex', className)}>
|
|
41
|
+
<Toolbar aria-label="Actions">
|
|
42
|
+
{onReact && options && (
|
|
43
|
+
<Popover
|
|
44
|
+
side="top"
|
|
45
|
+
align="right"
|
|
46
|
+
anchor={strip}
|
|
47
|
+
ariaLabel="Reactions"
|
|
48
|
+
className="w-auto min-w-0"
|
|
49
|
+
contentClassName="p-1"
|
|
50
|
+
open={picking}
|
|
51
|
+
onOpenChange={setOpen}
|
|
52
|
+
trigger={
|
|
53
|
+
<ToolbarButton tooltip="React" aria-label="React">
|
|
54
|
+
<IconMoodPlus size={16} stroke={1.5} />
|
|
55
|
+
</ToolbarButton>
|
|
56
|
+
}
|
|
57
|
+
>
|
|
58
|
+
<ReactionPicker
|
|
59
|
+
options={[...options]}
|
|
60
|
+
surface={false}
|
|
61
|
+
onSelect={(emoji) => {
|
|
62
|
+
setOpen(false)
|
|
63
|
+
onReact(emoji)
|
|
64
|
+
}}
|
|
65
|
+
/>
|
|
66
|
+
</Popover>
|
|
67
|
+
)}
|
|
68
|
+
{onReply && (
|
|
69
|
+
<ToolbarButton tooltip="Reply" aria-label="Reply" onClick={onReply}>
|
|
70
|
+
<IconMessage2 size={16} stroke={1.5} />
|
|
71
|
+
</ToolbarButton>
|
|
72
|
+
)}
|
|
73
|
+
{resolves && (
|
|
74
|
+
<>
|
|
75
|
+
{answers && <ToolbarSeparator />}
|
|
76
|
+
{resolved ? (
|
|
77
|
+
<ToolbarButton tooltip="Reopen" aria-label="Reopen" onClick={onReopen}>
|
|
78
|
+
<IconCircleDashed size={16} stroke={1.5} />
|
|
79
|
+
</ToolbarButton>
|
|
80
|
+
) : (
|
|
81
|
+
<ToolbarButton variant="resolve" tooltip="Resolve" aria-label="Resolve" onClick={onResolve}>
|
|
82
|
+
<IconCircleCheck size={16} stroke={1.5} />
|
|
83
|
+
</ToolbarButton>
|
|
84
|
+
)}
|
|
85
|
+
</>
|
|
86
|
+
)}
|
|
87
|
+
{more && (
|
|
88
|
+
<>
|
|
89
|
+
{(answers || resolves) && <ToolbarSeparator />}
|
|
90
|
+
{more}
|
|
91
|
+
</>
|
|
92
|
+
)}
|
|
93
|
+
</Toolbar>
|
|
94
|
+
</div>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks'
|
|
2
|
+
import * as Stories from './ConversationCard.stories'
|
|
3
|
+
|
|
4
|
+
<Meta of={Stories} />
|
|
5
|
+
|
|
6
|
+
# ConversationCard
|
|
7
|
+
|
|
8
|
+
One comment, the same in every app: who, when, the words, files, cards, reactions and the way into its replies, with the actions on hover and the ⋯ menu.
|
|
9
|
+
|
|
10
|
+
<Canvas of={Stories.Comment} />
|
|
11
|
+
|
|
12
|
+
## When
|
|
13
|
+
|
|
14
|
+
- **A comment** in any conversation: in the comments beside a page, or filling the page with its thread beside it (**ConversationLayout**).
|
|
15
|
+
- `own` on yours: Edit (with `editor`) and Delete (with `onDelete`) in its menu. The card asks before it deletes.
|
|
16
|
+
- `resolved`: folded. "✓ Resolved" by the time, with who, when and the note on hover; "Person two → the note · time" above its replies row. While its thread is closed, the words fold to their first line, without files or reactions; open, it is whole.
|
|
17
|
+
- `about` on a comment on a part of the page: a **QuotedLine** under the name, above the words.
|
|
18
|
+
- `isNew`, `urgent`: the dot or the urgent mark, and a hairline, until it is read.
|
|
19
|
+
|
|
20
|
+
<Canvas of={Stories.Replies} />
|
|
21
|
+
|
|
22
|
+
<Canvas of={Stories.Resolved} />
|
|
23
|
+
|
|
24
|
+
<Canvas of={Stories.OnAPart} />
|
|
25
|
+
|
|
26
|
+
## When not
|
|
27
|
+
|
|
28
|
+
- A reply in a thread → **ReplyCard**: no replies of its own, no Resolve.
|
|
29
|
+
- A link to something, alone → **LinkCard**; a card someone attached sits in the words as an **AttachedCard**.
|
|
30
|
+
- A row in a list of places → **NavItem**.
|
|
31
|
+
|
|
32
|
+
## How
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { ConversationCard } from '@estiva-app/ui'
|
|
36
|
+
|
|
37
|
+
<ConversationCard
|
|
38
|
+
author={author}
|
|
39
|
+
time={timeOf(comment)}
|
|
40
|
+
edited={editedWords}
|
|
41
|
+
reactions={{ reactions: reactions, options: options, nameOf: nameOf, viewer: me, onToggle: (emoji: string) => react(comment, emoji) }}
|
|
42
|
+
replies={{ count: replyCount, faces: faces, last: lastTime, isNew: hasNew }}
|
|
43
|
+
resolved={resolution}
|
|
44
|
+
onResolve={(note) => resolve(comment, note)}
|
|
45
|
+
onReopen={() => reopen(comment)}
|
|
46
|
+
own={isMine}
|
|
47
|
+
editor={(done) => editBoxFor(comment, done)}
|
|
48
|
+
onDelete={() => remove(comment)}
|
|
49
|
+
onClick={() => openThread(comment)}
|
|
50
|
+
>
|
|
51
|
+
{wordsOf(comment)}
|
|
52
|
+
</ConversationCard>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
- **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.
|
|
56
|
+
- **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.
|
|
57
|
+
- **Resolve opens the dialog**: **ResolveDialog**, then `onResolve(note)`. Answer `false` when it was refused; the dialog stays.
|
|
58
|
+
- 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.
|
|
59
|
+
- The strip shows while the card is pointed at or has focus, and holds while its reactions or its menu are open.
|
|
60
|
+
|
|
61
|
+
## What it owns
|
|
62
|
+
|
|
63
|
+
| It does | So you never write | Refused when written by hand |
|
|
64
|
+
|---|---|---|
|
|
65
|
+
| Shows its actions while pointed at, and holds them while a menu is open | hover state and an outside-click check | |
|
|
66
|
+
| Asks before it deletes | a confirm dialog | |
|
|
67
|
+
| Opens the Resolve dialog, and closes it once resolved | a dialog and its open state | |
|
|
68
|
+
| Says it is resolved, with who and the note, and folds it while its thread is closed | a resolved line or chip of your own | |
|
|
69
|
+
|
|
70
|
+
## Props
|
|
71
|
+
|
|
72
|
+
<Controls />
|