@designa8/vibedesign-v6 1.20.20 → 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/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,451 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
3
|
+
import { Button } from "../Button";
|
|
4
|
+
import { Icon } from "../Icon";
|
|
5
|
+
|
|
6
|
+
export interface MarketingNavLink {
|
|
7
|
+
label: string;
|
|
8
|
+
href: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface MarketingNavAction {
|
|
12
|
+
label: string;
|
|
13
|
+
onClick?: () => void;
|
|
14
|
+
href?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface MarketingNavAccount {
|
|
18
|
+
/** Display name, shown above the email in the account panel. */
|
|
19
|
+
name?: string;
|
|
20
|
+
/** Email shown in the panel and next to the avatar when the bar is wide. */
|
|
21
|
+
email: string;
|
|
22
|
+
/** Optional avatar image. When omitted a gradient mark with initials is used. */
|
|
23
|
+
avatarSrc?: string;
|
|
24
|
+
/** Called from the "Settings" item (desktop panel and mobile panel). */
|
|
25
|
+
onSettings?: () => void;
|
|
26
|
+
/** Called from the "Log out" item (desktop panel and mobile panel). */
|
|
27
|
+
onLogout?: () => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface MarketingNavbarProps
|
|
31
|
+
extends Omit<React.HTMLAttributes<HTMLElement>, "children"> {
|
|
32
|
+
brandName?: string;
|
|
33
|
+
/** Optional logo image. When omitted a gradient atom mark is rendered. */
|
|
34
|
+
logoSrc?: string;
|
|
35
|
+
brandHref?: string;
|
|
36
|
+
links?: MarketingNavLink[];
|
|
37
|
+
/** Secondary auth action (e.g. "Log in"). Hidden when null. */
|
|
38
|
+
secondaryAction?: MarketingNavAction | null;
|
|
39
|
+
/** Primary CTA (e.g. "Start free" or "Open studio"). Hidden when null. */
|
|
40
|
+
primaryAction?: MarketingNavAction | null;
|
|
41
|
+
/**
|
|
42
|
+
* Signed-in account. When provided, an avatar button with an account panel
|
|
43
|
+
* (email, settings, log out) is rendered on the right, and the same identity
|
|
44
|
+
* block appears inside the mobile menu panel. Pass null when logged out.
|
|
45
|
+
*/
|
|
46
|
+
account?: MarketingNavAccount | null;
|
|
47
|
+
/** When false the email only appears inside the account panel. */
|
|
48
|
+
showAccountEmail?: boolean;
|
|
49
|
+
/** Label for the settings menu item. */
|
|
50
|
+
settingsLabel?: string;
|
|
51
|
+
/** Label for the log out menu item. */
|
|
52
|
+
logoutLabel?: string;
|
|
53
|
+
/** Called for link clicks; lets a router intercept navigation. */
|
|
54
|
+
onLinkClick?: (
|
|
55
|
+
link: MarketingNavLink,
|
|
56
|
+
e: React.MouseEvent<HTMLAnchorElement>,
|
|
57
|
+
) => void;
|
|
58
|
+
/** Applies to the "bar" variant only. The "floating" variant is always fixed. */
|
|
59
|
+
sticky?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* "bar" (default) is the full-width bar. "floating" is a detached,
|
|
62
|
+
* frosted-glass surface fixed to the top of the viewport. It is a rounded
|
|
63
|
+
* card on mobile (same radius open or closed) and a pill from md up.
|
|
64
|
+
*/
|
|
65
|
+
variant?: "bar" | "floating";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const DEFAULT_LINKS: MarketingNavLink[] = [
|
|
69
|
+
{ label: "Gallery", href: "#gallery" },
|
|
70
|
+
{ label: "How it works", href: "#how-it-works" },
|
|
71
|
+
{ label: "Pricing", href: "/pricing" },
|
|
72
|
+
{ label: "Docs", href: "#docs" },
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
const DEFAULT_SECONDARY: MarketingNavAction = { label: "Log in" };
|
|
76
|
+
const DEFAULT_PRIMARY: MarketingNavAction = { label: "Start free" };
|
|
77
|
+
|
|
78
|
+
const linkFocus =
|
|
79
|
+
"cursor-pointer transition duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue";
|
|
80
|
+
|
|
81
|
+
const itemClass = `flex w-full items-center gap-sm rounded-sm px-sm py-sm text-left text-body-sm text-ink transition duration-150 ease-out hover:bg-surface-soft active:scale-[0.98] ${linkFocus}`;
|
|
82
|
+
|
|
83
|
+
export const MarketingNavbar = React.forwardRef<HTMLElement, MarketingNavbarProps>(
|
|
84
|
+
(
|
|
85
|
+
{
|
|
86
|
+
brandName = "Atoms Design",
|
|
87
|
+
logoSrc,
|
|
88
|
+
brandHref = "/",
|
|
89
|
+
links = DEFAULT_LINKS,
|
|
90
|
+
secondaryAction = DEFAULT_SECONDARY,
|
|
91
|
+
primaryAction = DEFAULT_PRIMARY,
|
|
92
|
+
account = null,
|
|
93
|
+
showAccountEmail = true,
|
|
94
|
+
settingsLabel = "Settings",
|
|
95
|
+
logoutLabel = "Log out",
|
|
96
|
+
onLinkClick,
|
|
97
|
+
sticky = true,
|
|
98
|
+
variant = "bar",
|
|
99
|
+
className = "",
|
|
100
|
+
style,
|
|
101
|
+
...rest
|
|
102
|
+
},
|
|
103
|
+
ref,
|
|
104
|
+
) => {
|
|
105
|
+
const [open, setOpen] = React.useState(false);
|
|
106
|
+
const [accountOpen, setAccountOpen] = React.useState(false);
|
|
107
|
+
const [accountCoords, setAccountCoords] = React.useState<{
|
|
108
|
+
top: number;
|
|
109
|
+
right: number;
|
|
110
|
+
} | null>(null);
|
|
111
|
+
|
|
112
|
+
const panelId = React.useId();
|
|
113
|
+
const accountPanelId = React.useId();
|
|
114
|
+
const accountBtnRef = React.useRef<HTMLButtonElement>(null);
|
|
115
|
+
const accountPanelRef = React.useRef<HTMLDivElement>(null);
|
|
116
|
+
|
|
117
|
+
const floating = variant === "floating";
|
|
118
|
+
|
|
119
|
+
React.useEffect(() => {
|
|
120
|
+
if (!open) return;
|
|
121
|
+
const onKey = (e: KeyboardEvent) => {
|
|
122
|
+
if (e.key === "Escape") setOpen(false);
|
|
123
|
+
};
|
|
124
|
+
document.addEventListener("keydown", onKey);
|
|
125
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
126
|
+
}, [open]);
|
|
127
|
+
|
|
128
|
+
const updateAccountCoords = React.useCallback(() => {
|
|
129
|
+
const el = accountBtnRef.current;
|
|
130
|
+
if (!el) return;
|
|
131
|
+
const rect = el.getBoundingClientRect();
|
|
132
|
+
setAccountCoords({
|
|
133
|
+
top: rect.bottom + 8,
|
|
134
|
+
right: Math.max(8, window.innerWidth - rect.right),
|
|
135
|
+
});
|
|
136
|
+
}, []);
|
|
137
|
+
|
|
138
|
+
React.useEffect(() => {
|
|
139
|
+
if (!accountOpen) return;
|
|
140
|
+
updateAccountCoords();
|
|
141
|
+
const onPointerDown = (e: PointerEvent) => {
|
|
142
|
+
const target = e.target as Node;
|
|
143
|
+
if (accountBtnRef.current?.contains(target)) return;
|
|
144
|
+
if (accountPanelRef.current?.contains(target)) return;
|
|
145
|
+
setAccountOpen(false);
|
|
146
|
+
};
|
|
147
|
+
const onKey = (e: KeyboardEvent) => {
|
|
148
|
+
if (e.key === "Escape") setAccountOpen(false);
|
|
149
|
+
};
|
|
150
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
151
|
+
document.addEventListener("keydown", onKey);
|
|
152
|
+
window.addEventListener("resize", updateAccountCoords);
|
|
153
|
+
window.addEventListener("scroll", updateAccountCoords, true);
|
|
154
|
+
return () => {
|
|
155
|
+
document.removeEventListener("pointerdown", onPointerDown);
|
|
156
|
+
document.removeEventListener("keydown", onKey);
|
|
157
|
+
window.removeEventListener("resize", updateAccountCoords);
|
|
158
|
+
window.removeEventListener("scroll", updateAccountCoords, true);
|
|
159
|
+
};
|
|
160
|
+
}, [accountOpen, updateAccountCoords]);
|
|
161
|
+
|
|
162
|
+
const pickAccountAction = (fn?: () => void) => {
|
|
163
|
+
setAccountOpen(false);
|
|
164
|
+
setOpen(false);
|
|
165
|
+
fn?.();
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const runAction = (a: MarketingNavAction) => {
|
|
169
|
+
setOpen(false);
|
|
170
|
+
if (a.onClick) {
|
|
171
|
+
a.onClick();
|
|
172
|
+
} else if (a.href && typeof window !== "undefined") {
|
|
173
|
+
window.location.assign(a.href);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const renderAction = (
|
|
178
|
+
a: MarketingNavAction,
|
|
179
|
+
variant: "primary" | "ghost",
|
|
180
|
+
full = false,
|
|
181
|
+
) => (
|
|
182
|
+
<Button
|
|
183
|
+
variant={variant}
|
|
184
|
+
size="md"
|
|
185
|
+
onClick={() => runAction(a)}
|
|
186
|
+
className={`shrink-0 whitespace-nowrap !rounded-full ${full ? "w-full" : ""} ${
|
|
187
|
+
floating && variant === "ghost" ? "!text-ink" : ""
|
|
188
|
+
}`}
|
|
189
|
+
>
|
|
190
|
+
{a.label}
|
|
191
|
+
</Button>
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
const hasActions = Boolean(secondaryAction || primaryAction);
|
|
195
|
+
|
|
196
|
+
const avatar = (size = "h-8 w-8") => {
|
|
197
|
+
if (account?.avatarSrc) {
|
|
198
|
+
return (
|
|
199
|
+
<img
|
|
200
|
+
src={account.avatarSrc}
|
|
201
|
+
alt=""
|
|
202
|
+
className={`${size} shrink-0 rounded-full object-cover`}
|
|
203
|
+
/>
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
const initials = (account?.name || account?.email || "?")
|
|
207
|
+
.trim()
|
|
208
|
+
.charAt(0)
|
|
209
|
+
.toUpperCase();
|
|
210
|
+
return (
|
|
211
|
+
<span
|
|
212
|
+
aria-hidden="true"
|
|
213
|
+
className={`${size} flex shrink-0 items-center justify-center rounded-full bg-linear-to-br from-logo-violet via-logo-pink to-logo-orange text-caption text-on-primary`}
|
|
214
|
+
>
|
|
215
|
+
{initials}
|
|
216
|
+
</span>
|
|
217
|
+
);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
const accountRows = (
|
|
221
|
+
<div className="flex flex-col gap-xxs">
|
|
222
|
+
<button
|
|
223
|
+
type="button"
|
|
224
|
+
onClick={() => pickAccountAction(account?.onSettings)}
|
|
225
|
+
className={itemClass}
|
|
226
|
+
>
|
|
227
|
+
<Icon name="settings-gear" className="size-4 shrink-0 text-muted" />
|
|
228
|
+
<span className="flex-1 truncate">{settingsLabel}</span>
|
|
229
|
+
</button>
|
|
230
|
+
<button
|
|
231
|
+
type="button"
|
|
232
|
+
onClick={() => pickAccountAction(account?.onLogout)}
|
|
233
|
+
className={itemClass}
|
|
234
|
+
>
|
|
235
|
+
<Icon name="logout-sign-out" className="size-4 shrink-0 text-muted" />
|
|
236
|
+
<span className="flex-1 truncate">{logoutLabel}</span>
|
|
237
|
+
</button>
|
|
238
|
+
</div>
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
const accountPanel =
|
|
242
|
+
account && accountCoords && typeof document !== "undefined"
|
|
243
|
+
? createPortal(
|
|
244
|
+
<div
|
|
245
|
+
ref={accountPanelRef}
|
|
246
|
+
id={accountPanelId}
|
|
247
|
+
data-state={accountOpen ? "open" : "closed"}
|
|
248
|
+
style={{
|
|
249
|
+
top: accountCoords.top,
|
|
250
|
+
right: accountCoords.right,
|
|
251
|
+
zIndex: "var(--z-dropdown, 1000)",
|
|
252
|
+
}}
|
|
253
|
+
className="fixed min-w-60 max-w-80 origin-top-right overflow-hidden rounded-lg border border-hairline-soft bg-surface p-xxs shadow-overlay transition duration-200 ease-out will-change-transform data-[state=closed]:invisible data-[state=closed]:pointer-events-none data-[state=closed]:-translate-y-1 data-[state=closed]:scale-95 data-[state=closed]:opacity-0 data-[state=open]:visible data-[state=open]:translate-y-0 data-[state=open]:scale-100 data-[state=open]:opacity-100"
|
|
254
|
+
>
|
|
255
|
+
<div className="flex items-center gap-sm px-sm py-sm">
|
|
256
|
+
{avatar()}
|
|
257
|
+
<div className="min-w-0">
|
|
258
|
+
{account.name && (
|
|
259
|
+
<p className="truncate text-body-sm text-ink">{account.name}</p>
|
|
260
|
+
)}
|
|
261
|
+
<p className="truncate text-caption text-muted">{account.email}</p>
|
|
262
|
+
</div>
|
|
263
|
+
</div>
|
|
264
|
+
<div className="my-xxs h-px bg-hairline-soft" />
|
|
265
|
+
{accountRows}
|
|
266
|
+
</div>,
|
|
267
|
+
document.body,
|
|
268
|
+
)
|
|
269
|
+
: null;
|
|
270
|
+
|
|
271
|
+
const desktopLinkClass = floating
|
|
272
|
+
? `whitespace-nowrap rounded-full px-sm py-xs text-body-sm font-weight-body-md text-ink hover:bg-surface-soft active:scale-[0.98] ${linkFocus}`
|
|
273
|
+
: `whitespace-nowrap rounded-xs text-body-sm text-muted hover:text-ink ${linkFocus}`;
|
|
274
|
+
|
|
275
|
+
const content = (
|
|
276
|
+
<>
|
|
277
|
+
<div
|
|
278
|
+
className={`mx-auto flex h-16 w-full items-center justify-between gap-sm md:gap-md lg:gap-lg ${
|
|
279
|
+
floating
|
|
280
|
+
? "px-md md:w-auto md:justify-start md:gap-lg lg:px-lg"
|
|
281
|
+
: "max-w-7xl px-md lg:px-lg"
|
|
282
|
+
}`}
|
|
283
|
+
>
|
|
284
|
+
<a
|
|
285
|
+
href={brandHref}
|
|
286
|
+
className={`flex shrink-0 items-center gap-sm rounded-sm text-ink no-underline active:scale-[0.98] ${linkFocus}`}
|
|
287
|
+
>
|
|
288
|
+
{logoSrc ? (
|
|
289
|
+
<img src={logoSrc} alt="" className="h-8 w-8 rounded-sm object-cover" />
|
|
290
|
+
) : (
|
|
291
|
+
<span className="flex h-8 w-8 items-center justify-center rounded-sm bg-linear-to-br from-logo-violet via-logo-pink to-logo-orange text-on-primary">
|
|
292
|
+
<Icon name="atom" size={18} />
|
|
293
|
+
</span>
|
|
294
|
+
)}
|
|
295
|
+
<span
|
|
296
|
+
className={`whitespace-nowrap text-body-md text-ink ${floating ? "font-weight-body-md" : ""}`}
|
|
297
|
+
>
|
|
298
|
+
{brandName}
|
|
299
|
+
</span>
|
|
300
|
+
</a>
|
|
301
|
+
|
|
302
|
+
<nav
|
|
303
|
+
className={`hidden items-center md:flex ${
|
|
304
|
+
floating ? "gap-sm lg:gap-md" : "gap-md lg:gap-lg"
|
|
305
|
+
}`}
|
|
306
|
+
aria-label="Primary"
|
|
307
|
+
>
|
|
308
|
+
{links.map((l) => (
|
|
309
|
+
<a
|
|
310
|
+
key={l.href + l.label}
|
|
311
|
+
href={l.href}
|
|
312
|
+
onClick={(e) => onLinkClick?.(l, e)}
|
|
313
|
+
className={desktopLinkClass}
|
|
314
|
+
>
|
|
315
|
+
{l.label}
|
|
316
|
+
</a>
|
|
317
|
+
))}
|
|
318
|
+
</nav>
|
|
319
|
+
|
|
320
|
+
<div className="hidden shrink-0 items-center gap-xs md:flex lg:gap-sm">
|
|
321
|
+
{secondaryAction && renderAction(secondaryAction, "ghost")}
|
|
322
|
+
{primaryAction && renderAction(primaryAction, "primary")}
|
|
323
|
+
{account && (
|
|
324
|
+
<button
|
|
325
|
+
ref={accountBtnRef}
|
|
326
|
+
type="button"
|
|
327
|
+
aria-expanded={accountOpen}
|
|
328
|
+
aria-controls={accountPanelId}
|
|
329
|
+
aria-label={`Account: ${account.email}`}
|
|
330
|
+
onClick={() => {
|
|
331
|
+
setOpen(false);
|
|
332
|
+
setAccountOpen((v) => !v);
|
|
333
|
+
}}
|
|
334
|
+
className={`flex items-center gap-xs rounded-full border border-hairline-soft bg-surface/60 py-xxs pl-xxs pr-xs text-ink transition duration-150 ease-out hover:bg-surface-soft active:scale-[0.98] ${linkFocus}`}
|
|
335
|
+
>
|
|
336
|
+
{avatar()}
|
|
337
|
+
{showAccountEmail && (
|
|
338
|
+
<span className="hidden min-w-0 max-w-56 truncate whitespace-nowrap text-caption text-body xl:block">
|
|
339
|
+
{account.email}
|
|
340
|
+
</span>
|
|
341
|
+
)}
|
|
342
|
+
<Icon
|
|
343
|
+
name="chevron-down"
|
|
344
|
+
className={`size-4 shrink-0 text-muted transition-transform duration-200 ease-out ${
|
|
345
|
+
accountOpen ? "rotate-180" : "rotate-0"
|
|
346
|
+
}`}
|
|
347
|
+
/>
|
|
348
|
+
</button>
|
|
349
|
+
)}
|
|
350
|
+
</div>
|
|
351
|
+
|
|
352
|
+
<button
|
|
353
|
+
type="button"
|
|
354
|
+
className={`flex h-10 w-10 shrink-0 items-center justify-center rounded-full text-ink hover:bg-surface-soft active:scale-[0.98] md:hidden ${linkFocus}`}
|
|
355
|
+
aria-label={open ? "Close menu" : "Open menu"}
|
|
356
|
+
aria-expanded={open}
|
|
357
|
+
aria-controls={panelId}
|
|
358
|
+
onClick={() => {
|
|
359
|
+
setAccountOpen(false);
|
|
360
|
+
setOpen((v) => !v);
|
|
361
|
+
}}
|
|
362
|
+
>
|
|
363
|
+
<Icon name={open ? "close" : "hamburger-menu"} size={20} />
|
|
364
|
+
</button>
|
|
365
|
+
</div>
|
|
366
|
+
|
|
367
|
+
<div
|
|
368
|
+
id={panelId}
|
|
369
|
+
data-state={open ? "open" : "closed"}
|
|
370
|
+
className="grid origin-top transition-[grid-template-rows,opacity,visibility] duration-200 ease-out data-[state=closed]:invisible data-[state=closed]:grid-rows-[0fr] data-[state=closed]:opacity-0 data-[state=open]:grid-rows-[1fr] data-[state=open]:opacity-100 md:hidden"
|
|
371
|
+
>
|
|
372
|
+
<div className="overflow-hidden">
|
|
373
|
+
<div
|
|
374
|
+
className={`border-t border-hairline-soft px-lg pb-lg pt-sm ${
|
|
375
|
+
floating ? "bg-transparent" : "bg-canvas"
|
|
376
|
+
}`}
|
|
377
|
+
>
|
|
378
|
+
<nav className="flex flex-col" aria-label="Mobile">
|
|
379
|
+
{links.map((l) => (
|
|
380
|
+
<a
|
|
381
|
+
key={l.href + l.label}
|
|
382
|
+
href={l.href}
|
|
383
|
+
onClick={(e) => {
|
|
384
|
+
setOpen(false);
|
|
385
|
+
onLinkClick?.(l, e);
|
|
386
|
+
}}
|
|
387
|
+
className={`rounded-md px-sm py-md text-body-md text-ink transition duration-150 ease-out hover:bg-surface-soft active:scale-[0.98] ${linkFocus}`}
|
|
388
|
+
>
|
|
389
|
+
{l.label}
|
|
390
|
+
</a>
|
|
391
|
+
))}
|
|
392
|
+
</nav>
|
|
393
|
+
|
|
394
|
+
{hasActions && (
|
|
395
|
+
<div className="mt-md flex flex-col gap-sm">
|
|
396
|
+
{secondaryAction && renderAction(secondaryAction, "ghost", true)}
|
|
397
|
+
{primaryAction && renderAction(primaryAction, "primary", true)}
|
|
398
|
+
</div>
|
|
399
|
+
)}
|
|
400
|
+
|
|
401
|
+
{account && (
|
|
402
|
+
<div className="mt-md flex flex-col gap-xxs border-t border-hairline-soft pt-sm">
|
|
403
|
+
<div className="flex items-center gap-sm px-sm py-sm">
|
|
404
|
+
{avatar()}
|
|
405
|
+
<div className="min-w-0">
|
|
406
|
+
{account.name && (
|
|
407
|
+
<p className="truncate text-body-sm text-ink">{account.name}</p>
|
|
408
|
+
)}
|
|
409
|
+
<p className="truncate text-caption text-muted">
|
|
410
|
+
{account.email}
|
|
411
|
+
</p>
|
|
412
|
+
</div>
|
|
413
|
+
</div>
|
|
414
|
+
{accountRows}
|
|
415
|
+
</div>
|
|
416
|
+
)}
|
|
417
|
+
</div>
|
|
418
|
+
</div>
|
|
419
|
+
</div>
|
|
420
|
+
</>
|
|
421
|
+
);
|
|
422
|
+
|
|
423
|
+
const headerClass = floating
|
|
424
|
+
? `pointer-events-none fixed inset-x-0 top-md w-full px-md md:flex md:justify-center lg:px-lg ${className}`
|
|
425
|
+
: `${sticky ? "sticky top-0" : "relative"} w-full border-b border-hairline-soft bg-canvas/80 backdrop-blur-md ${className}`;
|
|
426
|
+
|
|
427
|
+
return (
|
|
428
|
+
<>
|
|
429
|
+
<header
|
|
430
|
+
ref={ref}
|
|
431
|
+
className={headerClass}
|
|
432
|
+
style={{
|
|
433
|
+
zIndex: floating || sticky ? "var(--z-sticky, 1100)" : undefined,
|
|
434
|
+
...style,
|
|
435
|
+
}}
|
|
436
|
+
{...rest}
|
|
437
|
+
>
|
|
438
|
+
{floating ? (
|
|
439
|
+
<div className="pointer-events-auto w-full overflow-hidden rounded-xl border border-hairline-soft/40 bg-canvas/80 shadow-md backdrop-blur-xl backdrop-saturate-150 md:w-auto md:rounded-full">
|
|
440
|
+
{content}
|
|
441
|
+
</div>
|
|
442
|
+
) : (
|
|
443
|
+
content
|
|
444
|
+
)}
|
|
445
|
+
</header>
|
|
446
|
+
{accountPanel}
|
|
447
|
+
</>
|
|
448
|
+
);
|
|
449
|
+
},
|
|
450
|
+
);
|
|
451
|
+
MarketingNavbar.displayName = "MarketingNavbar";
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MarketingNavbar } from "./MarketingNavbar";
|
|
3
|
+
|
|
4
|
+
export default function Preview() {
|
|
5
|
+
const [signedIn, setSignedIn] = React.useState(true);
|
|
6
|
+
const [last, setLast] = React.useState("none yet");
|
|
7
|
+
const [settingsOpen, setSettingsOpen] = React.useState(false);
|
|
8
|
+
|
|
9
|
+
const account = {
|
|
10
|
+
name: "Rae Molina",
|
|
11
|
+
email: "rae.molina@atoms.design",
|
|
12
|
+
onSettings: () => {
|
|
13
|
+
setSettingsOpen(true);
|
|
14
|
+
setLast("settings");
|
|
15
|
+
},
|
|
16
|
+
onLogout: () => {
|
|
17
|
+
setSignedIn(false);
|
|
18
|
+
setSettingsOpen(false);
|
|
19
|
+
setLast("logged out");
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div className="w-full max-w-5xl mx-auto p-lg space-y-xl">
|
|
25
|
+
<section className="space-y-sm">
|
|
26
|
+
<MarketingNavbar
|
|
27
|
+
variant="floating"
|
|
28
|
+
account={signedIn ? account : null}
|
|
29
|
+
secondaryAction={signedIn ? null : { label: "Log in" }}
|
|
30
|
+
primaryAction={
|
|
31
|
+
signedIn ? { label: "Open studio" } : { label: "Start free" }
|
|
32
|
+
}
|
|
33
|
+
onLinkClick={(_, e) => e.preventDefault()}
|
|
34
|
+
/>
|
|
35
|
+
<div className="flex min-h-24 items-end rounded-lg border border-dashed border-hairline bg-surface-soft/40 p-sm">
|
|
36
|
+
<p className="text-caption text-muted">
|
|
37
|
+
Floating variant — full-width card on mobile, a pill that hugs its
|
|
38
|
+
content from md up
|
|
39
|
+
</p>
|
|
40
|
+
</div>
|
|
41
|
+
</section>
|
|
42
|
+
|
|
43
|
+
<section className="space-y-sm">
|
|
44
|
+
<p className="text-caption text-muted">
|
|
45
|
+
Logged out — the marketing default
|
|
46
|
+
</p>
|
|
47
|
+
<div className="overflow-hidden rounded-lg border border-hairline">
|
|
48
|
+
<MarketingNavbar
|
|
49
|
+
sticky={false}
|
|
50
|
+
account={null}
|
|
51
|
+
onLinkClick={(_, e) => e.preventDefault()}
|
|
52
|
+
/>
|
|
53
|
+
</div>
|
|
54
|
+
</section>
|
|
55
|
+
|
|
56
|
+
<section className="space-y-sm">
|
|
57
|
+
<div className="flex flex-wrap items-center justify-between gap-sm">
|
|
58
|
+
<p className="text-caption text-muted">
|
|
59
|
+
Signed in — avatar button with the email, plus settings and log out
|
|
60
|
+
</p>
|
|
61
|
+
<button
|
|
62
|
+
type="button"
|
|
63
|
+
onClick={() => setSignedIn((v) => !v)}
|
|
64
|
+
className="cursor-pointer rounded-full border border-hairline px-sm py-xs text-caption 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"
|
|
65
|
+
>
|
|
66
|
+
{signedIn ? "Sign out" : "Sign in"}
|
|
67
|
+
</button>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<div className="rounded-lg border border-hairline">
|
|
71
|
+
<MarketingNavbar
|
|
72
|
+
sticky={false}
|
|
73
|
+
account={signedIn ? account : null}
|
|
74
|
+
secondaryAction={signedIn ? null : { label: "Log in" }}
|
|
75
|
+
primaryAction={
|
|
76
|
+
signedIn ? { label: "Open studio" } : { label: "Start free" }
|
|
77
|
+
}
|
|
78
|
+
onLinkClick={(link, e) => {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
setLast(link.label);
|
|
81
|
+
}}
|
|
82
|
+
/>
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<p className="text-caption text-muted">Last action: {last}</p>
|
|
86
|
+
|
|
87
|
+
{settingsOpen && signedIn && (
|
|
88
|
+
<div className="rounded-lg border border-hairline bg-surface p-md">
|
|
89
|
+
<div className="flex items-start justify-between gap-md">
|
|
90
|
+
<div className="min-w-0">
|
|
91
|
+
<p className="text-body-sm text-ink">Account settings</p>
|
|
92
|
+
<p className="truncate text-caption text-muted">
|
|
93
|
+
{account.email}
|
|
94
|
+
</p>
|
|
95
|
+
</div>
|
|
96
|
+
<button
|
|
97
|
+
type="button"
|
|
98
|
+
onClick={() => setSettingsOpen(false)}
|
|
99
|
+
className="cursor-pointer rounded-full px-sm py-xs text-caption text-muted 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"
|
|
100
|
+
>
|
|
101
|
+
Close
|
|
102
|
+
</button>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
)}
|
|
106
|
+
</section>
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
}
|