@estiva-app/ui 0.99.0 → 0.100.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 (50) hide show
  1. package/README.md +3 -1
  2. package/dist/ConversationCard.d.ts +6 -0
  3. package/dist/ConversationCard.d.ts.map +1 -1
  4. package/dist/ConversationLayout.d.ts +1 -1
  5. package/dist/ConversationLayout.d.ts.map +1 -1
  6. package/dist/ConversationMenu.d.ts +5 -1
  7. package/dist/ConversationMenu.d.ts.map +1 -1
  8. package/dist/Menu.d.ts +11 -3
  9. package/dist/Menu.d.ts.map +1 -1
  10. package/dist/MoveDialog.d.ts +6 -3
  11. package/dist/MoveDialog.d.ts.map +1 -1
  12. package/dist/RepliesRow.d.ts +5 -3
  13. package/dist/RepliesRow.d.ts.map +1 -1
  14. package/dist/Thread.d.ts +1 -1
  15. package/dist/Thread.d.ts.map +1 -1
  16. package/dist/index.js +62 -35
  17. package/dist/index.js.map +2 -2
  18. package/package.json +1 -1
  19. package/registry.json +80 -12
  20. package/src/ConversationCard.mdx +4 -0
  21. package/src/ConversationCard.states.test.tsx +67 -0
  22. package/src/ConversationCard.stories.tsx +16 -0
  23. package/src/ConversationCard.tsx +14 -6
  24. package/src/ConversationLayout.mdx +4 -0
  25. package/src/ConversationLayout.stories.tsx +28 -0
  26. package/src/ConversationLayout.test.tsx +54 -0
  27. package/src/ConversationLayout.tsx +6 -2
  28. package/src/ConversationMenu.mdx +3 -0
  29. package/src/ConversationMenu.stories.tsx +12 -0
  30. package/src/ConversationMenu.test.tsx +17 -0
  31. package/src/ConversationMenu.tsx +7 -3
  32. package/src/Menu.test.tsx +80 -0
  33. package/src/Menu.tsx +35 -14
  34. package/src/MenuItem.mdx +12 -0
  35. package/src/MenuItem.stories.tsx +39 -1
  36. package/src/MoveDialog.mdx +12 -1
  37. package/src/MoveDialog.stories.tsx +13 -0
  38. package/src/MoveDialog.test.tsx +36 -0
  39. package/src/MoveDialog.tsx +6 -3
  40. package/src/RepliesRow.mdx +6 -3
  41. package/src/RepliesRow.stories.tsx +3 -0
  42. package/src/RepliesRow.test.tsx +24 -0
  43. package/src/RepliesRow.tsx +12 -6
  44. package/src/ReplyCard.mdx +5 -0
  45. package/src/ReplyCard.stories.tsx +26 -0
  46. package/src/Thread.mdx +3 -1
  47. package/src/Thread.stories.tsx +39 -0
  48. package/src/Thread.tsx +6 -4
  49. package/src/seenOnScreen.test.tsx +59 -0
  50. package/stories/Choosing.mdx +1 -1
@@ -203,6 +203,45 @@ export const Under: Story = {
203
203
  },
204
204
  }
205
205
 
206
+ /**
207
+ * Under its comment, read by being seen too: a new reply keeps its edge until it has been on screen a moment
208
+ * (`useSeenOnScreen` for the thread, handed to its `seen`), as in the column beside.
209
+ */
210
+ export const UnderSeen: Story = {
211
+ name: 'Under its comment, new until seen',
212
+ render: function Render() {
213
+ const seen = useSeenOnScreen('story-under')
214
+ return (
215
+ <div className="flex h-[640px]">
216
+ <ConversationLayout
217
+ threads="under"
218
+ open="c1"
219
+ items={[
220
+ {
221
+ id: 'c1',
222
+ card: (
223
+ <ConversationCard author={ONE} time="11:08 AM" replies={{ count: 2, faces: [TWO, THREE], last: '11:52 AM' }}>
224
+ {WORDS}
225
+ </ConversationCard>
226
+ ),
227
+ thread: (
228
+ <Thread place="under" box={<WriteBox />} seen={seen}>
229
+ <ReplyCard id="u1" author={TWO} time="11:40 AM" isNew={!seen.ids.has('u1')}>
230
+ {SHORT}
231
+ </ReplyCard>
232
+ <ReplyCard id="u2" author={THREE} time="11:52 AM" isNew={!seen.ids.has('u2')}>
233
+ A second reply, new too.
234
+ </ReplyCard>
235
+ </Thread>
236
+ ),
237
+ },
238
+ ]}
239
+ />
240
+ </div>
241
+ )
242
+ },
243
+ }
244
+
206
245
  /** Your reply among them. */
207
246
  export const WithYours: Story = {
208
247
  name: 'With yours',
package/src/Thread.tsx CHANGED
@@ -48,7 +48,7 @@ export interface ThreadProps {
48
48
  title?: ReactNode
49
49
  /** Beside: the column's scrolling box. Where it scrolls is the thread's: it opens at the newest reply and goes to each new one. */
50
50
  bodyRef?: Ref<HTMLDivElement>
51
- /** Beside: what `useSeenOnScreen` made for this thread: it watches its replies (each `ReplyCard`'s `id`), and says in it which were seen. */
51
+ /** What `useSeenOnScreen` made for this thread: it watches its replies (each `ReplyCard`'s `id`), beside or under its comment, and says in it which were seen. */
52
52
  seen?: SeenOnScreen
53
53
  /** Placement only. */
54
54
  className?: string
@@ -96,8 +96,10 @@ export function Thread({
96
96
  },
97
97
  [bodyRef],
98
98
  )
99
- // A reply is read by being seen in its thread (Peek's PEE-44): each one is watched.
100
- useWatchSeen(seen, body, 'data-reply-id')
99
+ // A reply is read by being seen in its thread (Peek's PEE-44): each one is watched, beside in the column's box, and
100
+ // under its comment in the thread's own (one column; Ship, 2 November). The app's `bodyRef` stays the column's only.
101
+ const under = useRef<HTMLDivElement>(null)
102
+ useWatchSeen(seen, place === 'under' ? under : body, 'data-reply-id')
101
103
  /*
102
104
  Beside: it opens at its newest reply, before the paint, so it never shows its top for a frame and then jumps; and
103
105
  it goes to the newest each time a reply is added, or another thread is drawn in it (Peek's OPT-9). Each ReplyCard
@@ -124,7 +126,7 @@ export function Thread({
124
126
  const layoutLine = useContext(LineByLayout)
125
127
  if (place === 'under') {
126
128
  return (
127
- <div data-thread="under" className={cn('flex flex-col', className)}>
129
+ <div ref={under} data-thread="under" className={cn('flex flex-col', className)}>
128
130
  {(loading || anyIn(children)) && (
129
131
  // The replies hang from a line under the comment's face (20px in: its 8px and half its 24px), one step in (Ship's way).
130
132
  // 8px from the one card's right edge too, as the box under them: a hovered reply never touches it (Katerina, 31 October).
@@ -180,3 +180,62 @@ describe('useSeenOnScreen, where there is no IntersectionObserver (a test’s pa
180
180
  expect(seenNow()).toBe('a,b')
181
181
  })
182
182
  })
183
+
184
+ describe('useSeenOnScreen, in a Thread under its comment (one column; Ship, 2 November)', () => {
185
+ function OneColumn({ ids }: { ids: string[] }) {
186
+ const seen = useSeenOnScreen('thread')
187
+ return (
188
+ <>
189
+ <ConversationLayout
190
+ threads="under"
191
+ open="c"
192
+ onOpenChange={() => {}}
193
+ items={[
194
+ {
195
+ id: 'c',
196
+ card: (
197
+ <ConversationCard author={ONE} time="11:08 AM" replies={{ count: ids.length }}>
198
+ The comment
199
+ </ConversationCard>
200
+ ),
201
+ thread: (
202
+ <Thread place="under" seen={seen}>
203
+ {ids.map((id) => (
204
+ <ReplyCard key={id} id={id} author={ONE} time="11:30 AM">
205
+ {id}
206
+ </ReplyCard>
207
+ ))}
208
+ </Thread>
209
+ ),
210
+ },
211
+ ]}
212
+ />
213
+ <output data-testid="seen">{[...seen.ids].sort().join(',')}</output>
214
+ </>
215
+ )
216
+ }
217
+
218
+ it('a reply on screen for the dwell is seen, as in the thread beside; one never shown is not', () => {
219
+ render(<OneColumn ids={['r1', 'r2']} />)
220
+ show('r2', 1)
221
+ wait(DWELL)
222
+ expect(seenNow()).toBe('r2')
223
+ })
224
+
225
+ it('scrolling past before the dwell reads nothing', () => {
226
+ render(<OneColumn ids={['r1']} />)
227
+ show('r1', 1)
228
+ wait(DWELL - 100)
229
+ show('r1', 0)
230
+ wait(DWELL)
231
+ expect(seenNow()).toBe('')
232
+ })
233
+
234
+ it('a reply drawn later is watched too', () => {
235
+ const { rerender } = render(<OneColumn ids={['r1']} />)
236
+ rerender(<OneColumn ids={['r1', 'r2']} />)
237
+ show('r2', 1)
238
+ wait(DWELL)
239
+ expect(seenNow()).toBe('r2')
240
+ })
241
+ })
@@ -99,7 +99,7 @@ The same conversation in every app; only its colours are each app's.
99
99
  | Where a conversation shown away from its place was said, above its card | **ConversationPlace** — how it is related and the place, in your words |
100
100
  | One reply in a thread | **ReplyCard** — a comment's pieces, without replies of its own or Resolve |
101
101
  | A comment's replies and the box to write one | **Thread** — in the right column under its header, or under its comment |
102
- | The way into a thread | **RepliesRow** — faces, "2 replies", the last time and "1 new" |
102
+ | The way into a thread | **RepliesRow** — faces, "2 replies", the last time and how many are new ("2 new") |
103
103
  | Resolving, with a note | **ResolveDialog**; the comment then says who resolved it and the note: **ConversationCard** `resolved` |
104
104
  | The words a comment on a part is about | **QuotedLine** — above its name, and what changed since |
105
105
  | The comment a thread answers, at the top of its replies column | **PinnedComment** — Thread draws it from its `start` |