@linktr.ee/messaging-react 1.19.0 → 1.19.2

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linktr.ee/messaging-react",
3
- "version": "1.19.0",
3
+ "version": "1.19.2",
4
4
  "description": "React messaging components built on messaging-core for web applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -138,7 +138,7 @@ const CustomChannelPreview = React.memo<CustomChannelPreviewProps>(
138
138
 
139
139
  {/* Message and unread badge row */}
140
140
  <div className="flex items-center justify-between gap-2 min-w-0">
141
- <p className="text-xs text-stone mr-2 flex-1 line-clamp-2">
141
+ <p className="text-xs text-stone flex-1 line-clamp-1">
142
142
  {messagePreview}
143
143
  </p>
144
144
  {unreadCount > 0 && (
@@ -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="size-5 text-black/90"
155
- weight={isStarred ? 'fill' : 'regular'}
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="size-5 text-black/90"
206
- weight={isStarred ? 'fill' : 'regular'}
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
  )}