@linktr.ee/messaging-react 1.32.1 → 1.33.0-rc-1777504230
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/{Card-ClE_iExA.js → Card-BsqYzZt1.js} +55 -55
- package/dist/Card-BsqYzZt1.js.map +1 -0
- package/dist/{Card-1CQEn-OT.js → Card-Cnn9V-W7.js} +44 -44
- package/dist/Card-Cnn9V-W7.js.map +1 -0
- package/dist/assets/index.css +1 -1
- package/dist/index-BMfupE8K.js +3130 -0
- package/dist/index-BMfupE8K.js.map +1 -0
- package/dist/index.d.ts +19 -1
- package/dist/index.js +20 -2477
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ChannelInfoDialog/index.tsx +3 -1
- package/src/components/ChannelView.stories.tsx +38 -0
- package/src/components/ChannelView.test.tsx +25 -6
- package/src/components/ChannelView.tsx +26 -6
- package/src/components/CustomMessageInput/CustomMessageInput.stories.tsx +180 -0
- package/src/components/CustomMessageInput/CustomMessageInput.test.tsx +63 -1
- package/src/components/CustomMessageInput/index.tsx +24 -5
- package/src/components/LockedAttachment/components/Creator/Card.tsx +11 -11
- package/src/components/LockedAttachment/components/MediaPlayer.tsx +10 -1
- package/src/components/LockedAttachment/components/Visitor/Card.tsx +9 -9
- package/src/components/LockedAttachment/components/Visitor/CardActions.tsx +2 -2
- package/src/components/MediaMessage/MediaMessage.stories.tsx +233 -0
- package/src/components/MediaMessage/MediaMessage.test.tsx +520 -0
- package/src/components/MediaMessage/index.tsx +476 -0
- package/src/components/MessagingShell/index.tsx +2 -0
- package/src/index.ts +2 -0
- package/src/styles.css +49 -0
- package/src/types.ts +13 -0
- package/dist/Card-1CQEn-OT.js.map +0 -1
- package/dist/Card-ClE_iExA.js.map +0 -1
- package/dist/MediaPlayer-B9Ws2NeE.js +0 -292
- package/dist/MediaPlayer-B9Ws2NeE.js.map +0 -1
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import type { Meta, StoryFn } from '@storybook/react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import type { LocalMessage } from 'stream-chat'
|
|
4
|
+
|
|
5
|
+
import { MediaMessage } from '.'
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof MediaMessage> = {
|
|
8
|
+
title: 'Components/MediaMessage',
|
|
9
|
+
component: MediaMessage,
|
|
10
|
+
parameters: {
|
|
11
|
+
layout: 'centered',
|
|
12
|
+
},
|
|
13
|
+
}
|
|
14
|
+
export default meta
|
|
15
|
+
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Shared helpers
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
const SENDER = { id: 'user-other', name: 'Jane Creator', image: 'https://i.pravatar.cc/40?img=5' }
|
|
21
|
+
const ME = { id: 'user-me', name: 'Me' }
|
|
22
|
+
|
|
23
|
+
const base = (overrides: Partial<LocalMessage> = {}): LocalMessage => ({
|
|
24
|
+
id: 'msg-1',
|
|
25
|
+
text: '',
|
|
26
|
+
type: 'regular',
|
|
27
|
+
created_at: new Date(),
|
|
28
|
+
updated_at: new Date(),
|
|
29
|
+
user: SENDER,
|
|
30
|
+
attachments: [],
|
|
31
|
+
...overrides,
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const VARIANTS = [
|
|
35
|
+
{
|
|
36
|
+
label: 'Video',
|
|
37
|
+
attachment: {
|
|
38
|
+
type: 'video',
|
|
39
|
+
asset_url: 'https://www.w3schools.com/html/mov_bbb.mp4',
|
|
40
|
+
mime_type: 'video/mp4',
|
|
41
|
+
title: "Alicia's Workout Plan",
|
|
42
|
+
file_size: 788_456,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
label: 'Audio',
|
|
47
|
+
attachment: {
|
|
48
|
+
type: 'audio',
|
|
49
|
+
asset_url: 'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3',
|
|
50
|
+
mime_type: 'audio/mpeg',
|
|
51
|
+
title: 'Morning Meditation',
|
|
52
|
+
file_size: 6_900_000,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
label: 'Image',
|
|
57
|
+
attachment: {
|
|
58
|
+
type: 'image',
|
|
59
|
+
image_url: 'https://picsum.photos/seed/storybook/560/315',
|
|
60
|
+
mime_type: 'image/jpeg',
|
|
61
|
+
title: 'Picture of my cat',
|
|
62
|
+
file_size: 3_355_443,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
label: 'Document',
|
|
67
|
+
attachment: {
|
|
68
|
+
type: 'file',
|
|
69
|
+
asset_url: 'https://www.w3.org/WAI/WCAG21/wcag21.pdf',
|
|
70
|
+
mime_type: 'application/pdf',
|
|
71
|
+
title: 'Strength Training Guide',
|
|
72
|
+
file_size: 1_240_000,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
label: 'Unknown',
|
|
77
|
+
attachment: {
|
|
78
|
+
type: 'file',
|
|
79
|
+
asset_url: 'https://www.w3.org/WAI/WCAG21/wcag21.pdf',
|
|
80
|
+
mime_type: 'application/octet-stream',
|
|
81
|
+
title: 'Unknown Attachment',
|
|
82
|
+
file_size: 456_000,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
] as const
|
|
86
|
+
|
|
87
|
+
const LINK_VARIANTS = [
|
|
88
|
+
{
|
|
89
|
+
label: 'With image',
|
|
90
|
+
attachment: {
|
|
91
|
+
type: 'link',
|
|
92
|
+
og_scrape_url: 'https://linktr.ee/brieparsons',
|
|
93
|
+
title: 'World Famous 3 Bottle Grey Wash Set',
|
|
94
|
+
text: 'When its time to shade, the World Famous Grey Wash set has you covered.',
|
|
95
|
+
image_url: 'https://picsum.photos/seed/linkcard/560/315',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
label: 'No image',
|
|
100
|
+
attachment: {
|
|
101
|
+
type: 'link',
|
|
102
|
+
og_scrape_url: 'https://linktr.ee/brieparsons',
|
|
103
|
+
title: 'World Famous 3 Bottle Grey Wash Set',
|
|
104
|
+
text: 'When its time to shade, the World Famous Grey Wash set has you covered.',
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
label: 'Title only',
|
|
109
|
+
attachment: {
|
|
110
|
+
type: 'link',
|
|
111
|
+
og_scrape_url: 'https://linktr.ee/someone',
|
|
112
|
+
title: 'Check out my Linktree',
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
label: 'URL only',
|
|
117
|
+
attachment: {
|
|
118
|
+
type: 'link',
|
|
119
|
+
og_scrape_url: 'https://linktr.ee/someone',
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
] as const
|
|
123
|
+
|
|
124
|
+
// ---------------------------------------------------------------------------
|
|
125
|
+
// Layout primitives
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
|
|
128
|
+
const GridTable: React.FC<{ children: React.ReactNode }> = ({ children }) => (
|
|
129
|
+
<div className="p-12 bg-[#F9F7F4]">
|
|
130
|
+
<table className="border-separate border-spacing-4">{children}</table>
|
|
131
|
+
</div>
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
const GridHead: React.FC<{ labels: readonly string[] }> = ({ labels }) => (
|
|
135
|
+
<thead>
|
|
136
|
+
<tr>
|
|
137
|
+
{labels.map((label) => (
|
|
138
|
+
<th key={label} className="text-left text-xs font-medium text-black/40 pb-2">
|
|
139
|
+
{label}
|
|
140
|
+
</th>
|
|
141
|
+
))}
|
|
142
|
+
</tr>
|
|
143
|
+
</thead>
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
// ---------------------------------------------------------------------------
|
|
147
|
+
// Stories
|
|
148
|
+
// ---------------------------------------------------------------------------
|
|
149
|
+
|
|
150
|
+
export const Received: StoryFn = () => (
|
|
151
|
+
<GridTable>
|
|
152
|
+
<GridHead labels={VARIANTS.map((v) => v.label)} />
|
|
153
|
+
<tbody>
|
|
154
|
+
<tr>
|
|
155
|
+
{VARIANTS.map(({ label, attachment }) => (
|
|
156
|
+
<td key={label} className="align-top">
|
|
157
|
+
<MediaMessage
|
|
158
|
+
isMyMessage={false}
|
|
159
|
+
message={base({ user: SENDER, attachments: [attachment as LocalMessage['attachments'][number]] })}
|
|
160
|
+
/>
|
|
161
|
+
</td>
|
|
162
|
+
))}
|
|
163
|
+
</tr>
|
|
164
|
+
</tbody>
|
|
165
|
+
</GridTable>
|
|
166
|
+
)
|
|
167
|
+
Received.parameters = {
|
|
168
|
+
docs: {
|
|
169
|
+
description: {
|
|
170
|
+
story: 'Received messages — left-aligned with avatar, light gray card background.',
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export const Sent: StoryFn = () => (
|
|
176
|
+
<GridTable>
|
|
177
|
+
<GridHead labels={VARIANTS.map((v) => v.label)} />
|
|
178
|
+
<tbody>
|
|
179
|
+
<tr>
|
|
180
|
+
{VARIANTS.map(({ label, attachment }) => (
|
|
181
|
+
<td key={label} className="align-top">
|
|
182
|
+
<MediaMessage
|
|
183
|
+
isMyMessage={true}
|
|
184
|
+
message={base({ user: ME, attachments: [attachment as LocalMessage['attachments'][number]] })}
|
|
185
|
+
/>
|
|
186
|
+
</td>
|
|
187
|
+
))}
|
|
188
|
+
</tr>
|
|
189
|
+
</tbody>
|
|
190
|
+
</GridTable>
|
|
191
|
+
)
|
|
192
|
+
Sent.parameters = {
|
|
193
|
+
docs: {
|
|
194
|
+
description: {
|
|
195
|
+
story: 'Sent messages — right-aligned, no avatar, black card background.',
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export const Links: StoryFn = () => (
|
|
201
|
+
<GridTable>
|
|
202
|
+
<GridHead labels={LINK_VARIANTS.map((v) => v.label)} />
|
|
203
|
+
<tbody>
|
|
204
|
+
<tr>
|
|
205
|
+
{LINK_VARIANTS.map(({ label, attachment }) => (
|
|
206
|
+
<td key={label} className="align-top">
|
|
207
|
+
<MediaMessage
|
|
208
|
+
isMyMessage={false}
|
|
209
|
+
message={base({ user: SENDER, attachments: [attachment as LocalMessage['attachments'][number]] })}
|
|
210
|
+
/>
|
|
211
|
+
</td>
|
|
212
|
+
))}
|
|
213
|
+
</tr>
|
|
214
|
+
<tr>
|
|
215
|
+
{LINK_VARIANTS.map(({ label, attachment }) => (
|
|
216
|
+
<td key={label} className="align-top">
|
|
217
|
+
<MediaMessage
|
|
218
|
+
isMyMessage={true}
|
|
219
|
+
message={base({ user: ME, attachments: [attachment as LocalMessage['attachments'][number]] })}
|
|
220
|
+
/>
|
|
221
|
+
</td>
|
|
222
|
+
))}
|
|
223
|
+
</tr>
|
|
224
|
+
</tbody>
|
|
225
|
+
</GridTable>
|
|
226
|
+
)
|
|
227
|
+
Links.parameters = {
|
|
228
|
+
docs: {
|
|
229
|
+
description: {
|
|
230
|
+
story: 'Link preview cards — top row received, bottom row sent. Shows thumbnail, title, description, and URL with image fallback.',
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
}
|