@linktr.ee/messaging-react 3.24.2-rc-1785436624 → 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 (29) hide show
  1. package/dist/{Card-BI3bA2Cj.js → Card-DcyixIfP.js} +2 -2
  2. package/dist/{Card-BI3bA2Cj.js.map → Card-DcyixIfP.js.map} +1 -1
  3. package/dist/{Card-iXdD3NF2.cjs → Card-_fDH4x4V.cjs} +2 -2
  4. package/dist/{Card-iXdD3NF2.cjs.map → Card-_fDH4x4V.cjs.map} +1 -1
  5. package/dist/{index-BlHbSVwK.js → index-DSQieSNh.js} +881 -798
  6. package/dist/index-DSQieSNh.js.map +1 -0
  7. package/dist/index-quV01XX7.cjs +2 -0
  8. package/dist/index-quV01XX7.cjs.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.d.ts +2 -2
  11. package/dist/index.js +1 -1
  12. package/package.json +2 -2
  13. package/src/components/LinkAttachment/LinkAttachment.stories.tsx +17 -9
  14. package/src/components/LinkAttachment/LinkAttachment.test.tsx +87 -53
  15. package/src/components/LinkAttachment/components/Composer/Card.tsx +1 -1
  16. package/src/components/LinkAttachment/components/Received/Card.tsx +1 -1
  17. package/src/components/LinkAttachment/components/Sent/Card.tsx +1 -1
  18. package/src/components/LinkAttachment/components/_shared/CardBody.tsx +11 -10
  19. package/src/components/LinkAttachment/components/_shared/CardShell.tsx +7 -1
  20. package/src/components/LinkAttachment/components/_shared/CardThumbnail.tsx +9 -0
  21. package/src/components/LinkAttachment/components/_shared/accentSurface.test.ts +151 -0
  22. package/src/components/LinkAttachment/components/_shared/accentSurface.ts +211 -0
  23. package/src/components/LinkAttachment/components/_shared/chinContrast.test.ts +64 -124
  24. package/src/components/LinkAttachment/components/_shared/chinContrast.ts +68 -71
  25. package/src/components/LinkAttachment/components/_shared/useChinPalette.ts +35 -31
  26. package/src/components/LinkAttachment/types.ts +2 -2
  27. package/dist/index-BlHbSVwK.js.map +0 -1
  28. package/dist/index-F3RRurYR.cjs +0 -2
  29. package/dist/index-F3RRurYR.cjs.map +0 -1
@@ -5,24 +5,10 @@ import React from 'react'
5
5
 
6
6
  import type { LinkAttachmentLayout, LinkAttachmentStatus } from '../../types'
7
7
 
8
+ import { accentSurface } from './accentSurface'
8
9
  import type { LinkAttachmentVariant } from './CardShell'
9
- import { isPlayableAudio } from './CardThumbnail'
10
- import {
11
- CHIN_FALLBACK_BG,
12
- chinTextColor,
13
- paintableAccent,
14
- } from './chinContrast'
15
-
16
- /**
17
- * Background each variant falls back to when no accent is paintable, as a hex.
18
- * Mirrors `CardShell`'s tailwind classes (`bg-[#1e2330]` / `bg-white`) — needed
19
- * separately because the bubble tail paints *outside* the shell's own box, via
20
- * an inline style a utility class can't reach.
21
- */
22
- const FALLBACK_BG_BY_VARIANT: Record<LinkAttachmentVariant, string> = {
23
- dark: CHIN_FALLBACK_BG,
24
- light: '#ffffff',
25
- }
10
+ import { AUDIO_BG, isPlayableAudio } from './CardThumbnail'
11
+ import { BUBBLE_BG_BY_VARIANT, inkFor } from './chinContrast'
26
12
 
27
13
  export interface ChinPaletteInput {
28
14
  variant: LinkAttachmentVariant
@@ -50,12 +36,15 @@ export interface ChinPalette {
50
36
  */
51
37
  accentStyle?: React.CSSProperties
52
38
  /**
53
- * Resolved chin text colour, or `undefined` to keep the variant's own
54
- * `text-*` classes (which already carry the right contrast for the
55
- * fallback fill).
39
+ * Ink for both chin lines, chosen against the surface the card actually
40
+ * paints — the derived accent, the audio strip, or the fallback fill. Always
41
+ * defined for a parseable surface.
56
42
  */
57
43
  chinTextColor?: string
58
- /** Colour the bubble tail paints in, always defined. */
44
+ /**
45
+ * Colour the bubble tail paints in, always defined: the accent when one is
46
+ * paintable, otherwise this side's plain bubble fill.
47
+ */
59
48
  tailColor: string
60
49
  /** True while the card renders as a skeleton. */
61
50
  isLoading: boolean
@@ -115,19 +104,34 @@ export function useChinPalette({
115
104
 
116
105
  // Truthiness rather than `!= null` so this tracks `CardThumbnail`'s own
117
106
  // `thumbnailUrl ?` branch, which renders the placeholder for `''` too.
118
- const hasHero =
119
- layout === 'featured' &&
120
- !!thumbnailUrl &&
121
- !isPlayableAudio(mimeType, sourceUrl) &&
122
- !heroFailed
123
- const accent =
124
- hasHero && status === 'ready' ? paintableAccent(accentColor) : undefined
107
+ //
108
+ // Playable audio is included even though its hero collapses to the native
109
+ // `<audio>` player and the artwork is never displayed. MES-1349 excluded it
110
+ // on the grounds that an accent is a claim about an image the viewer can see;
111
+ // the colour is now derived rather than painted raw, so it can no longer
112
+ // mislead about legibility, and an audio attachment with artwork is exactly
113
+ // the case where colour distinguishes one track from another. The cost is
114
+ // that a 404 artwork still tints the card here: the `<img>` never mounts, so
115
+ // `onImageError` cannot fire to withdraw it.
116
+ const hasArtwork = layout === 'featured' && !!thumbnailUrl && !heroFailed
117
+ const isAudio = isPlayableAudio(mimeType, sourceUrl)
118
+ const surface =
119
+ hasArtwork && status === 'ready'
120
+ ? accentSurface(accentColor, variant)
121
+ : undefined
122
+
123
+ // Whatever the card ends up painted with, legible or not, the ink is chosen
124
+ // against it. The accent is derived to suit this side's ink, but the audio
125
+ // strip and the fallback fill are imposed and cannot be refused — a sent
126
+ // audio card put white ink on `AUDIO_BG`'s near-white at 1.13:1 (MES-1388).
127
+ const painted =
128
+ surface ?? (isAudio ? AUDIO_BG : BUBBLE_BG_BY_VARIANT[variant])
125
129
 
126
130
  return {
127
131
  thumbnailUrl: heroFailed ? undefined : thumbnailUrl,
128
- accentStyle: accent ? { backgroundColor: accent } : undefined,
129
- chinTextColor: accent ? chinTextColor(accent) : undefined,
130
- tailColor: accent ?? FALLBACK_BG_BY_VARIANT[variant],
132
+ accentStyle: surface ? { backgroundColor: surface } : undefined,
133
+ chinTextColor: inkFor(painted),
134
+ tailColor: painted,
131
135
  isLoading: status === 'loading',
132
136
  onImageError,
133
137
  }
@@ -85,8 +85,8 @@ export interface LinkAttachmentBaseProps {
85
85
  * screen. Omitted, unparseable, `layout: 'classic'`, no `thumbnailUrl`,
86
86
  * `status` other than `'ready'`, a playable-audio `mimeType` + `sourceUrl`
87
87
  * (whose hero is the native player rather than an image), or a hero that
88
- * fails to load => the card falls back to `CHIN_FALLBACK_BG` with
89
- * `CHIN_TEXT_LIGHT`.
88
+ * fails to load, or the colour cannot clear AA against this side's ink =>
89
+ * the card falls back to `BUBBLE_BG_BY_VARIANT[variant]`, the plain bubble fill.
90
90
  */
91
91
  accentColor?: string
92
92