@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.
Files changed (173) hide show
  1. package/dist/AppShell.d.ts +25 -7
  2. package/dist/AppShell.d.ts.map +1 -1
  3. package/dist/ArchivedNotice.d.ts +28 -0
  4. package/dist/ArchivedNotice.d.ts.map +1 -0
  5. package/dist/Button.d.ts +4 -3
  6. package/dist/Button.d.ts.map +1 -1
  7. package/dist/Card.d.ts.map +1 -1
  8. package/dist/CommentBox.d.ts.map +1 -1
  9. package/dist/ConversationActions.d.ts +24 -0
  10. package/dist/ConversationActions.d.ts.map +1 -0
  11. package/dist/ConversationCard.d.ts +88 -0
  12. package/dist/ConversationCard.d.ts.map +1 -0
  13. package/dist/ConversationLayout.d.ts +50 -0
  14. package/dist/ConversationLayout.d.ts.map +1 -0
  15. package/dist/ConversationMenu.d.ts +24 -0
  16. package/dist/ConversationMenu.d.ts.map +1 -0
  17. package/dist/Divider.d.ts +23 -4
  18. package/dist/Divider.d.ts.map +1 -1
  19. package/dist/EditedMarker.d.ts +11 -0
  20. package/dist/EditedMarker.d.ts.map +1 -0
  21. package/dist/IconButton.d.ts +3 -3
  22. package/dist/IconButton.d.ts.map +1 -1
  23. package/dist/LinkParts.d.ts +3 -1
  24. package/dist/LinkParts.d.ts.map +1 -1
  25. package/dist/ListColumn.d.ts +3 -1
  26. package/dist/ListColumn.d.ts.map +1 -1
  27. package/dist/MetaText.d.ts +22 -0
  28. package/dist/MetaText.d.ts.map +1 -0
  29. package/dist/NavItem.d.ts.map +1 -1
  30. package/dist/PageHeader.d.ts +50 -0
  31. package/dist/PageHeader.d.ts.map +1 -0
  32. package/dist/Panel.d.ts +6 -0
  33. package/dist/Panel.d.ts.map +1 -1
  34. package/dist/PinnedComment.d.ts +17 -0
  35. package/dist/PinnedComment.d.ts.map +1 -0
  36. package/dist/QuotedLine.d.ts +16 -0
  37. package/dist/QuotedLine.d.ts.map +1 -0
  38. package/dist/ReactionHorizon.d.ts +14 -0
  39. package/dist/ReactionHorizon.d.ts.map +1 -0
  40. package/dist/RepliesRow.d.ts +26 -0
  41. package/dist/RepliesRow.d.ts.map +1 -0
  42. package/dist/ResolveDialog.d.ts +13 -0
  43. package/dist/ResolveDialog.d.ts.map +1 -0
  44. package/dist/Select.d.ts +1 -1
  45. package/dist/Select.d.ts.map +1 -1
  46. package/dist/Skeleton.d.ts +8 -4
  47. package/dist/Skeleton.d.ts.map +1 -1
  48. package/dist/Thread.d.ts +38 -0
  49. package/dist/Thread.d.ts.map +1 -0
  50. package/dist/TopBar.d.ts +3 -2
  51. package/dist/TopBar.d.ts.map +1 -1
  52. package/dist/UrgentMark.d.ts +6 -0
  53. package/dist/UrgentMark.d.ts.map +1 -0
  54. package/dist/commentBoxFrame.d.ts +3 -1
  55. package/dist/commentBoxFrame.d.ts.map +1 -1
  56. package/dist/conversation.examples.d.ts +52 -0
  57. package/dist/conversation.examples.d.ts.map +1 -0
  58. package/dist/editor.js +32 -24
  59. package/dist/editor.js.map +2 -2
  60. package/dist/eslint/index.js +2 -1
  61. package/dist/eslint/index.js.map +2 -2
  62. package/dist/eslint/no-native-title.d.ts +1 -1
  63. package/dist/eslint/no-native-title.d.ts.map +1 -1
  64. package/dist/eslint/no-restyled-part.d.ts.map +1 -1
  65. package/dist/index.d.ts +18 -2
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +1376 -433
  68. package/dist/index.js.map +4 -4
  69. package/dist/looks.d.ts +13 -1
  70. package/dist/looks.d.ts.map +1 -1
  71. package/dist/threadCard.d.ts +46 -0
  72. package/dist/threadCard.d.ts.map +1 -0
  73. package/package.json +1 -1
  74. package/registry.json +1873 -546
  75. package/src/AppShell.mdx +24 -10
  76. package/src/AppShell.stories.tsx +65 -31
  77. package/src/AppShell.test.tsx +92 -10
  78. package/src/AppShell.tsx +108 -18
  79. package/src/ArchivedNotice.mdx +46 -0
  80. package/src/ArchivedNotice.stories.tsx +52 -0
  81. package/src/ArchivedNotice.test.tsx +42 -0
  82. package/src/ArchivedNotice.tsx +71 -0
  83. package/src/Button.mdx +2 -2
  84. package/src/Button.tsx +8 -6
  85. package/src/Card.test.tsx +4 -4
  86. package/src/Card.tsx +6 -2
  87. package/src/CommentBox.test.tsx +2 -1
  88. package/src/CommentBox.tsx +14 -7
  89. package/src/ConfirmDialog.stories.tsx +12 -0
  90. package/src/ConversationActions.mdx +47 -0
  91. package/src/ConversationActions.stories.tsx +39 -0
  92. package/src/ConversationActions.tsx +96 -0
  93. package/src/ConversationCard.mdx +72 -0
  94. package/src/ConversationCard.states.test.tsx +330 -0
  95. package/src/ConversationCard.stories.tsx +135 -0
  96. package/src/ConversationCard.test.tsx +159 -0
  97. package/src/ConversationCard.tsx +522 -0
  98. package/src/ConversationLayout.mdx +61 -0
  99. package/src/ConversationLayout.stories.tsx +161 -0
  100. package/src/ConversationLayout.test.tsx +240 -0
  101. package/src/ConversationLayout.tsx +233 -0
  102. package/src/ConversationMenu.mdx +47 -0
  103. package/src/ConversationMenu.stories.tsx +42 -0
  104. package/src/ConversationMenu.test.tsx +47 -0
  105. package/src/ConversationMenu.tsx +57 -0
  106. package/src/Divider.mdx +36 -1
  107. package/src/Divider.stories.tsx +57 -0
  108. package/src/Divider.test.tsx +24 -1
  109. package/src/Divider.tsx +49 -9
  110. package/src/EditedMarker.mdx +36 -0
  111. package/src/EditedMarker.stories.tsx +24 -0
  112. package/src/EditedMarker.tsx +20 -0
  113. package/src/IconButton.mdx +2 -1
  114. package/src/IconButton.tsx +8 -5
  115. package/src/LinkParts.mdx +4 -0
  116. package/src/LinkParts.stories.tsx +10 -0
  117. package/src/LinkParts.tsx +5 -1
  118. package/src/ListColumn.tsx +9 -3
  119. package/src/MetaText.mdx +41 -0
  120. package/src/MetaText.stories.tsx +29 -0
  121. package/src/MetaText.tsx +38 -0
  122. package/src/NavItem.tsx +2 -11
  123. package/src/PageHeader.mdx +123 -0
  124. package/src/PageHeader.stories.tsx +174 -0
  125. package/src/PageHeader.test.tsx +99 -0
  126. package/src/PageHeader.tsx +105 -0
  127. package/src/Panel.mdx +12 -0
  128. package/src/Panel.stories.tsx +47 -5
  129. package/src/Panel.test.tsx +40 -0
  130. package/src/Panel.tsx +8 -2
  131. package/src/PinnedComment.mdx +40 -0
  132. package/src/PinnedComment.stories.tsx +21 -0
  133. package/src/PinnedComment.tsx +40 -0
  134. package/src/QuotedLine.mdx +44 -0
  135. package/src/QuotedLine.stories.tsx +30 -0
  136. package/src/QuotedLine.test.tsx +34 -0
  137. package/src/QuotedLine.tsx +33 -0
  138. package/src/ReactionHorizon.mdx +36 -0
  139. package/src/ReactionHorizon.stories.tsx +27 -0
  140. package/src/ReactionHorizon.tsx +27 -0
  141. package/src/RepliesRow.mdx +45 -0
  142. package/src/RepliesRow.stories.tsx +33 -0
  143. package/src/RepliesRow.test.tsx +47 -0
  144. package/src/RepliesRow.tsx +86 -0
  145. package/src/ReplyCard.mdx +50 -0
  146. package/src/ReplyCard.stories.tsx +68 -0
  147. package/src/ResolveDialog.mdx +44 -0
  148. package/src/ResolveDialog.stories.tsx +23 -0
  149. package/src/ResolveDialog.test.tsx +53 -0
  150. package/src/ResolveDialog.tsx +58 -0
  151. package/src/Select.tsx +12 -2
  152. package/src/Skeleton.stories.tsx +4 -1
  153. package/src/Skeleton.tsx +33 -4
  154. package/src/Thread.mdx +53 -0
  155. package/src/Thread.stories.tsx +167 -0
  156. package/src/Thread.test.tsx +83 -0
  157. package/src/Thread.tsx +113 -0
  158. package/src/TopBar.mdx +8 -6
  159. package/src/TopBar.stories.tsx +4 -3
  160. package/src/TopBar.tsx +8 -3
  161. package/src/UrgentMark.mdx +37 -0
  162. package/src/UrgentMark.stories.tsx +27 -0
  163. package/src/UrgentMark.tsx +15 -0
  164. package/src/commentBoxFrame.tsx +8 -4
  165. package/src/conversation.examples.tsx +135 -0
  166. package/src/eslint/no-native-title.ts +1 -1
  167. package/src/eslint/no-restyled-part.ts +1 -0
  168. package/src/index.ts +19 -2
  169. package/src/looks.ts +18 -2
  170. package/src/registry/registry.test.ts +7 -6
  171. package/src/threadCard.ts +84 -0
  172. package/stories/Choosing.mdx +21 -1
  173. package/tokens.css +14 -10
@@ -1,6 +1,8 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite'
2
- import { IconDotsVertical } from '@tabler/icons-react'
2
+ import { IconDotsVertical, IconX } from '@tabler/icons-react'
3
+ import { Chip } from './Chip'
3
4
  import { IconButton } from './IconButton'
5
+ import { PageHeader } from './PageHeader'
4
6
  import { Panel } from './Panel'
5
7
 
6
8
  /**
@@ -13,11 +15,12 @@ const meta = {
13
15
  component: Panel,
14
16
  parameters: { layout: 'fullscreen' },
15
17
  args: { title: 'Details', children: null, bodyClassName: 'flex flex-col gap-3 px-4 pt-3 pb-4' },
16
- argTypes: { children: { control: false }, actions: { control: false }, footer: { control: false } },
17
- // A side column of the frame: 380px wide and a fixed height, where a panel sits beside a page.
18
+ argTypes: { children: { control: false }, actions: { control: false }, header: { control: false }, footer: { control: false } },
19
+ // A side column of the frame: 380px wide and a fixed height, where a panel sits beside a page;
20
+ // 384px, the right column's width in every app (Katerina, 31 October), where a story says so.
18
21
  decorators: [
19
- (Story) => (
20
- <div className="flex h-[560px] w-[380px] flex-col border-l border-border-subtle bg-bg-surface">
22
+ (Story, { parameters }) => (
23
+ <div className={parameters.rightColumn ? 'flex h-[560px] w-[384px] flex-col border-l border-border-subtle bg-bg-surface' : 'flex h-[560px] w-[380px] flex-col border-l border-border-subtle bg-bg-surface'}>
21
24
  {Story()}
22
25
  </div>
23
26
  ),
@@ -70,6 +73,45 @@ export const WithAFooter: Story = {
70
73
  ),
71
74
  }
72
75
 
76
+ /** A chip before the close button, saying the state of what the panel shows; the right column's width, 384px. */
77
+ export const WithAChip: Story = {
78
+ parameters: { rightColumn: true },
79
+ args: {
80
+ actions: (
81
+ <>
82
+ <Chip type="success" label="Label" />
83
+ <IconButton tooltip="Close" aria-label="Close">
84
+ <IconX size={16} stroke={1.5} />
85
+ </IconButton>
86
+ </>
87
+ ),
88
+ },
89
+ render: (args) => <Panel {...args}>{paragraphs(3)}</Panel>,
90
+ }
91
+
92
+ /** A page's own bar in place of the panel's: a PageHeader, where the panel is the page. The body still scrolls under it. */
93
+ export const WithAPageHeader: Story = {
94
+ name: 'With a page header',
95
+ args: {
96
+ header: (
97
+ <PageHeader
98
+ title="Item one"
99
+ time={{ label: 'Edited 2 minutes ago', exact: '1 November 2026, 14:02' }}
100
+ actions={
101
+ <IconButton tooltip="More" aria-label="More">
102
+ <IconDotsVertical size={16} stroke={1.5} />
103
+ </IconButton>
104
+ }
105
+ />
106
+ ),
107
+ children: Array.from({ length: 24 }, (_, i) => (
108
+ <p key={i} className="text-body-2 text-text-secondary">
109
+ A line of the page, number {i + 1}.
110
+ </p>
111
+ )),
112
+ },
113
+ }
114
+
73
115
  /** Two panels in one column: the first capped at three fifths, each scrolls in its own room. */
74
116
  export const TwoInAColumn: Story = {
75
117
  render: (args) => (
@@ -0,0 +1,40 @@
1
+ // @vitest-environment jsdom
2
+ import { afterEach, describe, expect, it, vi } from 'vitest'
3
+ import { cleanup, render, screen } from '@testing-library/react'
4
+ import { Panel } from './Panel'
5
+
6
+ afterEach(cleanup)
7
+
8
+ function Breaks(): never {
9
+ throw new Error('the body broke')
10
+ }
11
+
12
+ describe('Panel', () => {
13
+ it('draws its own bar from its title', () => {
14
+ render(<Panel title="Details">Body</Panel>)
15
+ expect(screen.getByText('Details')).toBeTruthy()
16
+ })
17
+
18
+ it('draws a page’s own bar in place of its own, with `header`', () => {
19
+ render(
20
+ <Panel title="Details" header={<div>The page’s bar</div>}>
21
+ Body
22
+ </Panel>,
23
+ )
24
+ expect(screen.getByText('The page’s bar')).toBeTruthy()
25
+ expect(screen.queryByText('Details')).toBeNull()
26
+ expect(screen.getByText('Body')).toBeTruthy()
27
+ })
28
+
29
+ it('keeps its title when it breaks, even with a page’s bar, which may be what broke', () => {
30
+ vi.spyOn(console, 'error').mockImplementation(() => {})
31
+ render(
32
+ <Panel title="Details" header={<div>The page’s bar</div>}>
33
+ <Breaks />
34
+ </Panel>,
35
+ )
36
+ expect(screen.getByText('Details')).toBeTruthy()
37
+ expect(screen.queryByText('The page’s bar')).toBeNull()
38
+ vi.restoreAllMocks()
39
+ })
40
+ })
package/src/Panel.tsx CHANGED
@@ -35,6 +35,12 @@ export interface PanelProps {
35
35
  chevron?: boolean
36
36
  /** The panel's own actions, at the header's right — a `Toolbar` of `ToolbarButton`s, or one `IconButton`. */
37
37
  actions?: ReactNode
38
+ /**
39
+ * A page's own bar, in place of the one `title`, `chevron` and `actions` draw: a `PageHeader`, where the panel is
40
+ * the page (Peek's file pages, Leaf's documents), so the page's bar and its scrolling body are one panel. `title`
41
+ * still names the panel if it breaks.
42
+ */
43
+ header?: ReactNode
38
44
  /** The body. It scrolls when it is taller than the panel. */
39
45
  children: ReactNode
40
46
  /** A row fixed under the body that never scrolls — a reply box. */
@@ -49,10 +55,10 @@ export interface PanelProps {
49
55
  className?: string
50
56
  }
51
57
 
52
- function Frame({ title, chevron = false, actions, children, footer, bodyClassName, bodyRef, onBodyScroll, className, broken = false }: PanelProps & { broken?: boolean }) {
58
+ function Frame({ title, chevron = false, actions, header, children, footer, bodyClassName, bodyRef, onBodyScroll, className, broken = false }: PanelProps & { broken?: boolean }) {
53
59
  return (
54
60
  <div className={cn('flex h-full min-h-0 flex-1 flex-col', className)}>
55
- <ContainerHeader title={title} chevron={chevron} actions={actions} />
61
+ {header ?? <ContainerHeader title={title} chevron={chevron} actions={actions} />}
56
62
  {broken ? (
57
63
  // The message takes the room the body had and centres itself in it.
58
64
  <div className="flex min-h-0 flex-1 flex-col px-4">{children}</div>
@@ -0,0 +1,40 @@
1
+ import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks'
2
+ import * as Stories from './PinnedComment.stories'
3
+
4
+ <Meta of={Stories} />
5
+
6
+ # PinnedComment
7
+
8
+ The comment a thread answers, pinned at the top of the replies column: who, when, and its first line.
9
+
10
+ <Canvas of={Stories.Pinned} />
11
+
12
+ ## When
13
+
14
+ - At the top of a **Thread** in the right column. Thread draws it from its `start`.
15
+
16
+ <Canvas of={Stories.Deleted} />
17
+
18
+ ## When not
19
+
20
+ - The comment itself, in the list → **ConversationCard**.
21
+
22
+ ## How
23
+
24
+ ```tsx
25
+ import { Thread } from '@estiva-app/ui'
26
+
27
+ <Thread start={{ author: author, time: time, words: words }} onClose={onClose} box={box}>
28
+ {replies}
29
+ </Thread>
30
+ ```
31
+
32
+ - Give `time` its day: no day line stands above it here.
33
+
34
+ ## What it owns
35
+
36
+ Nothing. It only draws. Clicks and keys are yours.
37
+
38
+ ## Props
39
+
40
+ <Controls />
@@ -0,0 +1,21 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+ import { Column, ONE, WORDS } from './conversation.examples'
3
+ import { PinnedComment } from './PinnedComment'
4
+
5
+ /** The comment a thread answers, at the top of the replies column. */
6
+ const meta = {
7
+ title: 'Conversation/PinnedComment',
8
+ component: PinnedComment,
9
+ parameters: { layout: 'padded' },
10
+ args: { author: ONE, time: 'Today 11:08 AM', words: WORDS },
11
+ decorators: [(Story) => <Column>{Story()}</Column>],
12
+ } satisfies Meta<typeof PinnedComment>
13
+
14
+ export default meta
15
+ type Story = StoryObj<typeof meta>
16
+
17
+ /** Who, when, and its first line. */
18
+ export const Pinned: Story = {}
19
+
20
+ /** It was deleted; its replies stay under it. */
21
+ export const Deleted: Story = { args: { deleted: true } }
@@ -0,0 +1,40 @@
1
+ import type { ReactNode } from 'react'
2
+ import { Avatar } from './Avatar'
3
+ import { Card } from './Card'
4
+ import type { ConversationPerson } from './ConversationCard'
5
+ import { MetaText } from './MetaText'
6
+
7
+ export interface PinnedCommentProps {
8
+ author: ConversationPerson
9
+ /** When it was written, in the app's words, with its day: no day line stands above it here. */
10
+ time: ReactNode
11
+ /** Its words, cut to one line: plain words read best. */
12
+ words: ReactNode
13
+ /** It was deleted; its replies stay. */
14
+ deleted?: boolean
15
+ }
16
+
17
+ /**
18
+ * The comment a thread answers, pinned at the top of the replies column: who, when, and its first line, on a raised
19
+ * card. Peek's pinned message, moved with the conversation.
20
+ */
21
+ export function PinnedComment({ author, time, words, deleted = false }: PinnedCommentProps) {
22
+ return (
23
+ <Card fill="elevated" clip>
24
+ {deleted ? (
25
+ <p className="p-2 text-caption italic text-text-muted">This comment was deleted.</p>
26
+ ) : (
27
+ <div className="flex flex-col p-2">
28
+ <div className="flex items-center gap-2">
29
+ <Avatar size={24} src={author.picture} alt={author.name} />
30
+ <span className="min-w-0 truncate text-body-2-strong text-text-primary">{author.name}</span>
31
+ <MetaText className="shrink-0">{time}</MetaText>
32
+ </div>
33
+ <div className="pb-2 pl-8 pr-2 pt-1">
34
+ <div className="truncate text-caption text-text-secondary">{words}</div>
35
+ </div>
36
+ </div>
37
+ )}
38
+ </Card>
39
+ )
40
+ }
@@ -0,0 +1,44 @@
1
+ import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks'
2
+ import * as Stories from './QuotedLine.stories'
3
+
4
+ <Meta of={Stories} />
5
+
6
+ # QuotedLine
7
+
8
+ On a comment on a part of the page: the words it is on, in the page's own highlight, under the name and above the comment's words.
9
+
10
+ <Canvas of={Stories.Words} />
11
+
12
+ ## When
13
+
14
+ - On a **ConversationCard** about a part of the page, in its `about`.
15
+
16
+ <Canvas of={Stories.Reworded} />
17
+
18
+ <Canvas of={Stories.Gone} />
19
+
20
+ ## When not
21
+
22
+ - A whole block quoted in the words → **PartCard**.
23
+
24
+ ## How
25
+
26
+ ```tsx
27
+ import { ConversationCard, QuotedLine } from '@estiva-app/ui'
28
+
29
+ <ConversationCard author={author} time={time} about={<QuotedLine words={quote} state="reworded" />}>
30
+ {words}
31
+ </ConversationCard>
32
+ ```
33
+
34
+ - Two lines at most; the whole words are in the tooltip.
35
+ - A part with no words, a picture or a block: `label`, its name in your words.
36
+ - Made for the card's `about`: the card puts it under the name, where the words start.
37
+
38
+ ## What it owns
39
+
40
+ Nothing. It only draws. Clicks and keys are yours.
41
+
42
+ ## Props
43
+
44
+ <Controls />
@@ -0,0 +1,30 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+ import { Column } from './conversation.examples'
3
+ import { QuotedLine } from './QuotedLine'
4
+
5
+ /** On a comment on a part of the page, under the name and above its words: the words it is on, in the page's highlight. */
6
+ const meta = {
7
+ title: 'Conversation/QuotedLine',
8
+ component: QuotedLine,
9
+ parameters: { layout: 'padded' },
10
+ args: { words: 'the words this comment is on' },
11
+ decorators: [(Story) => <Column>{Story()}</Column>],
12
+ } satisfies Meta<typeof QuotedLine>
13
+
14
+ export default meta
15
+ type Story = StoryObj<typeof meta>
16
+
17
+ /** The words the comment is on, still in the text: in the page's highlight, so the two read as one. */
18
+ export const Words: Story = { name: 'Words' }
19
+
20
+ /** The words were changed since: the highlight goes grey, and "Changed since". */
21
+ export const Reworded: Story = { name: 'Words changed', args: { state: 'reworded' } }
22
+
23
+ /** The part was deleted from the page: the words struck through, and "Deleted from the page". */
24
+ export const Gone: Story = { name: 'Part deleted', args: { state: 'gone' } }
25
+
26
+ /** On a part with no words of its own, a picture: its name, in the app's words. */
27
+ export const Part: Story = { name: 'No words', args: { words: undefined, label: 'Picture: plan-sketch.png' } }
28
+
29
+ /** Words longer than two lines: cut, the whole in the tooltip. */
30
+ export const Long: Story = { name: 'Long words', args: { words: 'the words this comment is on, which run on past the width of the column, and on again, so that two lines are not enough and the words have to be cut before their end' } }
@@ -0,0 +1,34 @@
1
+ // @vitest-environment jsdom
2
+ import { afterEach, describe, expect, it } from 'vitest'
3
+ import { cleanup, render, screen } from '@testing-library/react'
4
+ import { QuotedLine } from './QuotedLine'
5
+
6
+ afterEach(cleanup)
7
+
8
+ describe('QuotedLine', () => {
9
+ it('marks the words in the page’s highlight while they are still in the text', () => {
10
+ const { container } = render(<QuotedLine words="the words this comment is on" />)
11
+ const mark = screen.getByText('the words this comment is on')
12
+ expect(mark.tagName).toBe('MARK')
13
+ expect(mark.className).toMatch(/\bbg-warning-muted\b/)
14
+ expect(container.querySelector('[data-quoted="here"]')).not.toBeNull()
15
+ })
16
+
17
+ it('says the words changed since, and loses the highlight', () => {
18
+ render(<QuotedLine words="the words" state="reworded" />)
19
+ expect(screen.getByText('Changed since')).toBeTruthy()
20
+ expect(screen.getByText('the words').className).not.toMatch(/\bbg-warning-muted\b/)
21
+ })
22
+
23
+ it('says the part was deleted, and strikes the words through', () => {
24
+ render(<QuotedLine words="the words" state="gone" />)
25
+ expect(screen.getByText('Deleted from the page')).toBeTruthy()
26
+ expect(screen.getByText('the words').className).toMatch(/\bline-through\b/)
27
+ })
28
+
29
+ it('gives a part with no words its name', () => {
30
+ const { container } = render(<QuotedLine label="Picture: plan-sketch.png" />)
31
+ expect(screen.getByText('Picture: plan-sketch.png')).toBeTruthy()
32
+ expect(container.querySelector('[data-quoted="part"]')).not.toBeNull()
33
+ })
34
+ })
@@ -0,0 +1,33 @@
1
+ import { cn } from './cn'
2
+ import { WithTooltip } from './Tooltip'
3
+
4
+ export interface QuotedLineProps {
5
+ /** The words the comment is on, as they were quoted. */
6
+ words?: string
7
+ /** `here`: still in the text. `reworded`: changed since. `gone`: their part was deleted from the page. */
8
+ state?: 'here' | 'reworded' | 'gone'
9
+ /** A part with no words, a picture or a whole block: what it is, in the app's words ("Picture: plan.png"). */
10
+ label?: string
11
+ }
12
+
13
+ const SINCE = { reworded: 'Changed since', gone: 'Deleted from the page' } as const
14
+
15
+ /**
16
+ * What a comment on a part of the page is on: its words, two lines at most, in the page's own highlight, so the two
17
+ * read as one. ConversationCard puts it under the name, above the comment's words ("above the message, not above the
18
+ * person": Katerina, 1 November). Words changed since or deleted lose the highlight and say so; a part with no words
19
+ * gives its name.
20
+ */
21
+ export function QuotedLine({ words, state = 'here', label }: QuotedLineProps) {
22
+ const shown = words ?? label ?? ''
23
+ return (
24
+ <div data-quoted={words ? state : 'part'} className="flex w-full min-w-0 flex-col gap-0.5">
25
+ <WithTooltip label={shown} wrapperClassName="flex min-w-0">
26
+ <p className="line-clamp-2 text-caption text-text-secondary">
27
+ <mark className={cn('rounded-sm px-0.5 text-text-primary [box-decoration-break:clone]', state === 'here' ? 'bg-warning-muted' : 'bg-bg-inset text-text-secondary', state === 'gone' && 'line-through')}>{shown}</mark>
28
+ </p>
29
+ </WithTooltip>
30
+ {state !== 'here' && <span className="text-caption italic text-text-muted">{SINCE[state]}</span>}
31
+ </div>
32
+ )
33
+ }
@@ -0,0 +1,36 @@
1
+ import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks'
2
+ import * as Stories from './ReactionHorizon.stories'
3
+
4
+ <Meta of={Stories} />
5
+
6
+ # ReactionHorizon
7
+
8
+ The line that says reactions are read only so far back, and how many older comments were not checked.
9
+
10
+ <Canvas of={Stories.Older} />
11
+
12
+ ## When
13
+
14
+ - Under a long conversation, when the app stopped reading reactions before the oldest comment.
15
+
16
+ ## When not
17
+
18
+ No alternative: when every reaction was read, it draws nothing, so it can always be placed.
19
+
20
+ ## How
21
+
22
+ ```tsx
23
+ import { ReactionHorizon } from '@estiva-app/ui'
24
+
25
+ <ReactionHorizon limit={200} omitted={14} cut={false} />
26
+ ```
27
+
28
+ - `limit`, `omitted` and `cut` are the app's to count.
29
+
30
+ ## What it owns
31
+
32
+ Nothing. It only draws. Clicks and keys are yours.
33
+
34
+ ## Props
35
+
36
+ <Controls />
@@ -0,0 +1,27 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+ import { Column } from './conversation.examples'
3
+ import { ReactionHorizon } from './ReactionHorizon'
4
+
5
+ /** How far back reactions are read. Nothing is drawn when every one was. */
6
+ const meta = {
7
+ title: 'Conversation/ReactionHorizon',
8
+ component: ReactionHorizon,
9
+ parameters: { layout: 'padded' },
10
+ args: { limit: 200, omitted: 14 },
11
+ decorators: [(Story) => <Column>{Story()}</Column>],
12
+ } satisfies Meta<typeof ReactionHorizon>
13
+
14
+ export default meta
15
+ type Story = StoryObj<typeof meta>
16
+
17
+ /** Older ones were not checked. */
18
+ export const Older: Story = {}
19
+
20
+ /** One older one. */
21
+ export const One: Story = { args: { omitted: 1 } }
22
+
23
+ /** The read was cut short. */
24
+ export const Cut: Story = { args: { omitted: 0, cut: true } }
25
+
26
+ /** Both. */
27
+ export const Both: Story = { args: { cut: true } }
@@ -0,0 +1,27 @@
1
+ export interface ReactionHorizonProps {
2
+ /** How many comments and replies back reactions are read for. */
3
+ limit: number
4
+ /** How many older ones were not checked. */
5
+ omitted: number
6
+ /** Some reactions may be missing: the read was cut short. */
7
+ cut?: boolean
8
+ }
9
+
10
+ /**
11
+ * The line that says reactions are read only so far back, and how many older comments were not checked. Nothing is
12
+ * drawn when every one was. Peek's, moved with the conversation.
13
+ */
14
+ export function ReactionHorizon({ limit, omitted, cut = false }: ReactionHorizonProps) {
15
+ if (omitted <= 0 && !cut) return null
16
+ return (
17
+ <p className="text-caption text-text-muted">
18
+ {omitted > 0 && (
19
+ <>
20
+ Reactions are shown for the latest {limit} comments and replies here. {omitted} older {omitted === 1 ? 'one was' : 'ones were'} not checked.
21
+ </>
22
+ )}
23
+ {omitted > 0 && cut && ' '}
24
+ {cut && 'Some reactions may be missing.'}
25
+ </p>
26
+ )
27
+ }
@@ -0,0 +1,45 @@
1
+ import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks'
2
+ import * as Stories from './RepliesRow.stories'
3
+
4
+ <Meta of={Stories} />
5
+
6
+ # RepliesRow
7
+
8
+ The way into a thread, under its comment: who replied, "2 replies", the last reply's time, and "1 new" until it is read.
9
+
10
+ <Canvas of={Stories.Several} />
11
+
12
+ ## When
13
+
14
+ - Under a comment with replies: **ConversationCard** draws it from its `replies`.
15
+ - `onOpen` where the row itself opens the thread (one column, the thread under its comment); without it, the card around it does.
16
+ - `open` while that thread is open under it: the chevron turns down and the row stays marked, and a press closes it. The whole card around it opens and closes the thread too.
17
+
18
+ <Canvas of={Stories.New} />
19
+ <Canvas of={Stories.Open} />
20
+
21
+ ## When not
22
+
23
+ - A count on its own → **MetaText**.
24
+ - Faces on their own → **AvatarGroup**.
25
+
26
+ ## How
27
+
28
+ ```tsx
29
+ import { RepliesRow } from '@estiva-app/ui'
30
+
31
+ <RepliesRow count={3} faces={faces} last="12:02 PM" isNew onOpen={() => openUnder(comment)} />
32
+ ```
33
+
34
+ - Faces and the last time show in Signal; in the other themes the row is the icon and the count.
35
+
36
+ ## What it owns
37
+
38
+ | It does | So you never write | Refused when written by hand |
39
+ |---|---|---|
40
+ | Says "1 reply" or "2 replies" | the plural | |
41
+ | Shows "1 new" until it is read, in the warning colour when urgent | the chip and its colour | |
42
+
43
+ ## Props
44
+
45
+ <Controls />
@@ -0,0 +1,33 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+ import { Column, THREE, TWO, YOU } from './conversation.examples'
3
+ import { RepliesRow } from './RepliesRow'
4
+
5
+ /** The way into a thread. In Signal it shows who replied and the last time; in the other themes, the count. */
6
+ const meta = {
7
+ title: 'Conversation/RepliesRow',
8
+ component: RepliesRow,
9
+ parameters: { layout: 'padded' },
10
+ args: { count: 3, faces: [TWO, THREE, YOU], last: '12:02 PM' },
11
+ decorators: [(Story) => <Column>{Story()}</Column>],
12
+ } satisfies Meta<typeof RepliesRow>
13
+
14
+ export default meta
15
+ type Story = StoryObj<typeof meta>
16
+
17
+ /** Several replies, with their faces. */
18
+ export const Several: Story = {}
19
+
20
+ /** One reply. */
21
+ export const One: Story = { args: { count: 1, faces: [TWO] } }
22
+
23
+ /** A reply not read yet. */
24
+ export const New: Story = { args: { isNew: true } }
25
+
26
+ /** A reply not read yet, in an urgent thread. */
27
+ export const Urgent: Story = { args: { isNew: true, urgent: true } }
28
+
29
+ /** A press on it opens the thread. */
30
+ export const Opens: Story = { args: { onOpen: () => {} } }
31
+
32
+ /** Its thread open under it, in one column: the chevron turned down, the row kept marked; a press closes it. */
33
+ export const Open: Story = { args: { onOpen: () => {}, open: true } }
@@ -0,0 +1,47 @@
1
+ // @vitest-environment jsdom
2
+ import { afterEach, describe, expect, it, vi } from 'vitest'
3
+ import { cleanup, fireEvent, render, screen } from '@testing-library/react'
4
+ import { RepliesRow } from './RepliesRow'
5
+
6
+ afterEach(cleanup)
7
+
8
+ describe('RepliesRow', () => {
9
+ it('says how many, in one or many', () => {
10
+ render(<RepliesRow count={1} />)
11
+ expect(screen.getByText('1 reply')).toBeTruthy()
12
+ cleanup()
13
+ render(<RepliesRow count={3} />)
14
+ expect(screen.getByText('3 replies')).toBeTruthy()
15
+ })
16
+
17
+ it('opens the thread with a press, and says whether it opens or closes it', () => {
18
+ const onOpen = vi.fn()
19
+ render(<RepliesRow count={2} onOpen={onOpen} />)
20
+ const row = screen.getByRole('button', { name: '2 replies, open the thread' })
21
+ expect(row.getAttribute('aria-expanded')).toBe('false')
22
+ fireEvent.click(row)
23
+ expect(onOpen).toHaveBeenCalledOnce()
24
+ cleanup()
25
+ render(<RepliesRow count={2} onOpen={onOpen} open />)
26
+ expect(screen.getByRole('button', { name: '2 replies, close the thread' }).getAttribute('aria-expanded')).toBe('true')
27
+ })
28
+
29
+ it('is no button of its own without onOpen: the card round it opens the thread', () => {
30
+ render(<RepliesRow count={2} />)
31
+ expect(screen.queryByRole('button')).toBeNull()
32
+ })
33
+
34
+ it('says "1 new" until it is read', () => {
35
+ render(<RepliesRow count={2} isNew />)
36
+ expect(screen.getByText('1 new')).toBeTruthy()
37
+ cleanup()
38
+ render(<RepliesRow count={2} />)
39
+ expect(screen.queryByText('1 new')).toBeNull()
40
+ })
41
+
42
+ it('shows the last reply’s time, and the faces in place of the icon', () => {
43
+ const { container } = render(<RepliesRow count={2} last="11:52 AM" faces={[{ name: 'Person two' }, { name: 'Person three' }]} />)
44
+ expect(screen.getByText('11:52 AM')).toBeTruthy()
45
+ expect(container.querySelectorAll('img, [data-avatar], [aria-label="Person two"]').length).toBeGreaterThan(0)
46
+ })
47
+ })