@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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
2
3
|
import { Button } from "../Button";
|
|
3
4
|
import { Icon } from "../Icon";
|
|
4
5
|
|
|
@@ -15,15 +16,18 @@ export interface ModalProps {
|
|
|
15
16
|
footer?: React.ReactNode;
|
|
16
17
|
/** Max-width variant. "full" fills almost the entire viewport (e.g. for
|
|
17
18
|
* media/image viewers) and always shows a close control even without a
|
|
18
|
-
* title.
|
|
19
|
-
|
|
19
|
+
* title. "fit" shrink-wraps the panel to its content (e.g. an image
|
|
20
|
+
* lightbox whose dialog matches the image size), capped to the viewport,
|
|
21
|
+
* and also always shows a close control. */
|
|
22
|
+
size?: "sm" | "md" | "lg" | "xl" | "2xl" | "full" | "fit";
|
|
20
23
|
}
|
|
21
24
|
|
|
22
|
-
const sizeMap: Record<"sm" | "md" | "lg" | "xl", string> = {
|
|
25
|
+
const sizeMap: Record<"sm" | "md" | "lg" | "xl" | "2xl", string> = {
|
|
23
26
|
sm: "max-w-sm",
|
|
24
27
|
md: "max-w-lg",
|
|
25
28
|
lg: "max-w-2xl",
|
|
26
29
|
xl: "max-w-4xl",
|
|
30
|
+
"2xl": "max-w-7xl",
|
|
27
31
|
};
|
|
28
32
|
|
|
29
33
|
export const Modal = React.forwardRef<HTMLDivElement, ModalProps>(
|
|
@@ -31,12 +35,24 @@ export const Modal = React.forwardRef<HTMLDivElement, ModalProps>(
|
|
|
31
35
|
// `mounted` controls DOM presence; `visible` drives the CSS transition
|
|
32
36
|
const [mounted, setMounted] = useState(false);
|
|
33
37
|
const [visible, setVisible] = useState(false);
|
|
34
|
-
|
|
38
|
+
// `portalReady` guards SSR / first render: document.body only exists on the client
|
|
39
|
+
const [portalReady, setPortalReady] = useState(false);
|
|
40
|
+
// Theme of the nearest themed ancestor, copied onto the portaled overlay so
|
|
41
|
+
// a nested `data-theme` subtree still styles the modal after it leaves that subtree.
|
|
42
|
+
const [theme, setTheme] = useState<string | undefined>(undefined);
|
|
43
|
+
const anchorRef = useRef<HTMLSpanElement>(null);
|
|
35
44
|
const isFull = size === "full";
|
|
45
|
+
const isFit = size === "fit";
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
setPortalReady(true);
|
|
49
|
+
}, []);
|
|
36
50
|
|
|
37
51
|
// Open: mount first, then trigger transition on the next frame
|
|
38
52
|
useEffect(() => {
|
|
39
53
|
if (isOpen) {
|
|
54
|
+
const themed = anchorRef.current?.closest("[data-theme]");
|
|
55
|
+
setTheme(themed?.getAttribute("data-theme") ?? undefined);
|
|
40
56
|
setMounted(true);
|
|
41
57
|
// Double rAF so the element is painted before the opacity class is
|
|
42
58
|
// added — otherwise the browser batches them and skips the fade.
|
|
@@ -62,12 +78,6 @@ export const Modal = React.forwardRef<HTMLDivElement, ModalProps>(
|
|
|
62
78
|
return () => document.removeEventListener("keydown", handleKey);
|
|
63
79
|
}, [mounted, onClose]);
|
|
64
80
|
|
|
65
|
-
if (!mounted) return null;
|
|
66
|
-
|
|
67
|
-
const handleBackdropClick = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
68
|
-
if (e.target === overlayRef.current) onClose();
|
|
69
|
-
};
|
|
70
|
-
|
|
71
81
|
const closeButton = (
|
|
72
82
|
<Button
|
|
73
83
|
variant="ghost"
|
|
@@ -80,21 +90,34 @@ export const Modal = React.forwardRef<HTMLDivElement, ModalProps>(
|
|
|
80
90
|
</Button>
|
|
81
91
|
);
|
|
82
92
|
|
|
83
|
-
|
|
93
|
+
const state = visible ? "open" : "closed";
|
|
94
|
+
|
|
95
|
+
const overlay = (
|
|
84
96
|
<div
|
|
85
|
-
ref={overlayRef}
|
|
86
97
|
role="dialog"
|
|
87
98
|
aria-modal="true"
|
|
88
99
|
aria-labelledby={title ? "modal-title" : undefined}
|
|
89
|
-
|
|
100
|
+
data-theme={theme}
|
|
101
|
+
data-state={state}
|
|
90
102
|
className={[
|
|
91
103
|
"fixed inset-0 flex items-center justify-center p-base",
|
|
92
104
|
"bg-[var(--color-scrim)]/60",
|
|
93
|
-
"transition-opacity duration-
|
|
94
|
-
|
|
105
|
+
"transition-opacity duration-200 ease-out",
|
|
106
|
+
"data-[state=open]:opacity-100 data-[state=closed]:opacity-0",
|
|
107
|
+
"data-[state=closed]:pointer-events-none",
|
|
95
108
|
].join(" ")}
|
|
96
|
-
style={{ zIndex: "var(--z-modal,
|
|
109
|
+
style={{ zIndex: "var(--z-modal, 1200)" }}
|
|
97
110
|
>
|
|
111
|
+
{/* Backdrop — a real button so click-to-dismiss is a valid control
|
|
112
|
+
(Escape is the keyboard path, so it stays out of the tab order). */}
|
|
113
|
+
<button
|
|
114
|
+
type="button"
|
|
115
|
+
tabIndex={-1}
|
|
116
|
+
aria-label="Close modal backdrop"
|
|
117
|
+
onClick={onClose}
|
|
118
|
+
className="absolute inset-0 h-full w-full cursor-pointer transition duration-150 ease-out hover:bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue disabled:cursor-not-allowed disabled:opacity-50"
|
|
119
|
+
/>
|
|
120
|
+
|
|
98
121
|
{/* Panel — bg-surface (not bg-canvas) so the panel visibly separates
|
|
99
122
|
from the page behind the scrim, especially in dark mode where
|
|
100
123
|
canvas and scrim are both near-black. A hairline border adds a
|
|
@@ -105,26 +128,30 @@ export const Modal = React.forwardRef<HTMLDivElement, ModalProps>(
|
|
|
105
128
|
modals never overflow. "full" instead drops the max-w/max-h caps
|
|
106
129
|
and takes almost the entire overlay so a high-resolution
|
|
107
130
|
object-contain image (or other full-bleed content) can fill the
|
|
108
|
-
viewport.
|
|
109
|
-
|
|
131
|
+
viewport. "fit" shrink-wraps to its content (w-fit h-auto) and is
|
|
132
|
+
capped to the viewport minus the overlay padding on both axes.
|
|
133
|
+
The body's overflow-y-auto lets long content scroll
|
|
134
|
+
within whichever height applies (except "fit"). */}
|
|
110
135
|
<div
|
|
111
136
|
ref={ref}
|
|
137
|
+
data-state={state}
|
|
112
138
|
className={[
|
|
113
139
|
"relative bg-surface border border-hairline rounded-lg",
|
|
114
140
|
"shadow-[0_8px_40px_0_rgba(0,0,0,0.18)]",
|
|
115
141
|
"flex flex-col overflow-hidden",
|
|
116
142
|
isFull
|
|
117
143
|
? "w-[calc(100%-2*var(--spacing-base))] h-[calc(100%-2*var(--spacing-base))] max-w-none max-h-none"
|
|
118
|
-
:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
144
|
+
: isFit
|
|
145
|
+
? "w-fit h-auto max-w-[calc(100vw-2*var(--spacing-base))] max-h-[calc(100dvh-2*var(--spacing-base))]"
|
|
146
|
+
: `w-full max-h-full ${sizeMap[size as "sm" | "md" | "lg" | "xl" | "2xl"]}`,
|
|
147
|
+
"transition duration-200 ease-out",
|
|
148
|
+
"data-[state=open]:translate-y-0 data-[state=open]:scale-100 data-[state=open]:opacity-100",
|
|
149
|
+
"data-[state=closed]:translate-y-2 data-[state=closed]:scale-[0.98] data-[state=closed]:opacity-0",
|
|
123
150
|
].join(" ")}
|
|
124
151
|
>
|
|
125
|
-
{/* Header — always shown for size="full" (even
|
|
126
|
-
so there's always a way to dismiss
|
|
127
|
-
{(title || isFull) && (
|
|
152
|
+
{/* Header — always shown for size="full" and size="fit" (even
|
|
153
|
+
without a title) so there's always a way to dismiss the panel. */}
|
|
154
|
+
{(title || isFull || isFit) && (
|
|
128
155
|
<div className="flex items-center justify-between px-lg py-base border-b border-hairline">
|
|
129
156
|
{title ? (
|
|
130
157
|
<h2 id="modal-title" className="text-heading-sm text-ink">
|
|
@@ -137,8 +164,20 @@ export const Modal = React.forwardRef<HTMLDivElement, ModalProps>(
|
|
|
137
164
|
</div>
|
|
138
165
|
)}
|
|
139
166
|
|
|
140
|
-
{/* Body
|
|
141
|
-
|
|
167
|
+
{/* Body — for size="full" it is also the containing block (`relative`)
|
|
168
|
+
so an `absolute inset-0` child fills the body only, not the
|
|
169
|
+
header/footer. For size="fit" it has no padding or scrolling so
|
|
170
|
+
the content (e.g. an image) sets the panel's size. */}
|
|
171
|
+
<div
|
|
172
|
+
className={[
|
|
173
|
+
isFit
|
|
174
|
+
? "p-0 overflow-hidden min-h-0 text-body-md text-body"
|
|
175
|
+
: "flex-1 min-h-0 px-lg py-base text-body-md text-body overflow-y-auto",
|
|
176
|
+
isFull ? "relative" : "",
|
|
177
|
+
]
|
|
178
|
+
.filter(Boolean)
|
|
179
|
+
.join(" ")}
|
|
180
|
+
>
|
|
142
181
|
{children}
|
|
143
182
|
</div>
|
|
144
183
|
|
|
@@ -151,6 +190,16 @@ export const Modal = React.forwardRef<HTMLDivElement, ModalProps>(
|
|
|
151
190
|
</div>
|
|
152
191
|
</div>
|
|
153
192
|
);
|
|
193
|
+
|
|
194
|
+
return (
|
|
195
|
+
<>
|
|
196
|
+
{/* Hidden in-tree anchor: lets us read the themed ancestor even while closed */}
|
|
197
|
+
<span ref={anchorRef} hidden aria-hidden="true" />
|
|
198
|
+
{mounted && portalReady && typeof document !== "undefined"
|
|
199
|
+
? createPortal(overlay, document.body)
|
|
200
|
+
: null}
|
|
201
|
+
</>
|
|
202
|
+
);
|
|
154
203
|
}
|
|
155
204
|
);
|
|
156
205
|
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Icon } from "../Icon";
|
|
3
|
+
|
|
4
|
+
export interface PreviewDockProps {
|
|
5
|
+
/** Label shown under the viewport icon, e.g. "Desktop" or "Mobile". Defaults to "Desktop". */
|
|
6
|
+
viewportLabel?: string;
|
|
7
|
+
viewportActive?: boolean;
|
|
8
|
+
onViewport?: () => void;
|
|
9
|
+
tokensActive?: boolean;
|
|
10
|
+
onTokens?: () => void;
|
|
11
|
+
themeActive?: boolean;
|
|
12
|
+
onTheme?: () => void;
|
|
13
|
+
fullscreenActive?: boolean;
|
|
14
|
+
onFullscreen?: () => void;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface DockActionProps {
|
|
19
|
+
icon: string;
|
|
20
|
+
label: string;
|
|
21
|
+
active: boolean;
|
|
22
|
+
onClick?: () => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const DockAction = ({ icon, label, active, onClick }: DockActionProps) => (
|
|
26
|
+
<button
|
|
27
|
+
type="button"
|
|
28
|
+
aria-label={label}
|
|
29
|
+
aria-pressed={active}
|
|
30
|
+
onClick={onClick}
|
|
31
|
+
className={[
|
|
32
|
+
"flex flex-1 basis-0 min-w-0 flex-col items-center justify-center gap-xxs px-sm py-xs rounded-lg",
|
|
33
|
+
"cursor-pointer transition duration-150 ease-out active:scale-[0.98]",
|
|
34
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue",
|
|
35
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
36
|
+
active
|
|
37
|
+
? "bg-primary text-on-primary hover:bg-primary-hover"
|
|
38
|
+
: "bg-transparent text-ink hover:bg-surface-soft",
|
|
39
|
+
].join(" ")}
|
|
40
|
+
>
|
|
41
|
+
<Icon name={icon} size={20} />
|
|
42
|
+
<span
|
|
43
|
+
className={[
|
|
44
|
+
"text-caption truncate max-w-full",
|
|
45
|
+
active ? "text-on-primary" : "text-muted",
|
|
46
|
+
].join(" ")}
|
|
47
|
+
>
|
|
48
|
+
{label}
|
|
49
|
+
</span>
|
|
50
|
+
</button>
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
export const PreviewDock = React.forwardRef<HTMLDivElement, PreviewDockProps>(
|
|
54
|
+
(
|
|
55
|
+
{
|
|
56
|
+
viewportLabel,
|
|
57
|
+
viewportActive = false,
|
|
58
|
+
onViewport,
|
|
59
|
+
tokensActive = false,
|
|
60
|
+
onTokens,
|
|
61
|
+
themeActive = false,
|
|
62
|
+
onTheme,
|
|
63
|
+
fullscreenActive = false,
|
|
64
|
+
onFullscreen,
|
|
65
|
+
className = "",
|
|
66
|
+
},
|
|
67
|
+
ref,
|
|
68
|
+
) => (
|
|
69
|
+
<div className="w-full flex justify-center">
|
|
70
|
+
<div
|
|
71
|
+
ref={ref}
|
|
72
|
+
role="toolbar"
|
|
73
|
+
aria-label="Preview actions"
|
|
74
|
+
className={[
|
|
75
|
+
"flex w-full items-stretch gap-xs p-xs",
|
|
76
|
+
"bg-canvas border border-hairline rounded-xl shadow-card",
|
|
77
|
+
className,
|
|
78
|
+
]
|
|
79
|
+
.filter(Boolean)
|
|
80
|
+
.join(" ")}
|
|
81
|
+
>
|
|
82
|
+
{onViewport && (
|
|
83
|
+
<DockAction
|
|
84
|
+
icon="desktop-monitor"
|
|
85
|
+
label={viewportLabel ?? "Desktop"}
|
|
86
|
+
active={viewportActive}
|
|
87
|
+
onClick={onViewport}
|
|
88
|
+
/>
|
|
89
|
+
)}
|
|
90
|
+
{onTokens && (
|
|
91
|
+
<DockAction
|
|
92
|
+
icon="settings-gear"
|
|
93
|
+
label="Tokens"
|
|
94
|
+
active={tokensActive}
|
|
95
|
+
onClick={onTokens}
|
|
96
|
+
/>
|
|
97
|
+
)}
|
|
98
|
+
{onTheme && (
|
|
99
|
+
<DockAction
|
|
100
|
+
icon="moon-dark-mode"
|
|
101
|
+
label="Dark"
|
|
102
|
+
active={themeActive}
|
|
103
|
+
onClick={onTheme}
|
|
104
|
+
/>
|
|
105
|
+
)}
|
|
106
|
+
{onFullscreen && (
|
|
107
|
+
<DockAction
|
|
108
|
+
icon="fullscreen-corners-expand"
|
|
109
|
+
label="Fullscreen"
|
|
110
|
+
active={fullscreenActive}
|
|
111
|
+
onClick={onFullscreen}
|
|
112
|
+
/>
|
|
113
|
+
)}
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
),
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
PreviewDock.displayName = "PreviewDock";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { PreviewDock } from "./PreviewDock";
|
|
3
|
+
|
|
4
|
+
export default function Preview() {
|
|
5
|
+
const [mobile, setMobile] = useState(true);
|
|
6
|
+
const [tokens, setTokens] = useState(false);
|
|
7
|
+
const [theme, setTheme] = useState(false);
|
|
8
|
+
const [full, setFull] = useState(false);
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<div className="w-full max-w-3xl mx-auto p-lg space-y-lg">
|
|
12
|
+
<div className="w-full max-w-md mx-auto">
|
|
13
|
+
<PreviewDock
|
|
14
|
+
viewportLabel={mobile ? "Mobile" : "Desktop"}
|
|
15
|
+
viewportActive={mobile}
|
|
16
|
+
onViewport={() => setMobile((v) => !v)}
|
|
17
|
+
tokensActive={tokens}
|
|
18
|
+
onTokens={() => setTokens((v) => !v)}
|
|
19
|
+
themeActive={theme}
|
|
20
|
+
onTheme={() => setTheme((v) => !v)}
|
|
21
|
+
fullscreenActive={full}
|
|
22
|
+
onFullscreen={() => setFull((v) => !v)}
|
|
23
|
+
/>
|
|
24
|
+
</div>
|
|
25
|
+
<div className="w-full max-w-md mx-auto">
|
|
26
|
+
<PreviewDock viewportLabel="Desktop" />
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -24,6 +24,11 @@ export interface PreviewToolbarProps {
|
|
|
24
24
|
* "Inspect tokens" with the secondary variant.
|
|
25
25
|
*/
|
|
26
26
|
inspecting?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Click handler for the Inspect tokens button. The button is optional:
|
|
29
|
+
* it only renders when this prop is provided, so consumers can hide it
|
|
30
|
+
* by omitting the prop.
|
|
31
|
+
*/
|
|
27
32
|
onInspectTokens?: () => void;
|
|
28
33
|
onFullscreen?: () => void;
|
|
29
34
|
onExpand?: () => void;
|
|
@@ -33,9 +38,15 @@ export interface PreviewToolbarProps {
|
|
|
33
38
|
* expanded is true — only one selection indicator is shown at a time.
|
|
34
39
|
*/
|
|
35
40
|
expanded?: boolean;
|
|
36
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Model name shown as a chip, e.g. "Sonnet 4.6". The chip is only
|
|
43
|
+
* rendered when this prop is provided (non-empty).
|
|
44
|
+
*/
|
|
37
45
|
modelLabel?: string;
|
|
38
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Component kind shown as a chip, e.g. "ATOM". The chip is only
|
|
48
|
+
* rendered when this prop is provided (non-empty).
|
|
49
|
+
*/
|
|
39
50
|
kindLabel?: string;
|
|
40
51
|
/**
|
|
41
52
|
* Legacy overflow handler — fired when the 3-dots button is clicked.
|
|
@@ -68,8 +79,8 @@ export const PreviewToolbar = React.forwardRef<HTMLDivElement, PreviewToolbarPro
|
|
|
68
79
|
onFullscreen,
|
|
69
80
|
onExpand,
|
|
70
81
|
expanded = false,
|
|
71
|
-
modelLabel
|
|
72
|
-
kindLabel
|
|
82
|
+
modelLabel,
|
|
83
|
+
kindLabel,
|
|
73
84
|
onOverflow,
|
|
74
85
|
overflowItems,
|
|
75
86
|
className = "",
|
|
@@ -130,17 +141,19 @@ export const PreviewToolbar = React.forwardRef<HTMLDivElement, PreviewToolbarPro
|
|
|
130
141
|
|
|
131
142
|
{/* ── Action buttons — wrap as a group below viewport row on mobile ── */}
|
|
132
143
|
<div className="flex flex-wrap items-center gap-sm">
|
|
133
|
-
{/* ── Inspect tokens button —
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
{/* ── Inspect tokens button — only rendered when onInspectTokens is provided ── */}
|
|
145
|
+
{onInspectTokens ? (
|
|
146
|
+
<Button
|
|
147
|
+
variant={inspecting ? "primary" : "secondary"}
|
|
148
|
+
size="sm"
|
|
149
|
+
aria-pressed={inspecting}
|
|
150
|
+
onClick={onInspectTokens}
|
|
151
|
+
className="gap-xs rounded-xl"
|
|
152
|
+
>
|
|
153
|
+
<Icon name="inspect-target-crosshair" size={15} />
|
|
154
|
+
{inspecting ? "Exit inspect" : "Inspect tokens"}
|
|
155
|
+
</Button>
|
|
156
|
+
) : null}
|
|
144
157
|
|
|
145
158
|
<Button
|
|
146
159
|
variant={darkMode ? "primary" : "secondary"}
|
|
@@ -163,21 +176,25 @@ export const PreviewToolbar = React.forwardRef<HTMLDivElement, PreviewToolbarPro
|
|
|
163
176
|
Fullscreen
|
|
164
177
|
</Button>
|
|
165
178
|
|
|
166
|
-
{/* ── Model chip (outlined primary style) ── */}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
{/* ── Model chip (outlined primary style) — only when modelLabel is provided ── */}
|
|
180
|
+
{modelLabel ? (
|
|
181
|
+
<Chip
|
|
182
|
+
label={modelLabel}
|
|
183
|
+
variant="default"
|
|
184
|
+
size="md"
|
|
185
|
+
className="border-primary text-primary bg-canvas cursor-default select-none"
|
|
186
|
+
/>
|
|
187
|
+
) : null}
|
|
188
|
+
|
|
189
|
+
{/* ── Kind chip (filled soft primary) — only when kindLabel is provided ── */}
|
|
190
|
+
{kindLabel ? (
|
|
191
|
+
<Chip
|
|
192
|
+
label={kindLabel}
|
|
193
|
+
variant="default"
|
|
194
|
+
size="md"
|
|
195
|
+
className="bg-primary-disabled border-primary-disabled text-primary cursor-default select-none"
|
|
196
|
+
/>
|
|
197
|
+
) : null}
|
|
181
198
|
|
|
182
199
|
{/* ── Overflow — renders as a Menu when overflowItems is supplied, ── */}
|
|
183
200
|
{/* falls back to the legacy bare-button onOverflow callback, and ── */}
|
|
@@ -31,7 +31,7 @@ export interface PricingCardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
31
31
|
features: string[];
|
|
32
32
|
/** Label for the primary CTA button. */
|
|
33
33
|
ctaLabel: string;
|
|
34
|
-
/** Called when the CTA button is clicked. */
|
|
34
|
+
/** Called when the CTA button is clicked. Not called when disabled. */
|
|
35
35
|
onCtaClick?: () => void;
|
|
36
36
|
/** Small caption under the CTA, e.g. "No credit card required". */
|
|
37
37
|
ctaCaption?: string;
|
|
@@ -48,6 +48,11 @@ export interface PricingCardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
48
48
|
selectedCreditValue?: string;
|
|
49
49
|
/** Called when the user picks a different credit tier. */
|
|
50
50
|
onCreditChange?: (value: string) => void;
|
|
51
|
+
/**
|
|
52
|
+
* When true, the whole card uses the disabled treatment: reduced opacity,
|
|
53
|
+
* a disabled CTA that never fires onCtaClick, and aria-disabled on the root.
|
|
54
|
+
*/
|
|
55
|
+
disabled?: boolean;
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
export const PricingCard = React.forwardRef<HTMLDivElement, PricingCardProps>(
|
|
@@ -67,7 +72,9 @@ export const PricingCard = React.forwardRef<HTMLDivElement, PricingCardProps>(
|
|
|
67
72
|
creditTiers,
|
|
68
73
|
selectedCreditValue,
|
|
69
74
|
onCreditChange,
|
|
75
|
+
disabled = false,
|
|
70
76
|
className,
|
|
77
|
+
style,
|
|
71
78
|
...rest
|
|
72
79
|
},
|
|
73
80
|
ref,
|
|
@@ -91,15 +98,18 @@ export const PricingCard = React.forwardRef<HTMLDivElement, PricingCardProps>(
|
|
|
91
98
|
<div
|
|
92
99
|
ref={ref}
|
|
93
100
|
className={[
|
|
94
|
-
"relative flex w-full flex-col rounded-xl border bg-canvas p-lg",
|
|
101
|
+
"relative flex h-full w-full flex-col rounded-xl border bg-canvas p-lg",
|
|
95
102
|
highlighted
|
|
96
103
|
? "border-primary shadow-modal"
|
|
97
104
|
: "border-hairline shadow-card",
|
|
105
|
+
disabled ? "cursor-not-allowed" : undefined,
|
|
98
106
|
className,
|
|
99
107
|
]
|
|
100
108
|
.filter(Boolean)
|
|
101
109
|
.join(" ")}
|
|
110
|
+
style={disabled ? { ...style, opacity: "var(--opacity-disabled)" } : style}
|
|
102
111
|
{...rest}
|
|
112
|
+
aria-disabled={disabled ? true : rest["aria-disabled"]}
|
|
103
113
|
>
|
|
104
114
|
{highlighted && (
|
|
105
115
|
<div className="absolute -top-3.5 left-1/2 -translate-x-1/2">
|
|
@@ -121,7 +131,7 @@ export const PricingCard = React.forwardRef<HTMLDivElement, PricingCardProps>(
|
|
|
121
131
|
{priceNote && !hasCreditTiers && <p className="mt-xs text-body-sm text-muted">{priceNote}</p>}
|
|
122
132
|
|
|
123
133
|
{hasCreditTiers && (
|
|
124
|
-
<div className="mt-md">
|
|
134
|
+
<div className={disabled ? "mt-md pointer-events-none" : "mt-md"} inert={disabled || undefined}>
|
|
125
135
|
<Dropdown
|
|
126
136
|
options={creditOptions!}
|
|
127
137
|
value={selectedCreditValue}
|
|
@@ -149,7 +159,8 @@ export const PricingCard = React.forwardRef<HTMLDivElement, PricingCardProps>(
|
|
|
149
159
|
<Button
|
|
150
160
|
variant={highlighted ? "primary" : "secondary"}
|
|
151
161
|
size="md"
|
|
152
|
-
onClick={onCtaClick}
|
|
162
|
+
onClick={disabled ? undefined : onCtaClick}
|
|
163
|
+
disabled={disabled}
|
|
153
164
|
className="w-full"
|
|
154
165
|
>
|
|
155
166
|
{ctaLabel}
|