@designa8/vibedesign-v6 1.20.19 → 2.1.1
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/fonts/plusjakartasans/PlusJakartaSans-Italic[wght].ttf +0 -0
- package/dist/fonts/plusjakartasans/PlusJakartaSans[wght].ttf +0 -0
- package/dist/index.cjs +12027 -4942
- package/dist/index.js +12089 -5004
- package/dist/styles.css +1393 -97
- package/package.json +116 -1
- package/src/atoms/AgentQuestionCard/AgentQuestionCard.tsx +567 -0
- package/src/atoms/AgentQuestionCard/index.ts +6 -0
- package/src/atoms/AgentQuestionCard/preview.tsx +199 -0
- package/src/atoms/AppLayout/AppLayout.tsx +85 -22
- package/src/atoms/AppLayout/preview.tsx +4 -0
- package/src/atoms/AppSidebar/AppSidebar.tsx +222 -137
- package/src/atoms/AppSidebar/preview.tsx +61 -8
- package/src/atoms/AppSidebarMobile/AppSidebarMobile.tsx +241 -169
- package/src/atoms/AppSidebarMobile/preview.tsx +59 -89
- package/src/atoms/AuthLogin/AuthLogin.tsx +86 -49
- package/src/atoms/AuthLogin/preview.tsx +16 -0
- package/src/atoms/AuthSignUp/AuthSignUp.tsx +206 -126
- package/src/atoms/AuthSignUp/preview.tsx +10 -0
- package/src/atoms/BillingToggle/BillingToggle.tsx +2 -2
- package/src/atoms/BottomSheet/BottomSheet.tsx +199 -0
- package/src/atoms/BottomSheet/index.ts +2 -0
- package/src/atoms/BottomSheet/preview.tsx +50 -0
- package/src/atoms/Button/Button.tsx +19 -3
- package/src/atoms/Button/preview.tsx +2 -1
- package/src/atoms/ChatHistorySidebar/ChatHistorySidebar.tsx +160 -84
- package/src/atoms/ChatHistorySidebar/preview.tsx +81 -42
- package/src/atoms/ChatScreen/ChatScreen.tsx +298 -33
- package/src/atoms/ChatScreen/preview.tsx +54 -90
- package/src/atoms/Chip/Chip.tsx +81 -33
- package/src/atoms/Chip/preview.tsx +39 -21
- package/src/atoms/CodeEditor/CodeEditor.tsx +10 -4
- package/src/atoms/ComponentActionsSheet/ComponentActionsSheet.tsx +165 -0
- package/src/atoms/ComponentActionsSheet/index.ts +7 -0
- package/src/atoms/ComponentActionsSheet/preview.tsx +67 -0
- package/src/atoms/ComponentCard/ComponentCard.tsx +17 -35
- package/src/atoms/ComponentCard/preview.tsx +9 -9
- package/src/atoms/DesignSystemLoader/DesignSystemLoader.tsx +153 -0
- package/src/atoms/DesignSystemLoader/index.ts +2 -0
- package/src/atoms/DesignSystemLoader/preview.tsx +19 -0
- package/src/atoms/DesignSystemShowcase/DesignSystemShowcase.tsx +410 -0
- package/src/atoms/DesignSystemShowcase/index.ts +6 -0
- package/src/atoms/DesignSystemShowcase/preview.tsx +22 -0
- package/src/atoms/DesignTokensPanel/DesignTokensPanel.data.ts +254 -0
- package/src/atoms/DesignTokensPanel/DesignTokensPanel.tsx +946 -0
- package/src/atoms/DesignTokensPanel/index.ts +9 -0
- package/src/atoms/DesignTokensPanel/preview.tsx +39 -0
- package/src/atoms/ExpandableMessage/ExpandableMessage.tsx +239 -0
- package/src/atoms/ExpandableMessage/fix-link-note.txt +3 -0
- package/src/atoms/ExpandableMessage/index.ts +2 -0
- package/src/atoms/ExpandableMessage/markdown.tsx +310 -0
- package/src/atoms/ExpandableMessage/preview.tsx +83 -0
- package/src/atoms/FilterTabBar/FilterTabBar.tsx +2 -2
- package/src/atoms/FontCombobox/FontCombobox.tsx +655 -0
- package/src/atoms/FontCombobox/index.ts +6 -0
- package/src/atoms/FontCombobox/preview.tsx +111 -0
- package/src/atoms/HomePageTemplate/HomePageTemplate.tsx +894 -96
- package/src/atoms/HomePageTemplate/preview.tsx +4 -0
- package/src/atoms/Icon/Icon.tsx +17 -11
- package/src/atoms/Icon/icons.data.ts +34 -0
- package/src/atoms/Input/Input.tsx +37 -21
- package/src/atoms/LandingHero/LandingHero.tsx +545 -0
- package/src/atoms/LandingHero/index.ts +6 -0
- package/src/atoms/LandingHero/preview.tsx +88 -0
- package/src/atoms/MarketingFooter/MarketingFooter.tsx +215 -0
- package/src/atoms/MarketingFooter/index.ts +7 -0
- package/src/atoms/MarketingFooter/preview.tsx +28 -0
- package/src/atoms/MarketingNavbar/MarketingNavbar.tsx +451 -0
- package/src/atoms/MarketingNavbar/index.ts +7 -0
- package/src/atoms/MarketingNavbar/preview.tsx +109 -0
- package/src/atoms/MobileActionsDrawer/MobileActionsDrawer.tsx +548 -0
- package/src/atoms/MobileActionsDrawer/index.ts +9 -0
- package/src/atoms/MobileActionsDrawer/preview.tsx +109 -0
- package/src/atoms/Modal/Modal.tsx +77 -28
- package/src/atoms/PreviewDock/PreviewDock.tsx +119 -0
- package/src/atoms/PreviewDock/index.ts +2 -0
- package/src/atoms/PreviewDock/preview.tsx +30 -0
- package/src/atoms/PreviewToolbar/PreviewToolbar.tsx +47 -30
- package/src/atoms/PricingCard/PricingCard.tsx +15 -4
- package/src/atoms/PricingPageTemplate/PricingPageTemplate.tsx +109 -89
- package/src/atoms/ProjectSettingsModal/ProjectSettingsModal.tsx +314 -0
- package/src/atoms/ProjectSettingsModal/index.ts +2 -0
- package/src/atoms/ProjectSettingsModal/preview.tsx +130 -0
- package/src/atoms/ProjectSettingsModal/switch.snippet.txt +8 -0
- package/src/atoms/PromptInputBar/PromptInputBar.tsx +750 -302
- package/src/atoms/PromptInputBar/preview.tsx +64 -64
- package/src/atoms/SettingsPageTemplate/SettingsPageTemplate.tsx +272 -0
- package/src/atoms/SettingsPageTemplate/index.ts +2 -0
- package/src/atoms/SettingsPageTemplate/preview.tsx +29 -0
- package/src/atoms/SidebarUpgradeBanner/SidebarUpgradeBanner.tsx +178 -0
- package/src/atoms/SidebarUpgradeBanner/index.ts +2 -0
- package/src/atoms/SidebarUpgradeBanner/preview.tsx +47 -0
- package/src/atoms/SkeletonChip/SkeletonChip.tsx +198 -0
- package/src/atoms/SkeletonChip/index.ts +2 -0
- package/src/atoms/SkeletonChip/preview.tsx +44 -0
- package/src/atoms/TemplateHeader/TemplateHeader.tsx +129 -0
- package/src/atoms/TemplateHeader/index.ts +2 -0
- package/src/atoms/TemplateHeader/preview.tsx +39 -0
- package/src/atoms/TemplateHero/TemplateHero.tsx +286 -0
- package/src/atoms/TemplateHero/index.ts +2 -0
- package/src/atoms/TemplateHero/preview.tsx +32 -0
- package/src/atoms/TemplateSummary/TemplateSummary.tsx +85 -0
- package/src/atoms/TemplateSummary/index.ts +2 -0
- package/src/atoms/TemplateSummary/preview.tsx +10 -0
- package/src/atoms/Toast/Toast.tsx +178 -0
- package/src/atoms/Toast/index.ts +2 -0
- package/src/atoms/Toast/preview.tsx +100 -0
- package/src/atoms/TopNavbar/TopNavbar.tsx +145 -67
- package/src/atoms/TopNavbar/preview.tsx +13 -7
- package/src/atoms/TopupModal/TopupModal.tsx +94 -0
- package/src/atoms/TopupModal/index.ts +2 -0
- package/src/atoms/TopupModal/preview.tsx +22 -0
- package/src/atoms/UpgradeCard/UpgradeCard.tsx +124 -43
- package/src/atoms/UpgradeCard/index.ts +1 -1
- package/src/atoms/UpgradeCard/preview.tsx +7 -14
- package/src/atoms/UpgradeModal/UpgradeModal.tsx +192 -0
- package/src/atoms/UpgradeModal/index.ts +2 -0
- package/src/atoms/UpgradeModal/preview.tsx +41 -0
- package/src/index.ts +23 -0
- package/src/tokens.css +45 -7
- package/dist/fonts/inter/Inter-Italic[opsz,wght].ttf +0 -0
- package/dist/fonts/inter/Inter[opsz,wght].ttf +0 -0
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Icon } from "../Icon";
|
|
3
|
+
|
|
4
|
+
type IconName = React.ComponentProps<typeof Icon>["name"];
|
|
5
|
+
|
|
6
|
+
export type DrawerItemType = "drawer" | "toggle" | "action";
|
|
7
|
+
|
|
8
|
+
export interface DrawerItem {
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
icon: IconName;
|
|
12
|
+
/** Trailing muted text, e.g. "v12". */
|
|
13
|
+
meta?: string;
|
|
14
|
+
/** Trailing count badge, e.g. "24". */
|
|
15
|
+
badge?: string;
|
|
16
|
+
/** "drawer" opens a second drawer, "toggle" flips inline, "action" fires onSelect only. */
|
|
17
|
+
type?: DrawerItemType;
|
|
18
|
+
checked?: boolean;
|
|
19
|
+
destructive?: boolean;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/** Solid brand tile (only used by quick actions). */
|
|
22
|
+
primary?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface DrawerSection {
|
|
26
|
+
id: string;
|
|
27
|
+
label?: string;
|
|
28
|
+
items: DrawerItem[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface DrawerCredits {
|
|
32
|
+
remaining: number;
|
|
33
|
+
total: number;
|
|
34
|
+
resetLabel?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface DrawerUpgrade {
|
|
38
|
+
title: string;
|
|
39
|
+
subtitle?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface MobileActionsDrawerProps
|
|
43
|
+
extends Omit<React.HTMLAttributes<HTMLDivElement>, "children"> {
|
|
44
|
+
open: boolean;
|
|
45
|
+
onOpenChange: (open: boolean) => void;
|
|
46
|
+
projectName?: string;
|
|
47
|
+
projectInitial?: string;
|
|
48
|
+
version?: string;
|
|
49
|
+
credits?: DrawerCredits;
|
|
50
|
+
upgrade?: DrawerUpgrade | null;
|
|
51
|
+
quickActions?: DrawerItem[];
|
|
52
|
+
sections?: DrawerSection[];
|
|
53
|
+
/** Id of the row whose second drawer is open. Omit to let the drawer manage it. */
|
|
54
|
+
activeItemId?: string | null;
|
|
55
|
+
onActiveItemChange?: (id: string | null) => void;
|
|
56
|
+
onSelect?: (id: string) => void;
|
|
57
|
+
onToggle?: (id: string, checked: boolean) => void;
|
|
58
|
+
/** Host-provided content of the second drawer. */
|
|
59
|
+
renderPanel?: (id: string, title: string) => React.ReactNode;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const DEFAULT_QUICK_ACTIONS: DrawerItem[] = [
|
|
63
|
+
{ id: "export", label: "Export", icon: "download", type: "drawer" },
|
|
64
|
+
{ id: "publish", label: "Publish", icon: "upload", type: "drawer", primary: true },
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
const DEFAULT_SECTIONS: DrawerSection[] = [
|
|
68
|
+
{
|
|
69
|
+
id: "project",
|
|
70
|
+
label: "Project",
|
|
71
|
+
items: [
|
|
72
|
+
{ id: "versions", label: "Versions", icon: "clock", meta: "v12", type: "drawer" },
|
|
73
|
+
{ id: "project-settings", label: "Project settings", icon: "settings-gear", type: "drawer" },
|
|
74
|
+
{ id: "files", label: "Files", icon: "file-document", type: "drawer" },
|
|
75
|
+
{ id: "drafts", label: "Drafts", icon: "square-pen", type: "drawer" },
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: "chats",
|
|
80
|
+
label: "Chats",
|
|
81
|
+
items: [
|
|
82
|
+
{ id: "all-chats", label: "All chats", icon: "chat-bubble", badge: "24", type: "drawer" },
|
|
83
|
+
{ id: "new-chat", label: "New chat", icon: "plus-add", type: "drawer" },
|
|
84
|
+
{ id: "search-chats", label: "Search chats", icon: "search-magnifier", type: "drawer" },
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: "preferences",
|
|
89
|
+
label: "Preferences",
|
|
90
|
+
items: [
|
|
91
|
+
{ id: "dark-mode", label: "Dark mode", icon: "moon-dark-mode", type: "toggle", checked: false },
|
|
92
|
+
{ id: "language", label: "Language", icon: "globe", meta: "English", type: "drawer" },
|
|
93
|
+
{ id: "notifications", label: "Notifications", icon: "bell", type: "drawer" },
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
id: "account",
|
|
98
|
+
items: [
|
|
99
|
+
{ id: "help", label: "Help & feedback", icon: "help-question-circle", type: "drawer" },
|
|
100
|
+
{ id: "sign-out", label: "Sign out", icon: "logout-sign-out", type: "action", destructive: true },
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
const FOCUSABLE =
|
|
106
|
+
'button:not([disabled]), [href], input:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
107
|
+
|
|
108
|
+
const pressable =
|
|
109
|
+
"cursor-pointer transition duration-150 ease-out active:scale-[0.98] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue disabled:cursor-not-allowed disabled:opacity-50";
|
|
110
|
+
|
|
111
|
+
const iconButton = `${pressable} flex size-9 shrink-0 items-center justify-center rounded-sm bg-surface-soft text-ink hover:bg-surface-strong`;
|
|
112
|
+
|
|
113
|
+
export const MobileActionsDrawer = React.forwardRef<
|
|
114
|
+
HTMLDivElement,
|
|
115
|
+
MobileActionsDrawerProps
|
|
116
|
+
>(
|
|
117
|
+
(
|
|
118
|
+
{
|
|
119
|
+
open,
|
|
120
|
+
onOpenChange,
|
|
121
|
+
projectName = "NovaCalc",
|
|
122
|
+
projectInitial,
|
|
123
|
+
version = "Main v12",
|
|
124
|
+
credits = { remaining: 5, total: 8, resetLabel: "Daily credits reset at midnight UTC" },
|
|
125
|
+
upgrade = { title: "Upgrade to Pro", subtitle: "Unlock more credits" },
|
|
126
|
+
quickActions = DEFAULT_QUICK_ACTIONS,
|
|
127
|
+
sections = DEFAULT_SECTIONS,
|
|
128
|
+
activeItemId,
|
|
129
|
+
onActiveItemChange,
|
|
130
|
+
onSelect,
|
|
131
|
+
onToggle,
|
|
132
|
+
renderPanel,
|
|
133
|
+
className,
|
|
134
|
+
style,
|
|
135
|
+
...rest
|
|
136
|
+
},
|
|
137
|
+
ref,
|
|
138
|
+
) => {
|
|
139
|
+
const [internalActive, setInternalActive] = React.useState<string | null>(null);
|
|
140
|
+
const isControlled = activeItemId !== undefined;
|
|
141
|
+
const activeId = isControlled ? activeItemId : internalActive;
|
|
142
|
+
const lastActive = React.useRef<string | null>(null);
|
|
143
|
+
if (activeId) lastActive.current = activeId;
|
|
144
|
+
const shownId = activeId ?? lastActive.current;
|
|
145
|
+
|
|
146
|
+
const setActive = (id: string | null) => {
|
|
147
|
+
if (!isControlled) setInternalActive(id);
|
|
148
|
+
onActiveItemChange?.(id);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const sheetRef = React.useRef<HTMLDivElement>(null);
|
|
152
|
+
const panelRef = React.useRef<HTMLDivElement>(null);
|
|
153
|
+
const closeRef = React.useRef<HTMLButtonElement>(null);
|
|
154
|
+
const backRef = React.useRef<HTMLButtonElement>(null);
|
|
155
|
+
|
|
156
|
+
const secondOpen = open && Boolean(activeId);
|
|
157
|
+
|
|
158
|
+
const closeAll = () => {
|
|
159
|
+
setActive(null);
|
|
160
|
+
onOpenChange(false);
|
|
161
|
+
};
|
|
162
|
+
const closeTop = () => {
|
|
163
|
+
if (secondOpen) setActive(null);
|
|
164
|
+
else onOpenChange(false);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// Title lookup for the second drawer.
|
|
168
|
+
const titles = React.useMemo(() => {
|
|
169
|
+
const map: Record<string, string> = {
|
|
170
|
+
credits: "Credits",
|
|
171
|
+
version: "Versions",
|
|
172
|
+
upgrade: upgrade?.title ?? "Upgrade",
|
|
173
|
+
};
|
|
174
|
+
[...quickActions, ...sections.flatMap((s) => s.items)].forEach((i) => {
|
|
175
|
+
map[i.id] = i.label;
|
|
176
|
+
});
|
|
177
|
+
return map;
|
|
178
|
+
}, [quickActions, sections, upgrade]);
|
|
179
|
+
const panelTitle = shownId ? (titles[shownId] ?? shownId) : "";
|
|
180
|
+
|
|
181
|
+
// Move focus into the top-most sheet when it opens.
|
|
182
|
+
React.useEffect(() => {
|
|
183
|
+
if (!open) return;
|
|
184
|
+
const t = window.setTimeout(() => {
|
|
185
|
+
(secondOpen ? backRef.current : closeRef.current)?.focus();
|
|
186
|
+
}, 60);
|
|
187
|
+
return () => window.clearTimeout(t);
|
|
188
|
+
}, [open, secondOpen]);
|
|
189
|
+
|
|
190
|
+
const onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {
|
|
191
|
+
if (!open) return;
|
|
192
|
+
if (e.key === "Escape") {
|
|
193
|
+
e.stopPropagation();
|
|
194
|
+
closeTop();
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
if (e.key === "Tab") {
|
|
198
|
+
const top = secondOpen ? panelRef.current : sheetRef.current;
|
|
199
|
+
if (!top) return;
|
|
200
|
+
const nodes = Array.from(top.querySelectorAll<HTMLElement>(FOCUSABLE));
|
|
201
|
+
if (nodes.length === 0) return;
|
|
202
|
+
const first = nodes[0];
|
|
203
|
+
const last = nodes[nodes.length - 1];
|
|
204
|
+
const current = document.activeElement;
|
|
205
|
+
if (e.shiftKey && current === first) {
|
|
206
|
+
e.preventDefault();
|
|
207
|
+
last.focus();
|
|
208
|
+
} else if (!e.shiftKey && current === last) {
|
|
209
|
+
e.preventDefault();
|
|
210
|
+
first.focus();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const onListKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {
|
|
216
|
+
if (e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
|
|
217
|
+
const rows = Array.from(
|
|
218
|
+
e.currentTarget.querySelectorAll<HTMLButtonElement>("[data-row]:not([disabled])"),
|
|
219
|
+
);
|
|
220
|
+
const idx = rows.indexOf(document.activeElement as HTMLButtonElement);
|
|
221
|
+
if (idx === -1) return;
|
|
222
|
+
e.preventDefault();
|
|
223
|
+
const next = e.key === "ArrowDown" ? idx + 1 : idx - 1;
|
|
224
|
+
rows[(next + rows.length) % rows.length]?.focus();
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// Swipe-down to close, driven from the drag handle.
|
|
228
|
+
const [dragY, setDragY] = React.useState(0);
|
|
229
|
+
const dragStart = React.useRef<number | null>(null);
|
|
230
|
+
const sheetHeight = () => sheetRef.current?.offsetHeight ?? 600;
|
|
231
|
+
const onHandleDown = (e: React.PointerEvent<HTMLDivElement>) => {
|
|
232
|
+
dragStart.current = e.clientY;
|
|
233
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
234
|
+
};
|
|
235
|
+
const onHandleMove = (e: React.PointerEvent<HTMLDivElement>) => {
|
|
236
|
+
if (dragStart.current === null) return;
|
|
237
|
+
setDragY(Math.max(0, e.clientY - dragStart.current));
|
|
238
|
+
};
|
|
239
|
+
const onHandleUp = () => {
|
|
240
|
+
if (dragStart.current === null) return;
|
|
241
|
+
const shouldClose = dragY > sheetHeight() * 0.3;
|
|
242
|
+
dragStart.current = null;
|
|
243
|
+
setDragY(0);
|
|
244
|
+
if (shouldClose) closeAll();
|
|
245
|
+
};
|
|
246
|
+
const dragging = dragY > 0;
|
|
247
|
+
|
|
248
|
+
const handleSelect = (item: DrawerItem) => {
|
|
249
|
+
const type = item.type ?? "drawer";
|
|
250
|
+
if (type === "toggle") {
|
|
251
|
+
onToggle?.(item.id, !item.checked);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (type === "drawer") setActive(item.id);
|
|
255
|
+
onSelect?.(item.id);
|
|
256
|
+
};
|
|
257
|
+
const openById = (id: string) => {
|
|
258
|
+
setActive(id);
|
|
259
|
+
onSelect?.(id);
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
const pct = credits.total > 0 ? Math.min(100, Math.max(0, (credits.remaining / credits.total) * 100)) : 0;
|
|
263
|
+
const outOfCredits = credits.remaining <= 0;
|
|
264
|
+
const initial = (projectInitial ?? projectName.charAt(0)).toUpperCase();
|
|
265
|
+
|
|
266
|
+
const renderRow = (item: DrawerItem) => {
|
|
267
|
+
const type = item.type ?? "drawer";
|
|
268
|
+
const selected = activeId === item.id;
|
|
269
|
+
const isToggle = type === "toggle";
|
|
270
|
+
return (
|
|
271
|
+
<button
|
|
272
|
+
key={item.id}
|
|
273
|
+
type="button"
|
|
274
|
+
data-row
|
|
275
|
+
disabled={item.disabled}
|
|
276
|
+
role={isToggle ? "switch" : undefined}
|
|
277
|
+
aria-checked={isToggle ? Boolean(item.checked) : undefined}
|
|
278
|
+
aria-haspopup={type === "drawer" ? "dialog" : undefined}
|
|
279
|
+
aria-expanded={type === "drawer" ? selected : undefined}
|
|
280
|
+
onClick={() => handleSelect(item)}
|
|
281
|
+
className={`${pressable} group flex min-h-[52px] w-full items-center gap-md px-md text-left focus-visible:ring-inset ${
|
|
282
|
+
selected ? "bg-primary-soft" : "bg-canvas hover:bg-surface-soft active:bg-surface-strong"
|
|
283
|
+
}`}
|
|
284
|
+
>
|
|
285
|
+
<span
|
|
286
|
+
className={`flex size-8 shrink-0 items-center justify-center rounded-full ${
|
|
287
|
+
selected ? "bg-canvas text-primary" : item.destructive ? "bg-semantic-error-soft text-semantic-error" : "bg-surface-soft text-body"
|
|
288
|
+
}`}
|
|
289
|
+
>
|
|
290
|
+
<Icon name={item.icon} size={18} />
|
|
291
|
+
</span>
|
|
292
|
+
<span
|
|
293
|
+
className={`flex-1 truncate text-body-md font-weight-body-sm ${
|
|
294
|
+
item.destructive ? "text-semantic-error" : "text-ink"
|
|
295
|
+
}`}
|
|
296
|
+
>
|
|
297
|
+
{item.label}
|
|
298
|
+
</span>
|
|
299
|
+
{item.meta ? <span className="text-body-sm text-muted">{item.meta}</span> : null}
|
|
300
|
+
{item.badge ? (
|
|
301
|
+
<span className="rounded-full bg-primary-soft px-sm py-xxs text-caption text-primary">
|
|
302
|
+
{item.badge}
|
|
303
|
+
</span>
|
|
304
|
+
) : null}
|
|
305
|
+
{isToggle ? (
|
|
306
|
+
<span
|
|
307
|
+
aria-hidden="true"
|
|
308
|
+
className={`relative h-6 w-10 shrink-0 rounded-full transition duration-200 ease-out ${
|
|
309
|
+
item.checked ? "bg-primary" : "bg-surface-strong"
|
|
310
|
+
}`}
|
|
311
|
+
>
|
|
312
|
+
<span
|
|
313
|
+
className={`absolute left-xxs top-xxs size-5 rounded-full bg-canvas shadow-sm transition duration-200 ease-out ${
|
|
314
|
+
item.checked ? "translate-x-4" : "translate-x-0"
|
|
315
|
+
}`}
|
|
316
|
+
/>
|
|
317
|
+
</span>
|
|
318
|
+
) : type === "drawer" ? (
|
|
319
|
+
<Icon
|
|
320
|
+
name="chevron-right"
|
|
321
|
+
size={16}
|
|
322
|
+
className="shrink-0 text-muted-soft transition duration-150 ease-out group-hover:translate-x-0.5"
|
|
323
|
+
/>
|
|
324
|
+
) : null}
|
|
325
|
+
</button>
|
|
326
|
+
);
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
return (
|
|
330
|
+
<div
|
|
331
|
+
ref={ref}
|
|
332
|
+
data-state={open ? "open" : "closed"}
|
|
333
|
+
onKeyDown={onKeyDown}
|
|
334
|
+
className={`absolute inset-0 w-full overflow-hidden data-[state=closed]:pointer-events-none ${className ?? ""}`}
|
|
335
|
+
style={{ zIndex: open ? "var(--z-modal, 1200)" : undefined, ...style }}
|
|
336
|
+
{...rest}
|
|
337
|
+
>
|
|
338
|
+
{/* Scrim */}
|
|
339
|
+
<button
|
|
340
|
+
type="button"
|
|
341
|
+
tabIndex={-1}
|
|
342
|
+
aria-label="Close menu"
|
|
343
|
+
onClick={closeTop}
|
|
344
|
+
data-state={open ? "open" : "closed"}
|
|
345
|
+
className="absolute inset-0 cursor-pointer bg-scrim transition-opacity duration-200 ease-out data-[state=closed]:opacity-0 data-[state=open]:opacity-60"
|
|
346
|
+
style={dragging ? { opacity: 0.6 * Math.max(0, 1 - dragY / sheetHeight()), transition: "none" } : undefined}
|
|
347
|
+
/>
|
|
348
|
+
|
|
349
|
+
{/* Primary drawer */}
|
|
350
|
+
<div
|
|
351
|
+
ref={sheetRef}
|
|
352
|
+
role="dialog"
|
|
353
|
+
aria-modal="true"
|
|
354
|
+
aria-label="Project menu"
|
|
355
|
+
aria-hidden={!open}
|
|
356
|
+
inert={!open || secondOpen}
|
|
357
|
+
data-state={open ? "open" : "closed"}
|
|
358
|
+
data-stacked={secondOpen}
|
|
359
|
+
data-dragging={dragging}
|
|
360
|
+
style={dragging ? { transform: `translateY(${dragY}px)` } : undefined}
|
|
361
|
+
className="absolute inset-x-0 bottom-0 flex max-h-[90%] origin-bottom flex-col rounded-t-xl bg-canvas shadow-card transition duration-[240ms] ease-out data-[dragging=true]:transition-none data-[state=closed]:translate-y-full data-[state=open]:translate-y-0 data-[stacked=true]:scale-[0.96] data-[stacked=true]:opacity-70"
|
|
362
|
+
>
|
|
363
|
+
<div
|
|
364
|
+
onPointerDown={onHandleDown}
|
|
365
|
+
onPointerMove={onHandleMove}
|
|
366
|
+
onPointerUp={onHandleUp}
|
|
367
|
+
onPointerCancel={onHandleUp}
|
|
368
|
+
className="flex shrink-0 touch-none justify-center pb-sm pt-md"
|
|
369
|
+
>
|
|
370
|
+
<span className="h-1 w-10 rounded-full bg-hairline-strong" />
|
|
371
|
+
</div>
|
|
372
|
+
|
|
373
|
+
{/* Header */}
|
|
374
|
+
<div className="flex shrink-0 items-center gap-md px-base pb-md">
|
|
375
|
+
<span
|
|
376
|
+
aria-hidden="true"
|
|
377
|
+
className="flex size-9 shrink-0 items-center justify-center rounded-sm bg-logo-orange text-body-md text-on-primary"
|
|
378
|
+
>
|
|
379
|
+
{initial}
|
|
380
|
+
</span>
|
|
381
|
+
<span className="truncate text-body-md font-weight-body-sm text-ink">{projectName}</span>
|
|
382
|
+
<button
|
|
383
|
+
type="button"
|
|
384
|
+
aria-haspopup="dialog"
|
|
385
|
+
aria-expanded={activeId === "version"}
|
|
386
|
+
onClick={() => openById("version")}
|
|
387
|
+
className={`${pressable} flex items-center gap-xs rounded-sm bg-surface-soft px-sm py-xs text-body-sm text-body hover:bg-surface-strong`}
|
|
388
|
+
>
|
|
389
|
+
{version}
|
|
390
|
+
<Icon name="chevron-down" size={14} />
|
|
391
|
+
</button>
|
|
392
|
+
<span className="flex-1" />
|
|
393
|
+
<button ref={closeRef} type="button" aria-label="Close menu" onClick={closeAll} className={iconButton}>
|
|
394
|
+
<Icon name="close" size={18} />
|
|
395
|
+
</button>
|
|
396
|
+
</div>
|
|
397
|
+
|
|
398
|
+
{/* Scroll body */}
|
|
399
|
+
<div
|
|
400
|
+
onKeyDown={onListKeyDown}
|
|
401
|
+
className="flex min-h-0 flex-1 flex-col gap-md overflow-y-auto px-base pb-lg"
|
|
402
|
+
>
|
|
403
|
+
{/* Credits */}
|
|
404
|
+
<button
|
|
405
|
+
type="button"
|
|
406
|
+
data-row
|
|
407
|
+
aria-haspopup="dialog"
|
|
408
|
+
aria-expanded={activeId === "credits"}
|
|
409
|
+
onClick={() => openById("credits")}
|
|
410
|
+
className={`${pressable} flex w-full flex-col gap-sm rounded-lg border border-hairline bg-canvas p-base text-left hover:bg-surface-soft`}
|
|
411
|
+
>
|
|
412
|
+
<span className="flex items-center justify-between">
|
|
413
|
+
<span className="text-body-md font-weight-body-md text-ink">Credits</span>
|
|
414
|
+
<span className={`flex items-center gap-xs text-body-sm ${outOfCredits ? "text-semantic-error" : "text-muted"}`}>
|
|
415
|
+
{credits.remaining} left
|
|
416
|
+
<Icon name="chevron-right" size={14} />
|
|
417
|
+
</span>
|
|
418
|
+
</span>
|
|
419
|
+
<span
|
|
420
|
+
role="progressbar"
|
|
421
|
+
aria-label="Credits remaining"
|
|
422
|
+
aria-valuemin={0}
|
|
423
|
+
aria-valuemax={credits.total}
|
|
424
|
+
aria-valuenow={credits.remaining}
|
|
425
|
+
className="block h-2 w-full overflow-hidden rounded-full bg-surface-strong"
|
|
426
|
+
>
|
|
427
|
+
<span
|
|
428
|
+
className={`block h-full rounded-full transition-[width] duration-200 ease-out ${outOfCredits ? "bg-semantic-error" : "bg-primary"}`}
|
|
429
|
+
style={{ width: `${outOfCredits ? 100 : pct}%` }}
|
|
430
|
+
/>
|
|
431
|
+
</span>
|
|
432
|
+
<span className={`flex items-center gap-sm text-caption ${outOfCredits ? "text-semantic-error" : "text-muted"}`}>
|
|
433
|
+
<span className={`size-1.5 rounded-full ${outOfCredits ? "bg-semantic-error" : "bg-muted-soft"}`} />
|
|
434
|
+
{outOfCredits ? "Out of credits" : credits.resetLabel}
|
|
435
|
+
</span>
|
|
436
|
+
</button>
|
|
437
|
+
|
|
438
|
+
{/* Quick actions */}
|
|
439
|
+
{quickActions.length > 0 ? (
|
|
440
|
+
<div className="grid grid-cols-2 gap-sm">
|
|
441
|
+
{quickActions.map((item) => (
|
|
442
|
+
<button
|
|
443
|
+
key={item.id}
|
|
444
|
+
type="button"
|
|
445
|
+
data-row
|
|
446
|
+
disabled={item.disabled}
|
|
447
|
+
aria-haspopup="dialog"
|
|
448
|
+
aria-expanded={activeId === item.id}
|
|
449
|
+
onClick={() => handleSelect(item)}
|
|
450
|
+
className={`${pressable} flex flex-col items-center justify-center gap-xs rounded-lg px-md py-base text-body-sm font-weight-body-md ${
|
|
451
|
+
item.primary
|
|
452
|
+
? "bg-primary text-on-primary hover:bg-primary-hover active:bg-primary-active"
|
|
453
|
+
: "bg-surface-soft text-ink hover:bg-surface-strong"
|
|
454
|
+
}`}
|
|
455
|
+
>
|
|
456
|
+
<Icon name={item.icon} size={22} />
|
|
457
|
+
{item.label}
|
|
458
|
+
</button>
|
|
459
|
+
))}
|
|
460
|
+
</div>
|
|
461
|
+
) : null}
|
|
462
|
+
|
|
463
|
+
{/* Upgrade banner */}
|
|
464
|
+
{upgrade ? (
|
|
465
|
+
<button
|
|
466
|
+
type="button"
|
|
467
|
+
data-row
|
|
468
|
+
aria-haspopup="dialog"
|
|
469
|
+
aria-expanded={activeId === "upgrade"}
|
|
470
|
+
onClick={() => openById("upgrade")}
|
|
471
|
+
className={`${pressable} group flex w-full items-center gap-md rounded-lg bg-primary-soft px-base py-md text-left hover:bg-surface-strong`}
|
|
472
|
+
>
|
|
473
|
+
<Icon name="sparkle" size={20} className="shrink-0 text-primary" />
|
|
474
|
+
<span className="flex min-w-0 flex-1 flex-col">
|
|
475
|
+
<span className="text-body-md font-weight-body-md text-primary">{upgrade.title}</span>
|
|
476
|
+
{upgrade.subtitle ? <span className="text-caption text-muted">{upgrade.subtitle}</span> : null}
|
|
477
|
+
</span>
|
|
478
|
+
<Icon
|
|
479
|
+
name="chevron-right"
|
|
480
|
+
size={16}
|
|
481
|
+
className="shrink-0 text-primary transition duration-150 ease-out group-hover:translate-x-0.5"
|
|
482
|
+
/>
|
|
483
|
+
</button>
|
|
484
|
+
) : null}
|
|
485
|
+
|
|
486
|
+
{/* Grouped list rows */}
|
|
487
|
+
{sections.map((section) => (
|
|
488
|
+
<section key={section.id} aria-label={section.label} className="flex flex-col gap-sm">
|
|
489
|
+
{section.label ? (
|
|
490
|
+
<h3 className="px-xs pt-xs text-caption font-weight-caption uppercase text-muted">
|
|
491
|
+
{section.label}
|
|
492
|
+
</h3>
|
|
493
|
+
) : null}
|
|
494
|
+
<div className="flex flex-col divide-y divide-hairline-soft overflow-hidden rounded-lg border border-hairline">
|
|
495
|
+
{section.items.map(renderRow)}
|
|
496
|
+
</div>
|
|
497
|
+
</section>
|
|
498
|
+
))}
|
|
499
|
+
</div>
|
|
500
|
+
</div>
|
|
501
|
+
|
|
502
|
+
{/* Second-level drawer (stacked) */}
|
|
503
|
+
<div
|
|
504
|
+
ref={panelRef}
|
|
505
|
+
role="dialog"
|
|
506
|
+
aria-modal="true"
|
|
507
|
+
aria-label={panelTitle || "Details"}
|
|
508
|
+
aria-hidden={!secondOpen}
|
|
509
|
+
inert={!secondOpen}
|
|
510
|
+
data-state={secondOpen ? "open" : "closed"}
|
|
511
|
+
className="absolute inset-x-0 bottom-0 flex h-[92%] flex-col overflow-hidden rounded-t-xl bg-canvas shadow-card transition duration-[240ms] ease-out data-[state=closed]:translate-y-full data-[state=open]:translate-y-0"
|
|
512
|
+
>
|
|
513
|
+
<div className="flex shrink-0 justify-center pb-sm pt-md">
|
|
514
|
+
<span className="h-1 w-10 rounded-full bg-hairline-strong" />
|
|
515
|
+
</div>
|
|
516
|
+
<div className="flex shrink-0 items-center gap-md border-b border-hairline-soft px-base pb-md">
|
|
517
|
+
<button ref={backRef} type="button" aria-label="Back" onClick={() => setActive(null)} className={iconButton}>
|
|
518
|
+
<Icon name="arrow-left" size={18} />
|
|
519
|
+
</button>
|
|
520
|
+
<h2 className="flex-1 truncate text-heading-sm font-weight-body-md text-ink">{panelTitle}</h2>
|
|
521
|
+
<button type="button" aria-label="Close menu" onClick={closeAll} className={iconButton}>
|
|
522
|
+
<Icon name="close" size={18} />
|
|
523
|
+
</button>
|
|
524
|
+
</div>
|
|
525
|
+
<div className="min-h-0 flex-1 overflow-y-auto bg-surface p-base">
|
|
526
|
+
{shownId && renderPanel ? (
|
|
527
|
+
renderPanel(shownId, panelTitle)
|
|
528
|
+
) : (
|
|
529
|
+
<div className="flex flex-col gap-md">
|
|
530
|
+
<p className="py-xxl text-center text-body-md text-muted">Content provided by agent</p>
|
|
531
|
+
{[0, 1, 2].map((n) => (
|
|
532
|
+
<div key={n} className="flex items-center gap-md rounded-md bg-surface-soft p-base">
|
|
533
|
+
<span className="size-10 shrink-0 rounded-full bg-surface-strong" />
|
|
534
|
+
<span className="flex flex-1 flex-col gap-sm">
|
|
535
|
+
<span className="h-2.5 w-3/4 rounded-full bg-surface-strong" />
|
|
536
|
+
<span className="h-2.5 w-2/5 rounded-full bg-surface-strong" />
|
|
537
|
+
</span>
|
|
538
|
+
</div>
|
|
539
|
+
))}
|
|
540
|
+
</div>
|
|
541
|
+
)}
|
|
542
|
+
</div>
|
|
543
|
+
</div>
|
|
544
|
+
</div>
|
|
545
|
+
);
|
|
546
|
+
},
|
|
547
|
+
);
|
|
548
|
+
MobileActionsDrawer.displayName = "MobileActionsDrawer";
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Icon } from "../Icon";
|
|
3
|
+
import { MobileActionsDrawer, type DrawerSection } from "./MobileActionsDrawer";
|
|
4
|
+
|
|
5
|
+
const INITIAL_SECTIONS: DrawerSection[] = [
|
|
6
|
+
{
|
|
7
|
+
id: "project",
|
|
8
|
+
label: "Project",
|
|
9
|
+
items: [
|
|
10
|
+
{ id: "versions", label: "Versions", icon: "clock", meta: "v12", type: "drawer" },
|
|
11
|
+
{ id: "project-settings", label: "Project settings", icon: "settings-gear", type: "drawer" },
|
|
12
|
+
{ id: "files", label: "Files", icon: "file-document", type: "drawer" },
|
|
13
|
+
{ id: "drafts", label: "Drafts", icon: "square-pen", type: "drawer" },
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: "chats",
|
|
18
|
+
label: "Chats",
|
|
19
|
+
items: [
|
|
20
|
+
{ id: "all-chats", label: "All chats", icon: "chat-bubble", badge: "24", type: "drawer" },
|
|
21
|
+
{ id: "new-chat", label: "New chat", icon: "plus-add", type: "drawer" },
|
|
22
|
+
{ id: "search-chats", label: "Search chats", icon: "search-magnifier", type: "drawer" },
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: "preferences",
|
|
27
|
+
label: "Preferences",
|
|
28
|
+
items: [
|
|
29
|
+
{ id: "dark-mode", label: "Dark mode", icon: "moon-dark-mode", type: "toggle", checked: false },
|
|
30
|
+
{ id: "language", label: "Language", icon: "globe", meta: "English", type: "drawer" },
|
|
31
|
+
{ id: "notifications", label: "Notifications", icon: "bell", type: "drawer" },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: "account",
|
|
36
|
+
items: [
|
|
37
|
+
{ id: "help", label: "Help & feedback", icon: "help-question-circle", type: "drawer" },
|
|
38
|
+
{ id: "sign-out", label: "Sign out", icon: "logout-sign-out", type: "action", destructive: true },
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
const CHATS = ["Calculator layout ideas", "Add calculation history", "Export to spreadsheet"];
|
|
44
|
+
|
|
45
|
+
export default function Preview() {
|
|
46
|
+
const [open, setOpen] = React.useState(false);
|
|
47
|
+
const [sections, setSections] = React.useState(INITIAL_SECTIONS);
|
|
48
|
+
const [lastAction, setLastAction] = React.useState<string>("Nothing selected yet");
|
|
49
|
+
|
|
50
|
+
const toggle = (id: string, checked: boolean) =>
|
|
51
|
+
setSections((prev) =>
|
|
52
|
+
prev.map((s) => ({
|
|
53
|
+
...s,
|
|
54
|
+
items: s.items.map((i) => (i.id === id ? { ...i, checked } : i)),
|
|
55
|
+
})),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div className="mx-auto w-full max-w-3xl space-y-base p-lg">
|
|
60
|
+
<p className="text-body-sm text-muted">
|
|
61
|
+
Tap the menu button to open the drawer. Rows with a chevron open a second, stacked drawer.
|
|
62
|
+
Dark mode toggles inline. Last action: <span className="text-ink">{lastAction}</span>
|
|
63
|
+
</p>
|
|
64
|
+
|
|
65
|
+
<div className="relative mx-auto h-[720px] w-full max-w-lg overflow-hidden rounded-xl border border-hairline bg-surface shadow-card">
|
|
66
|
+
{/* Mock app behind the drawer */}
|
|
67
|
+
<div className="flex h-full flex-col">
|
|
68
|
+
<header className="flex items-center gap-md border-b border-hairline bg-canvas px-base py-md">
|
|
69
|
+
<button
|
|
70
|
+
type="button"
|
|
71
|
+
aria-label="Open project menu"
|
|
72
|
+
aria-haspopup="dialog"
|
|
73
|
+
aria-expanded={open}
|
|
74
|
+
onClick={() => setOpen(true)}
|
|
75
|
+
className="flex size-9 cursor-pointer items-center justify-center rounded-sm bg-surface-soft text-ink transition duration-150 ease-out hover:bg-surface-strong active:scale-[0.98] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue"
|
|
76
|
+
>
|
|
77
|
+
<Icon name="hamburger-menu" size={18} />
|
|
78
|
+
</button>
|
|
79
|
+
<span className="flex-1 text-body-md text-ink">NovaCalc</span>
|
|
80
|
+
<span className="rounded-sm bg-surface-soft px-sm py-xs text-body-sm text-muted">Preview</span>
|
|
81
|
+
</header>
|
|
82
|
+
<div className="flex flex-1 flex-col gap-md p-base">
|
|
83
|
+
<div className="self-end rounded-lg bg-surface-soft px-base py-md text-body-sm text-ink">
|
|
84
|
+
build me a calculator
|
|
85
|
+
</div>
|
|
86
|
+
<p className="text-body-sm text-body">
|
|
87
|
+
I'll build a modern calculator app with a clean design and smooth interactions.
|
|
88
|
+
</p>
|
|
89
|
+
<ul className="flex flex-col gap-sm">
|
|
90
|
+
{CHATS.map((c) => (
|
|
91
|
+
<li key={c} className="rounded-md bg-canvas px-base py-md text-body-sm text-muted shadow-sm">
|
|
92
|
+
{c}
|
|
93
|
+
</li>
|
|
94
|
+
))}
|
|
95
|
+
</ul>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<MobileActionsDrawer
|
|
100
|
+
open={open}
|
|
101
|
+
onOpenChange={setOpen}
|
|
102
|
+
sections={sections}
|
|
103
|
+
onToggle={toggle}
|
|
104
|
+
onSelect={(id) => setLastAction(id)}
|
|
105
|
+
/>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
}
|