@linktr.ee/messaging-react 1.19.1 → 1.19.3
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/package.json
CHANGED
|
@@ -24,11 +24,11 @@ export const Avatar: React.FC<AvatarProps> = ({
|
|
|
24
24
|
}) => {
|
|
25
25
|
const emoji = getAvatarEmoji(id)
|
|
26
26
|
|
|
27
|
-
// Determine font size based on avatar size
|
|
28
27
|
const getFontSizeClass = () => {
|
|
29
28
|
if (size < 32) return 'text-xs'
|
|
30
29
|
if (size < 56) return 'text-sm'
|
|
31
|
-
return 'text-lg'
|
|
30
|
+
if (size < 120) return 'text-lg'
|
|
31
|
+
return 'text-4xl'
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const fontSizeClass = getFontSizeClass()
|
|
@@ -248,6 +248,88 @@ WithMessageActions.parameters = {
|
|
|
248
248
|
},
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
const WithStarButtonTemplate: StoryFn<ComponentProps> = (args) => {
|
|
252
|
+
const [client] = React.useState(() => {
|
|
253
|
+
const client = new StreamChat('mock-api-key', {
|
|
254
|
+
allowServerSideConnect: true,
|
|
255
|
+
})
|
|
256
|
+
client.userID = mockUser.id
|
|
257
|
+
client.user = mockUser
|
|
258
|
+
return client
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
const [channel, setChannel] = React.useState<ChannelType | null>(null)
|
|
262
|
+
|
|
263
|
+
useEffect(() => {
|
|
264
|
+
createMockChannel(client, true).then((mockChannel) => {
|
|
265
|
+
const updateChannelPin = (isStarred: boolean) => {
|
|
266
|
+
const member: ChannelMemberResponse = {
|
|
267
|
+
user: mockUser,
|
|
268
|
+
user_id: mockUser.id,
|
|
269
|
+
pinned_at: isStarred ? new Date().toISOString() : null,
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
client.dispatchEvent({
|
|
273
|
+
type: 'member.updated',
|
|
274
|
+
cid: mockChannel.cid,
|
|
275
|
+
member,
|
|
276
|
+
user: mockUser,
|
|
277
|
+
} as Event)
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
mockChannel.pin = async () => {
|
|
281
|
+
updateChannelPin(true)
|
|
282
|
+
return {} as QueryChannelAPIResponse
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
mockChannel.unpin = async () => {
|
|
286
|
+
updateChannelPin(false)
|
|
287
|
+
return {} as QueryChannelAPIResponse
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
setChannel(mockChannel)
|
|
291
|
+
})
|
|
292
|
+
}, [client])
|
|
293
|
+
|
|
294
|
+
if (!channel) {
|
|
295
|
+
return <div>Loading...</div>
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return (
|
|
299
|
+
<Chat client={client}>
|
|
300
|
+
<div className="h-screen w-full bg-white">
|
|
301
|
+
<ChannelView {...args} channel={channel} />
|
|
302
|
+
</div>
|
|
303
|
+
</Chat>
|
|
304
|
+
)
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export const WithStarButton: StoryFn<ComponentProps> =
|
|
308
|
+
WithStarButtonTemplate.bind({})
|
|
309
|
+
WithStarButton.args = {
|
|
310
|
+
showBackButton: false,
|
|
311
|
+
showStarButton: true,
|
|
312
|
+
onLeaveConversation: (channel) =>
|
|
313
|
+
console.log('Leave conversation:', channel.id),
|
|
314
|
+
onBlockParticipant: (participantId) =>
|
|
315
|
+
console.log('Block participant:', participantId),
|
|
316
|
+
}
|
|
317
|
+
WithStarButton.argTypes = {
|
|
318
|
+
showStarButton: {
|
|
319
|
+
control: false,
|
|
320
|
+
table: {
|
|
321
|
+
disable: true,
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
}
|
|
325
|
+
WithStarButton.parameters = {
|
|
326
|
+
docs: {
|
|
327
|
+
description: {
|
|
328
|
+
story: 'Channel view with a star button that toggles pinned state.',
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
}
|
|
332
|
+
|
|
251
333
|
const EmptyTemplate: StoryFn<ComponentProps> = (args) => {
|
|
252
334
|
const [client] = React.useState(() => {
|
|
253
335
|
const client = new StreamChat('mock-api-key', {
|
|
@@ -151,8 +151,11 @@ const CustomChannelHeader: React.FC<{
|
|
|
151
151
|
}
|
|
152
152
|
>
|
|
153
153
|
<StarIcon
|
|
154
|
-
className=
|
|
155
|
-
|
|
154
|
+
className={classNames('size-5', {
|
|
155
|
+
'text-yellow-600': isStarred,
|
|
156
|
+
'text-black/90': !isStarred,
|
|
157
|
+
})}
|
|
158
|
+
weight={isStarred ? 'duotone' : 'regular'}
|
|
156
159
|
/>
|
|
157
160
|
</button>
|
|
158
161
|
)}
|
|
@@ -202,8 +205,11 @@ const CustomChannelHeader: React.FC<{
|
|
|
202
205
|
}
|
|
203
206
|
>
|
|
204
207
|
<StarIcon
|
|
205
|
-
className=
|
|
206
|
-
|
|
208
|
+
className={classNames('size-5', {
|
|
209
|
+
'text-yellow-600': isStarred,
|
|
210
|
+
'text-black/90': !isStarred,
|
|
211
|
+
})}
|
|
212
|
+
weight={isStarred ? 'duotone' : 'regular'}
|
|
207
213
|
/>
|
|
208
214
|
</button>
|
|
209
215
|
)}
|