@designa8/vibedesign-v6 1.6.9 → 1.8.4
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 +249 -9
- package/dist/index.js +249 -9
- package/dist/styles.css +51 -6
- package/package.json +11 -1
- package/src/atoms/FilterTabBar/FilterTabBar.tsx +9 -17
- package/src/atoms/FilterTabBar/preview.tsx +79 -58
- package/src/atoms/PreviewToolbar/PreviewToolbar.tsx +253 -0
- package/src/atoms/PreviewToolbar/index.ts +2 -0
- package/src/atoms/PreviewToolbar/preview.tsx +81 -0
- package/src/atoms/Typography/Typography.tsx +107 -0
- package/src/atoms/Typography/index.ts +2 -0
- package/src/atoms/Typography/preview.tsx +132 -0
- package/src/index.ts +2 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Button } from "../Button";
|
|
3
|
+
import { Chip } from "../Chip";
|
|
4
|
+
|
|
5
|
+
// ─── Icons ─────────────────────────────────────────────────────────────────────
|
|
6
|
+
|
|
7
|
+
const DesktopIcon = () => (
|
|
8
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
9
|
+
<rect x="2" y="3" width="20" height="14" rx="2" />
|
|
10
|
+
<path d="M8 21h8M12 17v4" />
|
|
11
|
+
</svg>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const SidebarIcon = () => (
|
|
15
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
16
|
+
<rect x="2" y="3" width="20" height="18" rx="2" />
|
|
17
|
+
<path d="M9 3v18" />
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const MobileIcon = () => (
|
|
22
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
23
|
+
<rect x="5" y="2" width="14" height="20" rx="2" />
|
|
24
|
+
<circle cx="12" cy="17" r="1" fill="currentColor" stroke="none" />
|
|
25
|
+
</svg>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const ExpandIcon = () => (
|
|
29
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
30
|
+
<path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7" />
|
|
31
|
+
</svg>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
/** Circular cursor pointer icon (matching the reference's "inspect" icon) */
|
|
35
|
+
const InspectIcon = () => (
|
|
36
|
+
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
37
|
+
<circle cx="12" cy="12" r="9" />
|
|
38
|
+
<path d="M12 8v4l3 3" />
|
|
39
|
+
<circle cx="12" cy="12" r="1" fill="currentColor" stroke="none" />
|
|
40
|
+
</svg>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const MoonIcon = () => (
|
|
44
|
+
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
45
|
+
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" />
|
|
46
|
+
</svg>
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const FullscreenIcon = () => (
|
|
50
|
+
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
51
|
+
<polyline points="15 3 21 3 21 9" />
|
|
52
|
+
<polyline points="9 21 3 21 3 15" />
|
|
53
|
+
<line x1="21" y1="3" x2="14" y2="10" />
|
|
54
|
+
<line x1="3" y1="21" x2="10" y2="14" />
|
|
55
|
+
</svg>
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const DotsIcon = () => (
|
|
59
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" stroke="none" aria-hidden="true">
|
|
60
|
+
<circle cx="12" cy="5" r="1.6" />
|
|
61
|
+
<circle cx="12" cy="12" r="1.6" />
|
|
62
|
+
<circle cx="12" cy="19" r="1.6" />
|
|
63
|
+
</svg>
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
// ─── Types ─────────────────────────────────────────────────────────────────────
|
|
67
|
+
|
|
68
|
+
export type Viewport = "desktop" | "sidebar" | "mobile";
|
|
69
|
+
|
|
70
|
+
interface ViewportOption {
|
|
71
|
+
id: Viewport;
|
|
72
|
+
Icon: React.FC;
|
|
73
|
+
label: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const VIEWPORT_OPTIONS: ViewportOption[] = [
|
|
77
|
+
{ id: "desktop", Icon: DesktopIcon, label: "Desktop view" },
|
|
78
|
+
{ id: "sidebar", Icon: SidebarIcon, label: "Sidebar view" },
|
|
79
|
+
{ id: "mobile", Icon: MobileIcon, label: "Mobile view" },
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
// ─── Props ─────────────────────────────────────────────────────────────────────
|
|
83
|
+
|
|
84
|
+
export interface PreviewToolbarProps {
|
|
85
|
+
/** Currently active viewport */
|
|
86
|
+
viewport?: Viewport;
|
|
87
|
+
onViewportChange?: (v: Viewport) => void;
|
|
88
|
+
/** Dark mode state */
|
|
89
|
+
darkMode?: boolean;
|
|
90
|
+
onDarkToggle?: () => void;
|
|
91
|
+
/**
|
|
92
|
+
* When true, the Inspect tokens button shows "Exit inspect" with a primary
|
|
93
|
+
* (filled) variant to indicate the active state. When false (default), shows
|
|
94
|
+
* "Inspect tokens" with the secondary variant.
|
|
95
|
+
*/
|
|
96
|
+
inspecting?: boolean;
|
|
97
|
+
onInspectTokens?: () => void;
|
|
98
|
+
onFullscreen?: () => void;
|
|
99
|
+
onExpand?: () => void;
|
|
100
|
+
/** Model name shown as a chip, e.g. "Sonnet 4.6" */
|
|
101
|
+
modelLabel?: string;
|
|
102
|
+
/** Component kind shown as a chip, e.g. "ATOM" */
|
|
103
|
+
kindLabel?: string;
|
|
104
|
+
onOverflow?: () => void;
|
|
105
|
+
className?: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// ─── Viewport button — tight icon-only toggle not coverable by Button variants ─
|
|
109
|
+
|
|
110
|
+
interface VpBtnProps {
|
|
111
|
+
label: string;
|
|
112
|
+
active: boolean;
|
|
113
|
+
onClick: () => void;
|
|
114
|
+
children: React.ReactNode;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const ViewportBtn: React.FC<VpBtnProps> = ({ label, active, onClick, children }) => (
|
|
118
|
+
<Button
|
|
119
|
+
variant={active ? "primary" : "ghost"}
|
|
120
|
+
size="sm"
|
|
121
|
+
aria-label={label}
|
|
122
|
+
aria-pressed={active}
|
|
123
|
+
onClick={onClick}
|
|
124
|
+
className={["!w-8 !h-8 !p-0 rounded-sm shrink-0", active ? "" : "text-muted"].join(" ")}
|
|
125
|
+
>
|
|
126
|
+
{children}
|
|
127
|
+
</Button>
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
// ─── Main ──────────────────────────────────────────────────────────────────────
|
|
131
|
+
|
|
132
|
+
export const PreviewToolbar = React.forwardRef<HTMLDivElement, PreviewToolbarProps>(
|
|
133
|
+
(
|
|
134
|
+
{
|
|
135
|
+
viewport = "desktop",
|
|
136
|
+
onViewportChange,
|
|
137
|
+
darkMode = false,
|
|
138
|
+
onDarkToggle,
|
|
139
|
+
inspecting = false,
|
|
140
|
+
onInspectTokens,
|
|
141
|
+
onFullscreen,
|
|
142
|
+
onExpand,
|
|
143
|
+
modelLabel = "Sonnet 4.6",
|
|
144
|
+
kindLabel = "ATOM",
|
|
145
|
+
onOverflow,
|
|
146
|
+
className = "",
|
|
147
|
+
},
|
|
148
|
+
ref,
|
|
149
|
+
) => (
|
|
150
|
+
<div
|
|
151
|
+
ref={ref}
|
|
152
|
+
role="toolbar"
|
|
153
|
+
aria-label="Preview toolbar"
|
|
154
|
+
className={[
|
|
155
|
+
"inline-flex items-center gap-sm px-sm py-xs",
|
|
156
|
+
"bg-canvas border border-hairline rounded-xl shadow-md",
|
|
157
|
+
className,
|
|
158
|
+
].filter(Boolean).join(" ")}
|
|
159
|
+
>
|
|
160
|
+
{/* ── Viewport toggles ── */}
|
|
161
|
+
<div
|
|
162
|
+
role="group"
|
|
163
|
+
aria-label="Viewport size"
|
|
164
|
+
className="inline-flex items-center gap-xxs bg-surface-soft rounded-lg p-xxs"
|
|
165
|
+
>
|
|
166
|
+
{VIEWPORT_OPTIONS.map(({ id, Icon, label }) => (
|
|
167
|
+
<ViewportBtn
|
|
168
|
+
key={id}
|
|
169
|
+
label={label}
|
|
170
|
+
active={viewport === id}
|
|
171
|
+
onClick={() => onViewportChange?.(id)}
|
|
172
|
+
>
|
|
173
|
+
<Icon />
|
|
174
|
+
</ViewportBtn>
|
|
175
|
+
))}
|
|
176
|
+
|
|
177
|
+
<div className="w-px h-4 bg-hairline mx-xxs" aria-hidden />
|
|
178
|
+
|
|
179
|
+
<Button
|
|
180
|
+
variant="ghost"
|
|
181
|
+
size="sm"
|
|
182
|
+
aria-label="Expand preview"
|
|
183
|
+
onClick={onExpand}
|
|
184
|
+
className="!w-8 !h-8 !p-0 rounded-sm text-muted shrink-0"
|
|
185
|
+
>
|
|
186
|
+
<ExpandIcon />
|
|
187
|
+
</Button>
|
|
188
|
+
</div>
|
|
189
|
+
|
|
190
|
+
{/* ── Inspect tokens button — variant and label driven by `inspecting` prop ── */}
|
|
191
|
+
<Button
|
|
192
|
+
variant={inspecting ? "primary" : "secondary"}
|
|
193
|
+
size="sm"
|
|
194
|
+
aria-pressed={inspecting}
|
|
195
|
+
onClick={onInspectTokens}
|
|
196
|
+
className="gap-xs rounded-xl"
|
|
197
|
+
>
|
|
198
|
+
<InspectIcon />
|
|
199
|
+
{inspecting ? "Exit inspect" : "Inspect tokens"}
|
|
200
|
+
</Button>
|
|
201
|
+
|
|
202
|
+
<Button
|
|
203
|
+
variant={darkMode ? "primary" : "secondary"}
|
|
204
|
+
size="sm"
|
|
205
|
+
aria-pressed={darkMode}
|
|
206
|
+
onClick={onDarkToggle}
|
|
207
|
+
className="gap-xs rounded-xl"
|
|
208
|
+
>
|
|
209
|
+
<MoonIcon />
|
|
210
|
+
Dark
|
|
211
|
+
</Button>
|
|
212
|
+
|
|
213
|
+
<Button
|
|
214
|
+
variant="secondary"
|
|
215
|
+
size="sm"
|
|
216
|
+
onClick={onFullscreen}
|
|
217
|
+
className="gap-xs rounded-xl"
|
|
218
|
+
>
|
|
219
|
+
<FullscreenIcon />
|
|
220
|
+
Fullscreen
|
|
221
|
+
</Button>
|
|
222
|
+
|
|
223
|
+
{/* ── Model chip (outlined primary style) ── */}
|
|
224
|
+
<Chip
|
|
225
|
+
label={modelLabel ?? ""}
|
|
226
|
+
variant="default"
|
|
227
|
+
size="md"
|
|
228
|
+
className="border-primary text-primary bg-canvas cursor-default select-none"
|
|
229
|
+
/>
|
|
230
|
+
|
|
231
|
+
{/* ── Kind chip (filled soft primary) ── */}
|
|
232
|
+
<Chip
|
|
233
|
+
label={kindLabel ?? ""}
|
|
234
|
+
variant="default"
|
|
235
|
+
size="md"
|
|
236
|
+
className="bg-primary-disabled border-primary-disabled text-primary cursor-default select-none"
|
|
237
|
+
/>
|
|
238
|
+
|
|
239
|
+
{/* ── Overflow ── */}
|
|
240
|
+
<Button
|
|
241
|
+
variant="ghost"
|
|
242
|
+
size="sm"
|
|
243
|
+
aria-label="More options"
|
|
244
|
+
onClick={onOverflow}
|
|
245
|
+
className="!w-8 !h-8 !p-0 rounded-sm text-muted shrink-0"
|
|
246
|
+
>
|
|
247
|
+
<DotsIcon />
|
|
248
|
+
</Button>
|
|
249
|
+
</div>
|
|
250
|
+
),
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
PreviewToolbar.displayName = "PreviewToolbar";
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { PreviewToolbar, Viewport } from "./PreviewToolbar";
|
|
3
|
+
|
|
4
|
+
export default function PreviewToolbarPreview() {
|
|
5
|
+
const [viewport, setViewport] = useState<Viewport>("desktop");
|
|
6
|
+
const [darkMode, setDarkMode] = useState(false);
|
|
7
|
+
const [inspecting, setInspecting] = useState(false);
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<div className="w-full max-w-5xl mx-auto p-lg space-y-xl">
|
|
11
|
+
{/* Label */}
|
|
12
|
+
<div className="space-y-xxs">
|
|
13
|
+
<p className="text-body-sm text-muted uppercase tracking-wide">Preview toolbar</p>
|
|
14
|
+
<p className="text-body-sm text-muted">
|
|
15
|
+
Interactive — click the viewport icons, toggle Dark mode, and try Inspect tokens.
|
|
16
|
+
</p>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
{/* ── Interactive demo ─────────────────────────── */}
|
|
20
|
+
<div className="flex flex-col items-center gap-lg">
|
|
21
|
+
<div className="flex items-center justify-center w-full bg-surface-soft rounded-xl p-xl border border-hairline">
|
|
22
|
+
<PreviewToolbar
|
|
23
|
+
viewport={viewport}
|
|
24
|
+
onViewportChange={setViewport}
|
|
25
|
+
darkMode={darkMode}
|
|
26
|
+
onDarkToggle={() => setDarkMode((d) => !d)}
|
|
27
|
+
inspecting={inspecting}
|
|
28
|
+
onInspectTokens={() => setInspecting((i) => !i)}
|
|
29
|
+
onFullscreen={() => {}}
|
|
30
|
+
onExpand={() => {}}
|
|
31
|
+
onOverflow={() => {}}
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<p className="text-body-sm text-muted text-center">
|
|
36
|
+
Active viewport: <strong className="text-ink">{viewport}</strong> ·
|
|
37
|
+
Dark mode: <strong className="text-ink">{darkMode ? "on" : "off"}</strong> ·
|
|
38
|
+
Inspecting: <strong className="text-ink">{inspecting ? "on" : "off"}</strong>
|
|
39
|
+
</p>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
{/* ── Variant: inspecting=true ─────────────────── */}
|
|
43
|
+
<div className="space-y-sm">
|
|
44
|
+
<p className="text-body-sm text-muted font-weight-heading-sm">Inspecting active (inspecting=true)</p>
|
|
45
|
+
<div className="flex items-center justify-center w-full bg-canvas rounded-xl p-xl border border-hairline">
|
|
46
|
+
<PreviewToolbar
|
|
47
|
+
viewport="desktop"
|
|
48
|
+
inspecting
|
|
49
|
+
modelLabel="Sonnet 4.6"
|
|
50
|
+
kindLabel="ATOM"
|
|
51
|
+
/>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
{/* ── Variant: mobile active ──────────────────── */}
|
|
56
|
+
<div className="space-y-sm">
|
|
57
|
+
<p className="text-body-sm text-muted font-weight-heading-sm">Mobile active</p>
|
|
58
|
+
<div className="flex items-center justify-center w-full bg-canvas rounded-xl p-xl border border-hairline">
|
|
59
|
+
<PreviewToolbar
|
|
60
|
+
viewport="mobile"
|
|
61
|
+
modelLabel="Opus 4"
|
|
62
|
+
kindLabel="MOLECULE"
|
|
63
|
+
/>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
{/* ── Variant: dark mode on ───────────────────── */}
|
|
68
|
+
<div className="space-y-sm">
|
|
69
|
+
<p className="text-body-sm text-muted font-weight-heading-sm">Dark mode active</p>
|
|
70
|
+
<div className="flex items-center justify-center w-full bg-canvas rounded-xl p-xl border border-hairline">
|
|
71
|
+
<PreviewToolbar
|
|
72
|
+
viewport="sidebar"
|
|
73
|
+
darkMode
|
|
74
|
+
kindLabel="ORGANISM"
|
|
75
|
+
modelLabel="Haiku 3.5"
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export type TypographyRole =
|
|
4
|
+
| "display-lg"
|
|
5
|
+
| "heading-lg"
|
|
6
|
+
| "heading-md"
|
|
7
|
+
| "heading-sm"
|
|
8
|
+
| "body-lg"
|
|
9
|
+
| "body-md"
|
|
10
|
+
| "body-sm"
|
|
11
|
+
| "caption";
|
|
12
|
+
|
|
13
|
+
export type TypographyColor =
|
|
14
|
+
| "ink"
|
|
15
|
+
| "body"
|
|
16
|
+
| "muted"
|
|
17
|
+
| "muted-soft"
|
|
18
|
+
| "primary"
|
|
19
|
+
| "semantic-error"
|
|
20
|
+
| "semantic-success"
|
|
21
|
+
| "semantic-warning"
|
|
22
|
+
| "on-primary";
|
|
23
|
+
|
|
24
|
+
const roleTagMap: Record<TypographyRole, keyof React.JSX.IntrinsicElements> = {
|
|
25
|
+
"display-lg": "h1",
|
|
26
|
+
"heading-lg": "h2",
|
|
27
|
+
"heading-md": "h3",
|
|
28
|
+
"heading-sm": "h4",
|
|
29
|
+
"body-lg": "p",
|
|
30
|
+
"body-md": "p",
|
|
31
|
+
"body-sm": "p",
|
|
32
|
+
caption: "span",
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const roleClassMap: Record<TypographyRole, string> = {
|
|
36
|
+
"display-lg": "text-display-lg",
|
|
37
|
+
"heading-lg": "text-heading-lg",
|
|
38
|
+
"heading-md": "text-heading-md",
|
|
39
|
+
"heading-sm": "text-heading-sm",
|
|
40
|
+
"body-lg": "text-body-lg",
|
|
41
|
+
"body-md": "text-body-md",
|
|
42
|
+
"body-sm": "text-body-sm",
|
|
43
|
+
caption: "text-caption",
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const colorClassMap: Record<TypographyColor, string> = {
|
|
47
|
+
ink: "text-ink",
|
|
48
|
+
body: "text-body",
|
|
49
|
+
muted: "text-muted",
|
|
50
|
+
"muted-soft": "text-muted-soft",
|
|
51
|
+
primary: "text-primary",
|
|
52
|
+
"semantic-error": "text-semantic-error",
|
|
53
|
+
"semantic-success": "text-semantic-success",
|
|
54
|
+
"semantic-warning": "text-semantic-warning",
|
|
55
|
+
"on-primary": "text-on-primary",
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export interface TypographyProps
|
|
59
|
+
extends React.HTMLAttributes<HTMLElement> {
|
|
60
|
+
/** Token role that drives size, weight, line-height, and tracking */
|
|
61
|
+
role?: TypographyRole;
|
|
62
|
+
/** Token color alias */
|
|
63
|
+
color?: TypographyColor;
|
|
64
|
+
/** Override the default semantic HTML tag for this role */
|
|
65
|
+
as?: keyof React.JSX.IntrinsicElements;
|
|
66
|
+
/** Truncate to a single line with an ellipsis */
|
|
67
|
+
truncate?: boolean;
|
|
68
|
+
/** Render text in uppercase */
|
|
69
|
+
uppercase?: boolean;
|
|
70
|
+
children: React.ReactNode;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const Typography = React.forwardRef<HTMLElement, TypographyProps>(
|
|
74
|
+
(
|
|
75
|
+
{
|
|
76
|
+
role = "body-md",
|
|
77
|
+
color = "ink",
|
|
78
|
+
as,
|
|
79
|
+
truncate = false,
|
|
80
|
+
uppercase = false,
|
|
81
|
+
className = "",
|
|
82
|
+
children,
|
|
83
|
+
...rest
|
|
84
|
+
},
|
|
85
|
+
ref
|
|
86
|
+
) => {
|
|
87
|
+
const Tag = (as ?? roleTagMap[role]) as React.ElementType;
|
|
88
|
+
|
|
89
|
+
const classes = [
|
|
90
|
+
roleClassMap[role],
|
|
91
|
+
colorClassMap[color],
|
|
92
|
+
truncate ? "truncate" : "",
|
|
93
|
+
uppercase ? "uppercase tracking-wide" : "",
|
|
94
|
+
className,
|
|
95
|
+
]
|
|
96
|
+
.filter(Boolean)
|
|
97
|
+
.join(" ");
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<Tag ref={ref} className={classes} {...rest}>
|
|
101
|
+
{children}
|
|
102
|
+
</Tag>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
Typography.displayName = "Typography";
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Typography, TypographyRole } from "./Typography";
|
|
3
|
+
|
|
4
|
+
const roles: { role: TypographyRole; label: string; sample: string }[] = [
|
|
5
|
+
{
|
|
6
|
+
role: "display-lg",
|
|
7
|
+
label: "display-lg — 48px / 700",
|
|
8
|
+
sample: "The quick brown fox",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
role: "heading-lg",
|
|
12
|
+
label: "heading-lg — 32px / 700",
|
|
13
|
+
sample: "Design systems at scale",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
role: "heading-md",
|
|
17
|
+
label: "heading-md — 24px / 600",
|
|
18
|
+
sample: "Component-driven workflow",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
role: "heading-sm",
|
|
22
|
+
label: "heading-sm — 18px / 600",
|
|
23
|
+
sample: "Tokens drive everything",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
role: "body-lg",
|
|
27
|
+
label: "body-lg — 18px / 400",
|
|
28
|
+
sample:
|
|
29
|
+
"Great products start with a coherent design language that scales across every surface.",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
role: "body-md",
|
|
33
|
+
label: "body-md — 16px / 400",
|
|
34
|
+
sample:
|
|
35
|
+
"Consistent spacing, color, and typography keep the interface readable and the team aligned.",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
role: "body-sm",
|
|
39
|
+
label: "body-sm — 14px / 400",
|
|
40
|
+
sample:
|
|
41
|
+
"Small text is used for secondary information, helper text, and meta content.",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
role: "caption",
|
|
45
|
+
label: "caption — 12px / 400",
|
|
46
|
+
sample: "Last updated 3 minutes ago · Public",
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
const Divider = () => (
|
|
51
|
+
<div className="border-t border-hairline-soft" aria-hidden="true" />
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
export default function TypographyPreview() {
|
|
55
|
+
return (
|
|
56
|
+
<div className="w-full max-w-3xl mx-auto p-lg space-y-lg">
|
|
57
|
+
{/* Header */}
|
|
58
|
+
<div className="space-y-xs">
|
|
59
|
+
<Typography role="heading-md" color="ink">
|
|
60
|
+
Type Scale
|
|
61
|
+
</Typography>
|
|
62
|
+
<Typography role="body-sm" color="muted">
|
|
63
|
+
Every role maps to a token — size, weight, line-height, and tracking
|
|
64
|
+
update across the whole system when tokens change.
|
|
65
|
+
</Typography>
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
{/* Scale rows */}
|
|
69
|
+
<div className="bg-surface rounded-lg border border-hairline overflow-hidden">
|
|
70
|
+
{roles.map(({ role, label, sample }, i) => (
|
|
71
|
+
<React.Fragment key={role}>
|
|
72
|
+
{i > 0 && <Divider />}
|
|
73
|
+
<div className="flex flex-col gap-xs p-lg">
|
|
74
|
+
<Typography role="caption" color="muted-soft" as="span">
|
|
75
|
+
{label}
|
|
76
|
+
</Typography>
|
|
77
|
+
<Typography role={role} color="ink">
|
|
78
|
+
{sample}
|
|
79
|
+
</Typography>
|
|
80
|
+
</div>
|
|
81
|
+
</React.Fragment>
|
|
82
|
+
))}
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
{/* Color variants */}
|
|
86
|
+
<div className="space-y-xs">
|
|
87
|
+
<Typography role="heading-sm" color="ink">
|
|
88
|
+
Color variants
|
|
89
|
+
</Typography>
|
|
90
|
+
<Typography role="body-sm" color="muted">
|
|
91
|
+
Pass the <code className="text-primary font-weight-heading-sm text-body-sm">color</code> prop to apply any token color alias.
|
|
92
|
+
</Typography>
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
<div className="bg-surface rounded-lg border border-hairline p-lg flex flex-col gap-md">
|
|
96
|
+
{(
|
|
97
|
+
[
|
|
98
|
+
["ink", "ink — primary text"],
|
|
99
|
+
["body", "body — body text"],
|
|
100
|
+
["muted", "muted — secondary / helper"],
|
|
101
|
+
["muted-soft", "muted-soft — placeholder / disabled"],
|
|
102
|
+
["primary", "primary — brand accent"],
|
|
103
|
+
["semantic-success", "semantic-success — positive state"],
|
|
104
|
+
["semantic-warning", "semantic-warning — caution state"],
|
|
105
|
+
["semantic-error", "semantic-error — destructive / error"],
|
|
106
|
+
] as const
|
|
107
|
+
).map(([color, label]) => (
|
|
108
|
+
<Typography key={color} role="body-md" color={color}>
|
|
109
|
+
{label}
|
|
110
|
+
</Typography>
|
|
111
|
+
))}
|
|
112
|
+
</div>
|
|
113
|
+
|
|
114
|
+
{/* Utilities */}
|
|
115
|
+
<div className="space-y-xs">
|
|
116
|
+
<Typography role="heading-sm" color="ink">
|
|
117
|
+
Utilities
|
|
118
|
+
</Typography>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
<div className="bg-surface rounded-lg border border-hairline p-lg space-y-md">
|
|
122
|
+
<Typography role="body-md" color="muted" truncate>
|
|
123
|
+
Truncated long text: The quick brown fox jumps over the lazy dog and
|
|
124
|
+
keeps going all the way to the edge of the container and beyond.
|
|
125
|
+
</Typography>
|
|
126
|
+
<Typography role="body-md" color="primary" uppercase>
|
|
127
|
+
Uppercase with tracking
|
|
128
|
+
</Typography>
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
);
|
|
132
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -10,7 +10,9 @@ export * from "./atoms/FilterTabBar";
|
|
|
10
10
|
export * from "./atoms/Input";
|
|
11
11
|
export * from "./atoms/Modal";
|
|
12
12
|
export * from "./atoms/NavItem";
|
|
13
|
+
export * from "./atoms/PreviewToolbar";
|
|
13
14
|
export * from "./atoms/PromptInputBar";
|
|
14
15
|
export * from "./atoms/TopNavbar";
|
|
16
|
+
export * from "./atoms/Typography";
|
|
15
17
|
export * from "./atoms/UpgradeCard";
|
|
16
18
|
export * from "./atoms/WorkspaceMenu";
|