@linktr.ee/messaging-react 3.31.0 → 3.31.1-rc-1785922698
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": "3.31.
|
|
3
|
+
"version": "3.31.1-rc-1785922698",
|
|
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": "
|
|
53
|
+
"@linktr.ee/messaging-core": "2.4.0-rc-1785922698",
|
|
54
54
|
"@linktr.ee/messaging-taxonomy": "^0.5.0",
|
|
55
55
|
"@phosphor-icons/react": "^2.1.10",
|
|
56
56
|
"culori": "^4.0.2"
|
|
@@ -7,6 +7,10 @@ import {
|
|
|
7
7
|
import type { Meta, StoryFn } from '@storybook/react'
|
|
8
8
|
import React from 'react'
|
|
9
9
|
|
|
10
|
+
import { accentSurface } from './components/_shared/accentSurface'
|
|
11
|
+
import type { LinkAttachmentVariant } from './components/_shared/CardShell'
|
|
12
|
+
import { BUBBLE_BG_BY_VARIANT, inkFor } from './components/_shared/chinContrast'
|
|
13
|
+
|
|
10
14
|
import LinkAttachment from '.'
|
|
11
15
|
|
|
12
16
|
const IMAGE_THUMBNAIL = '/image-thumbnail.jpg'
|
|
@@ -451,3 +455,102 @@ export const AccentWithoutVisibleHero: StoryFn = () => (
|
|
|
451
455
|
)
|
|
452
456
|
|
|
453
457
|
AccentWithoutVisibleHero.parameters = { chromatic: { disableSnapshot: false } }
|
|
458
|
+
|
|
459
|
+
/* ──────────────────────────────────────────────────────────────────
|
|
460
|
+
Accent derivation swatches
|
|
461
|
+
────────────────────────────────────────────────────────────────── */
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Max-chroma sRGB colour for a hue — three phase-shifted cosines, so stepping
|
|
465
|
+
* the hue walks the wheel at the most saturated triple each hue has. Mirrors
|
|
466
|
+
* the generator `accentSurface.test.ts` sweeps.
|
|
467
|
+
*/
|
|
468
|
+
const vividHex = (hue: number): string =>
|
|
469
|
+
`#${[0, 120, 240]
|
|
470
|
+
.map((offset) =>
|
|
471
|
+
Math.round(127 + 127 * Math.cos(((hue + offset) * Math.PI) / 180))
|
|
472
|
+
.toString(16)
|
|
473
|
+
.padStart(2, '0')
|
|
474
|
+
)
|
|
475
|
+
.join('')}`
|
|
476
|
+
|
|
477
|
+
const HUE_SWEEP = Array.from({ length: 24 }, (_, i) => ({
|
|
478
|
+
label: `${i * 15}°`,
|
|
479
|
+
accentColor: vividHex(i * 15),
|
|
480
|
+
}))
|
|
481
|
+
|
|
482
|
+
// Neutrals and near-limits where the AA gate and the ink flip actually decide
|
|
483
|
+
// something, plus the two inputs that must never derive a surface.
|
|
484
|
+
const EDGE_SAMPLES: Array<{ label: string; accentColor?: string }> = [
|
|
485
|
+
{ label: 'mock #738883', accentColor: '#738883' },
|
|
486
|
+
{ label: 'pale #FFF099', accentColor: '#FFF099' },
|
|
487
|
+
{ label: 'near-white #FCF5E3', accentColor: '#FCF5E3' },
|
|
488
|
+
{ label: 'near-black #1e2330', accentColor: '#1e2330' },
|
|
489
|
+
{ label: 'neutral #767676', accentColor: '#767676' },
|
|
490
|
+
{ label: 'vivid #7008E7', accentColor: '#7008E7' },
|
|
491
|
+
{ label: 'none', accentColor: undefined },
|
|
492
|
+
{ label: 'malformed', accentColor: 'rebeccapurple' },
|
|
493
|
+
]
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* One derivation cell: the surface the card would paint for this accent and
|
|
497
|
+
* variant, drawn in the ink `inkFor` picks against it. `accentSurface` and
|
|
498
|
+
* `inkFor` are the only outputs `culori` feeds into the card, so this paints
|
|
499
|
+
* exactly what a colour-library swap could move — with the resolved hex printed
|
|
500
|
+
* so a shift also reads as a text diff. A refused accent shows the variant's
|
|
501
|
+
* fallback fill, tagged.
|
|
502
|
+
*/
|
|
503
|
+
const DerivedSwatch = ({
|
|
504
|
+
accentColor,
|
|
505
|
+
variant,
|
|
506
|
+
}: {
|
|
507
|
+
accentColor?: string
|
|
508
|
+
variant: LinkAttachmentVariant
|
|
509
|
+
}) => {
|
|
510
|
+
const surface = accentSurface(accentColor, variant)
|
|
511
|
+
const painted = surface ?? BUBBLE_BG_BY_VARIANT[variant]
|
|
512
|
+
return (
|
|
513
|
+
<div
|
|
514
|
+
className="flex h-12 flex-col justify-between rounded-md px-2 py-1.5 text-[11px] font-medium"
|
|
515
|
+
style={{ backgroundColor: painted, color: inkFor(painted) }}
|
|
516
|
+
>
|
|
517
|
+
<span>Yoga on Ice</span>
|
|
518
|
+
<span className="font-mono opacity-80">
|
|
519
|
+
{surface ?? `fallback ${painted}`}
|
|
520
|
+
</span>
|
|
521
|
+
</div>
|
|
522
|
+
)
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
const GridHead = ({ children }: { children: React.ReactNode }) => (
|
|
526
|
+
<div className="text-xs font-medium text-black/40">{children}</div>
|
|
527
|
+
)
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Isolates the colour maths behind the accent chin: for every hue at maximum
|
|
531
|
+
* chroma and every neutral/edge input, the `dark` (Sent) and `light` (Received)
|
|
532
|
+
* surfaces `accentSurface` derives, each in the ink `inkFor` returns for it.
|
|
533
|
+
* One snapshot, no hero pixels — a dense visual companion to the
|
|
534
|
+
* `accentSurface` hue-sweep unit test, so any drift in the derivation shows up
|
|
535
|
+
* as both a colour change and a hex text diff across adjacent rows.
|
|
536
|
+
*/
|
|
537
|
+
export const AccentDerivation: StoryFn = () => (
|
|
538
|
+
<div className="min-h-screen w-full bg-[#F9F7F4] p-8">
|
|
539
|
+
<div className="grid grid-cols-[6rem_1fr_1fr] items-center gap-x-4 gap-y-1.5">
|
|
540
|
+
<div />
|
|
541
|
+
<GridHead>Sent (dark stop)</GridHead>
|
|
542
|
+
<GridHead>Received (light stop)</GridHead>
|
|
543
|
+
{[...HUE_SWEEP, ...EDGE_SAMPLES].map(({ label, accentColor }) => (
|
|
544
|
+
<React.Fragment key={label}>
|
|
545
|
+
<div className="text-right text-xs font-medium text-black/40">
|
|
546
|
+
{label}
|
|
547
|
+
</div>
|
|
548
|
+
<DerivedSwatch accentColor={accentColor} variant="dark" />
|
|
549
|
+
<DerivedSwatch accentColor={accentColor} variant="light" />
|
|
550
|
+
</React.Fragment>
|
|
551
|
+
))}
|
|
552
|
+
</div>
|
|
553
|
+
</div>
|
|
554
|
+
)
|
|
555
|
+
|
|
556
|
+
AccentDerivation.parameters = { chromatic: { disableSnapshot: false } }
|