@estiva-app/ui 0.95.0 → 0.97.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/Avatar.d.ts +6 -1
- package/dist/Avatar.d.ts.map +1 -1
- package/dist/AvatarGroup.d.ts +2 -0
- package/dist/AvatarGroup.d.ts.map +1 -1
- 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/ComposerTriggers.d.ts +2 -0
- package/dist/ComposerTriggers.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 +90 -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 +4 -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/MembersDialog.d.ts +4 -0
- package/dist/MembersDialog.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/Person.d.ts +3 -1
- package/dist/Person.d.ts.map +1 -1
- package/dist/PersonTrigger.d.ts +1 -1
- package/dist/PersonTrigger.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 +27 -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 +33 -25
- 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 +1412 -448
- package/dist/index.js.map +4 -4
- package/dist/linked.d.ts +4 -0
- package/dist/linked.d.ts.map +1 -1
- package/dist/linkedFrom.d.ts +2 -0
- package/dist/linkedFrom.d.ts.map +1 -1
- 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 +1889 -544
- 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/Avatar.agent.test.tsx +63 -0
- package/src/Avatar.mdx +25 -0
- package/src/Avatar.stories.tsx +13 -0
- package/src/Avatar.tsx +51 -3
- package/src/AvatarGroup.tsx +3 -1
- 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/ComposerTriggers.stories.tsx +2 -0
- package/src/ComposerTriggers.tsx +3 -1
- 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 +524 -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/LinkCard.tsx +3 -3
- package/src/LinkChip.tsx +1 -1
- package/src/LinkParts.mdx +4 -0
- package/src/LinkParts.stories.tsx +10 -0
- package/src/LinkParts.tsx +9 -5
- package/src/LinkRow.tsx +1 -1
- package/src/ListColumn.tsx +9 -3
- package/src/MembersDialog.stories.tsx +11 -0
- package/src/MembersDialog.tsx +7 -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/Person.tsx +4 -2
- package/src/PersonTrigger.tsx +3 -3
- 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/linked.ts +4 -0
- package/src/linkedFrom.ts +5 -3
- package/src/looks.ts +18 -2
- package/src/registry/registry.test.ts +9 -7
- 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
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
/**
|
|
3
|
+
* An agent's face (Katerina, 1 November): a robot where a person's initials would be, wherever a face is drawn, and
|
|
4
|
+
* its picture when it has one. Before, every agent showed "C" for "Claude (steered by …)", like a person.
|
|
5
|
+
*
|
|
6
|
+
* jsdom never loads an image, so the picture tests fire the `<img>`'s own events.
|
|
7
|
+
*/
|
|
8
|
+
import { afterEach, describe, expect, it } from 'vitest'
|
|
9
|
+
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
|
10
|
+
import { Avatar } from './Avatar'
|
|
11
|
+
import { MembersDialog } from './MembersDialog'
|
|
12
|
+
import { Person } from './Person'
|
|
13
|
+
|
|
14
|
+
afterEach(cleanup)
|
|
15
|
+
|
|
16
|
+
const AGENT = 'Agent (steered by Ana Duarte)'
|
|
17
|
+
const tile = (container: HTMLElement) => container.firstElementChild as HTMLElement
|
|
18
|
+
|
|
19
|
+
describe('an agent’s face', () => {
|
|
20
|
+
it('is a robot, not its initials', () => {
|
|
21
|
+
const { container } = render(<Avatar name={AGENT} bot />)
|
|
22
|
+
expect(tile(container).textContent).toBe('')
|
|
23
|
+
expect(tile(container).querySelector('svg path')).not.toBeNull()
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('a person with the same kind of name still gets initials', () => {
|
|
27
|
+
const { container } = render(<Avatar name={AGENT} />)
|
|
28
|
+
expect(tile(container).textContent).toBe('A')
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('its picture still wins, and the robot shows if the picture fails', () => {
|
|
32
|
+
const { container } = render(<Avatar name={AGENT} bot src="https://example.test/agent.png" />)
|
|
33
|
+
const img = tile(container).querySelector('img')!
|
|
34
|
+
fireEvent.load(img)
|
|
35
|
+
expect(tile(container).querySelector('svg')).toBeNull()
|
|
36
|
+
cleanup()
|
|
37
|
+
const failed = render(<Avatar name={AGENT} bot src="https://example.test/agent.png" />)
|
|
38
|
+
fireEvent.error(tile(failed.container).querySelector('img')!)
|
|
39
|
+
expect(tile(failed.container).querySelector('svg path')).not.toBeNull()
|
|
40
|
+
expect(tile(failed.container).textContent).toBe('')
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('beside its name in a Person, the name is said once and no letter is drawn', () => {
|
|
44
|
+
const { container } = render(<Person name={AGENT} bot />)
|
|
45
|
+
expect(container.textContent).toBe(AGENT)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('in the members list, the agent’s row has the robot and the person’s row their initials', () => {
|
|
49
|
+
render(
|
|
50
|
+
<MembersDialog
|
|
51
|
+
members={[
|
|
52
|
+
{ id: 'ana', name: 'Ana Duarte' },
|
|
53
|
+
{ id: 'agent', name: AGENT, bot: true },
|
|
54
|
+
]}
|
|
55
|
+
onClose={() => {}}
|
|
56
|
+
/>,
|
|
57
|
+
)
|
|
58
|
+
const rowOf = (name: string) => screen.getByText(name).closest('div.flex.h-12') as HTMLElement
|
|
59
|
+
expect(rowOf('Ana Duarte').textContent).toBe('ADAna Duarte')
|
|
60
|
+
expect(rowOf(AGENT).textContent).toBe(AGENT)
|
|
61
|
+
expect(rowOf(AGENT).querySelector('svg path')).not.toBeNull()
|
|
62
|
+
})
|
|
63
|
+
})
|
package/src/Avatar.mdx
CHANGED
|
@@ -7,6 +7,7 @@ import * as AvatarStories from './Avatar.stories'
|
|
|
7
7
|
|
|
8
8
|
A person's face: their picture, or their initials on a colour that is
|
|
9
9
|
theirs, or — when there is no name to take initials from — a silhouette.
|
|
10
|
+
An agent's face is a robot on lime.
|
|
10
11
|
|
|
11
12
|
<Canvas of={AvatarStories.Sizes} />
|
|
12
13
|
|
|
@@ -68,6 +69,29 @@ a stack of members — and the tile becomes one image with one name.
|
|
|
68
69
|
|
|
69
70
|
<Canvas of={AvatarStories.Palette} />
|
|
70
71
|
|
|
72
|
+
### An agent
|
|
73
|
+
|
|
74
|
+
**`bot` draws a robot on lime** in place of the initials, for a profile that
|
|
75
|
+
says it is an agent (NIP-24's `bot: true`, which Estiva ID publishes for every
|
|
76
|
+
agent). Its picture still wins when it has one.
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
<Avatar name={profile.name} src={profile.picture} bot={profile.bot} />
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
- Take `bot` from the profile, **never from the name**: "steered by" is a
|
|
83
|
+
name, not a marker.
|
|
84
|
+
- Lime is the same in every theme, on the initials' light and shade. No
|
|
85
|
+
person's colour is near it, so an agent never reads as a person, nor as the
|
|
86
|
+
yellow urgent mark.
|
|
87
|
+
- The robot is drawn at 5/8 of the tile, larger than the silhouette, so it
|
|
88
|
+
still reads at 16px.
|
|
89
|
+
- Every part that draws a face takes `bot` with the person: `Person`,
|
|
90
|
+
`PersonTrigger`, `AvatarGroup`, `MembersPill`, `MembersDialog`, the mention
|
|
91
|
+
menu, a comment's and a reply's author, and the link parts.
|
|
92
|
+
|
|
93
|
+
<Canvas of={AvatarStories.Agent} />
|
|
94
|
+
|
|
71
95
|
- **Planned:** a Byline part — face · name · time — in migration stage 7.
|
|
72
96
|
|
|
73
97
|
- `initialsFor(name)` and `hueFor(name)` give the same initials and colour where
|
|
@@ -80,6 +104,7 @@ It does these by itself. Write none of them around it.
|
|
|
80
104
|
| It does | So you never write | Refused when written by hand |
|
|
81
105
|
|---|---|---|
|
|
82
106
|
| Shows initials from the name when there is no picture, or when it fails to load | an `onError`, or initials of your own | |
|
|
107
|
+
| Shows a robot for an agent (`bot`) when there is no picture | a robot icon of your own, or a check of the name | |
|
|
83
108
|
|
|
84
109
|
## Props
|
|
85
110
|
|
package/src/Avatar.stories.tsx
CHANGED
|
@@ -17,6 +17,19 @@ export const Initials: Story = {}
|
|
|
17
17
|
/** No name, no picture: the silhouette. Never a key, never a `?`. */
|
|
18
18
|
export const Unnamed: Story = { args: { name: undefined } }
|
|
19
19
|
|
|
20
|
+
/** An agent (its profile says `bot`): a robot on lime in place of its initials, at every size. */
|
|
21
|
+
export const Agent: Story = {
|
|
22
|
+
args: { name: 'Agent (steered by Ana Duarte)', bot: true },
|
|
23
|
+
parameters: { controls: { disable: true } },
|
|
24
|
+
render: (args) => (
|
|
25
|
+
<div className="flex items-end gap-3">
|
|
26
|
+
{[16, 20, 24, 32, 36].map((size) => (
|
|
27
|
+
<Avatar key={size} {...args} size={size} />
|
|
28
|
+
))}
|
|
29
|
+
</div>
|
|
30
|
+
),
|
|
31
|
+
}
|
|
32
|
+
|
|
20
33
|
/** A picture — here an inline SVG, so the story needs nothing from anywhere. */
|
|
21
34
|
export const WithPicture: Story = {
|
|
22
35
|
args: {
|
package/src/Avatar.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import { cn } from './cn'
|
|
|
6
6
|
/**
|
|
7
7
|
* A person's face: their picture, or their initials on a colour that is
|
|
8
8
|
* theirs, or — when there is no name to take initials from — a silhouette.
|
|
9
|
+
* An agent's is a robot on lime (`bot`), unless it has a picture.
|
|
9
10
|
*
|
|
10
11
|
* Peek's Avatar (2026-08-28), made self-contained: Peek's version found the
|
|
11
12
|
* picture itself, by name, from Peek's data (an upload in Convex, else the
|
|
@@ -39,6 +40,9 @@ export const hueFor = (key: string) => {
|
|
|
39
40
|
return HUES[Math.abs(h) % HUES.length]
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
/** The tile's ground from its hue: lighter at the top left, darker at the foot. An agent's lime takes it too. */
|
|
44
|
+
const groundFor = (hue: string) => `linear-gradient(160deg, color-mix(in srgb, ${hue} 92%, #fff) 0%, color-mix(in srgb, ${hue} 70%, #0b0d11) 100%)`
|
|
45
|
+
|
|
42
46
|
/**
|
|
43
47
|
* Peek's rule, sharpened: the first letter of the first two words — counting
|
|
44
48
|
* only words that begin with a letter or digit, so "Claude (steered by
|
|
@@ -72,10 +76,52 @@ export interface AvatarProps {
|
|
|
72
76
|
* of a name, not text, and a screen reader was reading them as text.
|
|
73
77
|
*/
|
|
74
78
|
label?: string
|
|
79
|
+
/**
|
|
80
|
+
* **An agent's face**: a robot in place of the initials, for a profile that says it is an agent (NIP-24's `bot`).
|
|
81
|
+
* Its picture still wins when it has one. Never worked out from the name: "steered by" is a name, not a marker.
|
|
82
|
+
*/
|
|
83
|
+
bot?: boolean
|
|
75
84
|
className?: string
|
|
76
85
|
}
|
|
77
86
|
|
|
78
|
-
|
|
87
|
+
/**
|
|
88
|
+
* An agent's robot: Remix Icon's `robot-2-fill`, copied as its one path rather than a second icon package, because
|
|
89
|
+
* Tabler has no solid robot (Katerina, 1 November, from six drawings in four open sets).
|
|
90
|
+
* Remix Icon License v1.0, Copyright (c) 2017–2026 Remix Design: use in a product is allowed; not as a logo, and
|
|
91
|
+
* not resold as icons.
|
|
92
|
+
*/
|
|
93
|
+
const ROBOT_PATH =
|
|
94
|
+
'M13.5 2C13.5 2.44425 13.3069 2.84339 13 3.11805V5H18C19.6569 5 21 6.34315 21 8V18C21 19.6569 19.6569 21 18 21H6C4.34315 21 3 19.6569 3 18V8C3 6.34315 4.34315 5 6 5H11V3.11805C10.6931 2.84339 10.5 2.44425 10.5 2C10.5 1.17157 11.1716 0.5 12 0.5C12.8284 0.5 13.5 1.17157 13.5 2ZM0 10H2V16H0V10ZM24 10H22V16H24V10ZM9 14.5C9.82843 14.5 10.5 13.8284 10.5 13C10.5 12.1716 9.82843 11.5 9 11.5C8.17157 11.5 7.5 12.1716 7.5 13C7.5 13.8284 8.17157 14.5 9 14.5ZM16.5 13C16.5 12.1716 15.8284 11.5 15 11.5C14.1716 11.5 13.5 12.1716 13.5 13C13.5 13.8284 14.1716 14.5 15 14.5C15.8284 14.5 16.5 13.8284 16.5 13Z'
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* An agent's colour: lime, the same in every theme and on the initials' light and shade (Katerina, 1 November). No
|
|
98
|
+
* person's hue is near it, so an agent never reads as a person, nor as the yellow urgent mark.
|
|
99
|
+
*/
|
|
100
|
+
const AGENT_HUE = '#d4ee4a'
|
|
101
|
+
|
|
102
|
+
/** An agent's face: the robot, larger than the silhouette (5/8 of the tile), so it still reads at 16px. */
|
|
103
|
+
function AgentFace({ size }: { size: number }) {
|
|
104
|
+
const glyph = Math.round(size * 0.625)
|
|
105
|
+
return (
|
|
106
|
+
<BaseAvatar.Fallback
|
|
107
|
+
render={<div />}
|
|
108
|
+
className="w-full h-full flex items-center justify-center"
|
|
109
|
+
style={{
|
|
110
|
+
/* eslint-disable no-restricted-syntax -- @estiva-escape: one colour in every theme, on the initials' light
|
|
111
|
+
and shade, and their ink: a palette, as HUES, so none of it can be a token. */
|
|
112
|
+
background: groundFor(AGENT_HUE),
|
|
113
|
+
color: '#08121c',
|
|
114
|
+
/* eslint-enable no-restricted-syntax */
|
|
115
|
+
}}
|
|
116
|
+
>
|
|
117
|
+
<svg width={glyph} height={glyph} viewBox="0 0 24 24" fill="currentColor" aria-hidden>
|
|
118
|
+
<path d={ROBOT_PATH} />
|
|
119
|
+
</svg>
|
|
120
|
+
</BaseAvatar.Fallback>
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function Avatar({ src, name, alt = '', size = 36, label: spoken, bot = false, className }: AvatarProps) {
|
|
79
125
|
const label = name || alt
|
|
80
126
|
// No picture handed in: the app's own, when it has said where pictures live (`AppProvider`).
|
|
81
127
|
const pictureFor = usePictureFor()
|
|
@@ -107,7 +153,9 @@ export function Avatar({ src, name, alt = '', size = 36, label: spoken, classNam
|
|
|
107
153
|
className="w-full h-full object-cover data-[error]:hidden"
|
|
108
154
|
/>
|
|
109
155
|
)}
|
|
110
|
-
{
|
|
156
|
+
{bot ? (
|
|
157
|
+
<AgentFace size={size} />
|
|
158
|
+
) : label ? (
|
|
111
159
|
<BaseAvatar.Fallback
|
|
112
160
|
render={<div />}
|
|
113
161
|
/*
|
|
@@ -133,7 +181,7 @@ export function Avatar({ src, name, alt = '', size = 36, label: spoken, classNam
|
|
|
133
181
|
// ink cannot be a token either.
|
|
134
182
|
color: '#08121c',
|
|
135
183
|
fontSize: Math.round(size * 0.36),
|
|
136
|
-
background:
|
|
184
|
+
background: groundFor(hueFor(label)),
|
|
137
185
|
/* eslint-enable no-restricted-syntax */
|
|
138
186
|
}}
|
|
139
187
|
>
|
package/src/AvatarGroup.tsx
CHANGED
|
@@ -20,6 +20,8 @@ export interface AvatarGroupMember {
|
|
|
20
20
|
name: string
|
|
21
21
|
/** Resolved by the caller. Absent draws the initials. */
|
|
22
22
|
picture?: string
|
|
23
|
+
/** An agent: its face is a robot, as Avatar's `bot`. */
|
|
24
|
+
bot?: boolean
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
export interface AvatarGroupProps {
|
|
@@ -67,7 +69,7 @@ export function AvatarGroup({ members, size = 24, on = 'surface' }: AvatarGroupP
|
|
|
67
69
|
{/* Each face says whose it is: a stack stands on its own, with no
|
|
68
70
|
name beside it to borrow. It read as its initials before —
|
|
69
71
|
"AD BC CD" — which is the drawing, not the person. */}
|
|
70
|
-
<Avatar size={size} name={member.name} src={member.picture} label={member.name} />
|
|
72
|
+
<Avatar size={size} name={member.name} src={member.picture} bot={member.bot} label={member.name} />
|
|
71
73
|
</span>
|
|
72
74
|
))}
|
|
73
75
|
</div>
|
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>
|
|
@@ -36,6 +36,8 @@ const PEOPLE: MentionPerson[] = ['one', 'two', 'three', 'four', 'five', 'six', '
|
|
|
36
36
|
description: i % 2 === 0 ? 'Label' : undefined,
|
|
37
37
|
pubkey: null,
|
|
38
38
|
}))
|
|
39
|
+
// An agent among them, second, so `@` shows its robot face at once.
|
|
40
|
+
PEOPLE.splice(1, 0, { id: 'agent', name: 'Agent (steered by Person one)', description: 'Agent', pubkey: null, bot: true })
|
|
39
41
|
|
|
40
42
|
const ITEMS: CaptionedItem[] = ['one', 'two', 'three'].map((n) => ({
|
|
41
43
|
id: `item-${n}`,
|
package/src/ComposerTriggers.tsx
CHANGED
|
@@ -40,6 +40,8 @@ export interface MentionPerson {
|
|
|
40
40
|
pubkey?: string | null
|
|
41
41
|
/** The face at the row's start. Default: the package `Avatar` for the name. */
|
|
42
42
|
avatar?: ReactNode
|
|
43
|
+
/** An agent: its face is a robot, as Avatar's `bot`. */
|
|
44
|
+
bot?: boolean
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
/** How many people the list shows. */
|
|
@@ -67,7 +69,7 @@ export function peopleMenu(urgent: boolean): SuggestionPopupOptions<MentionPerso
|
|
|
67
69
|
row: (person) => ({
|
|
68
70
|
label: person.name,
|
|
69
71
|
description: person.description,
|
|
70
|
-
leading: person.avatar ?? <Avatar size={32} alt={person.name} />,
|
|
72
|
+
leading: person.avatar ?? <Avatar size={32} alt={person.name} bot={person.bot} />,
|
|
71
73
|
hint: <EnterHint />,
|
|
72
74
|
size: 'tall',
|
|
73
75
|
}),
|
|
@@ -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 } }
|