@linktr.ee/messaging-react 3.24.2-rc-1785435591 → 3.25.0-rc-1785440433

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 (31) hide show
  1. package/dist/{Card-Cgn2G-VJ.js → Card-DcyixIfP.js} +2 -2
  2. package/dist/{Card-Cgn2G-VJ.js.map → Card-DcyixIfP.js.map} +1 -1
  3. package/dist/{Card-CRhkz5Jp.cjs → Card-_fDH4x4V.cjs} +2 -2
  4. package/dist/{Card-CRhkz5Jp.cjs.map → Card-_fDH4x4V.cjs.map} +1 -1
  5. package/dist/assets/index.css +1 -1
  6. package/dist/{index-Daw6ObfN.js → index-DSQieSNh.js} +892 -799
  7. package/dist/index-DSQieSNh.js.map +1 -0
  8. package/dist/index-quV01XX7.cjs +2 -0
  9. package/dist/index-quV01XX7.cjs.map +1 -0
  10. package/dist/index.cjs +1 -1
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.js +1 -1
  13. package/package.json +2 -2
  14. package/src/components/LinkAttachment/LinkAttachment.stories.tsx +17 -9
  15. package/src/components/LinkAttachment/LinkAttachment.test.tsx +104 -56
  16. package/src/components/LinkAttachment/components/Composer/Card.tsx +1 -1
  17. package/src/components/LinkAttachment/components/Received/Card.tsx +1 -1
  18. package/src/components/LinkAttachment/components/Sent/Card.tsx +1 -1
  19. package/src/components/LinkAttachment/components/_shared/CardBody.tsx +12 -11
  20. package/src/components/LinkAttachment/components/_shared/CardShell.tsx +17 -1
  21. package/src/components/LinkAttachment/components/_shared/CardThumbnail.tsx +10 -1
  22. package/src/components/LinkAttachment/components/_shared/accentSurface.test.ts +151 -0
  23. package/src/components/LinkAttachment/components/_shared/accentSurface.ts +211 -0
  24. package/src/components/LinkAttachment/components/_shared/chinContrast.test.ts +64 -124
  25. package/src/components/LinkAttachment/components/_shared/chinContrast.ts +68 -71
  26. package/src/components/LinkAttachment/components/_shared/useChinPalette.ts +35 -31
  27. package/src/components/LinkAttachment/types.ts +2 -2
  28. package/src/styles.css +8 -41
  29. package/dist/index-BwfUbPpY.cjs +0 -2
  30. package/dist/index-BwfUbPpY.cjs.map +0 -1
  31. package/dist/index-Daw6ObfN.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BwfUbPpY.cjs");exports.ActionButton=e.ActionButton;exports.Avatar=e.Avatar;exports.ChannelEmptyState=e.ChannelEmptyState;exports.ChannelList=e.ChannelList;exports.ChannelView=e.ChannelView;exports.CustomMessageProvider=e.CustomMessageProvider;exports.FaqList=e.FaqList;exports.FaqListItem=e.FaqListItem;exports.LinkAttachment=e.LinkAttachment;exports.LockedAttachment=e.LockedAttachment;exports.MediaMessage=e.MediaMessage;exports.MessageAttachment=e.MessageAttachment;exports.MessageBubble=e.MessageBubble;exports.MessageVoteButtons=e.MessageVoteButtons;exports.MessagingProvider=e.MessagingProvider;exports.MessagingShell=e.MessagingShell;exports.buildCompactMetaLabel=e.buildCompactMetaLabel;exports.formatFileSize=e.formatFileSize;exports.formatRelativeTime=e.formatRelativeTime;exports.getFileExtensionLabel=e.getFileExtensionLabel;exports.getMessageDisplayText=e.getMessageDisplayText;exports.isLinkAttachment=e.isLinkAttachment;exports.isUuidLike=e.isUuidLike;exports.messageAttachmentGroupPositionFromStream=e.bubbleGroupPositionFromStream;exports.normalizeLanguageCode=e.normalizeLanguageCode;exports.optimizeMessagingAttachmentUrl=e.optimizeMessagingAttachmentUrl;exports.resolveConversationParticipant=e.resolveConversationParticipant;exports.resolveLinkAttachment=e.resolveLinkAttachment;exports.resolveMediaFromMessage=e.resolveMediaFromMessage;exports.resolveParticipantDisplayName=e.resolveParticipantDisplayName;exports.useComposerLocked=e.useComposerLocked;exports.useCustomMessage=e.useCustomMessage;exports.useMessageVote=e.useMessageVote;exports.useMessaging=e.useMessaging;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-quV01XX7.cjs");exports.ActionButton=e.ActionButton;exports.Avatar=e.Avatar;exports.ChannelEmptyState=e.ChannelEmptyState;exports.ChannelList=e.ChannelList;exports.ChannelView=e.ChannelView;exports.CustomMessageProvider=e.CustomMessageProvider;exports.FaqList=e.FaqList;exports.FaqListItem=e.FaqListItem;exports.LinkAttachment=e.LinkAttachment;exports.LockedAttachment=e.LockedAttachment;exports.MediaMessage=e.MediaMessage;exports.MessageAttachment=e.MessageAttachment;exports.MessageBubble=e.MessageBubble;exports.MessageVoteButtons=e.MessageVoteButtons;exports.MessagingProvider=e.MessagingProvider;exports.MessagingShell=e.MessagingShell;exports.buildCompactMetaLabel=e.buildCompactMetaLabel;exports.formatFileSize=e.formatFileSize;exports.formatRelativeTime=e.formatRelativeTime;exports.getFileExtensionLabel=e.getFileExtensionLabel;exports.getMessageDisplayText=e.getMessageDisplayText;exports.isLinkAttachment=e.isLinkAttachment;exports.isUuidLike=e.isUuidLike;exports.messageAttachmentGroupPositionFromStream=e.bubbleGroupPositionFromStream;exports.normalizeLanguageCode=e.normalizeLanguageCode;exports.optimizeMessagingAttachmentUrl=e.optimizeMessagingAttachmentUrl;exports.resolveConversationParticipant=e.resolveConversationParticipant;exports.resolveLinkAttachment=e.resolveLinkAttachment;exports.resolveMediaFromMessage=e.resolveMediaFromMessage;exports.resolveParticipantDisplayName=e.resolveParticipantDisplayName;exports.useComposerLocked=e.useComposerLocked;exports.useCustomMessage=e.useCustomMessage;exports.useMessageVote=e.useMessageVote;exports.useMessaging=e.useMessaging;
2
2
  //# sourceMappingURL=index.cjs.map
package/dist/index.d.ts CHANGED
@@ -693,8 +693,8 @@ export declare interface LinkAttachmentBaseProps {
693
693
  * screen. Omitted, unparseable, `layout: 'classic'`, no `thumbnailUrl`,
694
694
  * `status` other than `'ready'`, a playable-audio `mimeType` + `sourceUrl`
695
695
  * (whose hero is the native player rather than an image), or a hero that
696
- * fails to load => the card falls back to `CHIN_FALLBACK_BG` with
697
- * `CHIN_TEXT_LIGHT`.
696
+ * fails to load, or the colour cannot clear AA against this side's ink =>
697
+ * the card falls back to `BUBBLE_BG_BY_VARIANT[variant]`, the plain bubble fill.
698
698
  */
699
699
  accentColor?: string;
700
700
  /**
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as e, b as t, C as i, c as o, d as n, e as m, F as r, f as g, L as l, h as M, M as c, i as u, j as L, k as h, l as p, m as d, n as v, p as C, q as A, s as k, t as F, u as b, v as P, w as f, x, o as y, y as z, z as B, B as S, D as q, E as D, G as E, H as V, I as w } from "./index-Daw6ObfN.js";
1
+ import { a as e, b as t, C as i, c as o, d as n, e as m, F as r, f as g, L as l, h as M, M as c, i as u, j as L, k as h, l as p, m as d, n as v, p as C, q as A, s as k, t as F, u as b, v as P, w as f, x, o as y, y as z, z as B, B as S, D as q, E as D, G as E, H as V, I as w } from "./index-DSQieSNh.js";
2
2
  export {
3
3
  e as ActionButton,
4
4
  t as Avatar,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linktr.ee/messaging-react",
3
- "version": "3.24.2-rc-1785435591",
3
+ "version": "3.25.0-rc-1785440433",
4
4
  "description": "React messaging components built on messaging-core for web applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@linktr.ee/component-library": "11.8.6",
53
- "@linktr.ee/messaging-core": "2.3.0-rc-1785435591",
53
+ "@linktr.ee/messaging-core": "2.3.0-rc-1785440433",
54
54
  "@linktr.ee/messaging-taxonomy": "^0.3.0",
55
55
  "@phosphor-icons/react": "^2.1.10"
56
56
  },
@@ -239,10 +239,10 @@ export const LinkApps: StoryFn = () => (
239
239
  ────────────────────────────────────────────────────────────────── */
240
240
 
241
241
  const ACCENTS: Array<{ label: string; accentColor?: string }> = [
242
- // The Figma mock's own chin colour. White measures 3.76:1 on it and fails
243
- // AA, so the contrast rule flips this card to near-black text and the
244
- // shipped card deliberately does NOT match the mock. This cell is the
245
- // trade-off, made visible for design review.
242
+ // The Figma mock's own chin colour. Painted raw it measures 3.76:1 against
243
+ // the sender's white ink, which is why the mock cannot simply be reproduced;
244
+ // derived, its hue survives at a lightness both inks clear. The shipped sent
245
+ // card is therefore darker than the mock on purpose (MES-1388).
246
246
  { label: '#738883 (mock)', accentColor: '#738883' },
247
247
  { label: '#AA9F93', accentColor: '#AA9F93' },
248
248
  { label: '#FFF099', accentColor: '#FFF099' },
@@ -260,12 +260,20 @@ const ACCENT_CARD = {
260
260
  }
261
261
 
262
262
  /**
263
- * The dominant-colour chin and its WCAG AA contrast rule (MES-1349).
263
+ * The dominant-colour card and its WCAG AA gate (MES-1349, corrected MES-1388).
264
264
  *
265
- * Each column is one extracted accent; the card derives its own chin text
266
- * colour by taking whichever of `#FFFFFF` / `#040403` scores the higher
267
- * contrast ratio against it. Every cell clears 4.5:1 — the two candidates'
268
- * passing ranges overlap, so no sRGB colour fails against both.
265
+ * Each column is one extracted accent. Ink is *fixed per side* — `text-white`
266
+ * when sent, `text-black/90` when received — so contrast decides whether the
267
+ * accent may paint at all rather than which text colour to use. An accent under
268
+ * 4.5:1 against that side's ink is discarded for the plain message bubble fill
269
+ * (`#1e2330` sent, `#f1f0ee` received), so a card without a usable colour reads
270
+ * like the text bubbles around it.
271
+ *
272
+ * Each column is a synthetic base colour chosen to probe the derivation, not a
273
+ * colour taken from the hero — in production `accent_color` is extracted from
274
+ * the attachment image itself, so a photograph's own hue is what arrives here.
275
+ * Every column paints on both sides: the derivation moves lightness, never hue,
276
+ * so a base is never refused for contrast.
269
277
  *
270
278
  * The bottom rows cover the states where the accent is deliberately ignored:
271
279
  * `classic` has no image to extract from, and `loading` has no image yet.
@@ -108,42 +108,77 @@ describe('LinkAttachment.Sent', () => {
108
108
  })
109
109
  })
110
110
 
111
- describe('LinkAttachment accent chin (MES-1349)', () => {
112
- const ACCENT = '#738883'
111
+ describe('LinkAttachment accent chin (MES-1349, MES-1388)', () => {
112
+ const ACCENT = '#7008E7'
113
+ // The near-white dominant colour from the MES-1388 report. Painted raw it put
114
+ // white ink on 1.09:1; derived, it is legible on both sides.
115
+ const PALE_ACCENT = '#FCF5E3'
113
116
  const CARD_PROPS = {
114
117
  title: 'Yoga on Ice with Brie Nala',
115
118
  url: 'tr.ee/briewebsite',
116
119
  thumbnailUrl: 'https://cdn.example.com/yoga.jpg',
117
120
  }
118
121
 
119
- it('paints the card with the accent and flips the chin text to near-black', async () => {
122
+ const surfaceOf = (element: HTMLElement) => element.style.backgroundColor
123
+
124
+ it('derives a dark surface for the sender and inks it white', async () => {
120
125
  renderWithProviders(
121
126
  <LinkAttachment.Sent {...CARD_PROPS} accentColor={ACCENT} />
122
127
  )
123
- // White on #738883 measures 3.76:1 and fails AA, so the rule must pick
124
- // the dark candidate even though the Figma mock draws white.
125
- expect(await screen.findByRole('link')).toHaveStyle({
126
- backgroundColor: ACCENT,
127
- })
128
- expect(screen.getByText(CARD_PROPS.title)).toHaveStyle({ color: '#040403' })
129
- expect(screen.getByText(CARD_PROPS.url)).toHaveStyle({ color: '#040403' })
128
+ const root = await screen.findByRole('link')
129
+ // Not the raw accent: the hue is kept, the lightness is replaced with the
130
+ // stop this side's ink can clear. Painting the extracted colour verbatim is
131
+ // what MES-1388 was reported for.
132
+ expect(surfaceOf(root)).not.toBe('')
133
+ expect(root).not.toHaveStyle({ backgroundColor: ACCENT })
134
+ expect(screen.getByText(CARD_PROPS.title)).toHaveStyle({ color: '#FFFFFF' })
130
135
  })
131
136
 
132
- it('picks light text on a dark accent', async () => {
137
+ it('derives a pale surface for the receiver and inks it near-black', async () => {
133
138
  renderWithProviders(
134
- <LinkAttachment.Sent {...CARD_PROPS} accentColor="#7008E7" />
139
+ <LinkAttachment.Received {...CARD_PROPS} accentColor={ACCENT} />
135
140
  )
136
- expect(await screen.findByText(CARD_PROPS.title)).toHaveStyle({
137
- color: '#FFFFFF',
138
- })
141
+ const root = await screen.findByRole('link')
142
+ expect(surfaceOf(root)).not.toBe('')
143
+ expect(root).not.toHaveStyle({ backgroundColor: ACCENT })
144
+ expect(screen.getByText(CARD_PROPS.title)).toHaveStyle({ color: '#040403' })
139
145
  })
140
146
 
141
- it('leaves the variant fill in place when no accent is given', async () => {
147
+ it('colours both sides from one extracted colour, never rejecting it', async () => {
148
+ // The pale report colour and the vivid one both paint, on both sides — the
149
+ // feature adds colour to every card with an image rather than half of them.
150
+ for (const accentColor of [ACCENT, PALE_ACCENT]) {
151
+ const sent = renderWithProviders(
152
+ <LinkAttachment.Sent {...CARD_PROPS} accentColor={accentColor} />
153
+ )
154
+ expect(surfaceOf(await screen.findByRole('link'))).not.toBe('')
155
+ sent.unmount()
156
+
157
+ const received = renderWithProviders(
158
+ <LinkAttachment.Received {...CARD_PROPS} accentColor={accentColor} />
159
+ )
160
+ expect(surfaceOf(await screen.findByRole('link'))).not.toBe('')
161
+ received.unmount()
162
+ }
163
+ })
164
+
165
+ it('falls back to a self-contained fill, not a consumer theme token', async () => {
142
166
  renderWithProviders(<LinkAttachment.Sent {...CARD_PROPS} />)
143
167
  const root = await screen.findByRole('link')
144
- expect(root.style.backgroundColor).toBe('')
145
- expect(root.className).toContain('bg-shade')
146
- expect(screen.getByText(CARD_PROPS.title).style.color).toBe('')
168
+ expect(surfaceOf(root)).toBe('')
169
+
170
+ // The fill has to survive in consumers that do not share our Tailwind
171
+ // theme. This package ships no utilities, so consumers generate our classes
172
+ // against their own preset: `bg-shade` compiled here but was dropped in
173
+ // frontyard (Arbor preset, no `shade` colour), leaving the chin transparent
174
+ // under the own-message `color: white` (MES-1388). An arbitrary value is
175
+ // generated from the class name alone, so assert that shape — not the
176
+ // literal colour, which design may change.
177
+ const fill = root.className
178
+ .split(/\s+/)
179
+ .find((c) => c.startsWith('bg-') && c !== 'bg-white')
180
+ expect(fill).toBeDefined()
181
+ expect(fill).toMatch(/^bg-\[/)
147
182
  })
148
183
 
149
184
  it('treats an unparseable accent as no accent', async () => {
@@ -152,7 +187,8 @@ describe('LinkAttachment accent chin (MES-1349)', () => {
152
187
  )
153
188
  const root = await screen.findByRole('link')
154
189
  expect(root.style.backgroundColor).toBe('')
155
- expect(screen.getByText(CARD_PROPS.title).style.color).toBe('')
190
+ // Ink still comes from the surface — here the sender's fallback fill.
191
+ expect(screen.getByText(CARD_PROPS.title)).toHaveStyle({ color: '#FFFFFF' })
156
192
  })
157
193
 
158
194
  it('drops the accent when the hero image fails to load', async () => {
@@ -160,13 +196,13 @@ describe('LinkAttachment accent chin (MES-1349)', () => {
160
196
  <LinkAttachment.Sent {...CARD_PROPS} accentColor={ACCENT} />
161
197
  )
162
198
  const root = await screen.findByRole('link')
163
- expect(root).toHaveStyle({ backgroundColor: ACCENT })
199
+ expect(root.style.backgroundColor).not.toBe('')
164
200
 
165
- // An accent derived from an image the viewer cannot see is a lie, so the
201
+ // A surface derived from an image the viewer cannot see is a lie, so the
166
202
  // card falls all the way back rather than keeping a colour with no source.
167
203
  fireEvent.error(screen.getByRole('img'))
168
204
  expect(root.style.backgroundColor).toBe('')
169
- expect(screen.getByText(CARD_PROPS.title).style.color).toBe('')
205
+ expect(screen.getByText(CARD_PROPS.title)).toHaveStyle({ color: '#FFFFFF' })
170
206
  })
171
207
 
172
208
  it('drops the accent when a playable video poster fails to load', () => {
@@ -186,50 +222,51 @@ describe('LinkAttachment accent chin (MES-1349)', () => {
186
222
  const shell = container.querySelector(
187
223
  '[class*="select-none"]'
188
224
  ) as HTMLElement
189
- expect(shell).toHaveStyle({ backgroundColor: ACCENT })
225
+ expect(shell.style.backgroundColor).not.toBe('')
190
226
  expect(container.querySelector('video')).toHaveAttribute('poster')
191
227
 
192
228
  fireEvent.error(container.querySelector('img') as HTMLImageElement)
193
229
 
194
230
  expect(shell.style.backgroundColor).toBe('')
195
- expect(screen.getByText(CARD_PROPS.title).style.color).toBe('')
231
+ expect(screen.getByText(CARD_PROPS.title)).toHaveStyle({ color: '#FFFFFF' })
196
232
  // The failed poster is dropped with the accent, so the player falls back to
197
233
  // its own first frame instead of retrying a 404.
198
234
  expect(container.querySelector('video')).not.toHaveAttribute('poster')
199
235
  })
200
236
 
201
- it('drops the accent on a playable audio card so the audio fill survives', async () => {
202
- // The hero collapses to the native player, so the `<img>` never mounts and
203
- // `onImageError` can never fire — the gate has to be up front. `CardShell`
204
- // applies `accentStyle` as an inline `style`, which would otherwise outrank
205
- // `AUDIO_BG_CLASS` and ship a coloured card with no visible source image.
206
- // Reachable through Stream, which maps any playable link attachment to
207
- // `featured` (`linkCardPropsFromStreamAttachment`).
237
+ it('derives audio artwork into the surface, and inks the flat fill when there is none', async () => {
238
+ // MES-1349 refused the accent here because the hero collapses to the native
239
+ // player and the artwork is never shown. The colour is derived now, so it
240
+ // cannot mislead about legibility, and artwork is what distinguishes one
241
+ // track from another — so it paints. Reachable through Stream, which maps
242
+ // any playable link attachment to `featured`.
208
243
  const AUDIO = {
209
244
  mimeType: 'audio/mpeg',
210
245
  sourceUrl: 'https://cdn.example.com/clip.mp3',
211
246
  }
212
247
 
213
- const { container, unmount } = renderWithProviders(
248
+ const withArtwork = renderWithProviders(
214
249
  <LinkAttachment.Sent {...CARD_PROPS} {...AUDIO} accentColor={ACCENT} />
215
250
  )
216
- const sent = container.firstElementChild as HTMLElement
217
- expect(sent.style.backgroundColor).toBe('')
218
- expect(sent.className).toContain(AUDIO_BG_CLASS)
219
- expect(screen.getByText(CARD_PROPS.title).style.color).toBe('')
251
+ const painted = withArtwork.container.firstElementChild as HTMLElement
252
+ expect(painted.style.backgroundColor).not.toBe('')
220
253
  expect(screen.queryByRole('img')).toBeNull()
221
- unmount()
254
+ withArtwork.unmount()
222
255
 
223
- renderWithProviders(
224
- <LinkAttachment.Received
256
+ // No artwork: the flat audio fill stays, and this is the MES-1388 bug —
257
+ // `AUDIO_BG_CLASS` is near-white and lands on a *sent* card, whose variant
258
+ // ink is white. Ink must follow the fill it was given, not the variant.
259
+ const bare = renderWithProviders(
260
+ <LinkAttachment.Sent
225
261
  {...CARD_PROPS}
226
262
  {...AUDIO}
227
- accentColor={ACCENT}
263
+ thumbnailUrl={undefined}
228
264
  />
229
265
  )
230
- const received = await screen.findByTestId('link-attachment')
231
- expect(received.style.backgroundColor).toBe('')
232
- expect(received.className).toContain(AUDIO_BG_CLASS)
266
+ const flat = bare.container.firstElementChild as HTMLElement
267
+ expect(flat.style.backgroundColor).toBe('')
268
+ expect(flat.className).toContain(AUDIO_BG_CLASS)
269
+ expect(screen.getByText(CARD_PROPS.title)).toHaveStyle({ color: '#040403' })
233
270
  })
234
271
 
235
272
  it('drops the accent when the featured hero has no image to show', async () => {
@@ -244,21 +281,28 @@ describe('LinkAttachment accent chin (MES-1349)', () => {
244
281
  )
245
282
  const root = await screen.findByRole('link')
246
283
  expect(root.style.backgroundColor).toBe('')
247
- expect(root.className).toContain('bg-shade')
248
- expect(screen.getByText(CARD_PROPS.title).style.color).toBe('')
284
+ // Variant fill, asserted by shape not literal — see the self-contained-fill
285
+ // test above for why this must stay an arbitrary value (MES-1388).
286
+ expect(root.className).toMatch(/bg-\[/)
287
+ expect(screen.getByText(CARD_PROPS.title)).toHaveStyle({ color: '#FFFFFF' })
249
288
  })
250
289
 
251
290
  it('normalizes a hashless accent so the background actually paints', async () => {
252
- // `parseHex` accepts `738883`; `background-color: 738883` is invalid CSS
253
- // and the DOM drops it, while the chin still took `#040403` from the parsed
254
- // colour — 1.31:1 near-black on the dark fallback fill.
291
+ // The extractor returns a bare hex often enough that dropping it would lose
292
+ // the colour silently — `background-color: 7008E7` is invalid CSS (MES-1349).
293
+ const hashless = renderWithProviders(
294
+ <LinkAttachment.Sent {...CARD_PROPS} accentColor="7008E7" />
295
+ )
296
+ const derived = (await screen.findByRole('link')).style.backgroundColor
297
+ expect(derived).not.toBe('')
298
+ hashless.unmount()
299
+
255
300
  renderWithProviders(
256
- <LinkAttachment.Sent {...CARD_PROPS} accentColor="738883" />
301
+ <LinkAttachment.Sent {...CARD_PROPS} accentColor={ACCENT} />
302
+ )
303
+ expect((await screen.findByRole('link')).style.backgroundColor).toBe(
304
+ derived
257
305
  )
258
- const root = await screen.findByRole('link')
259
- expect(root.style.backgroundColor).not.toBe('')
260
- expect(root).toHaveStyle({ backgroundColor: ACCENT })
261
- expect(screen.getByText(CARD_PROPS.title)).toHaveStyle({ color: '#040403' })
262
306
  })
263
307
 
264
308
  it('lets a loading status outrank the audio hero on all three cards', () => {
@@ -304,8 +348,12 @@ describe('LinkAttachment accent chin (MES-1349)', () => {
304
348
  groupPosition="end"
305
349
  />
306
350
  )
307
- expect(await screen.findByTestId('link-card-tail')).toHaveStyle({
308
- backgroundColor: ACCENT,
351
+ // The tail paints outside the shell's own box, so it takes the surface as an
352
+ // inline colour — it has to be the *derived* one or the tail and the card
353
+ // would disagree.
354
+ const card = await screen.findByRole('link')
355
+ expect(screen.getByTestId('link-card-tail')).toHaveStyle({
356
+ backgroundColor: card.style.backgroundColor,
309
357
  })
310
358
  unmount()
311
359
 
@@ -147,6 +147,7 @@ const ComposerCard: React.FC<ComposerCardProps> = ({
147
147
  />
148
148
  )}
149
149
  <CardBody
150
+ chinTextColor={chin.chinTextColor}
150
151
  variant="dark"
151
152
  title={title}
152
153
  placeholderTitle={placeholderTitle}
@@ -155,7 +156,6 @@ const ComposerCard: React.FC<ComposerCardProps> = ({
155
156
  appIcon={appIcon}
156
157
  cta={cta}
157
158
  trailingAction={editButton}
158
- chinTextColor={chin.chinTextColor}
159
159
  isLoading={chin.isLoading}
160
160
  />
161
161
  </CardShell>
@@ -140,13 +140,13 @@ const ReceivedCard: React.FC<ReceivedCardProps> = ({
140
140
  />
141
141
  )}
142
142
  <CardBody
143
+ chinTextColor={chin.chinTextColor}
143
144
  variant="light"
144
145
  title={title}
145
146
  description={description}
146
147
  url={url}
147
148
  appIcon={appIcon}
148
149
  cta={wrappedCta}
149
- chinTextColor={chin.chinTextColor}
150
150
  isLoading={chin.isLoading}
151
151
  />
152
152
  </CardShell>
@@ -121,6 +121,7 @@ const SentCard: React.FC<SentCardProps> = ({
121
121
  />
122
122
  )}
123
123
  <CardBody
124
+ chinTextColor={chin.chinTextColor}
124
125
  variant="dark"
125
126
  title={title}
126
127
  placeholderTitle={placeholderTitle}
@@ -128,7 +129,6 @@ const SentCard: React.FC<SentCardProps> = ({
128
129
  url={url}
129
130
  appIcon={appIcon}
130
131
  cta={cta}
131
- chinTextColor={chin.chinTextColor}
132
132
  isLoading={chin.isLoading}
133
133
  />
134
134
  </CardShell>
@@ -14,6 +14,14 @@ export interface CardBodyProps {
14
14
  description?: string
15
15
  /** Footer URL shown below the description. Ignored when `cta` is set. */
16
16
  url?: string
17
+ /**
18
+ * Ink for both chin lines, from `chinContrast.inkFor` — measured against the
19
+ * surface this card actually paints, which may be a derived accent, the audio
20
+ * strip, or the variant fallback. Replaces the variant's own `text-*` classes
21
+ * (including their opacity) on both lines, so a card whose surface is not the
22
+ * variant default still reads (MES-1388).
23
+ */
24
+ chinTextColor?: string
17
25
  /**
18
26
  * Optional 16x16 brand badge rendered before the title (used by Link Apps:
19
27
  * Spotify, TikTok, FAQ, Form, etc.).
@@ -23,13 +31,6 @@ export interface CardBodyProps {
23
31
  cta?: LinkAttachmentCta
24
32
  /** Trailing action rendered on the right of the title/description block. */
25
33
  trailingAction?: React.ReactNode
26
- /**
27
- * Resolved chin text colour for an accent-painted card, from
28
- * `chinContrast.chinTextColor`. When set it replaces the variant's own
29
- * `text-*` classes (including their opacity) on both lines, because the
30
- * WCAG proof only holds for the two full-opacity candidates.
31
- */
32
- chinTextColor?: string
33
34
  /** Renders two neutral pulsing bars in place of the text. */
34
35
  isLoading?: boolean
35
36
  }
@@ -47,7 +48,7 @@ const SECONDARY_CLASS_BY_VARIANT: Record<LinkAttachmentVariant, string> = {
47
48
  }
48
49
 
49
50
  // Skeleton bars, variant-aware for the same reason the placeholder hero is: a
50
- // fixed dark tint is invisible on the dark card's own `bg-shade` fill. Values
51
+ // fixed dark tint is invisible on the dark card's own dark fill. Values
51
52
  // match `SkeletonTextLines`, the toolkit's existing skeleton bars, which also
52
53
  // documents why these are explicit black/white rather than `bg-current/N`
53
54
  // (Tailwind emits nothing for an opacity modifier on `current`).
@@ -69,6 +70,7 @@ const SKELETON_BAR_CLASS_BY_VARIANT: Record<LinkAttachmentVariant, string> = {
69
70
  */
70
71
  const CardBody: React.FC<CardBodyProps> = ({
71
72
  variant,
73
+ chinTextColor,
72
74
  title,
73
75
  placeholderTitle,
74
76
  description,
@@ -76,7 +78,6 @@ const CardBody: React.FC<CardBodyProps> = ({
76
78
  appIcon,
77
79
  cta,
78
80
  trailingAction,
79
- chinTextColor,
80
81
  isLoading = false,
81
82
  }) => {
82
83
  const isDark = variant === 'dark'
@@ -107,8 +108,6 @@ const CardBody: React.FC<CardBodyProps> = ({
107
108
  chinTextColor == null && SECONDARY_CLASS_BY_VARIANT[variant]
108
109
  )
109
110
 
110
- const chinTextStyle = chinTextColor ? { color: chinTextColor } : undefined
111
-
112
111
  if (isLoading) {
113
112
  const barClass = classNames(
114
113
  'animate-pulse rounded',
@@ -126,6 +125,8 @@ const CardBody: React.FC<CardBodyProps> = ({
126
125
  )
127
126
  }
128
127
 
128
+ const chinTextStyle = chinTextColor ? { color: chinTextColor } : undefined
129
+
129
130
  return (
130
131
  <div className="shrink-0 px-4 py-3">
131
132
  <div className="flex items-end gap-3">
@@ -100,7 +100,23 @@ const CardShell: React.FC<CardShellProps> = ({
100
100
  // Kept underneath `accentStyle` rather than swapped out: the inline
101
101
  // background wins on specificity, and leaving the class in place means
102
102
  // an accent that somehow doesn't paint still lands on a sane surface.
103
- bgClassName ?? (variant === 'dark' ? 'bg-shade' : 'bg-white'),
103
+ //
104
+ // MUST be an arbitrary value, not a theme token. This package ships no
105
+ // Tailwind utilities — `dist/assets/index.css` is only the hand-written
106
+ // `.str-chat`/`.mes-*` CSS — so consumers generate our classes by scanning
107
+ // `messaging-react/dist` against *their own* theme. `shade` comes from the
108
+ // component-library preset that this package builds with; frontyard builds
109
+ // on the Arbor preset and has no such colour, so `bg-shade` was silently
110
+ // dropped, the chin rendered transparent, and the own-message `color: white`
111
+ // left the title and URL invisible (MES-1388). An arbitrary value is
112
+ // generated from the class name alone and cannot depend on consumer theme.
113
+ //
114
+ // Both values are the plain message bubble's own fill, so a card with no
115
+ // usable accent matches the text bubbles around it: `#1e2330` is
116
+ // `--str-chat__own-message-bubble-background-color` and `#f1f0ee` is
117
+ // `--str-chat__message-bubble-background-color`. Mirrored in
118
+ // `chinContrast.BUBBLE_BG_BY_VARIANT`, which the bubble tail reads.
119
+ bgClassName ?? (variant === 'dark' ? 'bg-[#1e2330]' : 'bg-[#f1f0ee]'),
104
120
  // `focus-ring` is a design-system utility from the component-library
105
121
  // tailwind preset — outline-none + a black 2px focus-visible ring
106
122
  // with offset, so keyboard users can see the focused card.
@@ -70,7 +70,16 @@ export const isPlayableMedia = (mimeType?: string, sourceUrl?: string) => {
70
70
  * Background colour the LinkAttachment cards switch to when the source is
71
71
  * audio — flat neutral around the native `<audio>` chrome regardless of
72
72
  * the dark / light variant.
73
+ *
74
+ * The hex is exported alongside the class because the card's ink is chosen by
75
+ * measuring contrast against whatever surface it lands on, and contrast needs
76
+ * channels rather than a class name. They are written out twice on purpose:
77
+ * Tailwind only generates utilities it can find as complete literals when it
78
+ * scans `dist`, so building the class from the constant
79
+ * (`` `bg-[${AUDIO_BG}]` ``) would emit nothing at all. `chinContrast.test.ts`
80
+ * asserts the two stay in step.
73
81
  */
82
+ export const AUDIO_BG = '#F2F3F4'
74
83
  export const AUDIO_BG_CLASS = 'bg-[#F2F3F4]'
75
84
 
76
85
  /**
@@ -129,7 +138,7 @@ const CardThumbnail: React.FC<CardThumbnailProps> = ({
129
138
  >
130
139
  {isLoading ? (
131
140
  // Reuses the placeholder fill: a fixed `bg-black/[0.06]` would be
132
- // invisible on the dark card's `bg-shade` surface. Stock Tailwind only
141
+ // invisible on the dark card's dark surface. Stock Tailwind only
133
142
  // — `animate-shimmer` exists in this package's own tailwind config but
134
143
  // not in either consumer's, so it would compile to nothing in
135
144
  // frontyard and profiles while looking right in this Storybook.