@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,27 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
+
import { UnreadDot } from './UnreadDot'
|
|
3
|
+
import { UrgentMark } from './UrgentMark'
|
|
4
|
+
|
|
5
|
+
/** Urgent and new, in the unread dot's 24px slot. */
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Conversation/UrgentMark',
|
|
8
|
+
component: UrgentMark,
|
|
9
|
+
parameters: { layout: 'padded' },
|
|
10
|
+
} satisfies Meta<typeof UrgentMark>
|
|
11
|
+
|
|
12
|
+
export default meta
|
|
13
|
+
type Story = StoryObj<typeof meta>
|
|
14
|
+
|
|
15
|
+
/** The mark. */
|
|
16
|
+
export const Urgent: Story = {}
|
|
17
|
+
|
|
18
|
+
/** Beside the plain unread dot it stands in for. */
|
|
19
|
+
export const BesideTheDot: Story = {
|
|
20
|
+
name: 'Beside the dot',
|
|
21
|
+
render: () => (
|
|
22
|
+
<span className="flex items-center gap-2">
|
|
23
|
+
<UnreadDot />
|
|
24
|
+
<UrgentMark />
|
|
25
|
+
</span>
|
|
26
|
+
),
|
|
27
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IconAlertSquareRounded } from '@tabler/icons-react'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Urgent and new: a 12px warning mark on its tint, in the unread dot's 24px slot. A row of the navigation that is
|
|
5
|
+
* urgent and unread, and a comment or reply that is urgent and new, draw this one mark.
|
|
6
|
+
*/
|
|
7
|
+
export function UrgentMark() {
|
|
8
|
+
return (
|
|
9
|
+
<div className="flex h-6 w-6 shrink-0 items-center justify-center" data-urgent>
|
|
10
|
+
<div className="flex items-center rounded-full bg-warning-muted p-0.5 signal:shadow-glow-warning">
|
|
11
|
+
<IconAlertSquareRounded size={12} stroke={2.5} className="text-warning-default" />
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
)
|
|
15
|
+
}
|
package/src/commentBoxFrame.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import { Toolbar } from './Toolbar'
|
|
|
8
8
|
import { cn } from './cn'
|
|
9
9
|
import { richTextClassName } from './RichText'
|
|
10
10
|
import { ScrollArea } from './ScrollArea'
|
|
11
|
-
import { WRITING_BOX_CLASSES } from './looks'
|
|
11
|
+
import { BOX_HINT_CLASSES, WRITING_BOX_CLASSES, WRITING_RING_CLASSES } from './looks'
|
|
12
12
|
import { SelectionToolbar, type SelectionToolbarProps } from './SelectionToolbar'
|
|
13
13
|
import { isSuggestionActive } from './suggestionPopup'
|
|
14
14
|
|
|
@@ -102,14 +102,18 @@ export interface BoxFrameProps {
|
|
|
102
102
|
attachments?: ReactNode
|
|
103
103
|
/** The row under it all: the tools and Send, or the keys and Cancel/Save. */
|
|
104
104
|
footer: ReactNode
|
|
105
|
+
/** Signal's focus ring. Off for the edit box, whose edge only darkens on focus, as in Ship. Default on. */
|
|
106
|
+
ring?: boolean
|
|
105
107
|
/** On the box itself. */
|
|
106
108
|
className?: string
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
/** The one frame both boxes draw: the bordered box, its text in a `ScrollArea`, what is attached, the footer. */
|
|
110
|
-
export function BoxFrame({ editor, marked = false, selection, placeholder, empty = false, attachments, footer, className }: BoxFrameProps) {
|
|
112
|
+
export function BoxFrame({ editor, marked = false, selection, placeholder, empty = false, attachments, footer, ring = true, className }: BoxFrameProps) {
|
|
111
113
|
return (
|
|
112
|
-
|
|
114
|
+
// Focused, the edge darkens (the send box in Signal takes the accent and its glow instead). In Leaf, the edge every
|
|
115
|
+
// field takes, in the send box and the edit box alike (Katerina, 31 October); never the accent on Peek's edit box (1 November).
|
|
116
|
+
<div className={cn(WRITING_BOX_CLASSES, ring && WRITING_RING_CLASSES, 'focus-within:border-border-strong leaf:focus-within:border-border-focus transition-colors', className)}>
|
|
113
117
|
<div data-composer-editor data-marked={marked || undefined} className={cn('relative min-h-[20px] transition-all', marked && 'border-l-4 border-border-strong pl-2')}>
|
|
114
118
|
<ScrollArea className={COMPOSE_SCROLL_CLASSES.area} viewportClassName={COMPOSE_SCROLL_CLASSES.viewport} contentClassName={COMPOSE_SCROLL_CLASSES.content}>
|
|
115
119
|
<EditorContent editor={editor} />
|
|
@@ -207,7 +211,7 @@ export function SendBox({ editor, onSend, placeholder, tools, attachments, ready
|
|
|
207
211
|
<span />
|
|
208
212
|
)}
|
|
209
213
|
<div className="flex items-center gap-2.5">
|
|
210
|
-
<span className=
|
|
214
|
+
<span className={BOX_HINT_CLASSES}>Enter to send · Shift+Enter new line</span>
|
|
211
215
|
{/* Focus stays in the text: the press sends on its way down. A keyboard press is the click (`detail` 0), so a click never sends twice. */}
|
|
212
216
|
<IconButton
|
|
213
217
|
variant="primary"
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// @estiva-escape(component-has-a-page, component-has-a-story): the conversation stories' shared placeholders (people, reactions, words, a box), not a part; nothing here is exported from the package
|
|
2
|
+
import { useState, type ReactNode } from 'react'
|
|
3
|
+
import type { JSONContent } from '@tiptap/react'
|
|
4
|
+
import { AttachedCard } from './AttachedCard'
|
|
5
|
+
import { AttachmentCard } from './AttachmentCard'
|
|
6
|
+
import { CommentBox, type SendAnswer, type UploadAnswer } from './CommentBox'
|
|
7
|
+
import { InlineChip } from './InlineChip'
|
|
8
|
+
import { Link } from './Link'
|
|
9
|
+
import { ITEM, ready } from './linked.examples'
|
|
10
|
+
import { PartCard } from './PartCard'
|
|
11
|
+
import type { ReactionCount, ReactionRowProps } from './ReactionRow'
|
|
12
|
+
import { RichText } from './RichText'
|
|
13
|
+
|
|
14
|
+
export const OPTIONS = [
|
|
15
|
+
{ emoji: '👍', label: 'Makes sense' },
|
|
16
|
+
{ emoji: '💯', label: 'Agree' },
|
|
17
|
+
{ emoji: '🙏', label: 'Thank you' },
|
|
18
|
+
{ emoji: '🎉', label: 'Celebrate' },
|
|
19
|
+
{ emoji: '👀', label: 'Looking' },
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
export const ME = 'me'
|
|
23
|
+
const NAMES: Record<string, string> = { me: 'You', a: 'Person one', b: 'Person two', c: 'Person three' }
|
|
24
|
+
export const nameOf = (id: string) => NAMES[id] ?? 'Someone'
|
|
25
|
+
|
|
26
|
+
export const ONE = { name: 'Person one' }
|
|
27
|
+
export const TWO = { name: 'Person two' }
|
|
28
|
+
export const THREE = { name: 'Person three' }
|
|
29
|
+
export const YOU = { name: 'You' }
|
|
30
|
+
|
|
31
|
+
export const WORDS = 'A comment says what its author wrote. Its replies sit in the thread under it, and anyone here can react.'
|
|
32
|
+
export const SHORT = 'A reply answers the comment above it.'
|
|
33
|
+
export const LONG =
|
|
34
|
+
'A long comment keeps its whole text. It runs on for several lines so the card can be seen at its full height: the face and the name stay at the top, the words wrap under them, and the strip of actions stays in the top right corner while the card is pointed at. Nothing is cut, and the reactions and the replies row sit under the last line, as they do under a short one.'
|
|
35
|
+
|
|
36
|
+
/** Yours on or off, as the relay would count it. */
|
|
37
|
+
export function toggled(reactions: readonly ReactionCount[], emoji: string): ReactionCount[] {
|
|
38
|
+
const found = reactions.find((r) => r.emoji === emoji)
|
|
39
|
+
if (!found) return [...reactions, { emoji, by: [ME] }]
|
|
40
|
+
return reactions
|
|
41
|
+
.map((r) => (r.emoji !== emoji ? r : { ...r, by: r.by.includes(ME) ? r.by.filter((id) => id !== ME) : [...r.by, ME] }))
|
|
42
|
+
.filter((r) => r.by.length > 0)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const SOME: ReactionCount[] = [
|
|
46
|
+
{ emoji: '👍', by: ['a', 'b'] },
|
|
47
|
+
{ emoji: '🎉', by: [ME] },
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
/** Reactions that answer a press, as an app's would. */
|
|
51
|
+
export function useReactions(start: readonly ReactionCount[] = []): ReactionRowProps {
|
|
52
|
+
const [reactions, setReactions] = useState<readonly ReactionCount[]>(start)
|
|
53
|
+
return { reactions, options: OPTIONS, nameOf, viewer: ME, onToggle: (emoji) => setReactions((now) => toggled(now, emoji)) }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Pictures and files under the words. */
|
|
57
|
+
export function Files() {
|
|
58
|
+
return (
|
|
59
|
+
<>
|
|
60
|
+
<AttachmentCard name="picture-one.png" size={840_000} contentType="image/png" onOpen={() => {}} />
|
|
61
|
+
<AttachmentCard name="summary.pdf" size={2_412_000} href="#file" onDownload={() => {}} />
|
|
62
|
+
</>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Words with a person named in them, and a link. */
|
|
67
|
+
export function Mentions() {
|
|
68
|
+
return (
|
|
69
|
+
<p>
|
|
70
|
+
<InlineChip tone="person">Person two</InlineChip> can you check this against <Link href="#somewhere">the page it came from</Link> before it goes out?
|
|
71
|
+
</p>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Words, and a card its author attached. */
|
|
76
|
+
export function WithCard() {
|
|
77
|
+
return (
|
|
78
|
+
<>
|
|
79
|
+
<p>{SHORT}</p>
|
|
80
|
+
<AttachedCard link={ready(ITEM)} />
|
|
81
|
+
</>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const BLOCKS = [{ type: 'paragraph' as const, inline: [{ text: 'A block quoted from somewhere else, as it reads there now.', marks: [] }] }]
|
|
86
|
+
|
|
87
|
+
/** Words, and a block quoted from something else. */
|
|
88
|
+
export function WithBlock() {
|
|
89
|
+
return (
|
|
90
|
+
<>
|
|
91
|
+
<p>{SHORT}</p>
|
|
92
|
+
<PartCard state="ready" kind="issue" heading="Item one" partKey="ABC-2" href="#part">
|
|
93
|
+
<RichText blocks={BLOCKS} size="small" />
|
|
94
|
+
</PartCard>
|
|
95
|
+
</>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const saved = (): Promise<SendAnswer> => new Promise((resolve) => setTimeout(() => resolve({ accepted: true }), 400))
|
|
100
|
+
const refused = (): Promise<SendAnswer> => new Promise((resolve) => setTimeout(() => resolve({ accepted: false, reason: 'try again in a moment' }), 600))
|
|
101
|
+
const asBody = (text: string): JSONContent => ({ type: 'doc', content: [{ type: 'paragraph', content: [{ type: 'text', text }] }] })
|
|
102
|
+
|
|
103
|
+
/** The box a comment is edited in: the kit's CommentBox, as an app hands it to the card. */
|
|
104
|
+
export function EditBox({ text, done, refuse = false }: { text: string; done: () => void; refuse?: boolean }) {
|
|
105
|
+
return (
|
|
106
|
+
<CommentBox
|
|
107
|
+
people={[]}
|
|
108
|
+
label="Edit"
|
|
109
|
+
placeholder={null}
|
|
110
|
+
send={refuse ? refused : saved}
|
|
111
|
+
edit={{
|
|
112
|
+
body: asBody(text),
|
|
113
|
+
onCancel: done,
|
|
114
|
+
onSave: async () => {
|
|
115
|
+
const answer = await (refuse ? refused() : saved())
|
|
116
|
+
if (answer.accepted) done()
|
|
117
|
+
return answer
|
|
118
|
+
},
|
|
119
|
+
}}
|
|
120
|
+
/>
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** A file taken in a moment later, as an app's upload answers. */
|
|
125
|
+
const uploaded = (file: File): Promise<UploadAnswer> => new Promise((resolve) => setTimeout(() => resolve({ accepted: true, value: file.name }), 900))
|
|
126
|
+
|
|
127
|
+
/** The box a reply or a comment is written in, with its tools as an app gives them: the paperclip. */
|
|
128
|
+
export function WriteBox({ label = 'Reply', closed }: { label?: string; closed?: string }) {
|
|
129
|
+
return <CommentBox people={[]} label={label} placeholder={`${label}…`} send={saved} upload={uploaded} closed={closed ? { reason: closed } : undefined} />
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** A column's width: 384px, every app's right column. */
|
|
133
|
+
export function Column({ children }: { children: ReactNode }) {
|
|
134
|
+
return <div className="flex w-[384px] flex-col gap-2">{children}</div>
|
|
135
|
+
}
|
|
@@ -8,7 +8,7 @@ import { bindingOfTag, partsOfFile, type Node, type Parser, type PartBinding } f
|
|
|
8
8
|
* the browser shows it as its tooltip. `no-native-title.test.ts` holds this
|
|
9
9
|
* list to the catalogue: a part that gains a `title` of its own joins it.
|
|
10
10
|
*/
|
|
11
|
-
export const PARTS_WITH_A_TITLE = ['CollapsibleSection', 'ConfirmDialog', 'ContainerHeader', 'DialogShell', 'ListColumn', 'NavTree', 'NavTreeSection', 'Panel', 'SectionHeader'] as const
|
|
11
|
+
export const PARTS_WITH_A_TITLE = ['CollapsibleSection', 'ConfirmDialog', 'ContainerHeader', 'ConversationLayout', 'DialogShell', 'ListColumn', 'NavTree', 'NavTreeSection', 'PageHeader', 'Panel', 'SectionHeader', 'Thread'] as const
|
|
12
12
|
|
|
13
13
|
const child = (node: Node, key: string) => node[key] as Node | null | undefined
|
|
14
14
|
const nameOf = (node: Node | null | undefined): string | undefined =>
|
|
@@ -148,6 +148,7 @@ export const PART_LOOK_PROPS: Record<string, string[]> = {
|
|
|
148
148
|
Link: ['variant', 'truncate', 'cover'],
|
|
149
149
|
MenuItem: ['size', 'selected', 'destructive'],
|
|
150
150
|
MenuSub: ['selected'],
|
|
151
|
+
MetaText: ['size'],
|
|
151
152
|
NavItem: ['active'],
|
|
152
153
|
Person: ['size'],
|
|
153
154
|
ProgressBar: ['variant'],
|
package/src/index.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* TypeScript that produced it.
|
|
11
11
|
*/
|
|
12
12
|
export { AppProvider, type AppProviderProps } from './AppProvider'
|
|
13
|
-
export { AppShell, type AppShellProps } from './AppShell'
|
|
13
|
+
export { AppShell, useSidebarFold, type AppShellProps, type SidebarFoldOptions } from './AppShell'
|
|
14
14
|
export { AttachmentCard, type AttachmentCardProps, type AttachmentCardState } from './AttachmentCard'
|
|
15
15
|
export { Avatar, hueFor, initialsFor, type AvatarProps } from './Avatar'
|
|
16
16
|
export { AvatarGroup, type AvatarGroupMember, type AvatarGroupProps } from './AvatarGroup'
|
|
@@ -72,7 +72,7 @@ export { EmptyState, type EmptyStateProps } from './EmptyState'
|
|
|
72
72
|
export { EntryShell, type EntryShellProps } from './EntryShell'
|
|
73
73
|
export { ErrorBoundary, type ErrorBoundaryProps } from './ErrorBoundary'
|
|
74
74
|
export { ProgressBar, type ProgressBarProps, type ProgressBarVariant } from './ProgressBar'
|
|
75
|
-
export { SkeletonBar, SkeletonList, SkeletonRow } from './Skeleton'
|
|
75
|
+
export { SkeletonBar, SkeletonConversation, SkeletonList, SkeletonRow } from './Skeleton'
|
|
76
76
|
export { Breadcrumb, type BreadcrumbProps, type Crumb } from './Breadcrumb'
|
|
77
77
|
export { EnterHint, Menu, MenuItem, MenuPanel, MenuRow, MenuSection, MenuSeparator, MenuSub, type MenuItemProps, type MenuPanelProps, type MenuProps, type MenuSubProps } from './Menu'
|
|
78
78
|
export { NavItem, type NavItemProps } from './NavItem'
|
|
@@ -132,11 +132,28 @@ export { TopBar, type TopBarProps } from './TopBar'
|
|
|
132
132
|
export { PersonTrigger, type PersonTriggerProps } from './PersonTrigger'
|
|
133
133
|
export { Property, type PropertyProps } from './Property'
|
|
134
134
|
export { Reaction, type ReactionProps } from './Reaction'
|
|
135
|
+
export { ConversationActions, type ConversationActionsProps } from './ConversationActions'
|
|
136
|
+
export { ConversationCard, ReplyCard, type ConversationCardProps, type ConversationEntryProps, type ConversationPerson, type ReplyCardProps } from './ConversationCard'
|
|
137
|
+
export { ConversationLayout, type ConversationItem, type ConversationLayoutProps } from './ConversationLayout'
|
|
138
|
+
// The box at a thread's foot takes the caret when a ConversationLayout opens it: one context, shared with the editor's CommentBox.
|
|
139
|
+
export { caretOnOpen } from './threadCard'
|
|
140
|
+
export { ConversationMenu, type ConversationMenuProps } from './ConversationMenu'
|
|
141
|
+
export { EditedMarker, type EditedMarkerProps } from './EditedMarker'
|
|
142
|
+
export { MetaText, type MetaTextProps } from './MetaText'
|
|
143
|
+
export { QuotedLine, type QuotedLineProps } from './QuotedLine'
|
|
144
|
+
export { ReactionHorizon, type ReactionHorizonProps } from './ReactionHorizon'
|
|
145
|
+
export { RepliesRow, type RepliesRowProps } from './RepliesRow'
|
|
146
|
+
export { ResolveDialog, type ResolveDialogProps } from './ResolveDialog'
|
|
147
|
+
export { PinnedComment, type PinnedCommentProps } from './PinnedComment'
|
|
148
|
+
export { ArchivedNotice, type ArchivedNoticeProps } from './ArchivedNotice'
|
|
149
|
+
export { Thread, type ThreadProps, type ThreadStart } from './Thread'
|
|
150
|
+
export { UrgentMark } from './UrgentMark'
|
|
135
151
|
export { ReactionRow, AddReactionButton, whoReacted, type ReactionRowProps, type AddReactionButtonProps, type ReactionCount } from './ReactionRow'
|
|
136
152
|
export { SearchInput, type SearchInputProps } from './SearchInput'
|
|
137
153
|
export { SectionHeader, type SectionAction, type SectionHeaderProps } from './SectionHeader'
|
|
138
154
|
export { ContainerHeader, type ContainerHeaderProps } from './ContainerHeader'
|
|
139
155
|
export { Panel, type PanelProps } from './Panel'
|
|
156
|
+
export { PageHeader, type PageHeaderMeta, type PageHeaderProps } from './PageHeader'
|
|
140
157
|
export { ListColumn, type ListColumnProps } from './ListColumn'
|
|
141
158
|
export { CollapsibleSection, type CollapsibleSectionProps } from './CollapsibleSection'
|
|
142
159
|
export { SectionLabel } from './SectionLabel'
|
package/src/linked.ts
CHANGED
|
@@ -34,6 +34,8 @@ export interface LinkedStatus {
|
|
|
34
34
|
export interface LinkedPerson {
|
|
35
35
|
name: string
|
|
36
36
|
picture?: string
|
|
37
|
+
/** An agent: its face is a robot, as Avatar's `bot`. */
|
|
38
|
+
bot?: boolean
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
/** One choice a picker offers. */
|
|
@@ -44,6 +46,8 @@ export interface PickerOption {
|
|
|
44
46
|
colour?: StatusColour
|
|
45
47
|
/** A person's picture: the option draws their face. */
|
|
46
48
|
picture?: string
|
|
49
|
+
/** An agent: its face is a robot, as Avatar's `bot`. */
|
|
50
|
+
bot?: boolean
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
/**
|
package/src/linkedFrom.ts
CHANGED
|
@@ -16,6 +16,8 @@ import type { LinkState, Linked, LinkedChild, LinkedConversation, LinkedKind, Li
|
|
|
16
16
|
export interface LinkedProfile {
|
|
17
17
|
displayName?: string
|
|
18
18
|
picture?: string
|
|
19
|
+
/** NIP-24's `bot`: the profile is an agent's. */
|
|
20
|
+
bot?: boolean
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
/** One of interop's resolved slots. */
|
|
@@ -178,7 +180,7 @@ function childrenOf<T extends LinkedSource>(object: T, options: LinkedFromOption
|
|
|
178
180
|
href: options.hrefOf(child, false),
|
|
179
181
|
...(key ? { key } : {}),
|
|
180
182
|
status: { label: status?.value ?? nounOf(child) ?? 'File', colour: colourOf(status?.colour) ?? 'muted' },
|
|
181
|
-
...(person?.displayName ? { owner: { name: person.displayName, ...(person.picture ? { picture: person.picture } : {}) } } : {}),
|
|
183
|
+
...(person?.displayName ? { owner: { name: person.displayName, ...(person.picture ? { picture: person.picture } : {}), ...(person.bot ? { bot: true } : {}) } } : {}),
|
|
182
184
|
}
|
|
183
185
|
})
|
|
184
186
|
}
|
|
@@ -238,7 +240,7 @@ function ownerOf(object: LinkedSource, options: Pick<LinkedFromOptions, 'directo
|
|
|
238
240
|
if (!slot) return undefined
|
|
239
241
|
const person = people?.[slot.value]
|
|
240
242
|
return {
|
|
241
|
-
owner: { value: slot.value, options: [{ value: slot.value, label: person?.displayName ?? '—', ...(person?.picture ? { picture: person.picture } : {}) }] },
|
|
243
|
+
owner: { value: slot.value, options: [{ value: slot.value, label: person?.displayName ?? '—', ...(person?.picture ? { picture: person.picture } : {}), ...(person?.bot ? { bot: true } : {}) }] },
|
|
242
244
|
...(slot.label ? { ownerLabel: slot.label } : {}),
|
|
243
245
|
}
|
|
244
246
|
}
|
|
@@ -273,7 +275,7 @@ export function linkedFrom<T extends LinkedSource>(object: T, options: LinkedFro
|
|
|
273
275
|
kind: 'message',
|
|
274
276
|
title: name,
|
|
275
277
|
href,
|
|
276
|
-
author: { name, ...(person?.picture ? { picture: person.picture } : {}) },
|
|
278
|
+
author: { name, ...(person?.picture ? { picture: person.picture } : {}), ...(person?.bot ? { bot: true } : {}) },
|
|
277
279
|
...(body ? { body } : {}),
|
|
278
280
|
...(updated ? { updated } : {}),
|
|
279
281
|
}
|
package/src/looks.ts
CHANGED
|
@@ -67,6 +67,15 @@ export const MUTED_CONTROL_CLASSES = 'text-text-secondary hover:bg-bg-hover hove
|
|
|
67
67
|
/** A control that opens a menu: a hover fill, held while its menu is up — PersonTrigger's row, and a ContainerHeader title with a menu. */
|
|
68
68
|
export const MENU_TRIGGER_CLASSES = 'cursor-pointer rounded-md transition-colors hover:bg-bg-hover data-[popup-open]:bg-bg-hover'
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* A column that folds sideways, as Peek's rail did (Katerina, 31 October: one fold in every app): 300ms, none under
|
|
72
|
+
* prefers-reduced-motion. Folded, it fades and is then hidden, so nothing in it can be seen once it has gone; with
|
|
73
|
+
* the `transition-[…]` naming `opacity` and `visibility`. AppShell's navigation, and ListColumn closing with it.
|
|
74
|
+
*/
|
|
75
|
+
export const FOLD_MOTION_CLASSES = 'duration-300 ease-in-out motion-reduce:transition-none'
|
|
76
|
+
export const FOLDED_CLASSES = 'invisible opacity-0'
|
|
77
|
+
export const UNFOLDED_CLASSES = 'visible opacity-100'
|
|
78
|
+
|
|
70
79
|
/**
|
|
71
80
|
* A panel that slides open and shut on Base UI's Collapsible: Base UI measures
|
|
72
81
|
* it and writes its height to a variable, `auto` again once the slide ends, and
|
|
@@ -80,12 +89,19 @@ export const COLLAPSIBLE_PANEL_CLASSES = 'h-[var(--collapsible-panel-height)] ov
|
|
|
80
89
|
* `looks.ts`, Katerina 24 September), moved with the comment box. Inset, a hairline,
|
|
81
90
|
* 12px in, 16px between the text and the row under it; the focus ring in Signal.
|
|
82
91
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
92
|
+
// A field's fill and edge, as every field has (Katerina, 31 October: the comment box is a field, and every field has its fill).
|
|
93
|
+
export const WRITING_BOX_CLASSES = 'relative bg-bg-field border border-border-field rounded-lg p-3 flex flex-col gap-4'
|
|
94
|
+
|
|
95
|
+
/** The keys under the send box, in words: "Enter to send · Shift+Enter new line". One line, cut when the room runs out; no key caps. The edit box writes none (Katerina, 1 November). */
|
|
96
|
+
export const BOX_HINT_CLASSES = 'min-w-0 truncate select-none text-caption text-text-muted signal:font-mono signal:text-menu signal:font-normal signal:tracking-wider'
|
|
97
|
+
|
|
98
|
+
/** Signal's focus ring (the glow) on the send box, as on every field. The edit box has no glow and no accent edge (Katerina, 31 October, 1 November). */
|
|
99
|
+
export const WRITING_RING_CLASSES = 'signal:transition-shadow signal:focus-within:border-border-focus signal:focus-within:shadow-focus-ring'
|
|
85
100
|
|
|
86
101
|
/** The 36px tile a file's type sits in: AttachmentCard's, and a link's kind in LinkRow, LinkCard and PartCard (Katerina, 29 Oct). */
|
|
87
102
|
export const TYPE_TILE_CLASSES = 'size-9 rounded-md bg-bg-active flex items-center justify-center shrink-0 text-text-secondary'
|
|
88
103
|
|
|
104
|
+
|
|
89
105
|
/** The bar down a quoted part's left edge: PartCard's blocks, and (proposal) a card's latest conversation. */
|
|
90
106
|
export const QUOTE_BAR_CLASSES = 'border-l-2 border-border-default pl-3'
|
|
91
107
|
|
|
@@ -48,20 +48,20 @@ describe('the registry builds', () => {
|
|
|
48
48
|
expect(registry.entries.map((one) => one.name).sort()).toEqual(values.map((one) => one.name).sort())
|
|
49
49
|
})
|
|
50
50
|
|
|
51
|
-
it('counts
|
|
51
|
+
it('counts 229 names over 114 files: 155 components, 71 helpers and 3 hooks (ArchivedNotice, the card on an archived file, from Peek, Ship and Leaf, on 31 October; caretOnOpen, the box at a thread’s foot taking the caret when a ConversationLayout opens it, without scrolling, on 31 October; the conversation from Peek for every app, with PageHeader and PinnedComment, on 31 October, and ResolutionNote and ResolutionHistory gone with the resolved looks not picked, on 1 November; useSidebarFold, a folded sidebar kept folded in every app, on 31 October; cardShapeMemory, a card’s last shape on this device, lifted from Peek and Ship for Leaf, and ReferenceCards and useReferenceCards gone with their deprecated page, in the widget review, on 30 October; inTheBox, a card or part in a box being written in, on the files’ fill and in words, on 29 October; archivedLine, the line on an archived file in every app (PEEKM-2), on 23 October; keepCommentBoxWarm, a box built ahead, exported as 0.84.0 promised (PEEKM-1), on 21 October;linkedFrom and linkStateFrom, one card for a file in every app (5ebf2756), on 21 October; ComposeBox, ComposeKeys and COMPOSE_EDITOR_CLASSES gone into CommentBox’s own frame (one box), on 21 October; LinkPlaces with linkPlaceAt and staysChip, a link in a document drawn where it sits (WBD-4), on 20 October; DocumentEditor, one document editor for every app, and PersonReference, `@` in a document (WBD-3), on 20 October; toggleTableHeaderRow, a table’s header row on and off (LEAF-12), on 19 October;EntryShell, the screen while nobody is signed in, moved from Peek (AUT-3), on 17 October; CommentBox with commentBoxRows, and ReactionRow with AddReactionButton and whoReacted, the shared comment box and reaction row (COMM-2), on 17 October; the link widgets — LinkChip, LinkRow, LinkCard, CardUnder, PartCard, LinkPreview and their parts, with useCanHover, chosenOf, loadingShapeOf and unavailableMemory — from the Widgets 2 prototype, on 16 October; InlineText, a title or the line under it edited where it stands (SUM-4), on 16 October; ComposeBox with ComposeKeys and its classes, CommentHighlights with its five helpers, and keepSelection and releaseSelection, from the Leaf prototype (LEAF-4), on 16 October;NavTree, NavTreeSection, the composer triggers and UnreadDot joined on 2 October; BlockHandle and EditorBlockHandle (RIC-18) on 2 October, moveBlock and blockDropCursor, the drop in the gutter, on 5 October, MembersPill and MembersDialog, moved from Peek (SHI-31), on 6 October, ShowMore on 7 October, AppProvider on 8 October, and KindIcon, thingKindOf and PastedImages with its two helpers, moved from Peek, on 8 October; CodeBlockColours, the coloured code block of the editor, on 9 October; Checklist, Callout, isChecklistTick and calloutLook (RIC-19) on 13 October; EditorTableControls and its four actions (RIC-21) on 13 October; ReferenceCards, useReferenceCards and its three helpers, the card a chip in a document asks for, on 14 October; LinkChips and its two helpers, a URL in a document read as its chip, on 14 October; ReferenceMenu, ReferenceMenuView and three helpers, the menu of a chip while writing, on 14 October; PastedMarkdown, markdown pasted as the blocks it spells (LEAF-10), on 15 October; turnIntoRows, turnListInto and turnQuoteInto, the block menu’s Turn into for a list and a quote (LEAF-11), on 15 October)', () => {
|
|
52
52
|
// The reconciliation GATES.md §24 explains. If this changes, that changes.
|
|
53
53
|
// The `EDITOR_EXTENSIONS` count as components by their names; they are
|
|
54
54
|
// editor extensions, documented on SelectionToolbar's, BlockNodes' and
|
|
55
55
|
// ComposerTriggers' pages.
|
|
56
56
|
const kinds = registry.entries.reduce<Record<string, number>>((all, one) => ({ ...all, [one.kind]: (all[one.kind] ?? 0) + 1 }), {})
|
|
57
|
-
expect(kinds).toEqual({ component:
|
|
58
|
-
expect(new Set(registry.entries.map((one) => one.sourceFile)).size).toBe(
|
|
57
|
+
expect(kinds).toEqual({ component: 155, helper: 71, hook: 3 })
|
|
58
|
+
expect(new Set(registry.entries.map((one) => one.sourceFile)).size).toBe(114)
|
|
59
59
|
})
|
|
60
60
|
|
|
61
61
|
it('gives every entry a purpose, from its own page or from the comment above it', () => {
|
|
62
62
|
expect(registry.entries.filter((one) => one.purpose.trim() === '')).toEqual([])
|
|
63
|
-
expect(registry.entries.filter((one) => one.purposeFrom === 'page').length).toBe(
|
|
64
|
-
expect(registry.entries.filter((one) => one.purposeFrom === 'comment').length).toBe(
|
|
63
|
+
expect(registry.entries.filter((one) => one.purposeFrom === 'page').length).toBe(105)
|
|
64
|
+
expect(registry.entries.filter((one) => one.purposeFrom === 'comment').length).toBe(124)
|
|
65
65
|
})
|
|
66
66
|
|
|
67
67
|
it('takes a name with a page of its own from the page, and a name without one from the code', () => {
|
|
@@ -262,10 +262,11 @@ describe('the ids point at something', () => {
|
|
|
262
262
|
|
|
263
263
|
it('gives every component a page and a story, and only a helper none', () => {
|
|
264
264
|
const without = registry.entries.filter((one) => one.docsId === null || one.storyId === null)
|
|
265
|
-
// The helpers in a file with no page: cn, the shortcut names, the editor's suggestion wiring (documented on SuggestionMenu's page), the link widgets' data helpers (documented on LinkCard's and LinkChip's pages; linkedFrom's and cardShapeMemory's on LinkCard's),
|
|
265
|
+
// The helpers in a file with no page: cn, the shortcut names, the editor's suggestion wiring (documented on SuggestionMenu's page), the link widgets' data helpers (documented on LinkCard's and LinkChip's pages; linkedFrom's and cardShapeMemory's on LinkCard's), a chip's card choice (ReferenceMenu writes it), and the caret a ConversationLayout gives a thread's box (documented on ConversationLayout's page).
|
|
266
266
|
expect(without.map((one) => one.name).sort()).toEqual([
|
|
267
267
|
'archivedLine',
|
|
268
268
|
'cardShapeMemory',
|
|
269
|
+
'caretOnOpen',
|
|
269
270
|
'chosenOf',
|
|
270
271
|
'cn',
|
|
271
272
|
'inTheBox',
|
|
@@ -362,7 +363,7 @@ describe('a second parser agrees', async () => {
|
|
|
362
363
|
const INHERITED_WITH_A_DEFAULT = new Set(['Button.type', 'IconButton.type', 'TextInput.type', 'SearchInput.placeholder'])
|
|
363
364
|
|
|
364
365
|
/**
|
|
365
|
-
* The
|
|
366
|
+
* The nineteen where **this registry is right and `react-docgen` is not**.
|
|
366
367
|
*
|
|
367
368
|
* `IdentityPanelProps extends Omit<IdentityMenuProps, 'compact'>` and
|
|
368
369
|
* `PersonTriggerProps extends Omit<PersonProps, 'className'>`: docgen does not
|
|
@@ -387,6 +388,7 @@ const DOCGEN_STOPS_AT_OMIT = new Set([
|
|
|
387
388
|
'IdentityPanel.children',
|
|
388
389
|
'PersonTrigger.name',
|
|
389
390
|
'PersonTrigger.picture',
|
|
391
|
+
'PersonTrigger.bot',
|
|
390
392
|
'PersonTrigger.fallback',
|
|
391
393
|
'PersonTrigger.size',
|
|
392
394
|
'ToolbarLink.variant',
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { createContext, useLayoutEffect, useState, type RefObject } from 'react'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Inside a thread drawn as one card (a comment open in one column, its replies under it): its cards draw no new edge
|
|
5
|
+
* of their own, the one card is their edge. Set by ConversationLayout and Thread; read by ConversationCard and ReplyCard.
|
|
6
|
+
*/
|
|
7
|
+
export const InThreadCard = createContext(false)
|
|
8
|
+
|
|
9
|
+
/** A comment's place in a `ConversationLayout`: whether its thread is open, and how a press opens or closes it. */
|
|
10
|
+
export interface ConversationItemState {
|
|
11
|
+
/** One column: its thread opens under it. Otherwise two columns, beside. */
|
|
12
|
+
under: boolean
|
|
13
|
+
/** Its thread is the open one. */
|
|
14
|
+
open: boolean
|
|
15
|
+
/** A press on the card or its replies row: opens its thread; in one column, a second press closes it. */
|
|
16
|
+
toggle: () => void
|
|
17
|
+
/** Reply: opens its thread, never closes it. */
|
|
18
|
+
show: () => void
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Set by ConversationLayout round each comment, read by ConversationCard: so a card opens and closes its thread, says
|
|
23
|
+
* so on its replies row, and is marked while open beside, the same in every app with no wiring of its own.
|
|
24
|
+
*/
|
|
25
|
+
export const InConversationItem = createContext<ConversationItemState | null>(null)
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Counts the times a thread has opened in a ConversationLayout. The box at the thread's foot takes the caret each time
|
|
29
|
+
* it changes, at the box's end, without scrolling: the comment that was pressed stays where it is (Katerina, 31
|
|
30
|
+
* October). 0, as outside a layout or for the thread open when the page is drawn: the box waits to be pressed.
|
|
31
|
+
*/
|
|
32
|
+
export const caretOnOpen = createContext(0)
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Set by ConversationLayout round each comment in one column: it draws an open comment's line itself, one bar from the
|
|
36
|
+
* comment's face to its thread's last reply. The card and the thread then draw no pieces of it.
|
|
37
|
+
*/
|
|
38
|
+
export const LineByLayout = createContext(false)
|
|
39
|
+
|
|
40
|
+
/** The room between a face and the line under it. */
|
|
41
|
+
const FACE_GAP = 4
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The line from a face down, as ONE bar measured in `root`: from 4px under the comment's face (`[data-face]` in
|
|
45
|
+
* `[data-comment-body]`: never a reply's, when the comment is deleted or being edited and shows none) — it never touches the
|
|
46
|
+
* face; Katerina, 1 November — to the end. It ends at the thread's replies (`[data-thread-replies]`), or, with none yet, at
|
|
47
|
+
* the comment's own foot (`[data-comment-body]`); with `toDot`, at the centre of the resolved line's dot (`[data-dot]`). Pieces drawn in separate
|
|
48
|
+
* boxes met a pixel apart at some zooms, a step where the thread began (Katerina, 1 November: "the line breaks in the
|
|
49
|
+
* middle"); one bar cannot. Measured again whenever `root` changes size. `null` until measured, or when `active` is false.
|
|
50
|
+
*/
|
|
51
|
+
export function useFaceLine(root: RefObject<HTMLElement | null>, active: boolean, toDot = false) {
|
|
52
|
+
const [line, setLine] = useState<{ top: number; height: number } | null>(null)
|
|
53
|
+
useLayoutEffect(() => {
|
|
54
|
+
const el = root.current
|
|
55
|
+
if (!active || !el) {
|
|
56
|
+
setLine(null)
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
const measure = () => {
|
|
60
|
+
const face = el.querySelector('[data-comment-body] [data-face]')
|
|
61
|
+
const target =
|
|
62
|
+
toDot
|
|
63
|
+
? el.querySelector('[data-dot]')
|
|
64
|
+
: (el.querySelector('[data-thread-replies]') ?? el.querySelector('[data-comment-body]'))
|
|
65
|
+
if (!face || !target) {
|
|
66
|
+
setLine(null)
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
const box = el.getBoundingClientRect()
|
|
70
|
+
const origin = box.top + el.clientTop
|
|
71
|
+
const to = target.getBoundingClientRect()
|
|
72
|
+
const top = face.getBoundingClientRect().bottom - origin + FACE_GAP
|
|
73
|
+
const bottom = (toDot ? to.top + to.height / 2 : to.bottom) - origin
|
|
74
|
+
const next = { top, height: Math.max(0, bottom - top) }
|
|
75
|
+
setLine((was) => (was && Math.abs(was.top - next.top) < 0.01 && Math.abs(was.height - next.height) < 0.01 ? was : next))
|
|
76
|
+
}
|
|
77
|
+
measure()
|
|
78
|
+
if (typeof ResizeObserver === 'undefined') return
|
|
79
|
+
const watch = new ResizeObserver(measure)
|
|
80
|
+
watch.observe(el)
|
|
81
|
+
return () => watch.disconnect()
|
|
82
|
+
}, [root, active, toDot])
|
|
83
|
+
return line
|
|
84
|
+
}
|
package/stories/Choosing.mdx
CHANGED
|
@@ -84,12 +84,31 @@ fork freely, owe nothing back, mention it on the package's ticket.
|
|
|
84
84
|
| "Are you sure?" | **ConfirmDialog** |
|
|
85
85
|
| A picture full screen, from a thumbnail | **Lightbox** — an **AttachmentCard** opens one by itself |
|
|
86
86
|
|
|
87
|
+
## A conversation
|
|
88
|
+
|
|
89
|
+
The same conversation in every app; only its colours are each app's.
|
|
90
|
+
|
|
91
|
+
| You need | Reach for |
|
|
92
|
+
|---|---|
|
|
93
|
+
| Where the comments sit, and where a thread opens | **ConversationLayout** — two columns, the thread beside them; or one 384px column, the thread under its comment |
|
|
94
|
+
| One comment | **ConversationCard** — the words, files, cards, reactions, replies row, the actions on hover and the ⋯ menu |
|
|
95
|
+
| One reply in a thread | **ReplyCard** — a comment's pieces, without replies of its own or Resolve |
|
|
96
|
+
| A comment's replies and the box to write one | **Thread** — in the right column under its header, or under its comment |
|
|
97
|
+
| The way into a thread | **RepliesRow** — faces, "2 replies", the last time and "1 new" |
|
|
98
|
+
| Resolving, with a note | **ResolveDialog**; the comment then says who resolved it and the note, and folds: **ConversationCard** `resolved` |
|
|
99
|
+
| The words a comment on a part is about | **QuotedLine** — above its name, and what changed since |
|
|
100
|
+
| The comment a thread answers, at the top of its replies column | **PinnedComment** — Thread draws it from its `start` |
|
|
101
|
+
| The strip on a pointed-at comment, and its ⋯ menu | **ConversationActions** and **ConversationMenu** — the cards draw both |
|
|
102
|
+
| A time beside a name, "(edited)", urgent and new | **MetaText**, **EditedMarker**, **UrgentMark** |
|
|
103
|
+
| How far back reactions were read | **ReactionHorizon** — draws nothing when every one was |
|
|
104
|
+
|
|
87
105
|
## Structure and wayfinding
|
|
88
106
|
|
|
89
107
|
| You need | Reach for |
|
|
90
108
|
|---|---|
|
|
91
109
|
| Label–value rows (a details rail) | **Property** — `row` and `stacked` |
|
|
92
110
|
| The bar across the top of a column: its title, and the buttons that act on the whole column | **ContainerHeader** — inside the package's columns; in an app, the header comes with **Panel** or **ListColumn** |
|
|
111
|
+
| The bar at the top of a page: its name with an icon, a face or a lock, quiet counts, when it last changed, the members and the page's buttons | **PageHeader** — ContainerHeader's 48px bar with a place for each; a **Breadcrumb** in the title's place for a trail |
|
|
93
112
|
| A box that can hold more than fits — a list that grows with its data counts, even when today's data fits | **ScrollArea** — its bar is drawn over the content and takes no width |
|
|
94
113
|
| Text that can run long above things the reader needs, cut behind a fade | **ShowMore** — measures; what fits has no button |
|
|
95
114
|
| A status, a count or a category, in a small pill | **Chip** — six colour types; the colour is the message, the label makes it legible |
|
|
@@ -98,7 +117,7 @@ fork freely, owe nothing back, mention it on the package's ticket.
|
|
|
98
117
|
| A section heading, chevron, hover actions, a count beside the title | **SectionHeader** |
|
|
99
118
|
| A group of rows that opens and closes, and stays how you left it | **CollapsibleSection** — `storageKey` remembers |
|
|
100
119
|
| The uppercase micro-label | **SectionLabel** |
|
|
101
|
-
| A hairline | **Divider** |
|
|
120
|
+
| A hairline, or a line with words in the middle | **Divider** — `label`; `look="section"` between stretches of a list, `sticky` while it scrolls |
|
|
102
121
|
| Where am I, and the way back up | **Breadcrumb** |
|
|
103
122
|
| A link — in text, on a title, beside a note, or a whole box | **Link** — `text`, `quiet`, `underlined`, `plain`; `external` for a new tab |
|
|
104
123
|
| A document or an image attached to something, posted or waiting to be sent | **AttachmentCard** — the file decides the shape; `pending` in a composer |
|
|
@@ -131,6 +150,7 @@ fork freely, owe nothing back, mention it on the package's ticket.
|
|
|
131
150
|
| It happened, briefly | **Toast**, via `useToast` inside a `ToastProvider` |
|
|
132
151
|
| It happened, and must not be missed | **Toast** with `durationMs: 0` and an action — it floats and stays until dismissed (D21) |
|
|
133
152
|
| The whole surface has something to say | **Banner** — the strip under the top bar, full width; `onDismiss` if the reader closes it rather than the app |
|
|
153
|
+
| The file is archived | **ArchivedNotice** — the grey card at the top of its page and in the comment box's place: who, when, the resolution, and Unarchive |
|
|
134
154
|
| A part that breaks without taking the page with it | **ErrorBoundary** — around each column, panel or conversation, and once around the app; `label` says what it holds |
|
|
135
155
|
|
|
136
156
|
## The frame
|