@designa8/vibedesign-linear-internal-v1-b737 0.4.0 → 0.5.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 +1283 -1168
- package/dist/index.js +1311 -1196
- package/dist/styles.css +15 -0
- package/package.json +6 -1
- package/src/atoms/CodePreview/CodePreview.tsx +161 -0
- package/src/atoms/CodePreview/index.ts +2 -0
- package/src/atoms/CodePreview/preview.tsx +74 -0
- package/src/index.ts +1 -0
package/dist/styles.css
CHANGED
|
@@ -707,6 +707,9 @@
|
|
|
707
707
|
.h-xs {
|
|
708
708
|
height: var(--spacing-xs);
|
|
709
709
|
}
|
|
710
|
+
.max-h-64 {
|
|
711
|
+
max-height: calc(var(--spacing) * 64);
|
|
712
|
+
}
|
|
710
713
|
.max-h-72 {
|
|
711
714
|
max-height: calc(var(--spacing) * 72);
|
|
712
715
|
}
|
|
@@ -1398,6 +1401,12 @@
|
|
|
1398
1401
|
.bg-canvas {
|
|
1399
1402
|
background-color: var(--color-canvas);
|
|
1400
1403
|
}
|
|
1404
|
+
.bg-canvas\/90 {
|
|
1405
|
+
background-color: color-mix(in srgb, #FFFFFF 90%, transparent);
|
|
1406
|
+
@supports (color: color-mix(in lab, red, red)) {
|
|
1407
|
+
background-color: color-mix(in oklab, var(--color-canvas) 90%, transparent);
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1401
1410
|
.bg-current {
|
|
1402
1411
|
background-color: currentcolor;
|
|
1403
1412
|
}
|
|
@@ -1753,12 +1762,18 @@
|
|
|
1753
1762
|
--tw-tracking: var(--tracking-overline);
|
|
1754
1763
|
letter-spacing: var(--tracking-overline);
|
|
1755
1764
|
}
|
|
1765
|
+
.break-words {
|
|
1766
|
+
overflow-wrap: break-word;
|
|
1767
|
+
}
|
|
1756
1768
|
.whitespace-nowrap {
|
|
1757
1769
|
white-space: nowrap;
|
|
1758
1770
|
}
|
|
1759
1771
|
.whitespace-pre {
|
|
1760
1772
|
white-space: pre;
|
|
1761
1773
|
}
|
|
1774
|
+
.whitespace-pre-wrap {
|
|
1775
|
+
white-space: pre-wrap;
|
|
1776
|
+
}
|
|
1762
1777
|
.text-body {
|
|
1763
1778
|
color: var(--color-body);
|
|
1764
1779
|
}
|
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.5.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",
|
|
@@ -139,6 +139,11 @@
|
|
|
139
139
|
"kind": "Organism",
|
|
140
140
|
"description": null
|
|
141
141
|
},
|
|
142
|
+
{
|
|
143
|
+
"name": "CodePreview",
|
|
144
|
+
"kind": "Molecule",
|
|
145
|
+
"description": null
|
|
146
|
+
},
|
|
142
147
|
{
|
|
143
148
|
"name": "Combobox",
|
|
144
149
|
"kind": "Molecule",
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Button } from "../Button";
|
|
3
|
+
import { Icon } from "../Icon";
|
|
4
|
+
import { Spinner } from "../Spinner";
|
|
5
|
+
|
|
6
|
+
export interface CodePreviewLine {
|
|
7
|
+
/** The raw text of the line, rendered verbatim (no syntax highlighting). */
|
|
8
|
+
text: string;
|
|
9
|
+
/**
|
|
10
|
+
* `heading` is an emphasised line — brand color at medium weight, used for
|
|
11
|
+
* section titles inside a rendered document. `default` is body text.
|
|
12
|
+
*/
|
|
13
|
+
tone?: "heading" | "default";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface CodePreviewProps
|
|
17
|
+
extends Omit<React.HTMLAttributes<HTMLDivElement>, "onCopy"> {
|
|
18
|
+
/** Lines to render. Pass `text` instead for a plain block. */
|
|
19
|
+
lines?: CodePreviewLine[];
|
|
20
|
+
/** Convenience alternative to `lines`: split on newlines. */
|
|
21
|
+
text?: string;
|
|
22
|
+
/** Right-aligned, muted line numbers in a fixed gutter. */
|
|
23
|
+
lineNumbers?: boolean;
|
|
24
|
+
/** Shows the Copy button in the top-right corner. */
|
|
25
|
+
copyable?: boolean;
|
|
26
|
+
/** Called after the text was copied successfully. */
|
|
27
|
+
onCopy?: () => void;
|
|
28
|
+
/** Lays a canvas overlay with a spinner and `loadingLabel` over the panel. */
|
|
29
|
+
loading?: boolean;
|
|
30
|
+
/** Message shown by the loading overlay. Also its accessible name. */
|
|
31
|
+
loadingLabel?: string;
|
|
32
|
+
/** Caps the height of the panel and scrolls vertically. Default true. */
|
|
33
|
+
capped?: boolean;
|
|
34
|
+
/** Wrap long lines instead of scrolling horizontally. */
|
|
35
|
+
wrap?: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const cn = (...parts: Array<string | false | null | undefined>) =>
|
|
39
|
+
parts.filter(Boolean).join(" ");
|
|
40
|
+
|
|
41
|
+
export const CodePreview = React.forwardRef<HTMLDivElement, CodePreviewProps>(
|
|
42
|
+
(
|
|
43
|
+
{
|
|
44
|
+
lines,
|
|
45
|
+
text,
|
|
46
|
+
lineNumbers = false,
|
|
47
|
+
copyable = false,
|
|
48
|
+
onCopy,
|
|
49
|
+
loading = false,
|
|
50
|
+
loadingLabel = "Loading preview…",
|
|
51
|
+
capped = true,
|
|
52
|
+
wrap = false,
|
|
53
|
+
className,
|
|
54
|
+
"aria-label": ariaLabel = "Code preview",
|
|
55
|
+
...rest
|
|
56
|
+
},
|
|
57
|
+
ref,
|
|
58
|
+
) => {
|
|
59
|
+
const rows = React.useMemo<CodePreviewLine[]>(
|
|
60
|
+
() => lines ?? (text ?? "").split("\n").map((line) => ({ text: line })),
|
|
61
|
+
[lines, text],
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const [copied, setCopied] = React.useState(false);
|
|
65
|
+
const resetTimer = React.useRef<number | undefined>(undefined);
|
|
66
|
+
|
|
67
|
+
React.useEffect(
|
|
68
|
+
() => () => {
|
|
69
|
+
if (resetTimer.current) window.clearTimeout(resetTimer.current);
|
|
70
|
+
},
|
|
71
|
+
[],
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const handleCopy = () => {
|
|
75
|
+
const value = rows.map((row) => row.text).join("\n");
|
|
76
|
+
if (typeof navigator === "undefined" || !navigator.clipboard) return;
|
|
77
|
+
navigator.clipboard
|
|
78
|
+
.writeText(value)
|
|
79
|
+
.then(() => {
|
|
80
|
+
setCopied(true);
|
|
81
|
+
if (resetTimer.current) window.clearTimeout(resetTimer.current);
|
|
82
|
+
resetTimer.current = window.setTimeout(() => setCopied(false), 1600);
|
|
83
|
+
onCopy?.();
|
|
84
|
+
})
|
|
85
|
+
.catch(() => {
|
|
86
|
+
/* clipboard unavailable — leave the label unchanged */
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<div
|
|
92
|
+
ref={ref}
|
|
93
|
+
aria-label={ariaLabel}
|
|
94
|
+
aria-busy={loading || undefined}
|
|
95
|
+
className={cn(
|
|
96
|
+
"relative w-full overflow-hidden rounded-md border border-hairline bg-surface-soft",
|
|
97
|
+
className,
|
|
98
|
+
)}
|
|
99
|
+
{...rest}
|
|
100
|
+
>
|
|
101
|
+
{copyable ? (
|
|
102
|
+
<div className="flex items-center justify-end px-sm pt-sm">
|
|
103
|
+
<Button
|
|
104
|
+
variant="ghost"
|
|
105
|
+
size="sm"
|
|
106
|
+
onClick={handleCopy}
|
|
107
|
+
aria-label={copied ? "Copied to clipboard" : "Copy to clipboard"}
|
|
108
|
+
leadingIcon={<Icon name={copied ? "check" : "copy"} size={14} />}
|
|
109
|
+
>
|
|
110
|
+
<span aria-hidden="true">{copied ? "Copied" : "Copy"}</span>
|
|
111
|
+
</Button>
|
|
112
|
+
</div>
|
|
113
|
+
) : null}
|
|
114
|
+
|
|
115
|
+
<div
|
|
116
|
+
tabIndex={capped ? 0 : undefined}
|
|
117
|
+
role={capped ? "region" : undefined}
|
|
118
|
+
aria-label={capped ? ariaLabel : undefined}
|
|
119
|
+
className={cn(
|
|
120
|
+
"px-md py-sm font-mono text-caption focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus-blue",
|
|
121
|
+
capped && "max-h-64 overflow-y-auto overscroll-contain",
|
|
122
|
+
!wrap && "overflow-x-auto",
|
|
123
|
+
)}
|
|
124
|
+
>
|
|
125
|
+
{rows.map((line, index) => (
|
|
126
|
+
<div key={index} className="flex gap-md">
|
|
127
|
+
{lineNumbers ? (
|
|
128
|
+
<span
|
|
129
|
+
aria-hidden="true"
|
|
130
|
+
className="w-lg shrink-0 select-none text-right text-muted-soft"
|
|
131
|
+
>
|
|
132
|
+
{index + 1}
|
|
133
|
+
</span>
|
|
134
|
+
) : null}
|
|
135
|
+
<span
|
|
136
|
+
className={cn(
|
|
137
|
+
wrap ? "min-w-0 whitespace-pre-wrap break-words" : "whitespace-pre",
|
|
138
|
+
line.tone === "heading"
|
|
139
|
+
? "font-weight-label text-primary"
|
|
140
|
+
: "text-body",
|
|
141
|
+
)}
|
|
142
|
+
>
|
|
143
|
+
{line.text || "\u00A0"}
|
|
144
|
+
</span>
|
|
145
|
+
</div>
|
|
146
|
+
))}
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
{/* Stays mounted so the overlay can fade in and out. */}
|
|
150
|
+
<div
|
|
151
|
+
aria-hidden={loading ? undefined : "true"}
|
|
152
|
+
data-state={loading ? "open" : "closed"}
|
|
153
|
+
className="pointer-events-none absolute inset-0 flex items-center justify-center bg-canvas/90 transition-opacity duration-200 ease-out data-[state=open]:opacity-100 data-[state=closed]:opacity-0"
|
|
154
|
+
>
|
|
155
|
+
<Spinner size="sm" label={loading ? loadingLabel : undefined} />
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
);
|
|
159
|
+
},
|
|
160
|
+
);
|
|
161
|
+
CodePreview.displayName = "CodePreview";
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { CodePreview } from "./CodePreview";
|
|
3
|
+
import type { CodePreviewLine } from "./CodePreview";
|
|
4
|
+
import { Button } from "../Button";
|
|
5
|
+
|
|
6
|
+
const installLines: CodePreviewLine[] = [
|
|
7
|
+
{ text: "npm install @acme/design-system", tone: "heading" },
|
|
8
|
+
{ text: 'import { Button } from "@acme/design-system";' },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
const documentLines: CodePreviewLine[] = [
|
|
12
|
+
{ text: "## Surface", tone: "heading" },
|
|
13
|
+
{ text: "Cards sit on `canvas` and lift with `surface` plus a hairline border." },
|
|
14
|
+
{ text: "" },
|
|
15
|
+
{ text: "## Typography", tone: "heading" },
|
|
16
|
+
{ text: "Body copy uses the `body-md` role; captions use `caption`." },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const pathLines: CodePreviewLine[] = [
|
|
20
|
+
{ text: "design-system/" },
|
|
21
|
+
{ text: " tokens.json" },
|
|
22
|
+
{ text: " components/" },
|
|
23
|
+
{ text: " Button.tsx" },
|
|
24
|
+
{ text: " CodePreview.tsx" },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
export default function CodePreviewPreview() {
|
|
28
|
+
const [loading, setLoading] = React.useState(false);
|
|
29
|
+
const [copyCount, setCopyCount] = React.useState(0);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div className="w-full max-w-3xl mx-auto p-lg space-y-lg bg-canvas text-ink">
|
|
33
|
+
<section className="space-y-sm">
|
|
34
|
+
<p className="text-label text-muted">Install command with copy</p>
|
|
35
|
+
<CodePreview lines={installLines} copyable onCopy={() => setCopyCount((n) => n + 1)} />
|
|
36
|
+
<p className="text-caption text-muted-soft">Copy events: {copyCount}</p>
|
|
37
|
+
</section>
|
|
38
|
+
|
|
39
|
+
<section className="space-y-sm">
|
|
40
|
+
<p className="text-label text-muted">Numbered, wrapped document</p>
|
|
41
|
+
<CodePreview text={documentLines.map((l) => l.text).join("\n")} lineNumbers wrap />
|
|
42
|
+
</section>
|
|
43
|
+
|
|
44
|
+
<section className="space-y-sm">
|
|
45
|
+
<p className="text-label text-muted">Capped and scrolling (no wrap)</p>
|
|
46
|
+
<CodePreview
|
|
47
|
+
lines={[
|
|
48
|
+
...pathLines,
|
|
49
|
+
...pathLines,
|
|
50
|
+
...pathLines,
|
|
51
|
+
{ text: "This line is intentionally long so the horizontal scroll engages: design-system/components/CodePreview/CodePreview.tsx" },
|
|
52
|
+
]}
|
|
53
|
+
lineNumbers
|
|
54
|
+
capped
|
|
55
|
+
/>
|
|
56
|
+
</section>
|
|
57
|
+
|
|
58
|
+
<section className="space-y-sm">
|
|
59
|
+
<div className="flex items-center justify-between gap-sm">
|
|
60
|
+
<p className="text-label text-muted">Loading overlay</p>
|
|
61
|
+
<Button variant="secondary" size="sm" onClick={() => setLoading((v) => !v)}>
|
|
62
|
+
{loading ? "Hide overlay" : "Show overlay"}
|
|
63
|
+
</Button>
|
|
64
|
+
</div>
|
|
65
|
+
<CodePreview
|
|
66
|
+
text={"# DESIGN.md\nname: Acme design system\nbrand: #5E6AD2\nradius: 8px"}
|
|
67
|
+
lineNumbers
|
|
68
|
+
loading={loading}
|
|
69
|
+
loadingLabel="Loading preview…"
|
|
70
|
+
/>
|
|
71
|
+
</section>
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -21,6 +21,7 @@ export * from "./atoms/ChatWindow";
|
|
|
21
21
|
export * from "./atoms/Checkbox";
|
|
22
22
|
export * from "./atoms/Chip";
|
|
23
23
|
export * from "./atoms/CodeEditor";
|
|
24
|
+
export * from "./atoms/CodePreview";
|
|
24
25
|
export * from "./atoms/Combobox";
|
|
25
26
|
export * from "./atoms/CommentThread";
|
|
26
27
|
export * from "./atoms/DataTable";
|