@linktr.ee/messaging-react 4.2.1 → 4.3.0-rc-1787410254

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.
@@ -1,270 +0,0 @@
1
- import type { Meta, StoryFn } from '@storybook/react'
2
- import React from 'react'
3
- import type { LocalMessage } from 'stream-chat'
4
-
5
- import { now } from '../../stories/decorators/storyTime'
6
-
7
- import { MediaMessage } from '.'
8
-
9
- const meta: Meta<typeof MediaMessage> = {
10
- title: 'MediaMessage',
11
- component: MediaMessage,
12
- parameters: {
13
- layout: 'fullscreen',
14
- },
15
- }
16
- export default meta
17
-
18
- type MessageAttachment = NonNullable<LocalMessage['attachments']>[number]
19
-
20
- const base = (overrides: Partial<LocalMessage> = {}): LocalMessage => {
21
- const defaultMessage: LocalMessage = {
22
- id: 'msg-1',
23
- text: '',
24
- type: 'regular',
25
- created_at: now(),
26
- updated_at: now(),
27
- deleted_at: null,
28
- pinned_at: null,
29
- status: 'received',
30
- attachments: [],
31
- }
32
-
33
- return {
34
- ...defaultMessage,
35
- ...overrides,
36
- created_at: overrides.created_at ?? defaultMessage.created_at,
37
- updated_at: overrides.updated_at ?? defaultMessage.updated_at,
38
- deleted_at: overrides.deleted_at ?? defaultMessage.deleted_at,
39
- pinned_at: overrides.pinned_at ?? defaultMessage.pinned_at,
40
- status: overrides.status ?? defaultMessage.status,
41
- }
42
- }
43
-
44
- const VARIANTS = [
45
- {
46
- label: 'Video',
47
- attachment: {
48
- type: 'video',
49
- asset_url: 'https://www.w3schools.com/html/mov_bbb.mp4',
50
- mime_type: 'video/mp4',
51
- title: "Alicia's Workout Plan",
52
- file_size: 788_456,
53
- },
54
- },
55
- {
56
- label: 'Audio',
57
- attachment: {
58
- type: 'audio',
59
- asset_url:
60
- 'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3',
61
- mime_type: 'audio/mpeg',
62
- title: 'Morning Meditation',
63
- file_size: 6_900_000,
64
- },
65
- },
66
- {
67
- label: 'Image',
68
- attachment: {
69
- type: 'image',
70
- image_url: 'https://picsum.photos/seed/storybook/560/315',
71
- mime_type: 'image/jpeg',
72
- title: 'Picture of my cat',
73
- file_size: 3_355_443,
74
- },
75
- },
76
- {
77
- label: 'Document',
78
- attachment: {
79
- type: 'file',
80
- asset_url: 'https://www.w3.org/WAI/WCAG21/wcag21.pdf',
81
- mime_type: 'application/pdf',
82
- title: 'Strength Training Guide',
83
- file_size: 1_240_000,
84
- },
85
- },
86
- {
87
- label: 'Unknown',
88
- attachment: {
89
- type: 'file',
90
- asset_url: 'https://www.w3.org/WAI/WCAG21/wcag21.pdf',
91
- mime_type: 'application/octet-stream',
92
- title: 'Unknown Attachment',
93
- file_size: 456_000,
94
- },
95
- },
96
- ] as const
97
-
98
- const LINK_VARIANTS = [
99
- {
100
- label: 'With image',
101
- attachment: {
102
- type: 'link',
103
- og_scrape_url: 'https://linktr.ee/brieparsons',
104
- title: 'World Famous 3 Bottle Grey Wash Set',
105
- text: 'When its time to shade, the World Famous Grey Wash set has you covered.',
106
- image_url: 'https://picsum.photos/seed/linkcard/560/315',
107
- },
108
- },
109
- {
110
- label: 'No image',
111
- attachment: {
112
- type: 'link',
113
- og_scrape_url: 'https://linktr.ee/brieparsons',
114
- title: 'World Famous 3 Bottle Grey Wash Set',
115
- text: 'When its time to shade, the World Famous Grey Wash set has you covered.',
116
- },
117
- },
118
- {
119
- label: 'Title only',
120
- attachment: {
121
- type: 'link',
122
- og_scrape_url: 'https://linktr.ee/someone',
123
- title: 'Check out my Linktree',
124
- },
125
- },
126
- {
127
- label: 'URL only',
128
- attachment: {
129
- type: 'link',
130
- og_scrape_url: 'https://linktr.ee/someone',
131
- },
132
- },
133
- ] as const
134
-
135
- const Table: React.FC<{ children: React.ReactNode }> = ({ children }) => (
136
- <div className="min-h-screen w-full p-12 bg-[#F9F7F4]">
137
- <table className="border-separate border-spacing-4">{children}</table>
138
- </div>
139
- )
140
-
141
- const TableHead: React.FC<{ variants: readonly { label: string }[] }> = ({
142
- variants,
143
- }) => (
144
- <thead>
145
- <tr>
146
- <th className="text-left text-xs font-medium text-black/40 pb-2" />
147
- {variants.map(({ label }) => (
148
- <th
149
- key={label}
150
- className="text-left text-xs font-medium text-black/40 pb-2"
151
- >
152
- {label}
153
- </th>
154
- ))}
155
- </tr>
156
- </thead>
157
- )
158
-
159
- export const Attachment: StoryFn = () => (
160
- <Table>
161
- <TableHead variants={VARIANTS} />
162
- <tbody>
163
- <tr>
164
- <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
165
- Visitor
166
- </td>
167
- {VARIANTS.map(({ label, attachment }) => (
168
- <td key={label} className="align-top">
169
- <MediaMessage
170
- isMyMessage={false}
171
- message={base({
172
- attachments: [attachment as MessageAttachment],
173
- })}
174
- />
175
- </td>
176
- ))}
177
- </tr>
178
- <tr>
179
- <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
180
- Creator
181
- </td>
182
- {VARIANTS.map(({ label, attachment }) => (
183
- <td key={label} className="align-top">
184
- <MediaMessage
185
- isMyMessage={true}
186
- message={base({
187
- attachments: [attachment as MessageAttachment],
188
- })}
189
- />
190
- </td>
191
- ))}
192
- </tr>
193
- </tbody>
194
- </Table>
195
- )
196
-
197
- export const Links: StoryFn = () => (
198
- <Table>
199
- <TableHead variants={LINK_VARIANTS} />
200
- <tbody>
201
- <tr>
202
- <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
203
- Visitor
204
- </td>
205
- {LINK_VARIANTS.map(({ label, attachment }) => (
206
- <td key={label} className="align-top">
207
- <MediaMessage
208
- isMyMessage={false}
209
- message={base({
210
- attachments: [attachment as MessageAttachment],
211
- })}
212
- />
213
- </td>
214
- ))}
215
- </tr>
216
- <tr>
217
- <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
218
- Creator
219
- </td>
220
- {LINK_VARIANTS.map(({ label, attachment }) => (
221
- <td key={label} className="align-top">
222
- <MediaMessage
223
- isMyMessage={true}
224
- message={base({
225
- attachments: [attachment as MessageAttachment],
226
- })}
227
- />
228
- </td>
229
- ))}
230
- </tr>
231
- </tbody>
232
- </Table>
233
- )
234
-
235
- /** Standalone cards (no chat bubble shell), matching LockedAttachment story layout. */
236
- export const Compound: StoryFn = () => (
237
- <Table>
238
- <TableHead variants={VARIANTS} />
239
- <tbody>
240
- <tr>
241
- <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
242
- MediaMessage.Visitor
243
- </td>
244
- {VARIANTS.map(({ label, attachment }) => (
245
- <td key={label} className="align-top">
246
- <MediaMessage.Visitor
247
- message={base({
248
- attachments: [attachment as MessageAttachment],
249
- })}
250
- />
251
- </td>
252
- ))}
253
- </tr>
254
- <tr>
255
- <td className="text-xs text-right font-medium text-black/40 pr-4 align-top pt-2">
256
- MediaMessage.Creator
257
- </td>
258
- {VARIANTS.map(({ label, attachment }) => (
259
- <td key={label} className="align-top">
260
- <MediaMessage.Creator
261
- message={base({
262
- attachments: [attachment as MessageAttachment],
263
- })}
264
- />
265
- </td>
266
- ))}
267
- </tr>
268
- </tbody>
269
- </Table>
270
- )