@linktr.ee/messaging-react 3.31.2-rc-1785926144 → 3.31.2-rc-1785926721
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-Ch6N2pkc.js → Card-CqYFVF6m.js} +2 -2
- package/dist/{Card-Ch6N2pkc.js.map → Card-CqYFVF6m.js.map} +1 -1
- package/dist/index-Ct_Jgy8P.cjs.map +1 -1
- package/dist/{index-BKkCNnea.js → index-ilHx7pIO.js} +11 -16
- package/dist/index-ilHx7pIO.js.map +1 -0
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/components/LinkAttachment/LinkAttachment.stories.tsx +7 -9
- package/src/components/LinkAttachment/LinkAttachment.test.tsx +7 -8
- package/src/components/LinkAttachment/components/_shared/BubbleTail.tsx +4 -4
- package/src/components/LinkAttachment/components/_shared/CardBody.tsx +1 -1
- package/src/components/LinkAttachment/components/_shared/CardShell.tsx +12 -17
- package/src/components/LinkAttachment/components/_shared/hex.ts +3 -5
- package/src/components/LinkAttachment/components/_shared/useChinPalette.ts +20 -32
- package/src/styles.css +9 -11
- package/dist/index-BKkCNnea.js.map +0 -1
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-
|
|
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-ilHx7pIO.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.31.2-rc-
|
|
3
|
+
"version": "3.31.2-rc-1785926721",
|
|
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.4.0-rc-
|
|
53
|
+
"@linktr.ee/messaging-core": "2.4.0-rc-1785926721",
|
|
54
54
|
"@linktr.ee/messaging-taxonomy": "^0.5.1",
|
|
55
55
|
"@phosphor-icons/react": "^2.1.10"
|
|
56
56
|
},
|
|
@@ -461,8 +461,8 @@ AccentWithoutVisibleHero.parameters = { chromatic: { disableSnapshot: false } }
|
|
|
461
461
|
|
|
462
462
|
/**
|
|
463
463
|
* Max-chroma sRGB colour for a hue — three phase-shifted cosines, so stepping
|
|
464
|
-
* the hue walks the wheel at the most saturated triple each hue has.
|
|
465
|
-
*
|
|
464
|
+
* the hue walks the wheel at the most saturated triple each hue has. Many of
|
|
465
|
+
* these sit outside sRGB at the surface stops, where the browser gamut-maps.
|
|
466
466
|
*/
|
|
467
467
|
const vividHex = (hue: number): string =>
|
|
468
468
|
`#${[0, 120, 240]
|
|
@@ -506,10 +506,9 @@ const FALLBACK_BG_CLASS: Record<LinkAttachmentVariant, string> = {
|
|
|
506
506
|
/**
|
|
507
507
|
* One derivation cell driven by the *same* CSS the card uses: a
|
|
508
508
|
* `.messaging-link-card` publishing `--accent`, so `styles.css` derives the
|
|
509
|
-
* surface via `oklch(from …)`.
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
* the browser's now, not JS's, so only the input is labelled.
|
|
509
|
+
* surface via `oklch(from …)`. A refused accent (`none` / `malformed`) publishes
|
|
510
|
+
* nothing and shows the fallback fill. The resolved surface hex lives only in
|
|
511
|
+
* the browser, so the cell labels its input.
|
|
513
512
|
*/
|
|
514
513
|
const DerivedSwatch = ({
|
|
515
514
|
accentColor,
|
|
@@ -547,9 +546,8 @@ const GridHead = ({ children }: { children: React.ReactNode }) => (
|
|
|
547
546
|
* Isolates the accent-chin surface: for every hue at maximum chroma and every
|
|
548
547
|
* neutral/edge input, the `dark` (Sent) and `light` (Received) surfaces CSS
|
|
549
548
|
* derives from the published `--accent`. One snapshot, no hero pixels — the
|
|
550
|
-
* dense diff target for the
|
|
551
|
-
*
|
|
552
|
-
* gamut clip diverges from culori's `clampChroma`, and will visibly diff.
|
|
549
|
+
* dense diff target for the derivation. In-gamut inputs (the neutral/edge rows)
|
|
550
|
+
* are stable; the max-chroma hue-sweep rows depend on the browser's gamut map.
|
|
553
551
|
*/
|
|
554
552
|
export const AccentDerivation: StoryFn = () => (
|
|
555
553
|
<div className="min-h-screen w-full bg-[#F9F7F4] p-8">
|
|
@@ -120,10 +120,9 @@ describe('LinkAttachment accent chin (MES-1349, MES-1388)', () => {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
// The colour derivation itself is CSS (`oklch(from …)` in styles.css) and is
|
|
123
|
-
// not computed by jsdom, so
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
// parity is covered by the `AccentDerivation` Chromatic story (MES-1412).
|
|
123
|
+
// not computed by jsdom, so these tests assert the contract React owns: the
|
|
124
|
+
// raw extracted hex is published as `--accent` (and dropped when there is no
|
|
125
|
+
// visible hero), leaving the surface derivation to the browser.
|
|
127
126
|
const accentOf = (element: HTMLElement) =>
|
|
128
127
|
element.style.getPropertyValue('--accent')
|
|
129
128
|
|
|
@@ -133,8 +132,8 @@ describe('LinkAttachment accent chin (MES-1349, MES-1388)', () => {
|
|
|
133
132
|
)
|
|
134
133
|
const root = await screen.findByRole('link')
|
|
135
134
|
expect(accentOf(root)).toBe(ACCENT)
|
|
136
|
-
// No inline background: the surface is derived from `--accent` in CSS,
|
|
137
|
-
//
|
|
135
|
+
// No inline background: the surface is derived from `--accent` in CSS, the
|
|
136
|
+
// raw accent is never painted verbatim.
|
|
138
137
|
expect(root.style.backgroundColor).toBe('')
|
|
139
138
|
expect(screen.getByText(CARD_PROPS.title)).toHaveStyle({ color: '#FFFFFF' })
|
|
140
139
|
})
|
|
@@ -295,8 +294,8 @@ describe('LinkAttachment accent chin (MES-1349, MES-1388)', () => {
|
|
|
295
294
|
|
|
296
295
|
it('normalizes a hashless accent so the derivation actually resolves', async () => {
|
|
297
296
|
// The extractor returns a bare hex often enough that dropping it would lose
|
|
298
|
-
// the colour silently — `oklch(from 7008E7 …)` never resolves
|
|
299
|
-
//
|
|
297
|
+
// the colour silently — `oklch(from 7008E7 …)` never resolves, so the
|
|
298
|
+
// published `--accent` must carry the `#`.
|
|
300
299
|
const hashless = renderWithProviders(
|
|
301
300
|
<LinkAttachment.Sent {...CARD_PROPS} accentColor="7008E7" />
|
|
302
301
|
)
|
|
@@ -4,10 +4,10 @@ import React from 'react'
|
|
|
4
4
|
export interface BubbleTailProps {
|
|
5
5
|
/**
|
|
6
6
|
* Raw extracted accent colour, published as `--accent` so the tail derives
|
|
7
|
-
* the same surface as the card in CSS (`styles.css`)
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* the same surface as the card in CSS (`styles.css`), or `undefined` to fall
|
|
8
|
+
* back to this side's plain bubble fill. The tail paints outside the shell's
|
|
9
|
+
* box and can't inherit its background, so it runs the derivation off its own
|
|
10
|
+
* `--accent`.
|
|
11
11
|
*/
|
|
12
12
|
accentHex?: string
|
|
13
13
|
/** Sender tails hang off the right edge, receiver tails mirror to the left. */
|
|
@@ -18,7 +18,7 @@ export interface CardBodyProps {
|
|
|
18
18
|
* Ink for both chin lines, from `useChinPalette` — fixed per surface (white on
|
|
19
19
|
* the dark stop, near-black on the pale stop and the audio strip). Replaces the
|
|
20
20
|
* variant's own `text-*` classes (including their opacity) on both lines, so a
|
|
21
|
-
* card whose surface is not the variant default still reads
|
|
21
|
+
* card whose surface is not the variant default still reads.
|
|
22
22
|
*/
|
|
23
23
|
chinTextColor?: string
|
|
24
24
|
/**
|
|
@@ -36,9 +36,9 @@ export interface CardShellProps {
|
|
|
36
36
|
bgClassName?: string
|
|
37
37
|
/**
|
|
38
38
|
* Raw extracted accent colour, published as the `--accent` custom property.
|
|
39
|
-
* `styles.css` derives the card surface from it
|
|
40
|
-
*
|
|
41
|
-
*
|
|
39
|
+
* `styles.css` derives the card surface from it (`oklch(from …)`) and paints
|
|
40
|
+
* it over the `bg-[…]` fallback where the browser supports it. `undefined`
|
|
41
|
+
* keeps the variant / `bgClassName` fill.
|
|
42
42
|
*/
|
|
43
43
|
accentHex?: string
|
|
44
44
|
/**
|
|
@@ -101,25 +101,20 @@ const CardShell: React.FC<CardShellProps> = ({
|
|
|
101
101
|
fixedHeight ? FIXED_HEIGHT_CLASS : 'block',
|
|
102
102
|
// The plain fallback fill, kept underneath the `--accent` derivation: the
|
|
103
103
|
// `.messaging-link-card[style*='--accent']` rule in `styles.css` outranks
|
|
104
|
-
// this single class, so a published accent paints over it
|
|
105
|
-
//
|
|
106
|
-
// lands on this sane surface.
|
|
104
|
+
// this single class, so a published accent paints over it and an unset one
|
|
105
|
+
// lands on this surface.
|
|
107
106
|
//
|
|
108
|
-
//
|
|
109
|
-
// Tailwind utilities
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
// on the Arbor preset and has no such colour, so `bg-shade` was silently
|
|
114
|
-
// dropped, the chin rendered transparent, and the own-message `color: white`
|
|
115
|
-
// left the title and URL invisible (MES-1388). An arbitrary value is
|
|
116
|
-
// generated from the class name alone and cannot depend on consumer theme.
|
|
107
|
+
// Must be an arbitrary value, not a theme token: this package ships no
|
|
108
|
+
// Tailwind utilities, so consumers generate our classes by scanning
|
|
109
|
+
// `messaging-react/dist` against their own theme. A theme colour a consumer
|
|
110
|
+
// lacks compiles to nothing and leaves the chin transparent; an arbitrary
|
|
111
|
+
// value is generated from the class name alone.
|
|
117
112
|
//
|
|
118
113
|
// Both values are the plain message bubble's own fill, so a card with no
|
|
119
114
|
// usable accent matches the text bubbles around it: `#1e2330` is
|
|
120
115
|
// `--str-chat__own-message-bubble-background-color` and `#f1f0ee` is
|
|
121
|
-
// `--str-chat__message-bubble-background-color
|
|
122
|
-
//
|
|
116
|
+
// `--str-chat__message-bubble-background-color`, mirrored by the bubble
|
|
117
|
+
// tail's own fills in `styles.css`.
|
|
123
118
|
bgClassName ?? (variant === 'dark' ? 'bg-[#1e2330]' : 'bg-[#f1f0ee]'),
|
|
124
119
|
// `focus-ring` is a design-system utility from the component-library
|
|
125
120
|
// tailwind preset — outline-none + a black 2px focus-visible ring
|
|
@@ -11,11 +11,9 @@
|
|
|
11
11
|
/**
|
|
12
12
|
* `#abc`, `#aabbcc`, or either without the leading `#`.
|
|
13
13
|
*
|
|
14
|
-
* The
|
|
15
|
-
* that rejecting them would
|
|
16
|
-
* exists — `
|
|
17
|
-
* how a card once rendered unaccented while every calculation behind it had
|
|
18
|
-
* succeeded (MES-1349).
|
|
14
|
+
* The optional hash is deliberate: the extractor returns bare hexes often
|
|
15
|
+
* enough that rejecting them would drop the colour. It is also why `toCssHex`
|
|
16
|
+
* exists — `738883` without the `#` is not a valid CSS colour.
|
|
19
17
|
*/
|
|
20
18
|
export const HEX_PATTERN = /^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i
|
|
21
19
|
|
|
@@ -42,13 +42,13 @@ export interface ChinPalette {
|
|
|
42
42
|
/**
|
|
43
43
|
* Raw extracted colour to publish as the `--accent` custom property on the
|
|
44
44
|
* shell and the tail, or `undefined` when there is no paintable accent. The
|
|
45
|
-
* hue
|
|
45
|
+
* card keeps its hue and swaps the lightness in CSS (`styles.css`).
|
|
46
46
|
*/
|
|
47
47
|
accentHex?: string
|
|
48
48
|
/**
|
|
49
49
|
* Ink for both chin lines: white on the sender's dark stop, near-black on the
|
|
50
|
-
* receiver's pale stop and on the audio strip. Fixed per surface
|
|
51
|
-
*
|
|
50
|
+
* receiver's pale stop and on the audio strip. Fixed per surface — the stops
|
|
51
|
+
* clear AA at every hue.
|
|
52
52
|
*/
|
|
53
53
|
chinTextColor: string
|
|
54
54
|
/** True while the card renders as a skeleton. */
|
|
@@ -58,33 +58,25 @@ export interface ChinPalette {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
* Resolves a link card
|
|
61
|
+
* Resolves the accent a link card publishes and tracks hero-image failure.
|
|
62
62
|
*
|
|
63
63
|
* The accent is a claim about an image the viewer can see, so it only paints
|
|
64
|
-
* when `CardThumbnail` actually mounts that image. Mirroring its branches
|
|
65
|
-
*
|
|
64
|
+
* when `CardThumbnail` actually mounts that image. Mirroring its branches, the
|
|
65
|
+
* hero is *not* the accent's source when:
|
|
66
66
|
*
|
|
67
67
|
* - `layout: 'classic'` — there is no hero region at all;
|
|
68
|
-
* - `status` is not `'ready'` — the hero is the pulsing skeleton
|
|
69
|
-
* no image yet;
|
|
68
|
+
* - `status` is not `'ready'` — the hero is the pulsing skeleton, no image yet;
|
|
70
69
|
* - `thumbnailUrl` is absent — the hero is the type-icon placeholder, or for a
|
|
71
70
|
* playable video a bare `bg-black` box with no poster;
|
|
72
71
|
* - the attachment is playable audio — the hero collapses to the native
|
|
73
|
-
* `<audio>` player and the `<img>` never mounts
|
|
74
|
-
*
|
|
75
|
-
* artwork-backed audio link preview shipped a coloured card with no visible
|
|
76
|
-
* source image, and the accent beat `AUDIO_BG_CLASS` on Sent / Received
|
|
77
|
-
* because `CardShell` applies it as an inline `style`, which outranks any
|
|
78
|
-
* `bg-*` class. `ComposerCard` already dodged that by returning early before
|
|
79
|
-
* it passes `accentStyle`; this is that same rule, stated once instead of
|
|
80
|
-
* three times (MES-1349);
|
|
72
|
+
* `<audio>` player and the `<img>` never mounts even though `thumbnailUrl` is
|
|
73
|
+
* set, so `onImageError` can never rescue it and the gate has to be up front;
|
|
81
74
|
* - the image 404s — an accent extracted from something the viewer cannot see.
|
|
82
75
|
* `onImageError` covers both hero shapes: the `<img>` reports directly, and a
|
|
83
76
|
* playable video's `poster` (which raises no event of its own) is verified by
|
|
84
77
|
* the hidden probe image in `CardThumbnail`.
|
|
85
78
|
*
|
|
86
|
-
* Every case
|
|
87
|
-
* the variant's own text colours.
|
|
79
|
+
* Every excluded case publishes no accent and keeps the variant's own fill.
|
|
88
80
|
*/
|
|
89
81
|
export function useChinPalette({
|
|
90
82
|
variant,
|
|
@@ -110,30 +102,26 @@ export function useChinPalette({
|
|
|
110
102
|
// Truthiness rather than `!= null` so this tracks `CardThumbnail`'s own
|
|
111
103
|
// `thumbnailUrl ?` branch, which renders the placeholder for `''` too.
|
|
112
104
|
//
|
|
113
|
-
// Playable audio stays excluded
|
|
114
|
-
//
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
// if the artwork 404'd. Colouring audio cards from their artwork is a change
|
|
118
|
-
// to the audio tickets (MES-1360 / MES-1361), not to this one.
|
|
105
|
+
// Playable audio stays excluded: its hero collapses to the native `<audio>`
|
|
106
|
+
// player, so the artwork never appears and an accent taken from it would claim
|
|
107
|
+
// an image the viewer cannot see. The `<img>` never mounts either, so
|
|
108
|
+
// `onImageError` could not withdraw the colour if the artwork 404'd.
|
|
119
109
|
const isAudio = isPlayableAudio(mimeType, sourceUrl)
|
|
120
110
|
const hasHero =
|
|
121
111
|
layout === 'featured' && !!thumbnailUrl && !isAudio && !heroFailed
|
|
122
112
|
const canDerive = hasHero && status === 'ready'
|
|
123
|
-
// Only a validated hex is published: `accent_color` is always a
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
//
|
|
127
|
-
// would silently lose the colour (MES-1349).
|
|
113
|
+
// Only a validated hex is published: the extracted `accent_color` is always a
|
|
114
|
+
// hex, and CSS would resolve any colour name, so narrow the input here. Bare
|
|
115
|
+
// hexes are accepted because the extractor omits the `#` often enough that
|
|
116
|
+
// rejecting them would silently lose the colour.
|
|
128
117
|
const accentHex =
|
|
129
118
|
canDerive && accentColor != null && HEX_PATTERN.test(accentColor.trim())
|
|
130
119
|
? toCssHex(accentColor)
|
|
131
120
|
: undefined
|
|
132
121
|
|
|
133
122
|
// The accent surface and the sender's dark fallback both take white ink; the
|
|
134
|
-
// pale receiver fallback and the imposed audio strip both take near-black
|
|
135
|
-
// the ink is fixed per surface
|
|
136
|
-
// card put white ink on the strip's near-white at 1.13:1 before (MES-1388).
|
|
123
|
+
// pale receiver fallback and the imposed audio strip both take near-black — so
|
|
124
|
+
// the ink is fixed per surface.
|
|
137
125
|
const chinTextColor = isAudio ? INK_ON_LIGHT : INK_BY_VARIANT[variant]
|
|
138
126
|
|
|
139
127
|
return {
|
package/src/styles.css
CHANGED
|
@@ -1101,13 +1101,12 @@
|
|
|
1101
1101
|
}
|
|
1102
1102
|
}
|
|
1103
1103
|
|
|
1104
|
-
/* Derived accent surface for `LinkAttachment` cards
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
4.5:1 against each side's ink at every hue by construction. */
|
|
1104
|
+
/* Derived accent surface for `LinkAttachment` cards. `--accent` is the raw
|
|
1105
|
+
colour extracted from the attachment image; the card keeps its hue and swaps
|
|
1106
|
+
the lightness to this side's `--surface-l` stop. Only paints where the browser
|
|
1107
|
+
resolves relative colour syntax and an accent is set — otherwise the card's
|
|
1108
|
+
`bg-[…]` fallback fill shows through. The stops clear 4.5:1 against each side's
|
|
1109
|
+
ink at every hue. */
|
|
1111
1110
|
.messaging-link-card[data-variant='dark'] {
|
|
1112
1111
|
--surface-l: 0.3;
|
|
1113
1112
|
}
|
|
@@ -1121,10 +1120,9 @@
|
|
|
1121
1120
|
}
|
|
1122
1121
|
}
|
|
1123
1122
|
|
|
1124
|
-
/* Bubble tail for `LinkAttachment` cards
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
the attachment image at send time and Tailwind cannot express a runtime hex.
|
|
1123
|
+
/* Bubble tail for `LinkAttachment` cards. Same 20x23 geometry and mask path as
|
|
1124
|
+
the text-bubble tails above; the fill is the card's accent surface, derived
|
|
1125
|
+
below from its own `--accent`.
|
|
1128
1126
|
|
|
1129
1127
|
Hand-written here rather than as a toolkit-only Tailwind utility on purpose:
|
|
1130
1128
|
`styles.css` ships as a built stylesheet that every consumer imports, whereas
|