@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,100 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Toast } from "./Toast";
|
|
3
|
+
|
|
4
|
+
type Item = {
|
|
5
|
+
id: string;
|
|
6
|
+
variant: "neutral" | "success" | "error" | "info";
|
|
7
|
+
title: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
actionLabel?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const ITEMS: Item[] = [
|
|
13
|
+
{ id: "neutral", variant: "neutral", title: "Changes saved to your draft.", actionLabel: "Undo" },
|
|
14
|
+
{ id: "success", variant: "success", title: "Project published successfully." },
|
|
15
|
+
{
|
|
16
|
+
id: "error",
|
|
17
|
+
variant: "error",
|
|
18
|
+
title: "Failed to publish project.",
|
|
19
|
+
description: "Check your connection and try again.",
|
|
20
|
+
actionLabel: "Retry",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "info",
|
|
24
|
+
variant: "info",
|
|
25
|
+
title: "New templates are available.",
|
|
26
|
+
description: "Explore the latest additions in the template library.",
|
|
27
|
+
actionLabel: "View",
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const triggerClass =
|
|
32
|
+
"cursor-pointer rounded-sm border border-hairline bg-canvas px-md py-sm text-body-sm text-ink transition duration-150 ease-out hover:bg-surface-soft active:scale-[0.98] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue";
|
|
33
|
+
|
|
34
|
+
export default function ToastPreview() {
|
|
35
|
+
const [open, setOpen] = React.useState<Record<string, boolean>>({
|
|
36
|
+
neutral: true,
|
|
37
|
+
success: true,
|
|
38
|
+
error: true,
|
|
39
|
+
info: true,
|
|
40
|
+
});
|
|
41
|
+
const [liveOpen, setLiveOpen] = React.useState(false);
|
|
42
|
+
|
|
43
|
+
const setItem = (id: string, value: boolean) =>
|
|
44
|
+
setOpen((prev) => ({ ...prev, [id]: value }));
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div className="w-full max-w-3xl mx-auto p-lg space-y-lg">
|
|
48
|
+
<section className="space-y-md">
|
|
49
|
+
<p className="text-caption uppercase tracking-wide text-muted">
|
|
50
|
+
Variants (dismiss or press Escape while focused)
|
|
51
|
+
</p>
|
|
52
|
+
<div className="flex flex-col">
|
|
53
|
+
{ITEMS.map((item) => (
|
|
54
|
+
<div key={item.id} className={open[item.id] ? "pb-sm" : "pb-0"}>
|
|
55
|
+
<Toast
|
|
56
|
+
variant={item.variant}
|
|
57
|
+
title={item.title}
|
|
58
|
+
description={item.description}
|
|
59
|
+
actionLabel={item.actionLabel}
|
|
60
|
+
open={open[item.id]}
|
|
61
|
+
onOpenChange={(v) => setItem(item.id, v)}
|
|
62
|
+
duration={0}
|
|
63
|
+
/>
|
|
64
|
+
</div>
|
|
65
|
+
))}
|
|
66
|
+
</div>
|
|
67
|
+
<div className="flex flex-wrap gap-sm">
|
|
68
|
+
<button
|
|
69
|
+
type="button"
|
|
70
|
+
className={triggerClass}
|
|
71
|
+
onClick={() =>
|
|
72
|
+
setOpen({ neutral: true, success: true, error: true, info: true })
|
|
73
|
+
}
|
|
74
|
+
>
|
|
75
|
+
Restore all
|
|
76
|
+
</button>
|
|
77
|
+
</div>
|
|
78
|
+
</section>
|
|
79
|
+
|
|
80
|
+
<section className="space-y-md">
|
|
81
|
+
<p className="text-caption uppercase tracking-wide text-muted">
|
|
82
|
+
Auto-dismiss in 4s (hover or focus pauses the timer)
|
|
83
|
+
</p>
|
|
84
|
+
<button
|
|
85
|
+
type="button"
|
|
86
|
+
className={triggerClass}
|
|
87
|
+
onClick={() => setLiveOpen(true)}
|
|
88
|
+
>
|
|
89
|
+
Show toast
|
|
90
|
+
</button>
|
|
91
|
+
<Toast
|
|
92
|
+
variant="success"
|
|
93
|
+
title="Link copied to clipboard."
|
|
94
|
+
open={liveOpen}
|
|
95
|
+
onOpenChange={setLiveOpen}
|
|
96
|
+
/>
|
|
97
|
+
</section>
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Button } from "../Button";
|
|
3
3
|
import { Icon } from "../Icon";
|
|
4
|
+
import { Chip } from "../Chip";
|
|
4
5
|
import { WorkspaceMenu } from "../WorkspaceMenu";
|
|
6
|
+
import { Menu, type MenuItem } from "../Menu";
|
|
5
7
|
|
|
6
8
|
// ---------------------------------------------------------------------------
|
|
7
9
|
// Version entry type — plain string OR rich object with optional metadata
|
|
@@ -84,7 +86,7 @@ const VersionDropdown: React.FC<VersionDropdownProps> = ({
|
|
|
84
86
|
}, [open]);
|
|
85
87
|
|
|
86
88
|
return (
|
|
87
|
-
<div ref={containerRef} className="relative inline-block" style={{ zIndex:
|
|
89
|
+
<div ref={containerRef} className="relative inline-block" style={{ zIndex: open ? "var(--z-dropdown, 1000)" : undefined }}>
|
|
88
90
|
{/* Trigger — matches WorkspaceMenu trigger shape */}
|
|
89
91
|
<Button
|
|
90
92
|
type="button"
|
|
@@ -108,45 +110,47 @@ const VersionDropdown: React.FC<VersionDropdownProps> = ({
|
|
|
108
110
|
</Button>
|
|
109
111
|
|
|
110
112
|
{/* Dropdown panel — matches WorkspaceMenu panel styling */}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
]
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
113
|
+
<ul
|
|
114
|
+
role="listbox"
|
|
115
|
+
aria-label="Select version"
|
|
116
|
+
data-state={open ? "open" : "closed"}
|
|
117
|
+
className={[
|
|
118
|
+
"absolute right-0 mt-xs rounded-xl origin-top",
|
|
119
|
+
"bg-surface border border-hairline-soft shadow-card",
|
|
120
|
+
"py-xs overflow-y-auto overflow-x-hidden",
|
|
121
|
+
"transition duration-200 ease-out",
|
|
122
|
+
"data-[state=open]:translate-y-0 data-[state=open]:scale-100 data-[state=open]:opacity-100",
|
|
123
|
+
"data-[state=closed]:pointer-events-none data-[state=closed]:-translate-y-1 data-[state=closed]:scale-95 data-[state=closed]:opacity-0",
|
|
124
|
+
].join(" ")}
|
|
125
|
+
style={{ minWidth: "220px", maxHeight: "350px" }}
|
|
126
|
+
>
|
|
127
|
+
{versions.map((item) => {
|
|
128
|
+
const label = getVersionLabel(item);
|
|
129
|
+
const entry = typeof item === "object" ? item : null;
|
|
130
|
+
const hasMetadata = entry && (entry.publishedAt || entry.publishedBy);
|
|
127
131
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
let metaLine: string | null = null;
|
|
133
|
+
if (hasMetadata) {
|
|
134
|
+
const parts: string[] = [];
|
|
135
|
+
if (entry.publishedAt) parts.push(relativeTime(entry.publishedAt));
|
|
136
|
+
if (entry.publishedBy) parts.push(entry.publishedBy);
|
|
137
|
+
metaLine = parts.join(" · ");
|
|
138
|
+
}
|
|
135
139
|
|
|
136
|
-
|
|
140
|
+
const isSelected = label === selected;
|
|
137
141
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
142
|
+
return (
|
|
143
|
+
<li key={label}>
|
|
144
|
+
<button
|
|
145
|
+
type="button"
|
|
141
146
|
role="option"
|
|
142
147
|
aria-selected={isSelected}
|
|
143
|
-
tabIndex={0}
|
|
144
148
|
onClick={() => { onSelect(label); setOpen(false); }}
|
|
145
149
|
onKeyDown={(e) => {
|
|
146
150
|
if (e.key === "Enter" || e.key === " ") { onSelect(label); setOpen(false); }
|
|
147
151
|
}}
|
|
148
152
|
className={[
|
|
149
|
-
"flex flex-col px-md cursor-pointer select-none",
|
|
153
|
+
"w-full flex flex-col items-start px-md cursor-pointer select-none",
|
|
150
154
|
"transition-colors duration-100",
|
|
151
155
|
metaLine ? "py-sm" : "py-xs",
|
|
152
156
|
isSelected
|
|
@@ -160,11 +164,11 @@ const VersionDropdown: React.FC<VersionDropdownProps> = ({
|
|
|
160
164
|
{metaLine && (
|
|
161
165
|
<span className="text-caption text-muted mt-xxs">{metaLine}</span>
|
|
162
166
|
)}
|
|
163
|
-
</
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
167
|
+
</button>
|
|
168
|
+
</li>
|
|
169
|
+
);
|
|
170
|
+
})}
|
|
171
|
+
</ul>
|
|
168
172
|
</div>
|
|
169
173
|
);
|
|
170
174
|
};
|
|
@@ -174,7 +178,10 @@ const VersionDropdown: React.FC<VersionDropdownProps> = ({
|
|
|
174
178
|
// ---------------------------------------------------------------------------
|
|
175
179
|
|
|
176
180
|
export interface TopNavbarProps extends React.HTMLAttributes<HTMLElement> {
|
|
177
|
-
/**
|
|
181
|
+
/**
|
|
182
|
+
* Initials for the user identity bubble. Kept for backwards compatibility
|
|
183
|
+
* with existing consumers — the avatar is no longer rendered in the navbar.
|
|
184
|
+
*/
|
|
178
185
|
avatarInitials?: string;
|
|
179
186
|
/** Current version label shown in the version pill */
|
|
180
187
|
version?: string;
|
|
@@ -184,12 +191,19 @@ export interface TopNavbarProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
184
191
|
* VersionEntry object with optional `publishedAt` and `publishedBy` metadata.
|
|
185
192
|
*/
|
|
186
193
|
versions?: VersionItem[];
|
|
187
|
-
/** Called when "Export
|
|
194
|
+
/** Called when "Export Design.md" is chosen from the Export menu — item is only rendered when provided */
|
|
188
195
|
onExport?: () => void;
|
|
196
|
+
/** Called when "Download design system codebase" is chosen from the Export menu — item is only rendered when provided */
|
|
197
|
+
onDownloadCodebase?: () => void;
|
|
189
198
|
/** Called when "Publish" is clicked — button is only rendered when provided */
|
|
190
199
|
onPublish?: () => void;
|
|
191
|
-
/** Called when
|
|
200
|
+
/** Called when the Upgrade button is clicked — button is only rendered when provided */
|
|
192
201
|
onShare?: () => void;
|
|
202
|
+
/**
|
|
203
|
+
* Label for the orange crown Upgrade button (also used as its aria-label).
|
|
204
|
+
* Only applies when `onShare` is provided. Defaults to "Upgrade".
|
|
205
|
+
*/
|
|
206
|
+
upgradeLabel?: string;
|
|
193
207
|
/** Called when a version is selected */
|
|
194
208
|
onVersionChange?: (v: string) => void;
|
|
195
209
|
/** Whether dark mode is currently active — controls which icon is shown (sun vs moon) */
|
|
@@ -199,26 +213,75 @@ export interface TopNavbarProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
199
213
|
* When omitted, the toggle button is not rendered.
|
|
200
214
|
*/
|
|
201
215
|
onToggleDarkMode?: () => void;
|
|
216
|
+
/**
|
|
217
|
+
* Remaining credits balance shown as a badge immediately to the left of the
|
|
218
|
+
* Export trigger. The badge renders when this is a finite number OR when
|
|
219
|
+
* `creditsLabel` is a non-empty string. Formatted with locale separators,
|
|
220
|
+
* e.g. `9900` → "9,900 credits".
|
|
221
|
+
*/
|
|
222
|
+
credits?: number;
|
|
223
|
+
/** Overrides the auto-formatted credits text, e.g. "Unlimited credits" */
|
|
224
|
+
creditsLabel?: string;
|
|
225
|
+
/**
|
|
226
|
+
* Called when the credits badge is clicked. When provided, the badge
|
|
227
|
+
* renders as an interactive button; otherwise it renders as a
|
|
228
|
+
* non-interactive Chip.
|
|
229
|
+
*/
|
|
230
|
+
onCreditsClick?: () => void;
|
|
202
231
|
}
|
|
203
232
|
|
|
204
233
|
export const TopNavbar = React.forwardRef<HTMLElement, TopNavbarProps>(
|
|
205
234
|
(
|
|
206
235
|
{
|
|
236
|
+
// Retained for backwards compatibility — the avatar bubble is no longer rendered.
|
|
207
237
|
avatarInitials = "DU",
|
|
208
238
|
version = "Latest",
|
|
209
239
|
versions = ["Latest", "v1.2", "v1.1", "v1.0"],
|
|
210
240
|
onExport,
|
|
241
|
+
onDownloadCodebase,
|
|
211
242
|
onPublish,
|
|
212
243
|
onShare,
|
|
244
|
+
upgradeLabel = "Upgrade",
|
|
213
245
|
onVersionChange,
|
|
214
246
|
darkMode = false,
|
|
215
247
|
onToggleDarkMode,
|
|
248
|
+
credits,
|
|
249
|
+
creditsLabel,
|
|
250
|
+
onCreditsClick,
|
|
216
251
|
className,
|
|
217
252
|
...rest
|
|
218
253
|
},
|
|
219
254
|
ref,
|
|
220
255
|
) => {
|
|
221
256
|
const [selected, setSelected] = React.useState(version);
|
|
257
|
+
void avatarInitials;
|
|
258
|
+
|
|
259
|
+
const exportItems: MenuItem[] = [];
|
|
260
|
+
if (onExport) {
|
|
261
|
+
exportItems.push({
|
|
262
|
+
id: "export-design-md",
|
|
263
|
+
label: "Export Design.md",
|
|
264
|
+
icon: "file-document",
|
|
265
|
+
onSelect: onExport,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
if (onDownloadCodebase) {
|
|
269
|
+
exportItems.push({
|
|
270
|
+
id: "download-codebase",
|
|
271
|
+
label: "Download design system codebase",
|
|
272
|
+
icon: "download",
|
|
273
|
+
onSelect: onDownloadCodebase,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Credits badge — rendered when `credits` is a finite number OR
|
|
278
|
+
// `creditsLabel` is a non-empty string.
|
|
279
|
+
const hasCreditsLabel = typeof creditsLabel === "string" && creditsLabel.trim().length > 0;
|
|
280
|
+
const hasCreditsNumber = typeof credits === "number" && Number.isFinite(credits);
|
|
281
|
+
const showCredits = hasCreditsLabel || hasCreditsNumber;
|
|
282
|
+
const creditsText = hasCreditsLabel
|
|
283
|
+
? (creditsLabel as string)
|
|
284
|
+
: `${Math.trunc(credits as number).toLocaleString()} credits`;
|
|
222
285
|
|
|
223
286
|
return (
|
|
224
287
|
<header
|
|
@@ -232,12 +295,33 @@ export const TopNavbar = React.forwardRef<HTMLElement, TopNavbarProps>(
|
|
|
232
295
|
.join(" ")}
|
|
233
296
|
{...rest}
|
|
234
297
|
>
|
|
235
|
-
{/*
|
|
236
|
-
{
|
|
237
|
-
|
|
238
|
-
<
|
|
239
|
-
|
|
240
|
-
|
|
298
|
+
{/* Credits badge — placed immediately to the left of the Export trigger */}
|
|
299
|
+
{showCredits && (
|
|
300
|
+
onCreditsClick ? (
|
|
301
|
+
<Button
|
|
302
|
+
type="button"
|
|
303
|
+
variant="ghost"
|
|
304
|
+
size="sm"
|
|
305
|
+
onClick={onCreditsClick}
|
|
306
|
+
aria-label={creditsText}
|
|
307
|
+
className="!px-sm"
|
|
308
|
+
>
|
|
309
|
+
{creditsText}
|
|
310
|
+
</Button>
|
|
311
|
+
) : (
|
|
312
|
+
<Chip label={creditsText} size="sm" variant="default" />
|
|
313
|
+
)
|
|
314
|
+
)}
|
|
315
|
+
|
|
316
|
+
{/* Export — only rendered when onExport or onDownloadCodebase is provided */}
|
|
317
|
+
{exportItems.length > 0 && (
|
|
318
|
+
<Menu
|
|
319
|
+
items={exportItems}
|
|
320
|
+
triggerLabel="Export"
|
|
321
|
+
align="right"
|
|
322
|
+
portal
|
|
323
|
+
aria-label="Export"
|
|
324
|
+
/>
|
|
241
325
|
)}
|
|
242
326
|
|
|
243
327
|
{/* Publish — only rendered when onPublish is provided */}
|
|
@@ -273,32 +357,26 @@ export const TopNavbar = React.forwardRef<HTMLElement, TopNavbarProps>(
|
|
|
273
357
|
</Button>
|
|
274
358
|
)}
|
|
275
359
|
|
|
276
|
-
{/* Upgrade — only rendered when onShare is provided
|
|
360
|
+
{/* Upgrade — only rendered when onShare is provided. Uses the brand
|
|
361
|
+
logo-orange token as its own recipe, independent of the Button
|
|
362
|
+
atom's primary variant (which stays untouched for other buttons).
|
|
363
|
+
Displays a crown icon before the configurable label. */}
|
|
277
364
|
{onShare && (
|
|
278
|
-
<Button
|
|
279
|
-
|
|
365
|
+
<Button
|
|
366
|
+
variant="primary"
|
|
367
|
+
size="sm"
|
|
368
|
+
onClick={onShare}
|
|
369
|
+
aria-label={upgradeLabel}
|
|
370
|
+
className={[
|
|
371
|
+
"!bg-[var(--color-logo-orange)] !text-on-primary !border-transparent",
|
|
372
|
+
"hover:!bg-[color-mix(in_srgb,var(--color-logo-orange)_85%,black)]",
|
|
373
|
+
"active:!bg-[color-mix(in_srgb,var(--color-logo-orange)_75%,black)]",
|
|
374
|
+
].join(" ")}
|
|
375
|
+
>
|
|
376
|
+
<Icon name="crown-lucide-outline-premium-badge" className="size-4 shrink-0 text-on-primary" />
|
|
377
|
+
{upgradeLabel}
|
|
280
378
|
</Button>
|
|
281
379
|
)}
|
|
282
|
-
|
|
283
|
-
{/* User avatar — circular identity trigger */}
|
|
284
|
-
<span
|
|
285
|
-
role="button"
|
|
286
|
-
tabIndex={0}
|
|
287
|
-
aria-label={`User menu — ${avatarInitials}`}
|
|
288
|
-
onKeyDown={(e) => {
|
|
289
|
-
if (e.key === "Enter" || e.key === " ") e.currentTarget.click();
|
|
290
|
-
}}
|
|
291
|
-
className={[
|
|
292
|
-
"inline-flex items-center justify-center shrink-0 cursor-pointer select-none",
|
|
293
|
-
"size-8 rounded-full bg-primary text-on-primary",
|
|
294
|
-
"text-caption font-weight-heading-sm uppercase",
|
|
295
|
-
"hover:bg-primary-hover active:bg-primary-active",
|
|
296
|
-
"transition-colors duration-150",
|
|
297
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-focus focus-visible:ring-offset-2",
|
|
298
|
-
].join(" ")}
|
|
299
|
-
>
|
|
300
|
-
{avatarInitials.slice(0, 2)}
|
|
301
|
-
</span>
|
|
302
380
|
</header>
|
|
303
381
|
);
|
|
304
382
|
},
|
|
@@ -23,20 +23,22 @@ const plainVersions = ["Latest", "v1.2", "v1.1", "v1.0"];
|
|
|
23
23
|
export default function TopNavbarPreview() {
|
|
24
24
|
const [published, setPublished] = React.useState(false);
|
|
25
25
|
const [darkMode, setDarkMode] = React.useState(false);
|
|
26
|
+
const [lastAction, setLastAction] = React.useState<string | null>(null);
|
|
26
27
|
|
|
27
28
|
return (
|
|
28
29
|
<div className="w-full max-w-5xl mx-auto bg-surface-soft flex flex-col gap-xxl py-lg">
|
|
29
30
|
|
|
30
|
-
{/* 1. All actions + dark mode toggle (interactive) */}
|
|
31
|
+
{/* 1. All actions + Export menu + dark mode toggle (interactive) */}
|
|
31
32
|
<section className="flex flex-col gap-sm">
|
|
32
33
|
<p className="px-lg text-caption text-muted uppercase">
|
|
33
|
-
All actions ·
|
|
34
|
+
All actions · Export menu (open it) · Publish · dark mode toggle
|
|
34
35
|
</p>
|
|
35
36
|
<TopNavbar
|
|
36
37
|
avatarInitials="DU"
|
|
37
38
|
version="Latest"
|
|
38
39
|
versions={manyVersions}
|
|
39
|
-
onExport={() =>
|
|
40
|
+
onExport={() => setLastAction("Exported Design.md")}
|
|
41
|
+
onDownloadCodebase={() => setLastAction("Downloaded design system codebase")}
|
|
40
42
|
onPublish={() => setPublished((p) => !p)}
|
|
41
43
|
onShare={() => undefined}
|
|
42
44
|
darkMode={darkMode}
|
|
@@ -45,20 +47,24 @@ export default function TopNavbarPreview() {
|
|
|
45
47
|
{published && (
|
|
46
48
|
<p className="px-lg text-body-sm text-semantic-success">Published!</p>
|
|
47
49
|
)}
|
|
50
|
+
{lastAction && (
|
|
51
|
+
<p className="px-lg text-body-sm text-semantic-success">{lastAction}</p>
|
|
52
|
+
)}
|
|
48
53
|
<p className="px-lg text-caption text-muted">
|
|
49
54
|
Current mode: <span className="text-ink font-weight-heading-sm">{darkMode ? "Dark" : "Light"}</span>
|
|
50
55
|
</p>
|
|
51
56
|
</section>
|
|
52
57
|
|
|
53
|
-
{/* 2.
|
|
58
|
+
{/* 2. Export menu with only the Export Design.md item (onDownloadCodebase omitted) */}
|
|
54
59
|
<section className="flex flex-col gap-sm">
|
|
55
60
|
<p className="px-lg text-caption text-muted uppercase">
|
|
56
|
-
|
|
61
|
+
Export menu — only "Export Design.md" (onDownloadCodebase omitted)
|
|
57
62
|
</p>
|
|
58
63
|
<TopNavbar
|
|
59
64
|
avatarInitials="DM"
|
|
60
65
|
version="v2.0"
|
|
61
66
|
versions={manyVersions}
|
|
67
|
+
onExport={() => setLastAction("Exported Design.md")}
|
|
62
68
|
onShare={() => undefined}
|
|
63
69
|
darkMode={true}
|
|
64
70
|
onToggleDarkMode={() => undefined}
|
|
@@ -80,10 +86,10 @@ export default function TopNavbarPreview() {
|
|
|
80
86
|
/>
|
|
81
87
|
</section>
|
|
82
88
|
|
|
83
|
-
{/* 4. No
|
|
89
|
+
{/* 4. No Export menu, no toggle — both omitted */}
|
|
84
90
|
<section className="flex flex-col gap-sm">
|
|
85
91
|
<p className="px-lg text-caption text-muted uppercase">
|
|
86
|
-
No dark mode toggle —
|
|
92
|
+
No Export menu, no dark mode toggle — callbacks omitted
|
|
87
93
|
</p>
|
|
88
94
|
<TopNavbar
|
|
89
95
|
avatarInitials="RO"
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Modal } from "../Modal";
|
|
3
|
+
import { PricingCard } from "../PricingCard";
|
|
4
|
+
import { Typography } from "../Typography";
|
|
5
|
+
import { Button } from "../Button";
|
|
6
|
+
|
|
7
|
+
export interface TopupModalOffer {
|
|
8
|
+
/** Number of credits granted by this one-time purchase. */
|
|
9
|
+
credits: number;
|
|
10
|
+
/** Price to display, e.g. "$10". */
|
|
11
|
+
price: string;
|
|
12
|
+
/** Overrides the default CTA label. */
|
|
13
|
+
ctaLabel?: string;
|
|
14
|
+
/** Overrides the default description under the credits headline. */
|
|
15
|
+
description?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface TopupModalProps {
|
|
19
|
+
/** Controls whether the modal is visible */
|
|
20
|
+
isOpen: boolean;
|
|
21
|
+
/** Called when the user clicks the backdrop or the close button */
|
|
22
|
+
onClose: () => void;
|
|
23
|
+
/** Modal heading */
|
|
24
|
+
title?: string;
|
|
25
|
+
/** Subtitle shown above the offer card */
|
|
26
|
+
subtitle?: string;
|
|
27
|
+
/** The credit offer to display — defaults to a 1,000-credit / $10 top-up */
|
|
28
|
+
offer?: TopupModalOffer;
|
|
29
|
+
/** Called when the user clicks the primary "Buy" CTA */
|
|
30
|
+
onBuy?: () => void;
|
|
31
|
+
/** Called when the user clicks the secondary "pick a larger plan" link. Omit to hide it. */
|
|
32
|
+
onUpgradePlan?: () => void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const DEFAULT_OFFER: TopupModalOffer = {
|
|
36
|
+
credits: 1000,
|
|
37
|
+
price: "$10",
|
|
38
|
+
ctaLabel: "Buy 1,000 credits",
|
|
39
|
+
description: "Add credits to your current balance without changing your plan.",
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const TopupModal = React.forwardRef<HTMLDivElement, TopupModalProps>(
|
|
43
|
+
(
|
|
44
|
+
{
|
|
45
|
+
isOpen,
|
|
46
|
+
onClose,
|
|
47
|
+
title = "You are out of credits",
|
|
48
|
+
subtitle = "Buy a one-time top-up to keep working, or pick a larger monthly plan.",
|
|
49
|
+
offer = DEFAULT_OFFER,
|
|
50
|
+
onBuy,
|
|
51
|
+
onUpgradePlan,
|
|
52
|
+
},
|
|
53
|
+
ref,
|
|
54
|
+
) => {
|
|
55
|
+
const creditsLabel = offer.credits.toLocaleString();
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<Modal ref={ref} isOpen={isOpen} onClose={onClose} title={title} size="sm">
|
|
59
|
+
<div className="flex w-full flex-col items-center gap-lg rounded-lg">
|
|
60
|
+
<Typography role="body-md" color="muted" className="text-center">
|
|
61
|
+
{subtitle}
|
|
62
|
+
</Typography>
|
|
63
|
+
|
|
64
|
+
<div className="w-full">
|
|
65
|
+
<PricingCard
|
|
66
|
+
planName={`${creditsLabel} credits`}
|
|
67
|
+
description={offer.description ?? "One-time credit top-up for subscribers."}
|
|
68
|
+
price={offer.price}
|
|
69
|
+
priceNote="One-time payment"
|
|
70
|
+
features={[
|
|
71
|
+
"Added to your current balance",
|
|
72
|
+
"Does not change your plan",
|
|
73
|
+
"Usable on every paid model",
|
|
74
|
+
]}
|
|
75
|
+
ctaLabel={offer.ctaLabel ?? `Buy ${creditsLabel} credits`}
|
|
76
|
+
ctaCaption="Cancel anytime on your subscription"
|
|
77
|
+
highlighted
|
|
78
|
+
highlightLabel="Top-up"
|
|
79
|
+
onCtaClick={() => onBuy?.()}
|
|
80
|
+
/>
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
{onUpgradePlan ? (
|
|
84
|
+
<Button variant="ghost" size="sm" onClick={onUpgradePlan}>
|
|
85
|
+
Or pick a larger monthly plan
|
|
86
|
+
</Button>
|
|
87
|
+
) : null}
|
|
88
|
+
</div>
|
|
89
|
+
</Modal>
|
|
90
|
+
);
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
TopupModal.displayName = "TopupModal";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { TopupModal } from "./TopupModal";
|
|
3
|
+
import { Button } from "../Button";
|
|
4
|
+
|
|
5
|
+
export default function TopupModalPreview() {
|
|
6
|
+
const [isOpen, setIsOpen] = useState(true);
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<div className="w-full max-w-3xl mx-auto p-lg space-y-lg">
|
|
10
|
+
<Button variant="primary" size="md" onClick={() => setIsOpen(true)}>
|
|
11
|
+
Open top-up modal
|
|
12
|
+
</Button>
|
|
13
|
+
|
|
14
|
+
<TopupModal
|
|
15
|
+
isOpen={isOpen}
|
|
16
|
+
onClose={() => setIsOpen(false)}
|
|
17
|
+
onBuy={() => setIsOpen(false)}
|
|
18
|
+
onUpgradePlan={() => setIsOpen(false)}
|
|
19
|
+
/>
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
}
|