@linktr.ee/messaging-react 3.9.0-rc-1783472582 → 3.9.0-rc-1783568295

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 (88) hide show
  1. package/dist/Card-B8Zz3GRL.js +132 -0
  2. package/dist/Card-B8Zz3GRL.js.map +1 -0
  3. package/dist/Card-BmYSOINp.cjs +2 -0
  4. package/dist/Card-BmYSOINp.cjs.map +1 -0
  5. package/dist/Card-BnJLBTl6.js +163 -0
  6. package/dist/Card-BnJLBTl6.js.map +1 -0
  7. package/dist/Card-DWT-IkeK.cjs +2 -0
  8. package/dist/Card-DWT-IkeK.cjs.map +1 -0
  9. package/dist/Card-Gapf9yEL.js +107 -0
  10. package/dist/Card-Gapf9yEL.js.map +1 -0
  11. package/dist/Card-WoQGTJ5n.cjs +2 -0
  12. package/dist/Card-WoQGTJ5n.cjs.map +1 -0
  13. package/dist/LockedThumbnail-Cu3qwKAd.js +220 -0
  14. package/dist/LockedThumbnail-Cu3qwKAd.js.map +1 -0
  15. package/dist/LockedThumbnail-DFByBLYS.cjs +2 -0
  16. package/dist/LockedThumbnail-DFByBLYS.cjs.map +1 -0
  17. package/dist/assets/index.css +1 -1
  18. package/dist/{index-B8gqCioX.js → index-Bv79lb0u.js} +1114 -1154
  19. package/dist/index-Bv79lb0u.js.map +1 -0
  20. package/dist/index-C1Zaiccm.cjs +2 -0
  21. package/dist/index-C1Zaiccm.cjs.map +1 -0
  22. package/dist/index.cjs +1 -1
  23. package/dist/index.d.ts +55 -98
  24. package/dist/index.js +1 -1
  25. package/dist/testing.d.ts +0 -1
  26. package/package.json +2 -2
  27. package/src/components/CustomMessage/CustomMessage.stories.tsx +1 -54
  28. package/src/components/CustomMessage/MessageTag.tsx +0 -8
  29. package/src/components/CustomMessage/index.tsx +22 -61
  30. package/src/components/CustomMessageInput/index.tsx +3 -0
  31. package/src/components/LockedAttachment/LockedAttachment.stories.tsx +340 -422
  32. package/src/components/LockedAttachment/components/Composer/Card.tsx +120 -100
  33. package/src/components/LockedAttachment/components/Composer/index.ts +2 -0
  34. package/src/components/LockedAttachment/components/Received/Card.tsx +191 -0
  35. package/src/components/LockedAttachment/components/{Media → Received}/CardActions.tsx +1 -3
  36. package/src/components/LockedAttachment/components/Received/index.ts +2 -0
  37. package/src/components/LockedAttachment/components/Sent/Card.tsx +177 -0
  38. package/src/components/LockedAttachment/components/Sent/index.ts +2 -0
  39. package/src/components/LockedAttachment/components/_shared/CardBody.tsx +3 -3
  40. package/src/components/LockedAttachment/components/_shared/GalleryThumbnail.tsx +38 -30
  41. package/src/components/LockedAttachment/components/_shared/LockBadge.tsx +19 -43
  42. package/src/components/LockedAttachment/components/_shared/{MediaShell.tsx → LockedCardShell.tsx} +7 -6
  43. package/src/components/LockedAttachment/components/_shared/{SingleThumbnail.tsx → LockedThumbnail.tsx} +6 -10
  44. package/src/components/LockedAttachment/index.tsx +28 -17
  45. package/src/components/LockedAttachment/types.ts +4 -28
  46. package/src/index.ts +5 -2
  47. package/src/stream-custom-data.ts +0 -1
  48. package/src/styles.css +0 -5
  49. package/dist/Card-BVZM0-06.js +0 -108
  50. package/dist/Card-BVZM0-06.js.map +0 -1
  51. package/dist/Card-D0hLrOxX.js +0 -221
  52. package/dist/Card-D0hLrOxX.js.map +0 -1
  53. package/dist/Card-DIr1UnfC.cjs +0 -2
  54. package/dist/Card-DIr1UnfC.cjs.map +0 -1
  55. package/dist/Card-DeSgaRTL.cjs +0 -2
  56. package/dist/Card-DeSgaRTL.cjs.map +0 -1
  57. package/dist/Card-DnaXMVrT.cjs +0 -2
  58. package/dist/Card-DnaXMVrT.cjs.map +0 -1
  59. package/dist/Card-xv52Ug43.js +0 -61
  60. package/dist/Card-xv52Ug43.js.map +0 -1
  61. package/dist/LoadingDots-Cn2y7g7L.cjs +0 -2
  62. package/dist/LoadingDots-Cn2y7g7L.cjs.map +0 -1
  63. package/dist/LoadingDots-nW6r0-Kg.js +0 -62
  64. package/dist/LoadingDots-nW6r0-Kg.js.map +0 -1
  65. package/dist/TextShell-CKQOFxoH.cjs +0 -2
  66. package/dist/TextShell-CKQOFxoH.cjs.map +0 -1
  67. package/dist/TextShell-DIyj9zQ7.js +0 -40
  68. package/dist/TextShell-DIyj9zQ7.js.map +0 -1
  69. package/dist/index-B8gqCioX.js.map +0 -1
  70. package/dist/index-IkikzyWM.cjs +0 -2
  71. package/dist/index-IkikzyWM.cjs.map +0 -1
  72. package/dist/usePreviewToggle-B0B8cfxy.cjs +0 -2
  73. package/dist/usePreviewToggle-B0B8cfxy.cjs.map +0 -1
  74. package/dist/usePreviewToggle-DRhRTUou.js +0 -357
  75. package/dist/usePreviewToggle-DRhRTUou.js.map +0 -1
  76. package/src/components/LockedAttachment/LockedAttachment.test.tsx +0 -104
  77. package/src/components/LockedAttachment/components/Media/Card.tsx +0 -235
  78. package/src/components/LockedAttachment/components/Text/Card.tsx +0 -177
  79. package/src/components/LockedAttachment/components/_shared/CardThumbnail.tsx +0 -92
  80. package/src/components/LockedAttachment/components/_shared/LoadingDots.tsx +0 -36
  81. package/src/components/LockedAttachment/components/_shared/PreviewToggle.tsx +0 -58
  82. package/src/components/LockedAttachment/components/_shared/PriceLockRow.tsx +0 -21
  83. package/src/components/LockedAttachment/components/_shared/PurchaseStatusBadge.tsx +0 -86
  84. package/src/components/LockedAttachment/components/_shared/SkeletonTextLines.tsx +0 -39
  85. package/src/components/LockedAttachment/components/_shared/TextShell.tsx +0 -19
  86. package/src/components/LockedAttachment/components/_shared/usePreviewToggle.test.ts +0 -67
  87. package/src/components/LockedAttachment/components/_shared/usePreviewToggle.ts +0 -89
  88. package/src/components/LockedAttachment/components/_shared/useReceivedSource.ts +0 -83
@@ -1,173 +1,10 @@
1
1
  import type { Meta, StoryFn } from '@storybook/react'
2
- import classNames from 'classnames'
3
2
  import React, { useState } from 'react'
4
- import { MessageText } from 'stream-chat-react'
5
3
 
6
4
  import type { LockedAttachmentGalleryItem } from './types'
7
5
 
8
6
  import LockedAttachment from '.'
9
7
 
10
- const meta: Meta = {
11
- title: 'LockedAttachment',
12
- parameters: { layout: 'fullscreen' },
13
- }
14
- export default meta
15
-
16
- const MatrixTable: React.FC<{ children: React.ReactNode }> = ({ children }) => (
17
- <div className="str-chat min-h-screen w-full bg-[#F9F7F4] p-12">
18
- <table className="border-separate border-spacing-4">
19
- <thead>
20
- <tr>
21
- <th className="w-8 pb-2" />
22
- <th className="pb-2 text-left text-xs font-medium text-black/40">
23
- Received (buyer&apos;s view)
24
- </th>
25
- <th className="pb-2 text-left text-xs font-medium text-black/40">
26
- Sent (creator&apos;s view)
27
- </th>
28
- </tr>
29
- </thead>
30
- <tbody>{children}</tbody>
31
- </table>
32
- </div>
33
- )
34
-
35
- const MatrixTableRow: React.FC<{
36
- label: React.ReactNode
37
- received: React.ReactNode
38
- sent: React.ReactNode
39
- }> = ({ label, received, sent }) => (
40
- <tr>
41
- <td className="whitespace-nowrap pr-4 align-top text-xs font-medium text-black/40">
42
- {label}
43
- </td>
44
- <td className="align-top">
45
- <MatrixTableCell isMine={false}>{received}</MatrixTableCell>
46
- </td>
47
- <td className="align-top">
48
- <MatrixTableCell isMine>{sent}</MatrixTableCell>
49
- </td>
50
- </tr>
51
- )
52
-
53
- /**
54
- * Mirrors the exact DOM `CustomMessage` produces around a paid TEXT
55
- * attachment (see `CustomMessage/index.tsx`'s `isTextAttachmentMessage`
56
- * branch), so the bubble color/radius CSS custom properties (scoped under
57
- * `.str-chat` in styles.css) resolve the same way they do for the real
58
- * consumer — no hardcoded fallback colors needed in the cards themselves.
59
- */
60
- const MatrixTableCell: React.FC<{
61
- isMine: boolean
62
- children: React.ReactNode
63
- }> = ({ isMine, children }) => (
64
- <div
65
- className={classNames(
66
- 'str-chat__message str-chat__message-simple str-chat__message--regular str-chat__message--received has-no-text',
67
- isMine
68
- ? 'str-chat__message--me str-chat__message-simple--me'
69
- : 'str-chat__message--other'
70
- )}
71
- >
72
- <div className="str-chat__message-inner">
73
- <div className="str-chat__message-bubble-wrapper">{children}</div>
74
- </div>
75
- </div>
76
- )
77
-
78
- export const Text: StoryFn = () => {
79
- const [isUnlocking, setUnlocking] = useState(false)
80
-
81
- // Matches what `CustomMessage` passes `MessageText` for a revealed paid
82
- // text attachment (`displayMessage`) — just enough of a `LocalMessage`
83
- // shape to render the real `str-chat__message-text` markup/CSS.
84
- const purchasedMessage = {
85
- text: "Here's the address, see you Thursday at 7!",
86
- type: 'regular',
87
- } as Parameters<typeof MessageText>[0]['message']
88
-
89
- return (
90
- <MatrixTable>
91
- <MatrixTableRow
92
- label="Preview"
93
- received={null}
94
- sent={
95
- <LockedAttachment.Composer
96
- contentType="text"
97
- placeholderAmountText="AU$0.00"
98
- onDismiss={() => alert('Removed')}
99
- />
100
- }
101
- />
102
- <MatrixTableRow
103
- label="Composer"
104
- received={null}
105
- sent={
106
- <LockedAttachment.Composer
107
- contentType="text"
108
- text={purchasedMessage?.text}
109
- amountText="AU$4.99"
110
- onDismiss={() => alert('Removed')}
111
- />
112
- }
113
- />
114
- <MatrixTableRow
115
- label="Idle"
116
- received={
117
- <LockedAttachment.Text
118
- isMine={false}
119
- amountText="AU$4.99"
120
- isUnlocking={isUnlocking}
121
- onUnlockClick={() => {
122
- setUnlocking(true)
123
- setTimeout(() => setUnlocking(false), 1500)
124
- }}
125
- />
126
- }
127
- sent={
128
- <LockedAttachment.Text
129
- isMine
130
- amountText="AU$4.99"
131
- paymentStatus="pending"
132
- />
133
- }
134
- />
135
- <MatrixTableRow
136
- label="Unlocking"
137
- received={
138
- <LockedAttachment.Text
139
- isMine={false}
140
- amountText="AU$4.99"
141
- isUnlocking
142
- />
143
- }
144
- sent={null}
145
- />
146
- <MatrixTableRow
147
- label="Purchased"
148
- received={
149
- <LockedAttachment.Text
150
- isMine={false}
151
- amountText="AU$4.99"
152
- paymentStatus="paid"
153
- >
154
- <MessageText message={purchasedMessage} />
155
- </LockedAttachment.Text>
156
- }
157
- sent={
158
- <LockedAttachment.Text
159
- isMine
160
- amountText="AU$4.99"
161
- paymentStatus="paid"
162
- >
163
- <MessageText message={purchasedMessage} />
164
- </LockedAttachment.Text>
165
- }
166
- />
167
- </MatrixTable>
168
- )
169
- }
170
-
171
8
  const VIDEO_THUMBNAIL_BLURRED = '/video-thumbnail-blurred.jpg'
172
9
  const VIDEO_THUMBNAIL = '/video-thumbnail.jpg'
173
10
  const VIDEO_SOURCE = '/video-source.mp4'
@@ -184,6 +21,12 @@ const AUDIO_THUMBNAIL_BLURRED = '/audio-thumbnail-blurred.jpg'
184
21
  const AUDIO_THUMBNAIL = '/audio-thumbnail.jpg'
185
22
  const AUDIO_SOURCE = '/audio-source.mp3'
186
23
 
24
+ const meta: Meta = {
25
+ title: 'LockedAttachment',
26
+ parameters: { layout: 'fullscreen' },
27
+ }
28
+ export default meta
29
+
187
30
  const VARIANTS = [
188
31
  {
189
32
  label: 'Video',
@@ -240,189 +83,182 @@ const VARIANTS = [
240
83
  const GALLERY_ITEMS: LockedAttachmentGalleryItem[] = [
241
84
  {
242
85
  mimeType: 'video/mp4',
243
- thumbnailUrl: VIDEO_THUMBNAIL,
86
+ thumbnailUrl: VIDEO_THUMBNAIL_BLURRED,
244
87
  sourceUrl: VIDEO_SOURCE,
245
88
  },
246
89
  {
247
90
  mimeType: 'image/jpeg',
248
- thumbnailUrl: IMAGE_THUMBNAIL,
91
+ thumbnailUrl: IMAGE_THUMBNAIL_BLURRED,
249
92
  sourceUrl: IMAGE_SOURCE,
250
93
  },
251
94
  {
252
- mimeType: 'application/pdf',
253
- thumbnailUrl: DOCUMENT_THUMBNAIL,
95
+ mimeType: 'image/jpeg',
96
+ thumbnailUrl: DOCUMENT_THUMBNAIL_BLURRED,
254
97
  sourceUrl: DOCUMENT_SOURCE,
255
98
  },
256
99
  {
257
- mimeType: 'audio/mpeg',
258
- thumbnailUrl: AUDIO_THUMBNAIL,
100
+ mimeType: 'image/jpeg',
101
+ thumbnailUrl: AUDIO_THUMBNAIL_BLURRED,
259
102
  sourceUrl: AUDIO_SOURCE,
260
103
  },
261
104
  ]
262
105
 
263
- const GALLERY_DETAIL = '1 video, 1 photo, 1 document, 1 audio'
106
+ const GALLERY_DETAIL = '1 video, 3 photos'
264
107
  const GALLERY_TITLE = 'Workout Guide'
265
108
 
266
- const MediaMatrix: React.FC<{ variant: (typeof VARIANTS)[number] }> = ({
267
- variant,
268
- }) => {
269
- const [isPaid, setPaid] = useState(false)
270
- const [isUnlocking, setUnlocking] = useState(false)
271
- const {
272
- title,
273
- mimeType,
274
- detail,
275
- thumbnailUrl,
276
- thumbnailUnlockedUrl,
277
- sourceUrl,
278
- } = variant
279
-
280
- const fetchSource = async () => ({
281
- sourceUrl,
282
- thumbnailUrl: thumbnailUnlockedUrl,
283
- })
284
-
285
- return (
286
- <MatrixTable>
287
- <MatrixTableRow
288
- label="Preview"
289
- received={null}
290
- sent={
291
- <LockedAttachment.Composer
292
- placeholderTitle="Attachment title"
293
- placeholderAmountText="AU$0.00"
294
- thumbnailUrl={thumbnailUrl}
295
- mimeType={mimeType}
296
- detail={detail}
297
- onFetchSource={fetchSource}
298
- />
299
- }
300
- />
301
- <MatrixTableRow
302
- label="Composer"
303
- received={null}
304
- sent={
305
- <LockedAttachment.Composer
306
- title={title}
307
- thumbnailUrl={thumbnailUrl}
308
- mimeType={mimeType}
309
- detail={detail}
310
- amountText="AU$9.99"
311
- onDismiss={() => alert('Dismissed')}
312
- />
313
- }
314
- />
315
- <MatrixTableRow
316
- label="Idle"
317
- received={
318
- <LockedAttachment.Media
319
- isMine={false}
320
- title={title}
321
- thumbnailUrl={thumbnailUrl}
322
- mimeType={mimeType}
323
- detail={detail}
324
- amountText="AU$9.99"
325
- paymentStatus={isPaid ? 'paid' : undefined}
326
- isUnlocking={isUnlocking}
327
- onUnlockClick={() => {
328
- setUnlocking(true)
329
- setTimeout(() => {
330
- setUnlocking(false)
331
- setPaid(true)
332
- }, 1500)
333
- }}
334
- onDownloadClick={() => alert('Download clicked')}
335
- onFetchSource={fetchSource}
336
- />
337
- }
338
- sent={
339
- <LockedAttachment.Media
340
- isMine
341
- title={title}
342
- thumbnailUrl={thumbnailUrl}
343
- mimeType={mimeType}
344
- detail={detail}
345
- amountText="AU$9.99"
346
- onFetchSource={fetchSource}
347
- />
348
- }
349
- />
350
- <MatrixTableRow
351
- label="Unlocking"
352
- received={
353
- <LockedAttachment.Media
354
- isMine={false}
355
- title={title}
356
- thumbnailUrl={thumbnailUrl}
357
- mimeType={mimeType}
358
- detail={detail}
359
- amountText="AU$9.99"
360
- isUnlocking
361
- onDownloadClick={() => alert('Download clicked')}
362
- onFetchSource={fetchSource}
363
- />
364
- }
365
- // Sender never unlocks their own message — no distinct state to show.
366
- sent={null}
367
- />
368
- <MatrixTableRow
369
- label="Purchased"
370
- received={
371
- <LockedAttachment.Media
372
- isMine={false}
373
- title={title}
374
- thumbnailUrl={thumbnailUrl}
375
- mimeType={mimeType}
376
- detail={detail}
377
- amountText="AU$9.99"
378
- paymentStatus="paid"
379
- onUnlockClick={() => alert('Unlock clicked')}
380
- onDownloadClick={() => alert('Download clicked')}
381
- onFetchSource={fetchSource}
382
- />
383
- }
384
- sent={
385
- <LockedAttachment.Media
386
- isMine
387
- title={title}
388
- thumbnailUrl={thumbnailUrl}
389
- mimeType={mimeType}
390
- detail={detail}
391
- amountText="AU$9.99"
392
- paymentStatus="paid"
393
- onFetchSource={fetchSource}
394
- />
395
- }
396
- />
397
- </MatrixTable>
398
- )
399
- }
400
-
401
- const variantByLabel = (label: string) =>
402
- VARIANTS.find((v) => v.label === label)!
403
-
404
- export const Video: StoryFn = () => (
405
- <MediaMatrix variant={variantByLabel('Video')} />
406
- )
407
- // LockedAttachment.Media (!isMine) autoplays the video preview once paid; even with
408
- // our SMIL/CSS animation freeze the <video> element advances frames
409
- // independently and produces a non-deterministic snapshot. Skip in Chromatic.
410
- Video.parameters = { chromatic: { disableSnapshot: true } }
411
-
412
- export const Audio: StoryFn = () => (
413
- <MediaMatrix variant={variantByLabel('Audio')} />
109
+ const Table = ({ children }: { children: React.ReactNode }) => (
110
+ <div className="min-h-screen w-full p-12 bg-[#F9F7F4]">
111
+ <table className="border-separate border-spacing-4">{children}</table>
112
+ </div>
414
113
  )
415
114
 
416
- export const Image: StoryFn = () => (
417
- <MediaMatrix variant={variantByLabel('Image')} />
115
+ const TableHead = ({
116
+ variants,
117
+ }: {
118
+ variants: { label: string; mimeType: string }[]
119
+ }) => (
120
+ <thead>
121
+ <tr>
122
+ <th className="text-left text-xs font-medium text-black/40 pb-2" />
123
+ {variants.map(({ label, mimeType }) => (
124
+ <th
125
+ key={mimeType}
126
+ className="text-left text-xs font-medium text-black/40 pb-2"
127
+ >
128
+ {label}
129
+ </th>
130
+ ))}
131
+ </tr>
132
+ </thead>
418
133
  )
419
134
 
420
- export const Document: StoryFn = () => (
421
- <MediaMatrix variant={variantByLabel('Document')} />
135
+ export const Composer: StoryFn = () => (
136
+ <Table>
137
+ <TableHead variants={VARIANTS} />
138
+ <tbody>
139
+ <tr>
140
+ <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
141
+ Preview
142
+ </td>
143
+ {VARIANTS.map(
144
+ ({
145
+ mimeType,
146
+ detail,
147
+ thumbnailUrl,
148
+ thumbnailUnlockedUrl,
149
+ sourceUrl,
150
+ }) => (
151
+ <td key={mimeType} className="align-top">
152
+ <LockedAttachment.Composer
153
+ placeholderTitle="Attachment title"
154
+ placeholderAmountText="AU$0.00"
155
+ thumbnailUrl={thumbnailUrl}
156
+ mimeType={mimeType}
157
+ detail={detail}
158
+ onFetchSource={async () => {
159
+ await new Promise((resolve) => setTimeout(resolve, 1500))
160
+ return {
161
+ sourceUrl: sourceUrl,
162
+ thumbnailUrl: thumbnailUnlockedUrl,
163
+ }
164
+ }}
165
+ />
166
+ </td>
167
+ )
168
+ )}
169
+ </tr>
170
+ <tr>
171
+ <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
172
+ Pending
173
+ </td>
174
+ {VARIANTS.map(({ title, mimeType, detail, thumbnailUrl }) => (
175
+ <td key={mimeType} className="align-top">
176
+ <LockedAttachment.Composer
177
+ title={title}
178
+ thumbnailUrl={thumbnailUrl}
179
+ mimeType={mimeType}
180
+ detail={detail}
181
+ amountText="AU$9.99"
182
+ onDismiss={() => alert('Dismissed')}
183
+ />
184
+ </td>
185
+ ))}
186
+ </tr>
187
+ </tbody>
188
+ </Table>
422
189
  )
423
190
 
424
- export const Unknown: StoryFn = () => (
425
- <MediaMatrix variant={variantByLabel('Unknown')} />
191
+ export const Sent: StoryFn = () => (
192
+ <Table>
193
+ <TableHead variants={VARIANTS} />
194
+ <tbody>
195
+ <tr>
196
+ <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
197
+ Sent
198
+ </td>
199
+ {VARIANTS.map(
200
+ ({
201
+ title,
202
+ mimeType,
203
+ detail,
204
+ thumbnailUrl,
205
+ thumbnailUnlockedUrl,
206
+ sourceUrl,
207
+ }) => (
208
+ <td key={mimeType} className="align-top">
209
+ <LockedAttachment.Sent
210
+ title={title}
211
+ thumbnailUrl={thumbnailUrl}
212
+ mimeType={mimeType}
213
+ detail={detail}
214
+ amountText="AU$9.99"
215
+ onFetchSource={async () => {
216
+ await new Promise((resolve) => setTimeout(resolve, 1500))
217
+ return {
218
+ sourceUrl: sourceUrl,
219
+ thumbnailUrl: thumbnailUnlockedUrl,
220
+ }
221
+ }}
222
+ />
223
+ </td>
224
+ )
225
+ )}
226
+ </tr>
227
+ <tr>
228
+ <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
229
+ Sold
230
+ </td>
231
+ {VARIANTS.map(
232
+ ({
233
+ title,
234
+ mimeType,
235
+ detail,
236
+ thumbnailUrl,
237
+ thumbnailUnlockedUrl,
238
+ sourceUrl,
239
+ }) => (
240
+ <td key={mimeType} className="align-top">
241
+ <LockedAttachment.Sent
242
+ title={title}
243
+ thumbnailUrl={thumbnailUrl}
244
+ mimeType={mimeType}
245
+ detail={detail}
246
+ amountText="AU$9.99"
247
+ paymentStatus="paid"
248
+ onFetchSource={async () => {
249
+ await new Promise((resolve) => setTimeout(resolve, 1500))
250
+ return {
251
+ sourceUrl: sourceUrl,
252
+ thumbnailUrl: thumbnailUnlockedUrl,
253
+ }
254
+ }}
255
+ />
256
+ </td>
257
+ )
258
+ )}
259
+ </tr>
260
+ </tbody>
261
+ </Table>
426
262
  )
427
263
 
428
264
  export const Gallery: StoryFn = () => {
@@ -430,103 +266,185 @@ export const Gallery: StoryFn = () => {
430
266
  const [isUnlocking, setUnlocking] = useState(false)
431
267
 
432
268
  return (
433
- <MatrixTable>
434
- <MatrixTableRow
435
- label="Preview"
436
- received={null}
437
- sent={
438
- <LockedAttachment.Composer
439
- detail={GALLERY_DETAIL}
440
- gallery={GALLERY_ITEMS}
441
- />
442
- }
443
- />
444
- <MatrixTableRow
445
- label="Composer"
446
- received={null}
447
- sent={
448
- <LockedAttachment.Composer
449
- title={GALLERY_TITLE}
450
- detail={GALLERY_DETAIL}
451
- amountText="AU$50.00"
452
- gallery={GALLERY_ITEMS}
453
- onDismiss={() => alert('Dismissed gallery')}
454
- onEditClick={() => alert('Edit gallery')}
455
- />
456
- }
457
- />
458
- <MatrixTableRow
459
- label="Idle"
460
- received={
461
- <LockedAttachment.Media
462
- isMine={false}
463
- title={GALLERY_TITLE}
464
- detail={GALLERY_DETAIL}
465
- amountText="AU$50.00"
466
- gallery={GALLERY_ITEMS}
467
- paymentStatus={isPaid ? 'paid' : undefined}
468
- isUnlocking={isUnlocking}
469
- onUnlockClick={() => {
470
- setUnlocking(true)
471
- setTimeout(() => {
472
- setUnlocking(false)
473
- setPaid(true)
474
- }, 1500)
475
- }}
476
- onDownloadClick={() => alert('Download gallery')}
477
- />
478
- }
479
- sent={
480
- <LockedAttachment.Media
481
- isMine
482
- title={GALLERY_TITLE}
483
- detail={GALLERY_DETAIL}
484
- amountText="AU$50.00"
485
- gallery={GALLERY_ITEMS}
486
- />
487
- }
488
- />
489
- <MatrixTableRow
490
- label="Unlocking"
491
- received={
492
- <LockedAttachment.Media
493
- isMine={false}
494
- title={GALLERY_TITLE}
495
- detail={GALLERY_DETAIL}
496
- amountText="AU$50.00"
497
- gallery={GALLERY_ITEMS}
498
- isUnlocking
499
- onDownloadClick={() => alert('Download gallery')}
500
- />
501
- }
502
- // Sender never unlocks their own message — no distinct state to show.
503
- sent={null}
504
- />
505
- <MatrixTableRow
506
- label="Purchased"
507
- received={
508
- <LockedAttachment.Media
509
- isMine={false}
510
- title={GALLERY_TITLE}
511
- detail={GALLERY_DETAIL}
512
- amountText="AU$50.00"
513
- paymentStatus="paid"
514
- gallery={GALLERY_ITEMS}
515
- onUnlockClick={() => alert('Unlock clicked')}
516
- onDownloadClick={() => alert('Download gallery')}
517
- />
518
- }
519
- sent={
520
- <LockedAttachment.Media
521
- isMine
522
- title={GALLERY_TITLE}
523
- detail={GALLERY_DETAIL}
524
- amountText="AU$50.00"
525
- paymentStatus="paid"
526
- gallery={GALLERY_ITEMS}
527
- />
528
- }
529
- />
530
- </MatrixTable>
269
+ <Table>
270
+ <thead>
271
+ <tr>
272
+ <th className="text-left text-xs font-medium text-black/40 pb-2" />
273
+ <th className="text-left text-xs font-medium text-black/40 pb-2">
274
+ Composer
275
+ </th>
276
+ <th className="text-left text-xs font-medium text-black/40 pb-2">
277
+ Sent
278
+ </th>
279
+ <th className="text-left text-xs font-medium text-black/40 pb-2">
280
+ Received
281
+ </th>
282
+ </tr>
283
+ </thead>
284
+ <tbody>
285
+ <tr>
286
+ <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
287
+ Locked
288
+ </td>
289
+ <td className="align-top">
290
+ <LockedAttachment.Composer
291
+ title={GALLERY_TITLE}
292
+ detail={GALLERY_DETAIL}
293
+ amountText="AU$50.00"
294
+ gallery={GALLERY_ITEMS}
295
+ onDismiss={() => alert('Dismissed gallery')}
296
+ onEditClick={() => alert('Edit gallery')}
297
+ />
298
+ </td>
299
+ <td className="align-top">
300
+ <LockedAttachment.Sent
301
+ title={GALLERY_TITLE}
302
+ detail={GALLERY_DETAIL}
303
+ amountText="AU$50.00"
304
+ gallery={GALLERY_ITEMS}
305
+ />
306
+ </td>
307
+ <td className="align-top">
308
+ <LockedAttachment.Received
309
+ title={GALLERY_TITLE}
310
+ detail={GALLERY_DETAIL}
311
+ amountText="AU$50.00"
312
+ gallery={GALLERY_ITEMS}
313
+ paymentStatus={isPaid ? 'paid' : undefined}
314
+ isUnlocking={isUnlocking}
315
+ onUnlockClick={() => {
316
+ setUnlocking(true)
317
+ setTimeout(() => {
318
+ setUnlocking(false)
319
+ setPaid(true)
320
+ }, 1500)
321
+ }}
322
+ onDownloadClick={() => alert('Download gallery')}
323
+ />
324
+ </td>
325
+ </tr>
326
+ <tr>
327
+ <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
328
+ Sold / Purchased
329
+ </td>
330
+ <td className="align-top">
331
+ <LockedAttachment.Composer
332
+ title={GALLERY_TITLE}
333
+ detail={GALLERY_DETAIL}
334
+ amountText="AU$50.00"
335
+ gallery={GALLERY_ITEMS}
336
+ onEditClick={() => alert('Edit gallery')}
337
+ />
338
+ </td>
339
+ <td className="align-top">
340
+ <LockedAttachment.Sent
341
+ title={GALLERY_TITLE}
342
+ detail={GALLERY_DETAIL}
343
+ amountText="AU$50.00"
344
+ paymentStatus="paid"
345
+ gallery={GALLERY_ITEMS}
346
+ />
347
+ </td>
348
+ <td className="align-top">
349
+ <LockedAttachment.Received
350
+ title={GALLERY_TITLE}
351
+ detail={GALLERY_DETAIL}
352
+ amountText="AU$50.00"
353
+ paymentStatus="paid"
354
+ gallery={GALLERY_ITEMS}
355
+ onDownloadClick={() => alert('Download gallery')}
356
+ />
357
+ </td>
358
+ </tr>
359
+ </tbody>
360
+ </Table>
531
361
  )
532
362
  }
363
+
364
+ export const Received: StoryFn = () => {
365
+ const [isPaid, setPaid] = useState<string | undefined>()
366
+ const [isUnlocking, setUnlocking] = useState<string | undefined>()
367
+
368
+ return (
369
+ <Table>
370
+ <TableHead variants={VARIANTS} />
371
+ <tbody>
372
+ <tr>
373
+ <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
374
+ Locked
375
+ </td>
376
+ {VARIANTS.map(
377
+ ({
378
+ title,
379
+ mimeType,
380
+ detail,
381
+ thumbnailUrl,
382
+ thumbnailUnlockedUrl,
383
+ sourceUrl,
384
+ }) => (
385
+ <td key={mimeType} className="align-top">
386
+ <LockedAttachment.Received
387
+ title={title}
388
+ thumbnailUrl={thumbnailUrl}
389
+ mimeType={mimeType}
390
+ detail={detail}
391
+ paymentStatus={isPaid === mimeType ? 'paid' : undefined}
392
+ amountText="AU$9.99"
393
+ isUnlocking={isUnlocking === mimeType}
394
+ onUnlockClick={() => {
395
+ setUnlocking(mimeType)
396
+ setTimeout(() => {
397
+ setUnlocking(undefined)
398
+ setPaid(mimeType)
399
+ }, 1500)
400
+ }}
401
+ onDownloadClick={() => alert('Download clicked')}
402
+ onFetchSource={async () => ({
403
+ sourceUrl: sourceUrl,
404
+ thumbnailUrl: thumbnailUnlockedUrl,
405
+ })}
406
+ />
407
+ </td>
408
+ )
409
+ )}
410
+ </tr>
411
+ <tr>
412
+ <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
413
+ Unlocked
414
+ </td>
415
+ {VARIANTS.map(
416
+ ({
417
+ title,
418
+ mimeType,
419
+ detail,
420
+ thumbnailUrl,
421
+ thumbnailUnlockedUrl,
422
+ sourceUrl,
423
+ }) => (
424
+ <td key={mimeType} className="align-top">
425
+ <LockedAttachment.Received
426
+ title={title}
427
+ thumbnailUrl={thumbnailUrl}
428
+ mimeType={mimeType}
429
+ detail={detail}
430
+ amountText="AU$9.99"
431
+ paymentStatus="paid"
432
+ onUnlockClick={() => alert('Unlock clicked')}
433
+ onDownloadClick={() => alert('Download clicked')}
434
+ onFetchSource={async () => ({
435
+ sourceUrl: sourceUrl,
436
+ thumbnailUrl: thumbnailUnlockedUrl,
437
+ })}
438
+ />
439
+ </td>
440
+ )
441
+ )}
442
+ </tr>
443
+ </tbody>
444
+ </Table>
445
+ )
446
+ }
447
+ // LockedAttachment.Received autoplays the video preview once paid; even with
448
+ // our SMIL/CSS animation freeze the <video> element advances frames
449
+ // independently and produces a non-deterministic snapshot. Skip in Chromatic.
450
+ Received.parameters = { chromatic: { disableSnapshot: true } }