@designa8/vibedesign-v6 1.15.1 → 1.20.12
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/index.cjs +3231 -1987
- package/dist/index.js +3237 -1993
- package/dist/styles.css +266 -25
- package/package.json +51 -1
- package/src/atoms/AppLayout/AppLayout.tsx +401 -395
- package/src/atoms/AppLayout/preview.tsx +29 -0
- package/src/atoms/AppSidebar/AppSidebar.tsx +182 -94
- package/src/atoms/AppSidebar/preview.tsx +20 -59
- package/src/atoms/AppSidebarMobile/AppSidebarMobile.tsx +27 -73
- package/src/atoms/AppSidebarMobile/preview.tsx +18 -18
- package/src/atoms/AuthLogin/AuthLogin.tsx +200 -0
- package/src/atoms/AuthLogin/index.ts +2 -0
- package/src/atoms/AuthLogin/preview.tsx +22 -0
- package/src/atoms/AuthScreen/AuthScreen.tsx +7 -7
- package/src/atoms/AuthSignUp/AuthSignUp.tsx +243 -0
- package/src/atoms/AuthSignUp/index.ts +2 -0
- package/src/atoms/AuthSignUp/preview.tsx +22 -0
- package/src/atoms/BillingToggle/BillingToggle.tsx +65 -0
- package/src/atoms/BillingToggle/index.ts +2 -0
- package/src/atoms/BillingToggle/preview.tsx +23 -0
- package/src/atoms/Button/Button.tsx +33 -17
- package/src/atoms/Button/preview.tsx +16 -0
- package/src/atoms/ChatHistorySidebar/ChatHistorySidebar.tsx +370 -0
- package/src/atoms/ChatHistorySidebar/index.ts +2 -0
- package/src/atoms/ChatHistorySidebar/preview.tsx +60 -0
- package/src/atoms/ChatScreen/ChatScreen.tsx +331 -134
- package/src/atoms/ChatScreen/preview.tsx +123 -2
- package/src/atoms/Checkbox/Checkbox.tsx +89 -0
- package/src/atoms/Checkbox/index.ts +2 -0
- package/src/atoms/Checkbox/preview.tsx +60 -0
- package/src/atoms/Dropdown/Dropdown.tsx +195 -0
- package/src/atoms/Dropdown/index.ts +2 -0
- package/src/atoms/Dropdown/preview.tsx +56 -0
- package/src/atoms/FaqAccordionItem/FaqAccordionItem.tsx +60 -0
- package/src/atoms/FaqAccordionItem/index.ts +2 -0
- package/src/atoms/FaqAccordionItem/preview.tsx +26 -0
- package/src/atoms/FilterTabBar/FilterTabBar.tsx +2 -2
- package/src/atoms/FilterTabBar/preview.tsx +21 -0
- package/src/atoms/HomePageTemplate/HomePageTemplate.tsx +20 -33
- package/src/atoms/HomePageTemplate/preview.tsx +2 -2
- package/src/atoms/Icon/Icon.tsx +7 -5
- package/src/atoms/Icon/icons.data.ts +52 -0
- package/src/atoms/Input/Input.tsx +17 -9
- package/src/atoms/Input/preview.tsx +24 -25
- package/src/atoms/Menu/Menu.tsx +320 -0
- package/src/atoms/Menu/index.ts +2 -0
- package/src/atoms/Menu/preview.tsx +63 -0
- package/src/atoms/Modal/Modal.tsx +43 -37
- package/src/atoms/Modal/preview.tsx +13 -0
- package/src/atoms/NavItem/NavItem.tsx +33 -45
- package/src/atoms/NavItem/preview.tsx +21 -26
- package/src/atoms/PreviewToolbar/PreviewToolbar.tsx +144 -192
- package/src/atoms/PreviewToolbar/preview.tsx +24 -4
- package/src/atoms/PricingCard/PricingCard.tsx +164 -0
- package/src/atoms/PricingCard/index.ts +2 -0
- package/src/atoms/PricingCard/preview.tsx +45 -0
- package/src/atoms/PricingPageTemplate/PricingPageTemplate.tsx +219 -0
- package/src/atoms/PricingPageTemplate/index.ts +2 -0
- package/src/atoms/PricingPageTemplate/preview.tsx +10 -0
- package/src/atoms/PromptInputBar/PromptInputBar.tsx +117 -158
- package/src/atoms/WorkspaceMenu/WorkspaceMenu.tsx +41 -167
- package/src/index.ts +10 -0
- package/src/tokens.css +5 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Button } from "../Button";
|
|
3
|
+
import { Icon } from "../Icon";
|
|
3
4
|
|
|
4
5
|
export interface NavItemShortcut {
|
|
5
6
|
/** E.g. "⌘" */
|
|
@@ -47,41 +48,15 @@ export interface NavItemProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
47
48
|
* Does NOT affect the parent NavItem's own `active` state.
|
|
48
49
|
*/
|
|
49
50
|
activeSubId?: string;
|
|
51
|
+
/**
|
|
52
|
+
* When true, this nav group always shows its sub-items/children expanded,
|
|
53
|
+
* regardless of the `expanded` prop, and hides the chevron affordance
|
|
54
|
+
* entirely (there is nothing to fold/unfold). Clicking the item still
|
|
55
|
+
* fires `onClick`, but `onExpandToggle` is never called. Defaults to false.
|
|
56
|
+
*/
|
|
57
|
+
alwaysExpanded?: boolean;
|
|
50
58
|
}
|
|
51
59
|
|
|
52
|
-
const ChevronDownIcon = () => (
|
|
53
|
-
<svg
|
|
54
|
-
viewBox="0 0 24 24"
|
|
55
|
-
fill="none"
|
|
56
|
-
stroke="currentColor"
|
|
57
|
-
strokeWidth="2"
|
|
58
|
-
strokeLinecap="round"
|
|
59
|
-
strokeLinejoin="round"
|
|
60
|
-
aria-hidden="true"
|
|
61
|
-
style={{ width: "14px", height: "14px", flexShrink: 0 }}
|
|
62
|
-
>
|
|
63
|
-
<polyline points="6 9 12 15 18 9" />
|
|
64
|
-
</svg>
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
const TrashIcon = () => (
|
|
68
|
-
<svg
|
|
69
|
-
viewBox="0 0 24 24"
|
|
70
|
-
fill="none"
|
|
71
|
-
stroke="currentColor"
|
|
72
|
-
strokeWidth="1.75"
|
|
73
|
-
strokeLinecap="round"
|
|
74
|
-
strokeLinejoin="round"
|
|
75
|
-
aria-hidden="true"
|
|
76
|
-
style={{ width: "14px", height: "14px", flexShrink: 0 }}
|
|
77
|
-
>
|
|
78
|
-
<polyline points="3 6 5 6 21 6" />
|
|
79
|
-
<path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6" />
|
|
80
|
-
<path d="M10 11v6M14 11v6" />
|
|
81
|
-
<path d="M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2" />
|
|
82
|
-
</svg>
|
|
83
|
-
);
|
|
84
|
-
|
|
85
60
|
interface SubItemRowProps {
|
|
86
61
|
item: NavItemSubItem;
|
|
87
62
|
isActive?: boolean;
|
|
@@ -141,7 +116,7 @@ const SubItemRow = ({ item, isActive = false }: SubItemRowProps) => {
|
|
|
141
116
|
].join(" ")}
|
|
142
117
|
tabIndex={hovered ? 0 : -1}
|
|
143
118
|
>
|
|
144
|
-
<
|
|
119
|
+
<Icon name="trash-delete" style={{ width: "14px", height: "14px" }} />
|
|
145
120
|
</Button>
|
|
146
121
|
)}
|
|
147
122
|
</li>
|
|
@@ -162,6 +137,7 @@ export const NavItem = React.forwardRef<HTMLLIElement, NavItemProps>(
|
|
|
162
137
|
iconOnly = false,
|
|
163
138
|
onClick,
|
|
164
139
|
activeSubId,
|
|
140
|
+
alwaysExpanded = false,
|
|
165
141
|
className,
|
|
166
142
|
...rest
|
|
167
143
|
},
|
|
@@ -170,13 +146,23 @@ export const NavItem = React.forwardRef<HTMLLIElement, NavItemProps>(
|
|
|
170
146
|
const hasSubItems = subItems && subItems.length > 0;
|
|
171
147
|
const hasChildren = React.Children.count(children) > 0;
|
|
172
148
|
const isExpandable = hasSubItems || hasChildren;
|
|
149
|
+
const effectiveExpanded = alwaysExpanded ? true : expanded;
|
|
173
150
|
const contentRef = React.useRef<HTMLDivElement>(null);
|
|
174
|
-
const [mounted, setMounted] = React.useState(Boolean(
|
|
175
|
-
const [visible, setVisible] = React.useState(Boolean(
|
|
151
|
+
const [mounted, setMounted] = React.useState(Boolean(effectiveExpanded));
|
|
152
|
+
const [visible, setVisible] = React.useState(Boolean(effectiveExpanded));
|
|
176
153
|
const [contentHeight, setContentHeight] = React.useState(0);
|
|
177
154
|
|
|
155
|
+
// The vertical guide line on the nested <ul> must sit exactly on the
|
|
156
|
+
// parent icon's horizontal center. The parent Button uses !px-sm
|
|
157
|
+
// (spacing.sm) and the icon box is 18px wide, so the icon center sits
|
|
158
|
+
// spacing.sm + 9px from the NavItem's left edge.
|
|
159
|
+
const treeGuideStyle: React.CSSProperties = {
|
|
160
|
+
marginLeft: "calc(var(--spacing-sm) + 9px)",
|
|
161
|
+
paddingLeft: "var(--spacing-sm)",
|
|
162
|
+
};
|
|
163
|
+
|
|
178
164
|
React.useEffect(() => {
|
|
179
|
-
if (
|
|
165
|
+
if (effectiveExpanded) {
|
|
180
166
|
setMounted(true);
|
|
181
167
|
const raf = requestAnimationFrame(() => {
|
|
182
168
|
if (contentRef.current) {
|
|
@@ -193,7 +179,7 @@ export const NavItem = React.forwardRef<HTMLLIElement, NavItemProps>(
|
|
|
193
179
|
setVisible(false);
|
|
194
180
|
const timer = window.setTimeout(() => setMounted(false), 220);
|
|
195
181
|
return () => window.clearTimeout(timer);
|
|
196
|
-
}, [
|
|
182
|
+
}, [effectiveExpanded, subItems, children]);
|
|
197
183
|
|
|
198
184
|
React.useEffect(() => {
|
|
199
185
|
if (!mounted || !contentRef.current) return;
|
|
@@ -208,7 +194,7 @@ export const NavItem = React.forwardRef<HTMLLIElement, NavItemProps>(
|
|
|
208
194
|
}, [mounted, subItems, children]);
|
|
209
195
|
|
|
210
196
|
const handleClick: React.MouseEventHandler<HTMLButtonElement> = (e) => {
|
|
211
|
-
if (isExpandable && onExpandToggle) {
|
|
197
|
+
if (isExpandable && onExpandToggle && !alwaysExpanded) {
|
|
212
198
|
onExpandToggle();
|
|
213
199
|
}
|
|
214
200
|
onClick?.(e);
|
|
@@ -224,7 +210,7 @@ export const NavItem = React.forwardRef<HTMLLIElement, NavItemProps>(
|
|
|
224
210
|
variant="ghost"
|
|
225
211
|
size="sm"
|
|
226
212
|
aria-current={active ? "page" : undefined}
|
|
227
|
-
aria-expanded={isExpandable ?
|
|
213
|
+
aria-expanded={isExpandable ? effectiveExpanded : undefined}
|
|
228
214
|
aria-label={iconOnly ? label : undefined}
|
|
229
215
|
title={iconOnly ? label : undefined}
|
|
230
216
|
onClick={handleClick}
|
|
@@ -286,15 +272,15 @@ export const NavItem = React.forwardRef<HTMLLIElement, NavItemProps>(
|
|
|
286
272
|
</span>
|
|
287
273
|
)}
|
|
288
274
|
|
|
289
|
-
{!iconOnly && isExpandable && (
|
|
275
|
+
{!iconOnly && isExpandable && !alwaysExpanded && (
|
|
290
276
|
<span
|
|
291
277
|
aria-hidden="true"
|
|
292
278
|
className={[
|
|
293
279
|
"ml-auto text-muted transition-transform duration-200 ease-in-out",
|
|
294
|
-
|
|
280
|
+
effectiveExpanded ? "rotate-180" : "rotate-0",
|
|
295
281
|
].join(" ")}
|
|
296
282
|
>
|
|
297
|
-
<
|
|
283
|
+
<Icon name="chevron-down" style={{ width: "14px", height: "14px" }} />
|
|
298
284
|
</span>
|
|
299
285
|
)}
|
|
300
286
|
</Button>
|
|
@@ -312,8 +298,9 @@ export const NavItem = React.forwardRef<HTMLLIElement, NavItemProps>(
|
|
|
312
298
|
<div ref={contentRef}>
|
|
313
299
|
{hasSubItems && (
|
|
314
300
|
<ul
|
|
315
|
-
className="
|
|
301
|
+
className="border-l border-hairline-soft space-y-xxs"
|
|
316
302
|
role="list"
|
|
303
|
+
style={treeGuideStyle}
|
|
317
304
|
>
|
|
318
305
|
{subItems!.map((item) => (
|
|
319
306
|
<SubItemRow
|
|
@@ -327,8 +314,9 @@ export const NavItem = React.forwardRef<HTMLLIElement, NavItemProps>(
|
|
|
327
314
|
|
|
328
315
|
{hasChildren && (
|
|
329
316
|
<ul
|
|
330
|
-
className="
|
|
317
|
+
className="border-l border-hairline-soft space-y-xxs"
|
|
331
318
|
role="list"
|
|
319
|
+
style={treeGuideStyle}
|
|
332
320
|
>
|
|
333
321
|
{children}
|
|
334
322
|
</ul>
|
|
@@ -1,32 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { NavItem } from "./NavItem";
|
|
3
|
+
import { Icon } from "../Icon";
|
|
3
4
|
|
|
4
|
-
const HomeIcon =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
</svg>
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
const SearchIcon = (
|
|
12
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" style={{ width: "18px", height: "18px" }}>
|
|
13
|
-
<circle cx="11" cy="11" r="8" />
|
|
14
|
-
<line x1="21" y1="21" x2="16.65" y2="16.65" />
|
|
15
|
-
</svg>
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
const FolderIcon = (
|
|
19
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" style={{ width: "18px", height: "18px" }}>
|
|
20
|
-
<path d="M3 7a2 2 0 0 1 2-2h3.93a2 2 0 0 1 1.66.9l.82 1.2A2 2 0 0 0 13.07 8H19a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z" />
|
|
21
|
-
</svg>
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
const SettingsIcon = (
|
|
25
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" style={{ width: "18px", height: "18px" }}>
|
|
26
|
-
<circle cx="12" cy="12" r="3" />
|
|
27
|
-
<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z" />
|
|
28
|
-
</svg>
|
|
29
|
-
);
|
|
5
|
+
const HomeIcon = <Icon name="home" style={{ width: "18px", height: "18px" }} />;
|
|
6
|
+
const SearchIcon = <Icon name="search-magnifier" style={{ width: "18px", height: "18px" }} />;
|
|
7
|
+
const FolderIcon = <Icon name="folder" style={{ width: "18px", height: "18px" }} />;
|
|
8
|
+
const SettingsIcon = <Icon name="settings-gear" style={{ width: "18px", height: "18px" }} />;
|
|
30
9
|
|
|
31
10
|
export default function NavItemPreview() {
|
|
32
11
|
const [projectsExpanded, setProjectsExpanded] = React.useState(true);
|
|
@@ -105,6 +84,22 @@ export default function NavItemPreview() {
|
|
|
105
84
|
</ul>
|
|
106
85
|
</div>
|
|
107
86
|
|
|
87
|
+
{/* Always-expanded group — no chevron, cannot be folded */}
|
|
88
|
+
<div>
|
|
89
|
+
<p className="text-caption text-muted mb-sm">Always-expanded group (alwaysExpanded — no chevron, stays open)</p>
|
|
90
|
+
<ul className="space-y-xxs w-64">
|
|
91
|
+
<NavItem
|
|
92
|
+
icon={FolderIcon}
|
|
93
|
+
label="Workspaces"
|
|
94
|
+
alwaysExpanded
|
|
95
|
+
subItems={[
|
|
96
|
+
{ id: "w1", label: "Marketing" },
|
|
97
|
+
{ id: "w2", label: "Engineering" },
|
|
98
|
+
]}
|
|
99
|
+
/>
|
|
100
|
+
</ul>
|
|
101
|
+
</div>
|
|
102
|
+
|
|
108
103
|
{/* Collapsed group */}
|
|
109
104
|
<div>
|
|
110
105
|
<p className="text-caption text-muted mb-sm">Collapsed group</p>
|
|
@@ -1,76 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Button } from "../Button";
|
|
3
3
|
import { Chip } from "../Chip";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const DesktopIcon = () => (
|
|
8
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
9
|
-
<rect x="2" y="3" width="20" height="14" rx="2" />
|
|
10
|
-
<path d="M8 21h8M12 17v4" />
|
|
11
|
-
</svg>
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
const MobileIcon = () => (
|
|
15
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
16
|
-
<rect x="5" y="2" width="14" height="20" rx="2" />
|
|
17
|
-
<circle cx="12" cy="17" r="1" fill="currentColor" stroke="none" />
|
|
18
|
-
</svg>
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const ExpandIcon = () => (
|
|
22
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
23
|
-
<path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7" />
|
|
24
|
-
</svg>
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
/** Circular cursor pointer icon (matching the reference's "inspect" icon) */
|
|
28
|
-
const InspectIcon = () => (
|
|
29
|
-
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
30
|
-
<circle cx="12" cy="12" r="9" />
|
|
31
|
-
<path d="M12 8v4l3 3" />
|
|
32
|
-
<circle cx="12" cy="12" r="1" fill="currentColor" stroke="none" />
|
|
33
|
-
</svg>
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
const MoonIcon = () => (
|
|
37
|
-
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
38
|
-
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" />
|
|
39
|
-
</svg>
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
const FullscreenIcon = () => (
|
|
43
|
-
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
44
|
-
<polyline points="15 3 21 3 21 9" />
|
|
45
|
-
<polyline points="9 21 3 21 3 15" />
|
|
46
|
-
<line x1="21" y1="3" x2="14" y2="10" />
|
|
47
|
-
<line x1="3" y1="21" x2="10" y2="14" />
|
|
48
|
-
</svg>
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
const DotsIcon = () => (
|
|
52
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" stroke="none" aria-hidden="true">
|
|
53
|
-
<circle cx="12" cy="5" r="1.6" />
|
|
54
|
-
<circle cx="12" cy="12" r="1.6" />
|
|
55
|
-
<circle cx="12" cy="19" r="1.6" />
|
|
56
|
-
</svg>
|
|
57
|
-
);
|
|
4
|
+
import { Icon } from "../Icon";
|
|
5
|
+
import { FilterTabBar, type FilterTab } from "../FilterTabBar";
|
|
6
|
+
import { Menu, type MenuItem } from "../Menu";
|
|
58
7
|
|
|
59
8
|
// ─── Types ─────────────────────────────────────────────────────────────────────
|
|
60
9
|
|
|
61
10
|
export type Viewport = "desktop" | "mobile";
|
|
62
11
|
|
|
63
|
-
interface ViewportOption {
|
|
64
|
-
id: Viewport;
|
|
65
|
-
Icon: React.FC;
|
|
66
|
-
label: string;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const VIEWPORT_OPTIONS: ViewportOption[] = [
|
|
70
|
-
{ id: "desktop", Icon: DesktopIcon, label: "Desktop view" },
|
|
71
|
-
{ id: "mobile", Icon: MobileIcon, label: "Mobile view" },
|
|
72
|
-
];
|
|
73
|
-
|
|
74
12
|
// ─── Props ─────────────────────────────────────────────────────────────────────
|
|
75
13
|
|
|
76
14
|
export interface PreviewToolbarProps {
|
|
@@ -90,8 +28,8 @@ export interface PreviewToolbarProps {
|
|
|
90
28
|
onFullscreen?: () => void;
|
|
91
29
|
onExpand?: () => void;
|
|
92
30
|
/**
|
|
93
|
-
* When true, the expand/arrows button renders
|
|
94
|
-
*
|
|
31
|
+
* When true, the expand/arrows button renders as the selected tab in the
|
|
32
|
+
* viewport cluster. None of the desktop/mobile buttons appear active while
|
|
95
33
|
* expanded is true — only one selection indicator is shown at a time.
|
|
96
34
|
*/
|
|
97
35
|
expanded?: boolean;
|
|
@@ -99,32 +37,23 @@ export interface PreviewToolbarProps {
|
|
|
99
37
|
modelLabel?: string;
|
|
100
38
|
/** Component kind shown as a chip, e.g. "ATOM" */
|
|
101
39
|
kindLabel?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Legacy overflow handler — fired when the 3-dots button is clicked.
|
|
42
|
+
* Ignored when `overflowItems` is provided (the button renders a real
|
|
43
|
+
* Menu instead). Kept for backwards compatibility with consumers that
|
|
44
|
+
* roll their own dropdown off this callback.
|
|
45
|
+
*/
|
|
102
46
|
onOverflow?: () => void;
|
|
47
|
+
/**
|
|
48
|
+
* When provided and non-empty, the overflow control renders as a Menu
|
|
49
|
+
* anchored to the trigger (right-aligned) instead of a bare button, so
|
|
50
|
+
* actions like a destructive "Delete" render as a real dropdown list.
|
|
51
|
+
* Takes precedence over `onOverflow`.
|
|
52
|
+
*/
|
|
53
|
+
overflowItems?: MenuItem[];
|
|
103
54
|
className?: string;
|
|
104
55
|
}
|
|
105
56
|
|
|
106
|
-
// ─── Viewport button — tight icon-only toggle not coverable by Button variants ─
|
|
107
|
-
|
|
108
|
-
interface VpBtnProps {
|
|
109
|
-
label: string;
|
|
110
|
-
active: boolean;
|
|
111
|
-
onClick: () => void;
|
|
112
|
-
children: React.ReactNode;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const ViewportBtn: React.FC<VpBtnProps> = ({ label, active, onClick, children }) => (
|
|
116
|
-
<Button
|
|
117
|
-
variant={active ? "primary" : "ghost"}
|
|
118
|
-
size="sm"
|
|
119
|
-
aria-label={label}
|
|
120
|
-
aria-pressed={active}
|
|
121
|
-
onClick={onClick}
|
|
122
|
-
className={["!w-8 !h-8 !p-0 rounded-sm shrink-0", active ? "" : "text-muted"].join(" ")}
|
|
123
|
-
>
|
|
124
|
-
{children}
|
|
125
|
-
</Button>
|
|
126
|
-
);
|
|
127
|
-
|
|
128
57
|
// ─── Main ──────────────────────────────────────────────────────────────────────
|
|
129
58
|
|
|
130
59
|
export const PreviewToolbar = React.forwardRef<HTMLDivElement, PreviewToolbarProps>(
|
|
@@ -142,118 +71,141 @@ export const PreviewToolbar = React.forwardRef<HTMLDivElement, PreviewToolbarPro
|
|
|
142
71
|
modelLabel = "Sonnet 4.6",
|
|
143
72
|
kindLabel = "ATOM",
|
|
144
73
|
onOverflow,
|
|
74
|
+
overflowItems,
|
|
145
75
|
className = "",
|
|
146
76
|
},
|
|
147
77
|
ref,
|
|
148
|
-
) =>
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
78
|
+
) => {
|
|
79
|
+
// Selection mapping: expand wins when active, otherwise the current viewport.
|
|
80
|
+
const selectedValue = expanded ? "expand" : viewport;
|
|
81
|
+
|
|
82
|
+
const viewportTabs: FilterTab[] = [
|
|
83
|
+
{ value: "desktop", icon: <Icon name="desktop-monitor" size={14} /> },
|
|
84
|
+
{ value: "mobile", icon: <Icon name="mobile-phone" size={14} /> },
|
|
85
|
+
{ value: "expand", icon: <Icon name="expand-diagonal-arrows" size={14} /> },
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
const handleViewportTabChange = (val: string) => {
|
|
89
|
+
if (val === "expand") {
|
|
90
|
+
onExpand?.();
|
|
91
|
+
} else {
|
|
92
|
+
onViewportChange?.(val as Viewport);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const overflowTrigger = (
|
|
97
|
+
<Button
|
|
98
|
+
variant="ghost"
|
|
99
|
+
size="sm"
|
|
100
|
+
aria-label="More options"
|
|
101
|
+
className="!w-8 !h-8 !p-0 rounded-sm text-muted shrink-0"
|
|
166
102
|
>
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
label={label}
|
|
171
|
-
active={!expanded && viewport === id}
|
|
172
|
-
onClick={() => onViewportChange?.(id)}
|
|
173
|
-
>
|
|
174
|
-
<Icon />
|
|
175
|
-
</ViewportBtn>
|
|
176
|
-
))}
|
|
177
|
-
|
|
178
|
-
<Button
|
|
179
|
-
variant={expanded ? "primary" : "ghost"}
|
|
180
|
-
size="sm"
|
|
181
|
-
aria-label="Expand preview"
|
|
182
|
-
aria-pressed={expanded}
|
|
183
|
-
onClick={onExpand}
|
|
184
|
-
className={[
|
|
185
|
-
"!w-8 !h-8 !p-0 rounded-sm shrink-0",
|
|
186
|
-
expanded ? "" : "text-muted",
|
|
187
|
-
].join(" ")}
|
|
188
|
-
>
|
|
189
|
-
<ExpandIcon />
|
|
190
|
-
</Button>
|
|
191
|
-
</div>
|
|
192
|
-
|
|
193
|
-
{/* ── Action buttons — wrap as a group below viewport row on mobile ── */}
|
|
194
|
-
<div className="flex flex-wrap items-center gap-sm">
|
|
195
|
-
{/* ── Inspect tokens button — variant and label driven by `inspecting` prop ── */}
|
|
196
|
-
<Button
|
|
197
|
-
variant={inspecting ? "primary" : "secondary"}
|
|
198
|
-
size="sm"
|
|
199
|
-
aria-pressed={inspecting}
|
|
200
|
-
onClick={onInspectTokens}
|
|
201
|
-
className="gap-xs rounded-xl"
|
|
202
|
-
>
|
|
203
|
-
<InspectIcon />
|
|
204
|
-
{inspecting ? "Exit inspect" : "Inspect tokens"}
|
|
205
|
-
</Button>
|
|
206
|
-
|
|
207
|
-
<Button
|
|
208
|
-
variant={darkMode ? "primary" : "secondary"}
|
|
209
|
-
size="sm"
|
|
210
|
-
aria-pressed={darkMode}
|
|
211
|
-
onClick={onDarkToggle}
|
|
212
|
-
className="gap-xs rounded-xl"
|
|
213
|
-
>
|
|
214
|
-
<MoonIcon />
|
|
215
|
-
Dark
|
|
216
|
-
</Button>
|
|
103
|
+
<Icon name="more-options-vertical-dots" size={16} />
|
|
104
|
+
</Button>
|
|
105
|
+
);
|
|
217
106
|
|
|
218
|
-
|
|
219
|
-
variant="secondary"
|
|
220
|
-
size="sm"
|
|
221
|
-
onClick={onFullscreen}
|
|
222
|
-
className="gap-xs rounded-xl"
|
|
223
|
-
>
|
|
224
|
-
<FullscreenIcon />
|
|
225
|
-
Fullscreen
|
|
226
|
-
</Button>
|
|
227
|
-
|
|
228
|
-
{/* ── Model chip (outlined primary style) ── */}
|
|
229
|
-
<Chip
|
|
230
|
-
label={modelLabel ?? ""}
|
|
231
|
-
variant="default"
|
|
232
|
-
size="md"
|
|
233
|
-
className="border-primary text-primary bg-canvas cursor-default select-none"
|
|
234
|
-
/>
|
|
107
|
+
const hasOverflowItems = !!overflowItems && overflowItems.length > 0;
|
|
235
108
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
109
|
+
return (
|
|
110
|
+
<div
|
|
111
|
+
ref={ref}
|
|
112
|
+
role="toolbar"
|
|
113
|
+
aria-label="Preview toolbar"
|
|
114
|
+
className={[
|
|
115
|
+
// On mobile: flex column direction with wrapping rows; on md+: single inline-flex row
|
|
116
|
+
"flex flex-wrap items-center gap-sm px-sm py-xs",
|
|
117
|
+
"md:inline-flex md:flex-nowrap",
|
|
118
|
+
"bg-canvas border border-hairline rounded-xl shadow-md",
|
|
119
|
+
className,
|
|
120
|
+
].filter(Boolean).join(" ")}
|
|
121
|
+
>
|
|
122
|
+
{/* ── Viewport toggles — reuses FilterTabBar's icon-only compact chrome ── */}
|
|
123
|
+
<FilterTabBar
|
|
124
|
+
tabs={viewportTabs}
|
|
125
|
+
value={selectedValue}
|
|
126
|
+
onChange={handleViewportTabChange}
|
|
127
|
+
aria-label="Viewport size"
|
|
128
|
+
className="w-full md:w-auto shadow-none"
|
|
242
129
|
/>
|
|
243
130
|
|
|
244
|
-
{/* ──
|
|
245
|
-
<
|
|
246
|
-
variant
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
131
|
+
{/* ── Action buttons — wrap as a group below viewport row on mobile ── */}
|
|
132
|
+
<div className="flex flex-wrap items-center gap-sm">
|
|
133
|
+
{/* ── Inspect tokens button — variant and label driven by `inspecting` prop ── */}
|
|
134
|
+
<Button
|
|
135
|
+
variant={inspecting ? "primary" : "secondary"}
|
|
136
|
+
size="sm"
|
|
137
|
+
aria-pressed={inspecting}
|
|
138
|
+
onClick={onInspectTokens}
|
|
139
|
+
className="gap-xs rounded-xl"
|
|
140
|
+
>
|
|
141
|
+
<Icon name="inspect-target-crosshair" size={15} />
|
|
142
|
+
{inspecting ? "Exit inspect" : "Inspect tokens"}
|
|
143
|
+
</Button>
|
|
144
|
+
|
|
145
|
+
<Button
|
|
146
|
+
variant={darkMode ? "primary" : "secondary"}
|
|
147
|
+
size="sm"
|
|
148
|
+
aria-pressed={darkMode}
|
|
149
|
+
onClick={onDarkToggle}
|
|
150
|
+
className="gap-xs rounded-xl"
|
|
151
|
+
>
|
|
152
|
+
<Icon name="moon-dark-mode" size={15} />
|
|
153
|
+
Dark
|
|
154
|
+
</Button>
|
|
155
|
+
|
|
156
|
+
<Button
|
|
157
|
+
variant="secondary"
|
|
158
|
+
size="sm"
|
|
159
|
+
onClick={onFullscreen}
|
|
160
|
+
className="gap-xs rounded-xl"
|
|
161
|
+
>
|
|
162
|
+
<Icon name="fullscreen-corners-expand" size={15} />
|
|
163
|
+
Fullscreen
|
|
164
|
+
</Button>
|
|
165
|
+
|
|
166
|
+
{/* ── Model chip (outlined primary style) ── */}
|
|
167
|
+
<Chip
|
|
168
|
+
label={modelLabel ?? ""}
|
|
169
|
+
variant="default"
|
|
170
|
+
size="md"
|
|
171
|
+
className="border-primary text-primary bg-canvas cursor-default select-none"
|
|
172
|
+
/>
|
|
173
|
+
|
|
174
|
+
{/* ── Kind chip (filled soft primary) ── */}
|
|
175
|
+
<Chip
|
|
176
|
+
label={kindLabel ?? ""}
|
|
177
|
+
variant="default"
|
|
178
|
+
size="md"
|
|
179
|
+
className="bg-primary-disabled border-primary-disabled text-primary cursor-default select-none"
|
|
180
|
+
/>
|
|
181
|
+
|
|
182
|
+
{/* ── Overflow — renders as a Menu when overflowItems is supplied, ── */}
|
|
183
|
+
{/* falls back to the legacy bare-button onOverflow callback, and ── */}
|
|
184
|
+
{/* is hidden entirely when neither is provided. Portal mode keeps ── */}
|
|
185
|
+
{/* the dropdown from clipping inside overflow-hidden panel headers. ── */}
|
|
186
|
+
{hasOverflowItems ? (
|
|
187
|
+
<Menu
|
|
188
|
+
items={overflowItems as MenuItem[]}
|
|
189
|
+
align="right"
|
|
190
|
+
portal={true}
|
|
191
|
+
aria-label="More options"
|
|
192
|
+
trigger={overflowTrigger}
|
|
193
|
+
/>
|
|
194
|
+
) : onOverflow ? (
|
|
195
|
+
<Button
|
|
196
|
+
variant="ghost"
|
|
197
|
+
size="sm"
|
|
198
|
+
aria-label="More options"
|
|
199
|
+
onClick={onOverflow}
|
|
200
|
+
className="!w-8 !h-8 !p-0 rounded-sm text-muted shrink-0"
|
|
201
|
+
>
|
|
202
|
+
<Icon name="more-options-vertical-dots" size={16} />
|
|
203
|
+
</Button>
|
|
204
|
+
) : null}
|
|
205
|
+
</div>
|
|
254
206
|
</div>
|
|
255
|
-
|
|
256
|
-
|
|
207
|
+
);
|
|
208
|
+
},
|
|
257
209
|
);
|
|
258
210
|
|
|
259
211
|
PreviewToolbar.displayName = "PreviewToolbar";
|