@designa8/vibedesign-linear-internal-v1-b737 0.7.0 → 0.9.0
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/README.md +1 -1
- package/dist/index.cjs +1204 -928
- package/dist/index.js +1232 -956
- package/dist/styles.css +33 -0
- package/package.json +11 -1
- package/src/atoms/DesignSystemLoader/DesignSystemLoader.tsx +139 -0
- package/src/atoms/DesignSystemLoader/index.ts +2 -0
- package/src/atoms/DesignSystemLoader/preview.tsx +19 -0
- package/src/atoms/ExpandableMessage/ExpandableMessage.tsx +224 -0
- package/src/atoms/ExpandableMessage/index.ts +5 -0
- package/src/atoms/ExpandableMessage/preview.tsx +102 -0
- package/src/index.ts +2 -0
package/dist/styles.css
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
--radius-lg: 12px;
|
|
25
25
|
--radius-xl: 16px;
|
|
26
26
|
--ease-out: cubic-bezier(0, 0, 0.2, 1);
|
|
27
|
+
--ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
|
|
27
28
|
--animate-spin: spin 1s linear infinite;
|
|
28
29
|
--animate-pulse: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
|
29
30
|
--aspect-video: 16 / 9;
|
|
@@ -79,6 +80,7 @@
|
|
|
79
80
|
--text-heading-sm--letter-spacing: -0.1px;
|
|
80
81
|
--text-body-lg: 15px;
|
|
81
82
|
--text-body-lg--font-weight: 400;
|
|
83
|
+
--leading-body-lg: 1.55;
|
|
82
84
|
--text-body-lg--line-height: 1.55;
|
|
83
85
|
--text-body-lg--letter-spacing: -0.1px;
|
|
84
86
|
--text-body-md: 14px;
|
|
@@ -310,6 +312,9 @@
|
|
|
310
312
|
.sticky {
|
|
311
313
|
position: sticky;
|
|
312
314
|
}
|
|
315
|
+
.-inset-md {
|
|
316
|
+
inset: calc(var(--spacing-md) * -1);
|
|
317
|
+
}
|
|
313
318
|
.inset-0 {
|
|
314
319
|
inset: 0;
|
|
315
320
|
}
|
|
@@ -707,6 +712,9 @@
|
|
|
707
712
|
.h-px {
|
|
708
713
|
height: 1px;
|
|
709
714
|
}
|
|
715
|
+
.h-xl {
|
|
716
|
+
height: var(--spacing-xl);
|
|
717
|
+
}
|
|
710
718
|
.h-xs {
|
|
711
719
|
height: var(--spacing-xs);
|
|
712
720
|
}
|
|
@@ -887,6 +895,9 @@
|
|
|
887
895
|
.max-w-48 {
|
|
888
896
|
max-width: calc(var(--spacing) * 48);
|
|
889
897
|
}
|
|
898
|
+
.max-w-drawer {
|
|
899
|
+
max-width: var(--container-drawer);
|
|
900
|
+
}
|
|
890
901
|
.max-w-full {
|
|
891
902
|
max-width: 100%;
|
|
892
903
|
}
|
|
@@ -1600,6 +1611,9 @@
|
|
|
1600
1611
|
.px-xxl {
|
|
1601
1612
|
padding-inline: var(--spacing-xxl);
|
|
1602
1613
|
}
|
|
1614
|
+
.py-0 {
|
|
1615
|
+
padding-block: 0;
|
|
1616
|
+
}
|
|
1603
1617
|
.py-base {
|
|
1604
1618
|
padding-block: var(--spacing-base);
|
|
1605
1619
|
}
|
|
@@ -1621,6 +1635,9 @@
|
|
|
1621
1635
|
.py-xs {
|
|
1622
1636
|
padding-block: var(--spacing-xs);
|
|
1623
1637
|
}
|
|
1638
|
+
.py-xxl {
|
|
1639
|
+
padding-block: var(--spacing-xxl);
|
|
1640
|
+
}
|
|
1624
1641
|
.py-xxs {
|
|
1625
1642
|
padding-block: var(--spacing-xxs);
|
|
1626
1643
|
}
|
|
@@ -1783,6 +1800,10 @@
|
|
|
1783
1800
|
letter-spacing: var(--tw-tracking, var(--text-overline--letter-spacing));
|
|
1784
1801
|
font-weight: var(--tw-font-weight, var(--text-overline--font-weight));
|
|
1785
1802
|
}
|
|
1803
|
+
.leading-body-lg {
|
|
1804
|
+
--tw-leading: var(--leading-body-lg);
|
|
1805
|
+
line-height: var(--leading-body-lg);
|
|
1806
|
+
}
|
|
1786
1807
|
.tracking-overline {
|
|
1787
1808
|
--tw-tracking: var(--tracking-overline);
|
|
1788
1809
|
letter-spacing: var(--tracking-overline);
|
|
@@ -1869,6 +1890,9 @@
|
|
|
1869
1890
|
.opacity-0 {
|
|
1870
1891
|
opacity: 0%;
|
|
1871
1892
|
}
|
|
1893
|
+
.opacity-30 {
|
|
1894
|
+
opacity: 30%;
|
|
1895
|
+
}
|
|
1872
1896
|
.opacity-50 {
|
|
1873
1897
|
opacity: 50%;
|
|
1874
1898
|
}
|
|
@@ -1979,6 +2003,10 @@
|
|
|
1979
2003
|
--tw-duration: 200ms;
|
|
1980
2004
|
transition-duration: 200ms;
|
|
1981
2005
|
}
|
|
2006
|
+
.ease-in-out {
|
|
2007
|
+
--tw-ease: var(--ease-in-out);
|
|
2008
|
+
transition-timing-function: var(--ease-in-out);
|
|
2009
|
+
}
|
|
1982
2010
|
.ease-out {
|
|
1983
2011
|
--tw-ease: var(--ease-out);
|
|
1984
2012
|
transition-timing-function: var(--ease-out);
|
|
@@ -2972,6 +3000,10 @@
|
|
|
2972
3000
|
inherits: false;
|
|
2973
3001
|
initial-value: solid;
|
|
2974
3002
|
}
|
|
3003
|
+
@property --tw-leading {
|
|
3004
|
+
syntax: "*";
|
|
3005
|
+
inherits: false;
|
|
3006
|
+
}
|
|
2975
3007
|
@property --tw-tracking {
|
|
2976
3008
|
syntax: "*";
|
|
2977
3009
|
inherits: false;
|
|
@@ -3151,6 +3183,7 @@
|
|
|
3151
3183
|
--tw-space-y-reverse: 0;
|
|
3152
3184
|
--tw-divide-y-reverse: 0;
|
|
3153
3185
|
--tw-border-style: solid;
|
|
3186
|
+
--tw-leading: initial;
|
|
3154
3187
|
--tw-tracking: initial;
|
|
3155
3188
|
--tw-ordinal: initial;
|
|
3156
3189
|
--tw-slashed-zero: initial;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@designa8/vibedesign-linear-internal-v1-b737",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Complete design system \"My Project linear-internal-v1\" generated by Atoms Design.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -189,6 +189,11 @@
|
|
|
189
189
|
"kind": "Organism",
|
|
190
190
|
"description": null
|
|
191
191
|
},
|
|
192
|
+
{
|
|
193
|
+
"name": "DesignSystemLoader",
|
|
194
|
+
"kind": "Organism",
|
|
195
|
+
"description": null
|
|
196
|
+
},
|
|
192
197
|
{
|
|
193
198
|
"name": "Divider",
|
|
194
199
|
"kind": "Atom",
|
|
@@ -209,6 +214,11 @@
|
|
|
209
214
|
"kind": "Molecule",
|
|
210
215
|
"description": null
|
|
211
216
|
},
|
|
217
|
+
{
|
|
218
|
+
"name": "ExpandableMessage",
|
|
219
|
+
"kind": "Molecule",
|
|
220
|
+
"description": null
|
|
221
|
+
},
|
|
212
222
|
{
|
|
213
223
|
"name": "FileUpload",
|
|
214
224
|
"kind": "Molecule",
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Icon } from "../Icon";
|
|
3
|
+
|
|
4
|
+
export interface DesignSystemLoaderProps
|
|
5
|
+
extends React.ComponentPropsWithoutRef<"div"> {
|
|
6
|
+
/** Primary status line announced to assistive tech. */
|
|
7
|
+
label?: string;
|
|
8
|
+
/** Secondary supporting line. */
|
|
9
|
+
sublabel?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Cells per side of the loading grid. */
|
|
13
|
+
const GRID = 9;
|
|
14
|
+
|
|
15
|
+
/** Full sweep length for one cell, in milliseconds. */
|
|
16
|
+
const SWEEP_MS = 2400;
|
|
17
|
+
/** Delay added per step of diagonal distance from the top-right corner. */
|
|
18
|
+
const STEP_MS = 35;
|
|
19
|
+
|
|
20
|
+
interface Sparkle {
|
|
21
|
+
top: string;
|
|
22
|
+
left: string;
|
|
23
|
+
size: number;
|
|
24
|
+
delay: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Positions are percentages of the sparkle layer, which is inset past the grid
|
|
29
|
+
* on every side — so each glyph lands in the ring around the cells, never
|
|
30
|
+
* hidden beneath them.
|
|
31
|
+
*/
|
|
32
|
+
const SPARKLES: readonly Sparkle[] = [
|
|
33
|
+
{ top: "0%", left: "14%", size: 10, delay: "0ms" },
|
|
34
|
+
{ top: "2%", left: "46%", size: 8, delay: "150ms" },
|
|
35
|
+
{ top: "1%", left: "78%", size: 9, delay: "75ms" },
|
|
36
|
+
{ top: "30%", left: "0%", size: 7, delay: "300ms" },
|
|
37
|
+
{ top: "58%", left: "97%", size: 8, delay: "125ms" },
|
|
38
|
+
{ top: "96%", left: "20%", size: 8, delay: "225ms" },
|
|
39
|
+
{ top: "93%", left: "62%", size: 10, delay: "375ms" },
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const KEYFRAMES = `
|
|
43
|
+
@keyframes dsl-twinkle {
|
|
44
|
+
0%, 100% { opacity: 0.2; transform: scale(0.85); }
|
|
45
|
+
50% { opacity: 0.9; transform: scale(1.1); }
|
|
46
|
+
}
|
|
47
|
+
@keyframes dsl-cell {
|
|
48
|
+
0% { background-color: var(--color-primary); border-color: transparent; border-style: solid; opacity: 1; }
|
|
49
|
+
8% { background-color: var(--color-primary); border-color: transparent; border-style: solid; opacity: 0.8; }
|
|
50
|
+
18% { background-color: var(--color-primary-soft); border-color: transparent; border-style: solid; opacity: 1; }
|
|
51
|
+
30% { background-color: var(--color-primary-soft); border-color: transparent; border-style: solid; opacity: 0.55; }
|
|
52
|
+
45% { background-color: var(--color-surface-soft); border-color: var(--color-hairline); border-style: solid; opacity: 1; }
|
|
53
|
+
62% { background-color: transparent; border-color: var(--color-hairline-strong); border-style: dashed; opacity: 1; }
|
|
54
|
+
82% { background-color: transparent; border-color: var(--color-hairline-strong); border-style: dashed; opacity: 1; }
|
|
55
|
+
100% { background-color: var(--color-primary); border-color: transparent; border-style: solid; opacity: 1; }
|
|
56
|
+
}
|
|
57
|
+
@media (prefers-reduced-motion: reduce) {
|
|
58
|
+
.dsl-animate { animation: none !important; }
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
61
|
+
|
|
62
|
+
export const DesignSystemLoader = React.forwardRef<
|
|
63
|
+
HTMLDivElement,
|
|
64
|
+
DesignSystemLoaderProps
|
|
65
|
+
>(
|
|
66
|
+
(
|
|
67
|
+
{
|
|
68
|
+
label = "Loading design system…",
|
|
69
|
+
sublabel = "Building your component library",
|
|
70
|
+
className,
|
|
71
|
+
...rest
|
|
72
|
+
},
|
|
73
|
+
ref,
|
|
74
|
+
) => (
|
|
75
|
+
<div
|
|
76
|
+
ref={ref}
|
|
77
|
+
role="status"
|
|
78
|
+
aria-live="polite"
|
|
79
|
+
aria-busy="true"
|
|
80
|
+
className={[
|
|
81
|
+
"mx-auto flex w-full max-w-3xl flex-col items-center justify-center gap-xl bg-canvas px-lg py-xxl text-center",
|
|
82
|
+
className,
|
|
83
|
+
]
|
|
84
|
+
.filter(Boolean)
|
|
85
|
+
.join(" ")}
|
|
86
|
+
{...rest}
|
|
87
|
+
>
|
|
88
|
+
<style>{KEYFRAMES}</style>
|
|
89
|
+
|
|
90
|
+
<div className="relative mx-auto w-full max-w-drawer">
|
|
91
|
+
<div className="pointer-events-none absolute -inset-md" aria-hidden="true">
|
|
92
|
+
{SPARKLES.map((sparkle) => (
|
|
93
|
+
<Icon
|
|
94
|
+
key={`${sparkle.top}-${sparkle.left}`}
|
|
95
|
+
name="sparkles"
|
|
96
|
+
size={sparkle.size}
|
|
97
|
+
className="dsl-animate absolute text-primary opacity-30"
|
|
98
|
+
style={{
|
|
99
|
+
top: sparkle.top,
|
|
100
|
+
left: sparkle.left,
|
|
101
|
+
animation: `dsl-twinkle 1.6s ease-in-out ${sparkle.delay} infinite`,
|
|
102
|
+
}}
|
|
103
|
+
/>
|
|
104
|
+
))}
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<div
|
|
108
|
+
className="relative grid gap-xxs"
|
|
109
|
+
aria-hidden="true"
|
|
110
|
+
style={{ gridTemplateColumns: `repeat(${GRID}, minmax(0, 1fr))` }}
|
|
111
|
+
>
|
|
112
|
+
{Array.from({ length: GRID * GRID }, (_, index) => {
|
|
113
|
+
const row = Math.floor(index / GRID);
|
|
114
|
+
const col = index % GRID;
|
|
115
|
+
const diagonal = row + (GRID - 1 - col);
|
|
116
|
+
return (
|
|
117
|
+
<span
|
|
118
|
+
key={index}
|
|
119
|
+
className="dsl-animate aspect-square rounded-xs border-2 border-transparent bg-primary"
|
|
120
|
+
style={{
|
|
121
|
+
animation: `dsl-cell ${SWEEP_MS}ms ease-in-out ${
|
|
122
|
+
diagonal * STEP_MS
|
|
123
|
+
}ms infinite both`,
|
|
124
|
+
}}
|
|
125
|
+
/>
|
|
126
|
+
);
|
|
127
|
+
})}
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<div className="mx-auto flex w-full max-w-drawer flex-col items-center gap-xs">
|
|
132
|
+
<p className="text-heading-sm text-ink">{label}</p>
|
|
133
|
+
<p className="text-body-sm text-muted">{sublabel}</p>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
),
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
DesignSystemLoader.displayName = "DesignSystemLoader";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { DesignSystemLoader } from "./DesignSystemLoader";
|
|
3
|
+
|
|
4
|
+
export default function DesignSystemLoaderPreview() {
|
|
5
|
+
return (
|
|
6
|
+
<div className="w-full max-w-3xl mx-auto p-lg space-y-xl bg-canvas">
|
|
7
|
+
<section className="rounded-lg border border-hairline bg-surface shadow-card overflow-hidden">
|
|
8
|
+
<DesignSystemLoader />
|
|
9
|
+
</section>
|
|
10
|
+
|
|
11
|
+
<section className="rounded-lg border border-hairline bg-surface shadow-card overflow-hidden">
|
|
12
|
+
<DesignSystemLoader
|
|
13
|
+
label="Opening workspace…"
|
|
14
|
+
sublabel="Restoring your last session"
|
|
15
|
+
/>
|
|
16
|
+
</section>
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Icon } from "../Icon";
|
|
3
|
+
|
|
4
|
+
export type ExpandableMessageVariant = "card" | "flush";
|
|
5
|
+
|
|
6
|
+
export interface ExpandableMessageProps
|
|
7
|
+
extends Omit<React.HTMLAttributes<HTMLDivElement>, "children"> {
|
|
8
|
+
/** Raw message text. Newlines split it into paragraphs; blank lines are dropped. */
|
|
9
|
+
content: string;
|
|
10
|
+
/** Lines a single paragraph shows before it is clamped. Default 4. */
|
|
11
|
+
maxLines?: number;
|
|
12
|
+
/** Controlled expanded state. */
|
|
13
|
+
expanded?: boolean;
|
|
14
|
+
/** Initial expanded state when uncontrolled. Default false. */
|
|
15
|
+
defaultExpanded?: boolean;
|
|
16
|
+
onExpandedChange?: (expanded: boolean) => void;
|
|
17
|
+
/** Disables the Show more / Show less toggle. */
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* `card` — surface block with padding, a soft shadow and a bottom fade over a
|
|
21
|
+
* clamped paragraph. `flush` — bare text only, for use inside a chat bubble.
|
|
22
|
+
*/
|
|
23
|
+
variant?: ExpandableMessageVariant;
|
|
24
|
+
/** Recolors the toggle, e.g. on a tinted or inverted chat bubble. */
|
|
25
|
+
toggleClassName?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const cn = (...parts: Array<string | false | null | undefined>) =>
|
|
29
|
+
parts.filter(Boolean).join(" ");
|
|
30
|
+
|
|
31
|
+
const clampStyle = (lines: number): React.CSSProperties => ({
|
|
32
|
+
display: "-webkit-box",
|
|
33
|
+
WebkitLineClamp: lines,
|
|
34
|
+
WebkitBoxOrient: "vertical",
|
|
35
|
+
overflow: "hidden",
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const CHUNK_TEXT_CLASS =
|
|
39
|
+
"whitespace-pre-wrap text-body-md leading-body-lg text-body";
|
|
40
|
+
|
|
41
|
+
interface MessageParagraphProps {
|
|
42
|
+
index: number;
|
|
43
|
+
text: string;
|
|
44
|
+
maxLines: number;
|
|
45
|
+
clamp: boolean;
|
|
46
|
+
showFade: boolean;
|
|
47
|
+
onOverflowChange: (index: number, overflowing: boolean) => void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* One paragraph plus an invisible, always-clamped twin used to measure whether
|
|
52
|
+
* the trimmed text is taller than `maxLines`. Measuring the twin (rather than
|
|
53
|
+
* the visible node) keeps the answer correct after the message is expanded.
|
|
54
|
+
*/
|
|
55
|
+
function MessageParagraph({
|
|
56
|
+
index,
|
|
57
|
+
text,
|
|
58
|
+
maxLines,
|
|
59
|
+
clamp,
|
|
60
|
+
showFade,
|
|
61
|
+
onOverflowChange,
|
|
62
|
+
}: MessageParagraphProps) {
|
|
63
|
+
const measureRef = React.useRef<HTMLParagraphElement>(null);
|
|
64
|
+
|
|
65
|
+
React.useLayoutEffect(() => {
|
|
66
|
+
const el = measureRef.current;
|
|
67
|
+
if (!el) return;
|
|
68
|
+
const update = () =>
|
|
69
|
+
onOverflowChange(index, el.scrollHeight - el.clientHeight > 1);
|
|
70
|
+
update();
|
|
71
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
72
|
+
const observer = new ResizeObserver(update);
|
|
73
|
+
observer.observe(el);
|
|
74
|
+
return () => observer.disconnect();
|
|
75
|
+
}, [index, text, maxLines, onOverflowChange]);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<div className="relative">
|
|
79
|
+
<p
|
|
80
|
+
className={CHUNK_TEXT_CLASS}
|
|
81
|
+
style={clamp ? clampStyle(maxLines) : undefined}
|
|
82
|
+
>
|
|
83
|
+
{text}
|
|
84
|
+
</p>
|
|
85
|
+
{showFade && (
|
|
86
|
+
<div
|
|
87
|
+
aria-hidden="true"
|
|
88
|
+
className="pointer-events-none absolute inset-x-0 bottom-0 h-xl"
|
|
89
|
+
style={{
|
|
90
|
+
background:
|
|
91
|
+
"linear-gradient(to bottom, transparent, var(--color-surface))",
|
|
92
|
+
}}
|
|
93
|
+
/>
|
|
94
|
+
)}
|
|
95
|
+
<p
|
|
96
|
+
ref={measureRef}
|
|
97
|
+
aria-hidden="true"
|
|
98
|
+
className={cn(
|
|
99
|
+
"invisible absolute inset-x-0 top-0 -z-10",
|
|
100
|
+
CHUNK_TEXT_CLASS,
|
|
101
|
+
)}
|
|
102
|
+
style={clampStyle(maxLines)}
|
|
103
|
+
>
|
|
104
|
+
{text}
|
|
105
|
+
</p>
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const ExpandableMessage = React.forwardRef<
|
|
111
|
+
HTMLDivElement,
|
|
112
|
+
ExpandableMessageProps
|
|
113
|
+
>(
|
|
114
|
+
(
|
|
115
|
+
{
|
|
116
|
+
content,
|
|
117
|
+
maxLines = 4,
|
|
118
|
+
expanded: expandedProp,
|
|
119
|
+
defaultExpanded = false,
|
|
120
|
+
onExpandedChange,
|
|
121
|
+
disabled = false,
|
|
122
|
+
variant = "card",
|
|
123
|
+
toggleClassName,
|
|
124
|
+
className,
|
|
125
|
+
...rest
|
|
126
|
+
},
|
|
127
|
+
ref,
|
|
128
|
+
) => {
|
|
129
|
+
const reactId = React.useId();
|
|
130
|
+
const textId = `expandable-message-${reactId.replace(/:/g, "")}`;
|
|
131
|
+
const isFlush = variant === "flush";
|
|
132
|
+
const isControlled = expandedProp !== undefined;
|
|
133
|
+
|
|
134
|
+
const [internalExpanded, setInternalExpanded] =
|
|
135
|
+
React.useState(defaultExpanded);
|
|
136
|
+
const expanded = isControlled ? expandedProp : internalExpanded;
|
|
137
|
+
|
|
138
|
+
const setExpanded = React.useCallback(
|
|
139
|
+
(next: boolean) => {
|
|
140
|
+
if (!isControlled) setInternalExpanded(next);
|
|
141
|
+
onExpandedChange?.(next);
|
|
142
|
+
},
|
|
143
|
+
[isControlled, onExpandedChange],
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const paragraphs = React.useMemo(
|
|
147
|
+
() => content.split(/\r?\n/).filter((line) => line.trim().length > 0),
|
|
148
|
+
[content],
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
const [overflowing, setOverflowing] = React.useState<boolean[]>([]);
|
|
152
|
+
const handleOverflowChange = React.useCallback(
|
|
153
|
+
(index: number, isOverflowing: boolean) => {
|
|
154
|
+
setOverflowing((prev) => {
|
|
155
|
+
if (prev[index] === isOverflowing) return prev;
|
|
156
|
+
const next = prev.slice();
|
|
157
|
+
next[index] = isOverflowing;
|
|
158
|
+
return next;
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
[],
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const canExpand = paragraphs.some(
|
|
165
|
+
(_, index) => overflowing[index] === true,
|
|
166
|
+
);
|
|
167
|
+
const toggleTone =
|
|
168
|
+
toggleClassName ?? "text-primary hover:text-primary-hover";
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
<div
|
|
172
|
+
ref={ref}
|
|
173
|
+
className={cn(
|
|
174
|
+
"w-full",
|
|
175
|
+
!isFlush && "rounded-lg bg-surface p-lg shadow-sm",
|
|
176
|
+
className,
|
|
177
|
+
)}
|
|
178
|
+
{...rest}
|
|
179
|
+
>
|
|
180
|
+
<div id={textId} className="flex flex-col gap-xs">
|
|
181
|
+
{paragraphs.map((text, index) => {
|
|
182
|
+
const clamp = !expanded && overflowing[index] === true;
|
|
183
|
+
return (
|
|
184
|
+
<MessageParagraph
|
|
185
|
+
key={index}
|
|
186
|
+
index={index}
|
|
187
|
+
text={text}
|
|
188
|
+
maxLines={maxLines}
|
|
189
|
+
clamp={clamp}
|
|
190
|
+
showFade={!isFlush && clamp}
|
|
191
|
+
onOverflowChange={handleOverflowChange}
|
|
192
|
+
/>
|
|
193
|
+
);
|
|
194
|
+
})}
|
|
195
|
+
</div>
|
|
196
|
+
|
|
197
|
+
{canExpand && (
|
|
198
|
+
<button
|
|
199
|
+
type="button"
|
|
200
|
+
disabled={disabled}
|
|
201
|
+
onClick={() => setExpanded(!expanded)}
|
|
202
|
+
aria-expanded={expanded}
|
|
203
|
+
aria-controls={textId}
|
|
204
|
+
className={cn(
|
|
205
|
+
"mt-xs flex w-full cursor-pointer items-center justify-start gap-xs rounded-none border-0 bg-transparent px-0 py-0 text-left text-body-sm font-weight-label transition-colors duration-150 ease-out hover:bg-surface-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus-blue disabled:cursor-not-allowed disabled:opacity-50",
|
|
206
|
+
toggleTone,
|
|
207
|
+
)}
|
|
208
|
+
>
|
|
209
|
+
<span>{expanded ? "Show less" : "Show more"}</span>
|
|
210
|
+
<Icon
|
|
211
|
+
name="chevron-down"
|
|
212
|
+
size={14}
|
|
213
|
+
className={cn(
|
|
214
|
+
"transition-transform duration-200 ease-out",
|
|
215
|
+
expanded ? "rotate-180" : "rotate-0",
|
|
216
|
+
)}
|
|
217
|
+
/>
|
|
218
|
+
</button>
|
|
219
|
+
)}
|
|
220
|
+
</div>
|
|
221
|
+
);
|
|
222
|
+
},
|
|
223
|
+
);
|
|
224
|
+
ExpandableMessage.displayName = "ExpandableMessage";
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Button } from "../Button";
|
|
3
|
+
import { ExpandableMessage } from "./ExpandableMessage";
|
|
4
|
+
|
|
5
|
+
const LONG = `I traced the regression to the token pipeline rather than the component itself, because the generated theme block was emitting the radius scale under the wrong prefix and every card in the review queue silently fell back to a zero radius while the panel kept showing the configured value. That mismatch is why the screenshots looked fine on one screen and broken on another: the panel reads the stored token, the preview reads the compiled CSS variable, and the two had drifted apart somewhere in the build step without either of them reporting an error.
|
|
6
|
+
|
|
7
|
+
The fix was to emit the scale from a single source and let both consumers read it, so once that landed the cards, the dialogs, the drawers, and the popovers all picked up the intended corners without touching a single component file. I also added a regression check that compares the compiled output against the stored tokens on every build, so this class of drift cannot come back quietly.
|
|
8
|
+
|
|
9
|
+
What still needs an owner is the migration of the older hand-written utilities in three feature folders, which will keep compiling but will not follow the scale until they are moved over.`;
|
|
10
|
+
|
|
11
|
+
const MULTI = `First paragraph explains the intent of the change and the one thing the reviewer should focus on, so the rest of the message can stay short and the decision does not need another round trip.
|
|
12
|
+
|
|
13
|
+
Second paragraph carries the details, including the measurement I used, the reason the earlier approach was abandoned, and the point where the two numbers stopped agreeing with each other.
|
|
14
|
+
|
|
15
|
+
Third paragraph lists the follow-up work that still needs an owner, because none of it is blocking this review but all of it matters before the next release goes out the door.`;
|
|
16
|
+
|
|
17
|
+
const SHORT =
|
|
18
|
+
"Rebuilt the preview bundle and confirmed the new radius scale compiles correctly across the queue.";
|
|
19
|
+
|
|
20
|
+
export default function ExpandableMessagePreview() {
|
|
21
|
+
const [expandedCard, setExpandedCard] = React.useState(false);
|
|
22
|
+
const [expandedFlush, setExpandedFlush] = React.useState(false);
|
|
23
|
+
const [maxLines, setMaxLines] = React.useState(3);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className="w-full max-w-3xl mx-auto space-y-lg p-lg">
|
|
27
|
+
<div className="space-y-xs">
|
|
28
|
+
<p className="text-caption text-muted">
|
|
29
|
+
Card · clamped at {maxLines} lines
|
|
30
|
+
</p>
|
|
31
|
+
<ExpandableMessage
|
|
32
|
+
content={LONG}
|
|
33
|
+
maxLines={maxLines}
|
|
34
|
+
expanded={expandedCard}
|
|
35
|
+
onExpandedChange={setExpandedCard}
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<div className="flex flex-wrap items-center gap-sm">
|
|
40
|
+
<Button
|
|
41
|
+
variant="secondary"
|
|
42
|
+
size="sm"
|
|
43
|
+
aria-pressed={maxLines === 2}
|
|
44
|
+
onClick={() => setMaxLines(2)}
|
|
45
|
+
>
|
|
46
|
+
2 lines
|
|
47
|
+
</Button>
|
|
48
|
+
<Button
|
|
49
|
+
variant="secondary"
|
|
50
|
+
size="sm"
|
|
51
|
+
aria-pressed={maxLines === 3}
|
|
52
|
+
onClick={() => setMaxLines(3)}
|
|
53
|
+
>
|
|
54
|
+
3 lines
|
|
55
|
+
</Button>
|
|
56
|
+
<Button
|
|
57
|
+
variant="secondary"
|
|
58
|
+
size="sm"
|
|
59
|
+
aria-pressed={maxLines === 6}
|
|
60
|
+
onClick={() => setMaxLines(6)}
|
|
61
|
+
>
|
|
62
|
+
6 lines
|
|
63
|
+
</Button>
|
|
64
|
+
<Button
|
|
65
|
+
variant="secondary"
|
|
66
|
+
size="sm"
|
|
67
|
+
onClick={() => setExpandedCard(false)}
|
|
68
|
+
>
|
|
69
|
+
Collapse card
|
|
70
|
+
</Button>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<div className="space-y-xs">
|
|
74
|
+
<p className="text-caption text-muted">
|
|
75
|
+
Flush · inside a tinted chat bubble
|
|
76
|
+
</p>
|
|
77
|
+
<div className="w-full rounded-lg bg-primary-soft p-md">
|
|
78
|
+
<ExpandableMessage
|
|
79
|
+
variant="flush"
|
|
80
|
+
content={MULTI}
|
|
81
|
+
maxLines={2}
|
|
82
|
+
expanded={expandedFlush}
|
|
83
|
+
onExpandedChange={setExpandedFlush}
|
|
84
|
+
toggleClassName="text-primary hover:text-primary-hover"
|
|
85
|
+
/>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
<div className="space-y-xs">
|
|
90
|
+
<p className="text-caption text-muted">Card · disabled toggle</p>
|
|
91
|
+
<ExpandableMessage content={MULTI} maxLines={2} disabled />
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<div className="space-y-xs">
|
|
95
|
+
<p className="text-caption text-muted">
|
|
96
|
+
Card · short content, no toggle
|
|
97
|
+
</p>
|
|
98
|
+
<ExpandableMessage content={SHORT} />
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -31,10 +31,12 @@ export * from "./atoms/DataTableDesktop";
|
|
|
31
31
|
export * from "./atoms/DataTableMobile";
|
|
32
32
|
export * from "./atoms/DatePickerInput";
|
|
33
33
|
export * from "./atoms/DateRangePicker";
|
|
34
|
+
export * from "./atoms/DesignSystemLoader";
|
|
34
35
|
export * from "./atoms/Divider";
|
|
35
36
|
export * from "./atoms/Drawer";
|
|
36
37
|
export * from "./atoms/Dropdown";
|
|
37
38
|
export * from "./atoms/DropdownMenu";
|
|
39
|
+
export * from "./atoms/ExpandableMessage";
|
|
38
40
|
export * from "./atoms/FileUpload";
|
|
39
41
|
export * from "./atoms/Footer";
|
|
40
42
|
export * from "./atoms/Form";
|