@designa8/vibedesign-v6 1.15.3 → 1.20.13
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 +6 -32
- package/dist/index.cjs +3232 -2143
- package/dist/index.js +3242 -2153
- package/dist/styles.css +266 -28
- package/package.json +52 -2
- package/src/atoms/AppLayout/AppLayout.tsx +401 -395
- package/src/atoms/AppLayout/preview.tsx +29 -0
- package/src/atoms/AppSidebar/AppSidebar.tsx +182 -94
- package/src/atoms/AppSidebar/preview.tsx +20 -59
- package/src/atoms/AppSidebarMobile/AppSidebarMobile.tsx +27 -73
- package/src/atoms/AppSidebarMobile/preview.tsx +18 -18
- package/src/atoms/AuthLogin/AuthLogin.tsx +200 -0
- package/src/atoms/AuthLogin/index.ts +2 -0
- package/src/atoms/AuthLogin/preview.tsx +22 -0
- package/src/atoms/AuthScreen/AuthScreen.tsx +7 -7
- package/src/atoms/AuthSignUp/AuthSignUp.tsx +243 -0
- package/src/atoms/AuthSignUp/index.ts +2 -0
- package/src/atoms/AuthSignUp/preview.tsx +22 -0
- package/src/atoms/BillingToggle/BillingToggle.tsx +65 -0
- package/src/atoms/BillingToggle/index.ts +2 -0
- package/src/atoms/BillingToggle/preview.tsx +23 -0
- package/src/atoms/Button/Button.tsx +33 -17
- package/src/atoms/Button/preview.tsx +16 -0
- package/src/atoms/ChatHistorySidebar/ChatHistorySidebar.tsx +370 -0
- package/src/atoms/ChatHistorySidebar/index.ts +2 -0
- package/src/atoms/ChatHistorySidebar/preview.tsx +60 -0
- package/src/atoms/ChatScreen/ChatScreen.tsx +331 -134
- package/src/atoms/ChatScreen/preview.tsx +123 -2
- package/src/atoms/Checkbox/Checkbox.tsx +89 -0
- package/src/atoms/Checkbox/index.ts +2 -0
- package/src/atoms/Checkbox/preview.tsx +60 -0
- package/src/atoms/Dropdown/Dropdown.tsx +195 -0
- package/src/atoms/Dropdown/index.ts +2 -0
- package/src/atoms/Dropdown/preview.tsx +56 -0
- package/src/atoms/ExportDesignMdModal/ExportDesignMdModal.tsx +46 -185
- package/src/atoms/ExportDesignMdModal/preview.tsx +24 -8
- package/src/atoms/FaqAccordionItem/FaqAccordionItem.tsx +60 -0
- package/src/atoms/FaqAccordionItem/index.ts +2 -0
- package/src/atoms/FaqAccordionItem/preview.tsx +26 -0
- package/src/atoms/FilterTabBar/FilterTabBar.tsx +8 -22
- package/src/atoms/HomePageTemplate/HomePageTemplate.tsx +20 -33
- package/src/atoms/HomePageTemplate/preview.tsx +2 -2
- package/src/atoms/Icon/Icon.tsx +7 -5
- package/src/atoms/Icon/icons.data.ts +53 -0
- package/src/atoms/Input/Input.tsx +17 -9
- package/src/atoms/Input/preview.tsx +24 -25
- package/src/atoms/Menu/Menu.tsx +320 -0
- package/src/atoms/Menu/index.ts +2 -0
- package/src/atoms/Menu/preview.tsx +63 -0
- package/src/atoms/Modal/Modal.tsx +43 -37
- package/src/atoms/Modal/preview.tsx +13 -0
- package/src/atoms/NavItem/NavItem.tsx +33 -45
- package/src/atoms/NavItem/preview.tsx +21 -26
- package/src/atoms/PreviewToolbar/PreviewToolbar.tsx +144 -192
- package/src/atoms/PreviewToolbar/preview.tsx +24 -4
- package/src/atoms/PricingCard/PricingCard.tsx +164 -0
- package/src/atoms/PricingCard/index.ts +2 -0
- package/src/atoms/PricingCard/preview.tsx +45 -0
- package/src/atoms/PricingPageTemplate/PricingPageTemplate.tsx +219 -0
- package/src/atoms/PricingPageTemplate/index.ts +2 -0
- package/src/atoms/PricingPageTemplate/preview.tsx +10 -0
- package/src/atoms/PromptInputBar/PromptInputBar.tsx +117 -158
- package/src/atoms/WorkspaceMenu/WorkspaceMenu.tsx +41 -167
- package/src/index.ts +10 -0
- package/src/tokens.css +5 -0
|
@@ -1,76 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Button } from "../Button";
|
|
3
3
|
import { Chip } from "../Chip";
|
|
4
|
-
|
|
5
|
-
|
|
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 MobileIcon = () => (
|
|
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="5" y="2" width="14" height="20" rx="2" />
|
|
17
|
-
<circle cx="12" cy="17" r="1" fill="currentColor" stroke="none" />
|
|
18
|
-
</svg>
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const ExpandIcon = () => (
|
|
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
|
-
<path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7" />
|
|
24
|
-
</svg>
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
/** Circular cursor pointer icon (matching the reference's "inspect" icon) */
|
|
28
|
-
const InspectIcon = () => (
|
|
29
|
-
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
30
|
-
<circle cx="12" cy="12" r="9" />
|
|
31
|
-
<path d="M12 8v4l3 3" />
|
|
32
|
-
<circle cx="12" cy="12" r="1" fill="currentColor" stroke="none" />
|
|
33
|
-
</svg>
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
const MoonIcon = () => (
|
|
37
|
-
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
38
|
-
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" />
|
|
39
|
-
</svg>
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
const FullscreenIcon = () => (
|
|
43
|
-
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
44
|
-
<polyline points="15 3 21 3 21 9" />
|
|
45
|
-
<polyline points="9 21 3 21 3 15" />
|
|
46
|
-
<line x1="21" y1="3" x2="14" y2="10" />
|
|
47
|
-
<line x1="3" y1="21" x2="10" y2="14" />
|
|
48
|
-
</svg>
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
const DotsIcon = () => (
|
|
52
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" stroke="none" aria-hidden="true">
|
|
53
|
-
<circle cx="12" cy="5" r="1.6" />
|
|
54
|
-
<circle cx="12" cy="12" r="1.6" />
|
|
55
|
-
<circle cx="12" cy="19" r="1.6" />
|
|
56
|
-
</svg>
|
|
57
|
-
);
|
|
4
|
+
import { Icon } from "../Icon";
|
|
5
|
+
import { FilterTabBar, type FilterTab } from "../FilterTabBar";
|
|
6
|
+
import { Menu, type MenuItem } from "../Menu";
|
|
58
7
|
|
|
59
8
|
// ─── Types ─────────────────────────────────────────────────────────────────────
|
|
60
9
|
|
|
61
10
|
export type Viewport = "desktop" | "mobile";
|
|
62
11
|
|
|
63
|
-
interface ViewportOption {
|
|
64
|
-
id: Viewport;
|
|
65
|
-
Icon: React.FC;
|
|
66
|
-
label: string;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const VIEWPORT_OPTIONS: ViewportOption[] = [
|
|
70
|
-
{ id: "desktop", Icon: DesktopIcon, label: "Desktop view" },
|
|
71
|
-
{ id: "mobile", Icon: MobileIcon, label: "Mobile view" },
|
|
72
|
-
];
|
|
73
|
-
|
|
74
12
|
// ─── Props ─────────────────────────────────────────────────────────────────────
|
|
75
13
|
|
|
76
14
|
export interface PreviewToolbarProps {
|
|
@@ -90,8 +28,8 @@ export interface PreviewToolbarProps {
|
|
|
90
28
|
onFullscreen?: () => void;
|
|
91
29
|
onExpand?: () => void;
|
|
92
30
|
/**
|
|
93
|
-
* When true, the expand/arrows button renders
|
|
94
|
-
*
|
|
31
|
+
* When true, the expand/arrows button renders as the selected tab in the
|
|
32
|
+
* viewport cluster. None of the desktop/mobile buttons appear active while
|
|
95
33
|
* expanded is true — only one selection indicator is shown at a time.
|
|
96
34
|
*/
|
|
97
35
|
expanded?: boolean;
|
|
@@ -99,32 +37,23 @@ export interface PreviewToolbarProps {
|
|
|
99
37
|
modelLabel?: string;
|
|
100
38
|
/** Component kind shown as a chip, e.g. "ATOM" */
|
|
101
39
|
kindLabel?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Legacy overflow handler — fired when the 3-dots button is clicked.
|
|
42
|
+
* Ignored when `overflowItems` is provided (the button renders a real
|
|
43
|
+
* Menu instead). Kept for backwards compatibility with consumers that
|
|
44
|
+
* roll their own dropdown off this callback.
|
|
45
|
+
*/
|
|
102
46
|
onOverflow?: () => void;
|
|
47
|
+
/**
|
|
48
|
+
* When provided and non-empty, the overflow control renders as a Menu
|
|
49
|
+
* anchored to the trigger (right-aligned) instead of a bare button, so
|
|
50
|
+
* actions like a destructive "Delete" render as a real dropdown list.
|
|
51
|
+
* Takes precedence over `onOverflow`.
|
|
52
|
+
*/
|
|
53
|
+
overflowItems?: MenuItem[];
|
|
103
54
|
className?: string;
|
|
104
55
|
}
|
|
105
56
|
|
|
106
|
-
// ─── Viewport button — tight icon-only toggle not coverable by Button variants ─
|
|
107
|
-
|
|
108
|
-
interface VpBtnProps {
|
|
109
|
-
label: string;
|
|
110
|
-
active: boolean;
|
|
111
|
-
onClick: () => void;
|
|
112
|
-
children: React.ReactNode;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const ViewportBtn: React.FC<VpBtnProps> = ({ label, active, onClick, children }) => (
|
|
116
|
-
<Button
|
|
117
|
-
variant={active ? "primary" : "ghost"}
|
|
118
|
-
size="sm"
|
|
119
|
-
aria-label={label}
|
|
120
|
-
aria-pressed={active}
|
|
121
|
-
onClick={onClick}
|
|
122
|
-
className={["!w-8 !h-8 !p-0 rounded-sm shrink-0", active ? "" : "text-muted"].join(" ")}
|
|
123
|
-
>
|
|
124
|
-
{children}
|
|
125
|
-
</Button>
|
|
126
|
-
);
|
|
127
|
-
|
|
128
57
|
// ─── Main ──────────────────────────────────────────────────────────────────────
|
|
129
58
|
|
|
130
59
|
export const PreviewToolbar = React.forwardRef<HTMLDivElement, PreviewToolbarProps>(
|
|
@@ -142,118 +71,141 @@ export const PreviewToolbar = React.forwardRef<HTMLDivElement, PreviewToolbarPro
|
|
|
142
71
|
modelLabel = "Sonnet 4.6",
|
|
143
72
|
kindLabel = "ATOM",
|
|
144
73
|
onOverflow,
|
|
74
|
+
overflowItems,
|
|
145
75
|
className = "",
|
|
146
76
|
},
|
|
147
77
|
ref,
|
|
148
|
-
) =>
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
78
|
+
) => {
|
|
79
|
+
// Selection mapping: expand wins when active, otherwise the current viewport.
|
|
80
|
+
const selectedValue = expanded ? "expand" : viewport;
|
|
81
|
+
|
|
82
|
+
const viewportTabs: FilterTab[] = [
|
|
83
|
+
{ value: "desktop", icon: <Icon name="desktop-monitor" size={14} /> },
|
|
84
|
+
{ value: "mobile", icon: <Icon name="mobile-phone" size={14} /> },
|
|
85
|
+
{ value: "expand", icon: <Icon name="expand-diagonal-arrows" size={14} /> },
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
const handleViewportTabChange = (val: string) => {
|
|
89
|
+
if (val === "expand") {
|
|
90
|
+
onExpand?.();
|
|
91
|
+
} else {
|
|
92
|
+
onViewportChange?.(val as Viewport);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const overflowTrigger = (
|
|
97
|
+
<Button
|
|
98
|
+
variant="ghost"
|
|
99
|
+
size="sm"
|
|
100
|
+
aria-label="More options"
|
|
101
|
+
className="!w-8 !h-8 !p-0 rounded-sm text-muted shrink-0"
|
|
166
102
|
>
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
label={label}
|
|
171
|
-
active={!expanded && viewport === id}
|
|
172
|
-
onClick={() => onViewportChange?.(id)}
|
|
173
|
-
>
|
|
174
|
-
<Icon />
|
|
175
|
-
</ViewportBtn>
|
|
176
|
-
))}
|
|
177
|
-
|
|
178
|
-
<Button
|
|
179
|
-
variant={expanded ? "primary" : "ghost"}
|
|
180
|
-
size="sm"
|
|
181
|
-
aria-label="Expand preview"
|
|
182
|
-
aria-pressed={expanded}
|
|
183
|
-
onClick={onExpand}
|
|
184
|
-
className={[
|
|
185
|
-
"!w-8 !h-8 !p-0 rounded-sm shrink-0",
|
|
186
|
-
expanded ? "" : "text-muted",
|
|
187
|
-
].join(" ")}
|
|
188
|
-
>
|
|
189
|
-
<ExpandIcon />
|
|
190
|
-
</Button>
|
|
191
|
-
</div>
|
|
192
|
-
|
|
193
|
-
{/* ── Action buttons — wrap as a group below viewport row on mobile ── */}
|
|
194
|
-
<div className="flex flex-wrap items-center gap-sm">
|
|
195
|
-
{/* ── Inspect tokens button — variant and label driven by `inspecting` prop ── */}
|
|
196
|
-
<Button
|
|
197
|
-
variant={inspecting ? "primary" : "secondary"}
|
|
198
|
-
size="sm"
|
|
199
|
-
aria-pressed={inspecting}
|
|
200
|
-
onClick={onInspectTokens}
|
|
201
|
-
className="gap-xs rounded-xl"
|
|
202
|
-
>
|
|
203
|
-
<InspectIcon />
|
|
204
|
-
{inspecting ? "Exit inspect" : "Inspect tokens"}
|
|
205
|
-
</Button>
|
|
206
|
-
|
|
207
|
-
<Button
|
|
208
|
-
variant={darkMode ? "primary" : "secondary"}
|
|
209
|
-
size="sm"
|
|
210
|
-
aria-pressed={darkMode}
|
|
211
|
-
onClick={onDarkToggle}
|
|
212
|
-
className="gap-xs rounded-xl"
|
|
213
|
-
>
|
|
214
|
-
<MoonIcon />
|
|
215
|
-
Dark
|
|
216
|
-
</Button>
|
|
103
|
+
<Icon name="more-options-vertical-dots" size={16} />
|
|
104
|
+
</Button>
|
|
105
|
+
);
|
|
217
106
|
|
|
218
|
-
|
|
219
|
-
variant="secondary"
|
|
220
|
-
size="sm"
|
|
221
|
-
onClick={onFullscreen}
|
|
222
|
-
className="gap-xs rounded-xl"
|
|
223
|
-
>
|
|
224
|
-
<FullscreenIcon />
|
|
225
|
-
Fullscreen
|
|
226
|
-
</Button>
|
|
227
|
-
|
|
228
|
-
{/* ── Model chip (outlined primary style) ── */}
|
|
229
|
-
<Chip
|
|
230
|
-
label={modelLabel ?? ""}
|
|
231
|
-
variant="default"
|
|
232
|
-
size="md"
|
|
233
|
-
className="border-primary text-primary bg-canvas cursor-default select-none"
|
|
234
|
-
/>
|
|
107
|
+
const hasOverflowItems = !!overflowItems && overflowItems.length > 0;
|
|
235
108
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
109
|
+
return (
|
|
110
|
+
<div
|
|
111
|
+
ref={ref}
|
|
112
|
+
role="toolbar"
|
|
113
|
+
aria-label="Preview toolbar"
|
|
114
|
+
className={[
|
|
115
|
+
// On mobile: flex column direction with wrapping rows; on md+: single inline-flex row
|
|
116
|
+
"flex flex-wrap items-center gap-sm px-sm py-xs",
|
|
117
|
+
"md:inline-flex md:flex-nowrap",
|
|
118
|
+
"bg-canvas border border-hairline rounded-xl shadow-md",
|
|
119
|
+
className,
|
|
120
|
+
].filter(Boolean).join(" ")}
|
|
121
|
+
>
|
|
122
|
+
{/* ── Viewport toggles — reuses FilterTabBar's icon-only compact chrome ── */}
|
|
123
|
+
<FilterTabBar
|
|
124
|
+
tabs={viewportTabs}
|
|
125
|
+
value={selectedValue}
|
|
126
|
+
onChange={handleViewportTabChange}
|
|
127
|
+
aria-label="Viewport size"
|
|
128
|
+
className="w-full md:w-auto shadow-none"
|
|
242
129
|
/>
|
|
243
130
|
|
|
244
|
-
{/* ──
|
|
245
|
-
<
|
|
246
|
-
variant
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
131
|
+
{/* ── Action buttons — wrap as a group below viewport row on mobile ── */}
|
|
132
|
+
<div className="flex flex-wrap items-center gap-sm">
|
|
133
|
+
{/* ── Inspect tokens button — variant and label driven by `inspecting` prop ── */}
|
|
134
|
+
<Button
|
|
135
|
+
variant={inspecting ? "primary" : "secondary"}
|
|
136
|
+
size="sm"
|
|
137
|
+
aria-pressed={inspecting}
|
|
138
|
+
onClick={onInspectTokens}
|
|
139
|
+
className="gap-xs rounded-xl"
|
|
140
|
+
>
|
|
141
|
+
<Icon name="inspect-target-crosshair" size={15} />
|
|
142
|
+
{inspecting ? "Exit inspect" : "Inspect tokens"}
|
|
143
|
+
</Button>
|
|
144
|
+
|
|
145
|
+
<Button
|
|
146
|
+
variant={darkMode ? "primary" : "secondary"}
|
|
147
|
+
size="sm"
|
|
148
|
+
aria-pressed={darkMode}
|
|
149
|
+
onClick={onDarkToggle}
|
|
150
|
+
className="gap-xs rounded-xl"
|
|
151
|
+
>
|
|
152
|
+
<Icon name="moon-dark-mode" size={15} />
|
|
153
|
+
Dark
|
|
154
|
+
</Button>
|
|
155
|
+
|
|
156
|
+
<Button
|
|
157
|
+
variant="secondary"
|
|
158
|
+
size="sm"
|
|
159
|
+
onClick={onFullscreen}
|
|
160
|
+
className="gap-xs rounded-xl"
|
|
161
|
+
>
|
|
162
|
+
<Icon name="fullscreen-corners-expand" size={15} />
|
|
163
|
+
Fullscreen
|
|
164
|
+
</Button>
|
|
165
|
+
|
|
166
|
+
{/* ── Model chip (outlined primary style) ── */}
|
|
167
|
+
<Chip
|
|
168
|
+
label={modelLabel ?? ""}
|
|
169
|
+
variant="default"
|
|
170
|
+
size="md"
|
|
171
|
+
className="border-primary text-primary bg-canvas cursor-default select-none"
|
|
172
|
+
/>
|
|
173
|
+
|
|
174
|
+
{/* ── Kind chip (filled soft primary) ── */}
|
|
175
|
+
<Chip
|
|
176
|
+
label={kindLabel ?? ""}
|
|
177
|
+
variant="default"
|
|
178
|
+
size="md"
|
|
179
|
+
className="bg-primary-disabled border-primary-disabled text-primary cursor-default select-none"
|
|
180
|
+
/>
|
|
181
|
+
|
|
182
|
+
{/* ── Overflow — renders as a Menu when overflowItems is supplied, ── */}
|
|
183
|
+
{/* falls back to the legacy bare-button onOverflow callback, and ── */}
|
|
184
|
+
{/* is hidden entirely when neither is provided. Portal mode keeps ── */}
|
|
185
|
+
{/* the dropdown from clipping inside overflow-hidden panel headers. ── */}
|
|
186
|
+
{hasOverflowItems ? (
|
|
187
|
+
<Menu
|
|
188
|
+
items={overflowItems as MenuItem[]}
|
|
189
|
+
align="right"
|
|
190
|
+
portal={true}
|
|
191
|
+
aria-label="More options"
|
|
192
|
+
trigger={overflowTrigger}
|
|
193
|
+
/>
|
|
194
|
+
) : onOverflow ? (
|
|
195
|
+
<Button
|
|
196
|
+
variant="ghost"
|
|
197
|
+
size="sm"
|
|
198
|
+
aria-label="More options"
|
|
199
|
+
onClick={onOverflow}
|
|
200
|
+
className="!w-8 !h-8 !p-0 rounded-sm text-muted shrink-0"
|
|
201
|
+
>
|
|
202
|
+
<Icon name="more-options-vertical-dots" size={16} />
|
|
203
|
+
</Button>
|
|
204
|
+
) : null}
|
|
205
|
+
</div>
|
|
254
206
|
</div>
|
|
255
|
-
|
|
256
|
-
|
|
207
|
+
);
|
|
208
|
+
},
|
|
257
209
|
);
|
|
258
210
|
|
|
259
211
|
PreviewToolbar.displayName = "PreviewToolbar";
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import { PreviewToolbar, Viewport } from "./PreviewToolbar";
|
|
3
|
+
import type { MenuItem } from "../Menu";
|
|
3
4
|
|
|
4
5
|
export default function PreviewToolbarPreview() {
|
|
5
6
|
const [viewport, setViewport] = useState<Viewport>("desktop");
|
|
6
7
|
const [darkMode, setDarkMode] = useState(false);
|
|
7
8
|
const [inspecting, setInspecting] = useState(false);
|
|
8
9
|
const [expanded, setExpanded] = useState(false);
|
|
10
|
+
const [lastAction, setLastAction] = useState("none");
|
|
11
|
+
|
|
12
|
+
const overflowItems: MenuItem[] = [
|
|
13
|
+
{ id: "duplicate", label: "Duplicate", icon: "copy", onSelect: () => setLastAction("Duplicate") },
|
|
14
|
+
{ id: "rename", label: "Rename", icon: "pencil-edit", onSelect: () => setLastAction("Rename") },
|
|
15
|
+
{
|
|
16
|
+
id: "delete",
|
|
17
|
+
label: "Delete",
|
|
18
|
+
icon: "trash-bin",
|
|
19
|
+
destructive: true,
|
|
20
|
+
withDividerBefore: true,
|
|
21
|
+
onSelect: () => setLastAction("Delete"),
|
|
22
|
+
},
|
|
23
|
+
];
|
|
9
24
|
|
|
10
25
|
return (
|
|
11
26
|
<div className="w-full max-w-5xl mx-auto p-lg space-y-xl">
|
|
@@ -13,7 +28,7 @@ export default function PreviewToolbarPreview() {
|
|
|
13
28
|
<div className="space-y-xxs">
|
|
14
29
|
<p className="text-body-sm text-muted uppercase tracking-wide">Preview toolbar</p>
|
|
15
30
|
<p className="text-body-sm text-muted">
|
|
16
|
-
Interactive — click the viewport icons, toggle Dark mode, Inspect tokens, and the
|
|
31
|
+
Interactive — click the viewport icons, toggle Dark mode, Inspect tokens, the Expand button, and the overflow menu.
|
|
17
32
|
</p>
|
|
18
33
|
</div>
|
|
19
34
|
|
|
@@ -30,7 +45,7 @@ export default function PreviewToolbarPreview() {
|
|
|
30
45
|
expanded={expanded}
|
|
31
46
|
onExpand={() => setExpanded((e) => !e)}
|
|
32
47
|
onFullscreen={() => {}}
|
|
33
|
-
|
|
48
|
+
overflowItems={overflowItems}
|
|
34
49
|
/>
|
|
35
50
|
</div>
|
|
36
51
|
|
|
@@ -38,7 +53,8 @@ export default function PreviewToolbarPreview() {
|
|
|
38
53
|
Active viewport: <strong className="text-ink">{viewport}</strong> ·
|
|
39
54
|
Dark mode: <strong className="text-ink">{darkMode ? "on" : "off"}</strong> ·
|
|
40
55
|
Inspecting: <strong className="text-ink">{inspecting ? "on" : "off"}</strong> ·
|
|
41
|
-
Expanded: <strong className="text-ink">{expanded ? "on" : "off"}</strong>
|
|
56
|
+
Expanded: <strong className="text-ink">{expanded ? "on" : "off"}</strong> ·
|
|
57
|
+
Last overflow action: <strong className="text-ink">{lastAction}</strong>
|
|
42
58
|
</p>
|
|
43
59
|
</div>
|
|
44
60
|
|
|
@@ -58,6 +74,7 @@ export default function PreviewToolbarPreview() {
|
|
|
58
74
|
inspecting
|
|
59
75
|
modelLabel="Sonnet 4.6"
|
|
60
76
|
kindLabel="ATOM"
|
|
77
|
+
overflowItems={overflowItems}
|
|
61
78
|
className="w-full"
|
|
62
79
|
/>
|
|
63
80
|
</div>
|
|
@@ -73,6 +90,7 @@ export default function PreviewToolbarPreview() {
|
|
|
73
90
|
expanded
|
|
74
91
|
modelLabel="Sonnet 4.6"
|
|
75
92
|
kindLabel="ATOM"
|
|
93
|
+
overflowItems={overflowItems}
|
|
76
94
|
/>
|
|
77
95
|
</div>
|
|
78
96
|
</div>
|
|
@@ -86,6 +104,7 @@ export default function PreviewToolbarPreview() {
|
|
|
86
104
|
inspecting
|
|
87
105
|
modelLabel="Sonnet 4.6"
|
|
88
106
|
kindLabel="ATOM"
|
|
107
|
+
overflowItems={overflowItems}
|
|
89
108
|
/>
|
|
90
109
|
</div>
|
|
91
110
|
</div>
|
|
@@ -95,10 +114,11 @@ export default function PreviewToolbarPreview() {
|
|
|
95
114
|
<p className="text-body-sm text-muted font-weight-heading-sm">Dark mode active</p>
|
|
96
115
|
<div className="flex items-start justify-center w-full bg-canvas rounded-xl p-xl border border-hairline">
|
|
97
116
|
<PreviewToolbar
|
|
98
|
-
viewport="
|
|
117
|
+
viewport="desktop"
|
|
99
118
|
darkMode
|
|
100
119
|
kindLabel="ORGANISM"
|
|
101
120
|
modelLabel="Haiku 3.5"
|
|
121
|
+
overflowItems={overflowItems}
|
|
102
122
|
/>
|
|
103
123
|
</div>
|
|
104
124
|
</div>
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Button } from "../Button";
|
|
3
|
+
import { Chip } from "../Chip";
|
|
4
|
+
import { Icon } from "../Icon";
|
|
5
|
+
import { Dropdown } from "../Dropdown";
|
|
6
|
+
import type { DropdownOption } from "../Dropdown";
|
|
7
|
+
|
|
8
|
+
export interface PricingCardCreditTier {
|
|
9
|
+
/** Unique value for this tier, e.g. "100". */
|
|
10
|
+
value: string;
|
|
11
|
+
/** Credits label, e.g. "100 credits". */
|
|
12
|
+
label: string;
|
|
13
|
+
/** Price for this tier, e.g. "$25 /mo". */
|
|
14
|
+
price: string;
|
|
15
|
+
/** Optional savings badge, e.g. "Save 2%". */
|
|
16
|
+
savingsLabel?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface PricingCardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
20
|
+
/** Plan name, e.g. "Free", "Pro", "Enterprise". */
|
|
21
|
+
planName: string;
|
|
22
|
+
/** One-line description of who the plan is for. */
|
|
23
|
+
description: string;
|
|
24
|
+
/** Price to display, e.g. "$0", "$19", "Custom". */
|
|
25
|
+
price: string;
|
|
26
|
+
/** Unit shown after the price, e.g. "/ month". Omit for custom pricing. */
|
|
27
|
+
priceUnit?: string;
|
|
28
|
+
/** Small note under the price, e.g. "Billed monthly" or "Tailored to your needs". */
|
|
29
|
+
priceNote?: string;
|
|
30
|
+
/** Feature bullet list. */
|
|
31
|
+
features: string[];
|
|
32
|
+
/** Label for the primary CTA button. */
|
|
33
|
+
ctaLabel: string;
|
|
34
|
+
/** Called when the CTA button is clicked. */
|
|
35
|
+
onCtaClick?: () => void;
|
|
36
|
+
/** Small caption under the CTA, e.g. "No credit card required". */
|
|
37
|
+
ctaCaption?: string;
|
|
38
|
+
/** When true, renders the highlighted "most popular" treatment. */
|
|
39
|
+
highlighted?: boolean;
|
|
40
|
+
/** Label for the highlight badge. Only shown when highlighted is true. */
|
|
41
|
+
highlightLabel?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Optional credit tiers. When provided, renders a Dropdown (below the
|
|
44
|
+
* price) letting the user pick a usage tier — e.g. "100 credits — $25/mo".
|
|
45
|
+
*/
|
|
46
|
+
creditTiers?: PricingCardCreditTier[];
|
|
47
|
+
/** Currently selected credit tier value. Required when creditTiers is set. */
|
|
48
|
+
selectedCreditValue?: string;
|
|
49
|
+
/** Called when the user picks a different credit tier. */
|
|
50
|
+
onCreditChange?: (value: string) => void;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const PricingCard = React.forwardRef<HTMLDivElement, PricingCardProps>(
|
|
54
|
+
(
|
|
55
|
+
{
|
|
56
|
+
planName,
|
|
57
|
+
description,
|
|
58
|
+
price,
|
|
59
|
+
priceUnit,
|
|
60
|
+
priceNote,
|
|
61
|
+
features,
|
|
62
|
+
ctaLabel,
|
|
63
|
+
onCtaClick,
|
|
64
|
+
ctaCaption,
|
|
65
|
+
highlighted = false,
|
|
66
|
+
highlightLabel = "Most popular",
|
|
67
|
+
creditTiers,
|
|
68
|
+
selectedCreditValue,
|
|
69
|
+
onCreditChange,
|
|
70
|
+
className,
|
|
71
|
+
...rest
|
|
72
|
+
},
|
|
73
|
+
ref,
|
|
74
|
+
) => {
|
|
75
|
+
const hasCreditTiers = !!creditTiers && creditTiers.length > 0;
|
|
76
|
+
|
|
77
|
+
const creditOptions: DropdownOption[] | undefined = hasCreditTiers
|
|
78
|
+
? creditTiers!.map((tier) => ({
|
|
79
|
+
label: tier.label,
|
|
80
|
+
value: tier.value,
|
|
81
|
+
meta: tier.price,
|
|
82
|
+
badge: tier.savingsLabel,
|
|
83
|
+
}))
|
|
84
|
+
: undefined;
|
|
85
|
+
|
|
86
|
+
const selectedTier = hasCreditTiers
|
|
87
|
+
? creditTiers!.find((tier) => tier.value === selectedCreditValue)
|
|
88
|
+
: undefined;
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<div
|
|
92
|
+
ref={ref}
|
|
93
|
+
className={[
|
|
94
|
+
"relative flex w-full flex-col rounded-xl border bg-canvas p-lg",
|
|
95
|
+
highlighted
|
|
96
|
+
? "border-primary shadow-modal"
|
|
97
|
+
: "border-hairline shadow-card",
|
|
98
|
+
className,
|
|
99
|
+
]
|
|
100
|
+
.filter(Boolean)
|
|
101
|
+
.join(" ")}
|
|
102
|
+
{...rest}
|
|
103
|
+
>
|
|
104
|
+
{highlighted && (
|
|
105
|
+
<div className="absolute -top-3.5 left-1/2 -translate-x-1/2">
|
|
106
|
+
<Chip label={highlightLabel} variant="primary" size="sm" className="uppercase tracking-wide" />
|
|
107
|
+
</div>
|
|
108
|
+
)}
|
|
109
|
+
|
|
110
|
+
<div className="flex flex-col gap-xxs">
|
|
111
|
+
<h3 className="text-heading-md text-ink">{planName}</h3>
|
|
112
|
+
<p className="text-body-sm text-muted">{description}</p>
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<div className="mt-lg flex items-baseline gap-xs">
|
|
116
|
+
<span className="text-display-lg text-ink" style={{ lineHeight: 1 }}>
|
|
117
|
+
{selectedTier ? selectedTier.price.split("/")[0].trim() : price}
|
|
118
|
+
</span>
|
|
119
|
+
{priceUnit && !selectedTier && <span className="text-body-sm text-muted">{priceUnit}</span>}
|
|
120
|
+
</div>
|
|
121
|
+
{priceNote && !hasCreditTiers && <p className="mt-xs text-body-sm text-muted">{priceNote}</p>}
|
|
122
|
+
|
|
123
|
+
{hasCreditTiers && (
|
|
124
|
+
<div className="mt-md">
|
|
125
|
+
<Dropdown
|
|
126
|
+
options={creditOptions!}
|
|
127
|
+
value={selectedCreditValue}
|
|
128
|
+
onChange={(v) => onCreditChange?.(v)}
|
|
129
|
+
placeholder="Select credits"
|
|
130
|
+
/>
|
|
131
|
+
</div>
|
|
132
|
+
)}
|
|
133
|
+
|
|
134
|
+
<div className="mt-lg border-t border-hairline pt-lg flex-1">
|
|
135
|
+
<ul className="flex flex-col gap-md" role="list">
|
|
136
|
+
{features.map((feature) => (
|
|
137
|
+
<li key={feature} className="flex items-start gap-sm">
|
|
138
|
+
<Icon
|
|
139
|
+
name="check-checkmark"
|
|
140
|
+
className="mt-0.5 size-4 flex-shrink-0 text-semantic-success"
|
|
141
|
+
/>
|
|
142
|
+
<span className="text-body-sm text-body">{feature}</span>
|
|
143
|
+
</li>
|
|
144
|
+
))}
|
|
145
|
+
</ul>
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
<div className="mt-lg flex flex-col items-center gap-sm">
|
|
149
|
+
<Button
|
|
150
|
+
variant={highlighted ? "primary" : "secondary"}
|
|
151
|
+
size="md"
|
|
152
|
+
onClick={onCtaClick}
|
|
153
|
+
className="w-full"
|
|
154
|
+
>
|
|
155
|
+
{ctaLabel}
|
|
156
|
+
</Button>
|
|
157
|
+
{ctaCaption && <span className="text-caption text-muted-soft">{ctaCaption}</span>}
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
);
|
|
161
|
+
},
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
PricingCard.displayName = "PricingCard";
|