@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,6 +1,7 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import { FilterTabBar } from "./FilterTabBar";
|
|
3
3
|
import { Icon } from "../Icon";
|
|
4
|
+
import { Input } from "../Input";
|
|
4
5
|
|
|
5
6
|
const tabsWithCounts = [
|
|
6
7
|
{ value: "all", label: "All", count: 15 },
|
|
@@ -21,6 +22,7 @@ export default function FilterTabBarPreview() {
|
|
|
21
22
|
const [active3, setActive3] = useState("all");
|
|
22
23
|
const [active4, setActive4] = useState("all");
|
|
23
24
|
const [active5, setActive5] = useState("all");
|
|
25
|
+
const [view, setView] = useState("grid");
|
|
24
26
|
|
|
25
27
|
return (
|
|
26
28
|
<div className="w-full max-w-3xl mx-auto p-xl flex flex-col items-start gap-xl bg-canvas py-xxl">
|
|
@@ -77,6 +79,25 @@ export default function FilterTabBarPreview() {
|
|
|
77
79
|
onChange={setActive5}
|
|
78
80
|
/>
|
|
79
81
|
</div>
|
|
82
|
+
|
|
83
|
+
{/* size="sm" — icon-only view switcher sharing the same 32px edge as Input size="sm" */}
|
|
84
|
+
<div className="flex flex-col gap-sm w-full">
|
|
85
|
+
<p className="text-caption text-muted uppercase tracking-wide">
|
|
86
|
+
size="sm" (flush with Input size="sm")
|
|
87
|
+
</p>
|
|
88
|
+
<div className="flex items-center gap-sm w-full">
|
|
89
|
+
<Input size="sm" placeholder="Search components..." className="flex-1" />
|
|
90
|
+
<FilterTabBar
|
|
91
|
+
size="sm"
|
|
92
|
+
tabs={[
|
|
93
|
+
{ value: "grid", icon: <Icon name="grid" size={14} /> },
|
|
94
|
+
{ value: "list", icon: <Icon name="list-view" size={14} /> },
|
|
95
|
+
]}
|
|
96
|
+
value={view}
|
|
97
|
+
onChange={setView}
|
|
98
|
+
/>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
80
101
|
</div>
|
|
81
102
|
);
|
|
82
103
|
}
|
|
@@ -4,37 +4,9 @@ import type { NavEntry } from "../AppSidebar";
|
|
|
4
4
|
import { AppSidebarMobile } from "../AppSidebarMobile";
|
|
5
5
|
import { PromptInputBar } from "../PromptInputBar";
|
|
6
6
|
import { Button } from "../Button";
|
|
7
|
+
import { Icon } from "../Icon";
|
|
7
8
|
import type { PromptMode, PromptInputBarModel } from "../PromptInputBar";
|
|
8
9
|
|
|
9
|
-
/* ─── Icons ─────────────────────────────────────────────────────────────── */
|
|
10
|
-
|
|
11
|
-
const HomeIcon = () => (
|
|
12
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" style={{ width: "18px", height: "18px" }} aria-hidden="true">
|
|
13
|
-
<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" />
|
|
14
|
-
<polyline points="9 22 9 12 15 12 15 22" />
|
|
15
|
-
</svg>
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
const FolderIcon = () => (
|
|
19
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" style={{ width: "18px", height: "18px" }} aria-hidden="true">
|
|
20
|
-
<path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z" />
|
|
21
|
-
</svg>
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
const LogoIcon = () => (
|
|
25
|
-
<svg width="26" height="26" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
26
|
-
<path d="M12 36C12 36 8 28 16 22C20 19 26 20 26 20C26 20 22 26 18 30C16 32 12 36 12 36Z" style={{ fill: "var(--color-logo-orange)" }} />
|
|
27
|
-
<path d="M24 8C24 8 36 12 36 24C36 30 32 36 26 38C26 38 28 30 26 24C25 20 24 8 24 8Z" style={{ fill: "var(--color-logo-violet)" }} />
|
|
28
|
-
<path d="M12 36C12 36 16 24 24 20C28 18 36 20 36 20C36 20 30 28 26 32C22 36 12 36 12 36Z" style={{ fill: "var(--color-logo-pink)", opacity: 0.7 }} />
|
|
29
|
-
</svg>
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
const SparkleIcon = () => (
|
|
33
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" style={{ width: "14px", height: "14px" }} aria-hidden="true">
|
|
34
|
-
<path d="M12 2l2.4 7.4H22l-6.2 4.5 2.4 7.4L12 17 5.8 21.3l2.4-7.4L2 9.4h7.6z" />
|
|
35
|
-
</svg>
|
|
36
|
-
);
|
|
37
|
-
|
|
38
10
|
/* ─── Suggestion Chip ────────────────────────────────────────────────────── */
|
|
39
11
|
interface SuggestionChipProps {
|
|
40
12
|
label: string;
|
|
@@ -69,6 +41,11 @@ export interface HomePageTemplateProps {
|
|
|
69
41
|
userName?: string;
|
|
70
42
|
/** User initials for the footer avatar */
|
|
71
43
|
userInitials?: string;
|
|
44
|
+
/**
|
|
45
|
+
* User's email address, shown as the header of the account menu that opens
|
|
46
|
+
* when the footer avatar is clicked. Forwarded to AppSidebar as `userEmail`.
|
|
47
|
+
*/
|
|
48
|
+
userEmail?: string;
|
|
72
49
|
/** Controlled prompt value */
|
|
73
50
|
promptValue?: string;
|
|
74
51
|
/** Called when prompt input changes */
|
|
@@ -112,6 +89,12 @@ export interface HomePageTemplateProps {
|
|
|
112
89
|
* Forwarded to both AppSidebar and AppSidebarMobile.
|
|
113
90
|
*/
|
|
114
91
|
onDarkModeToggle?: () => void;
|
|
92
|
+
/**
|
|
93
|
+
* Called when the user chooses "Logout" from the footer avatar menu.
|
|
94
|
+
* Forwarded to AppSidebar (desktop). AppSidebarMobile does not yet expose an
|
|
95
|
+
* onLogout prop, so it is not forwarded there.
|
|
96
|
+
*/
|
|
97
|
+
onLogout?: () => void;
|
|
115
98
|
/**
|
|
116
99
|
* List of available AI models forwarded to PromptInputBar.
|
|
117
100
|
* When omitted, the built-in DEFAULT_MODELS list is used.
|
|
@@ -139,11 +122,11 @@ export interface HomePageTemplateProps {
|
|
|
139
122
|
|
|
140
123
|
/* ─── Nav entries ────────────────────────────────────────────────────────── */
|
|
141
124
|
const NAV_ENTRIES: NavEntry[] = [
|
|
142
|
-
{ id: "home", label: "Home", icon: <
|
|
125
|
+
{ id: "home", label: "Home", icon: <Icon name="home" style={{ width: "18px", height: "18px" }} /> },
|
|
143
126
|
{
|
|
144
127
|
id: "projects",
|
|
145
128
|
label: "All projects",
|
|
146
|
-
icon: <
|
|
129
|
+
icon: <Icon name="folder" style={{ width: "18px", height: "18px" }} />,
|
|
147
130
|
subItems: [
|
|
148
131
|
{ id: "proj-1", label: "Design system" },
|
|
149
132
|
{ id: "proj-2", label: "Landing page" },
|
|
@@ -174,6 +157,7 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
|
|
|
174
157
|
{
|
|
175
158
|
userName = "Hello Designer",
|
|
176
159
|
userInitials = "N",
|
|
160
|
+
userEmail,
|
|
177
161
|
promptValue,
|
|
178
162
|
onPromptChange,
|
|
179
163
|
mode = "Build",
|
|
@@ -188,6 +172,7 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
|
|
|
188
172
|
onSubSelect,
|
|
189
173
|
darkMode,
|
|
190
174
|
onDarkModeToggle,
|
|
175
|
+
onLogout,
|
|
191
176
|
models,
|
|
192
177
|
selectedModelId,
|
|
193
178
|
onModelChange,
|
|
@@ -253,9 +238,11 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
|
|
|
253
238
|
showShareCard={true}
|
|
254
239
|
showUpgradeCard={true}
|
|
255
240
|
userInitials={userInitials}
|
|
241
|
+
userEmail={userEmail}
|
|
256
242
|
onInboxClick={() => {}}
|
|
257
243
|
darkMode={darkMode}
|
|
258
244
|
onDarkModeToggle={onDarkModeToggle}
|
|
245
|
+
onLogout={onLogout}
|
|
259
246
|
defaultExpandedIds={defaultExpandedIds}
|
|
260
247
|
style={{ height: "100%" }}
|
|
261
248
|
/>
|
|
@@ -291,7 +278,7 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
|
|
|
291
278
|
onDarkModeToggle={onDarkModeToggle}
|
|
292
279
|
/>
|
|
293
280
|
<div className="flex items-center gap-xs">
|
|
294
|
-
<
|
|
281
|
+
<Icon name="atom" style={{ width: "22px", height: "22px" }} />
|
|
295
282
|
<span className="text-body-sm font-weight-heading-sm text-ink">Atoms</span>
|
|
296
283
|
</div>
|
|
297
284
|
</div>
|
|
@@ -315,7 +302,7 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
|
|
|
315
302
|
aria-label="New design system"
|
|
316
303
|
className="!rounded-full flex items-center gap-xs"
|
|
317
304
|
>
|
|
318
|
-
<
|
|
305
|
+
<Icon name="sparkle" style={{ width: "14px", height: "14px" }} />
|
|
319
306
|
New design system
|
|
320
307
|
</Button>
|
|
321
308
|
|
|
@@ -5,8 +5,7 @@ export default function Preview() {
|
|
|
5
5
|
const [darkMode, setDarkMode] = React.useState(false);
|
|
6
6
|
|
|
7
7
|
return (
|
|
8
|
-
|
|
9
|
-
<div className="w-full" style={{ height: "100vh", overflow: "hidden" }}>
|
|
8
|
+
<div className="w-full" style={{ height: "640px", overflow: "hidden" }}>
|
|
10
9
|
<HomePageTemplate
|
|
11
10
|
userName="Hello Designer"
|
|
12
11
|
userInitials="N"
|
|
@@ -18,6 +17,7 @@ export default function Preview() {
|
|
|
18
17
|
]}
|
|
19
18
|
darkMode={darkMode}
|
|
20
19
|
onDarkModeToggle={() => setDarkMode((d) => !d)}
|
|
20
|
+
onLogout={() => window.alert("Logged out")}
|
|
21
21
|
style={{ width: "100%", height: "100%" }}
|
|
22
22
|
/>
|
|
23
23
|
</div>
|
package/src/atoms/Icon/Icon.tsx
CHANGED
|
@@ -10,17 +10,19 @@ export interface IconProps extends React.SVGProps<SVGSVGElement> {
|
|
|
10
10
|
export const Icon = React.forwardRef<SVGSVGElement, IconProps>(
|
|
11
11
|
({ name, size = 20, strokeWidth = 2, className, ...props }, ref) => {
|
|
12
12
|
const glyph = ICON_REGISTRY[name];
|
|
13
|
+
const isFill = "type" in glyph && glyph.type === "fill";
|
|
14
|
+
|
|
13
15
|
return (
|
|
14
16
|
<svg
|
|
15
17
|
ref={ref}
|
|
16
18
|
viewBox={glyph.viewBox}
|
|
17
19
|
width={size}
|
|
18
20
|
height={size}
|
|
19
|
-
fill="none"
|
|
20
|
-
stroke="currentColor"
|
|
21
|
-
strokeWidth={strokeWidth}
|
|
22
|
-
strokeLinecap="round"
|
|
23
|
-
strokeLinejoin="round"
|
|
21
|
+
fill={isFill ? "currentColor" : "none"}
|
|
22
|
+
stroke={isFill ? "none" : "currentColor"}
|
|
23
|
+
strokeWidth={isFill ? undefined : strokeWidth}
|
|
24
|
+
strokeLinecap={isFill ? undefined : "round"}
|
|
25
|
+
strokeLinejoin={isFill ? undefined : "round"}
|
|
24
26
|
className={className}
|
|
25
27
|
aria-hidden="true"
|
|
26
28
|
{...props}
|
|
@@ -8,6 +8,58 @@ export const ICON_REGISTRY = {
|
|
|
8
8
|
"layers": { viewBox: "0 0 24 24", paths: ["M12 3l8 4.5-8 4.5-8-4.5 8-4.5z", "M4 12l8 4.5 8-4.5", "M4 16.5l8 4.5 8-4.5"] },
|
|
9
9
|
"star": { viewBox: "0 0 24 24", paths: ["M12 3l2.6 5.6 6.1.7-4.5 4.2 1.2 6-5.4-3-5.4 3 1.2-6-4.5-4.2 6.1-.7L12 3z"] },
|
|
10
10
|
"archive": { viewBox: "0 0 24 24", paths: ["M3 4h18v4H3z", "M4.5 8v11a1 1 0 0 0 1 1h13a1 1 0 0 0 1-1V8", "M10 12.5h4"] },
|
|
11
|
+
"list-view": { viewBox: "0 0 24 24", paths: ["M4 6h16", "M4 12h16", "M4 18h16"] },
|
|
12
|
+
"google": { viewBox: "0 0 24 24", paths: ["M21.35 11.1h-9.17v2.98h5.27c-.23 1.4-1.6 4.1-5.27 4.1-3.17 0-5.76-2.62-5.76-5.86s2.59-5.86 5.76-5.86c1.8 0 3.01.77 3.7 1.43l2.52-2.43C16.95 3.61 14.68 2.6 12 2.6 6.98 2.6 2.9 6.7 2.9 11.72s4.08 9.12 9.1 9.12c5.25 0 8.73-3.69 8.73-8.89 0-.6-.06-1.05-.14-1.85z"] },
|
|
13
|
+
"pencil-edit": { viewBox: "0 0 24 24", paths: ["M12 20h9", "M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"] },
|
|
14
|
+
"trash-delete": { viewBox: "0 0 24 24", paths: ["M3 6h18", "M19 6l-1 14H6L5 6", "M10 11v6", "M14 11v6", "M9 6V4h6v2"] },
|
|
15
|
+
"desktop-monitor": { viewBox: "0 0 24 24", paths: ["M2 3h20v14H2z", "M8 21h8M12 17v4"] },
|
|
16
|
+
"mobile-phone": { viewBox: "0 0 24 24", paths: ["M5 2h14v20H5z", "M12 17h.01"] },
|
|
17
|
+
"expand-diagonal-arrows": { viewBox: "0 0 24 24", paths: ["M15 3h6v6", "M9 21H3v-6", "M21 3l-7 7", "M3 21l7-7"] },
|
|
18
|
+
"inspect-target-crosshair": { viewBox: "0 0 24 24", paths: ["M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0", "M12 8v4l3 3", "M12 12h.01"] },
|
|
19
|
+
"moon-dark-mode": { viewBox: "0 0 24 24", paths: ["M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"] },
|
|
20
|
+
"fullscreen-corners-expand": { viewBox: "0 0 24 24", paths: ["M15 3h6v6", "M9 21H3v-6", "M21 3l-7 7", "M3 21l7-7"] },
|
|
21
|
+
"more-options-vertical-dots": { viewBox: "0 0 24 24", paths: ["M12 5m-1.6 0a1.6 1.6 0 1 0 3.2 0a1.6 1.6 0 1 0 -3.2 0", "M12 12m-1.6 0a1.6 1.6 0 1 0 3.2 0a1.6 1.6 0 1 0 -3.2 0", "M12 19m-1.6 0a1.6 1.6 0 1 0 3.2 0a1.6 1.6 0 1 0 -3.2 0"] },
|
|
22
|
+
"logout-sign-out": { viewBox: "0 0 24 24", paths: ["M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4", "M16 17l5-5-5-5", "M21 12H9"] },
|
|
23
|
+
"gift-present": { viewBox: "0 0 24 24", paths: ["M20 12v10H4V12", "M2 7h20v5H2z", "M12 22V7", "M12 7H7.5a2.5 2.5 0 0 1 0-5C11 2 12 7 12 7z", "M12 7h4.5a2.5 2.5 0 0 0 0-5C13 2 12 7 12 7z"] },
|
|
24
|
+
"inbox-mail-tray": { viewBox: "0 0 24 24", paths: ["M22 12h-6l-2 3h-4l-2-3H2", "M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"] },
|
|
25
|
+
"sidebar-panel-toggle": { viewBox: "0 0 24 24", paths: ["M3 3h18v18H3z", "M9 3v18"] },
|
|
26
|
+
"sun-light-mode": { viewBox: "0 0 24 24", paths: ["M12 17a5 5 0 1 0 0-10 5 5 0 0 0 0 10z", "M12 1v2", "M12 21v2", "M4.22 4.22l1.42 1.42", "M18.36 18.36l1.42 1.42", "M1 12h2", "M21 12h2", "M4.22 19.78l1.42-1.42", "M18.36 5.64l1.42-1.42"] },
|
|
27
|
+
"home": { viewBox: "0 0 24 24", paths: ["M3 9.75L12 3l9 6.75V20a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V9.75z", "M9 21V12h6v9"] },
|
|
28
|
+
"search-magnifier": { viewBox: "0 0 24 24", paths: ["M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16z", "M21 21l-4.35-4.35"] },
|
|
29
|
+
"folder": { viewBox: "0 0 24 24", paths: ["M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"] },
|
|
30
|
+
"settings-gear": { viewBox: "0 0 24 24", paths: ["M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z", "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"] },
|
|
31
|
+
"file-document": { viewBox: "0 0 24 24", paths: ["M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z", "M14 2v6h6"] },
|
|
32
|
+
"sparkle": { viewBox: "0 0 24 24", paths: ["M12 2l2.4 7.4H22l-6.2 4.5 2.4 7.4L12 17 5.8 21.3l2.4-7.4L2 9.4h7.6z"] },
|
|
33
|
+
"lock-padlock": { viewBox: "0 0 24 24", paths: ["M6 11V8a6 6 0 1112 0v3", "M5 11h14a1 1 0 011 1v8a2 2 0 01-2 2H6a2 2 0 01-2-2v-8a1 1 0 011-1z"] },
|
|
34
|
+
"eye-show-password": { viewBox: "0 0 24 24", paths: ["M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z", "M12 15a3 3 0 100-6 3 3 0 000 6z"] },
|
|
35
|
+
"eye-off-hide-password": { viewBox: "0 0 24 24", paths: ["M3 3l18 18", "M10.58 10.58a3 3 0 004.24 4.24", "M9.88 5.09A9.77 9.77 0 0112 5c6.5 0 10 7 10 7a17.3 17.3 0 01-3.16 4.19M6.5 6.61C4.13 8.14 2 12 2 12a17.19 17.19 0 004.06 5.06A9.77 9.77 0 0012 19c1 0 1.96-.14 2.85-.4"] },
|
|
36
|
+
"loading-spinner": { viewBox: "0 0 24 24", paths: ["M12 3v3", "M12 18v3", "M5.636 5.636l2.121 2.121", "M16.243 16.243l2.121 2.121", "M3 12h3", "M18 12h3", "M5.636 18.364l2.121-2.121", "M16.243 7.757l2.121-2.121"] },
|
|
37
|
+
"hamburger-menu": { viewBox: "0 0 24 24", paths: ["M3 6h18", "M3 12h18", "M3 18h18"] },
|
|
38
|
+
"plus-add": { viewBox: "0 0 24 24", paths: ["M12 5v14", "M5 12h14"] },
|
|
39
|
+
"visual-edits-swap-arrows": { viewBox: "0 0 24 24", paths: ["M17 1l4 4-4 4", "M3 11V9a4 4 0 0 1 4-4h14", "M7 23l-4-4 4-4", "M21 13v2a4 4 0 0 1-4 4H3"] },
|
|
40
|
+
"microphone": {
|
|
41
|
+
viewBox: "-3 0 19 19",
|
|
42
|
+
type: "fill",
|
|
43
|
+
paths: [
|
|
44
|
+
"M11.665 7.915v1.31a5.257 5.257 0 0 1-1.514 3.694 5.174 5.174 0 0 1-1.641 1.126 5.04 5.04 0 0 1-1.456.384v1.899h2.312a.554.554 0 0 1 0 1.108H3.634a.554.554 0 0 1 0-1.108h2.312v-1.899a5.045 5.045 0 0 1-1.456-.384 5.174 5.174 0 0 1-1.641-1.126 5.257 5.257 0 0 1-1.514-3.695v-1.31a.554.554 0 1 1 1.109 0v1.31a4.131 4.131 0 0 0 1.195 2.917 3.989 3.989 0 0 0 5.722 0 4.133 4.133 0 0 0 1.195-2.917v-1.31a.554.554 0 1 1 1.109 0zM3.77 10.37a2.875 2.875 0 0 1-.233-1.146V4.738A2.905 2.905 0 0 1 3.77 3.58a3 3 0 0 1 1.59-1.59 2.902 2.902 0 0 1 1.158-.233 2.865 2.865 0 0 1 1.152.233 2.977 2.977 0 0 1 1.793 2.748l-.012 4.487a2.958 2.958 0 0 1-.856 2.09 3.025 3.025 0 0 1-.937.634 2.865 2.865 0 0 1-1.152.233 2.905 2.905 0 0 1-1.158-.233A2.957 2.957 0 0 1 3.77 10.37z",
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
"stop-square": { viewBox: "0 0 24 24", paths: ["M5 5h14v14H5z"] },
|
|
48
|
+
"arrow-up-send": { viewBox: "0 0 24 24", paths: ["M12 19V5", "M5 12l7-7 7 7"] },
|
|
49
|
+
"clock-thinking": { viewBox: "0 0 24 24", paths: ["M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z", "M12 8v4l2 2"] },
|
|
50
|
+
"read-open-book-document": { viewBox: "0 0 24 24", paths: ["M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z", "M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"] },
|
|
51
|
+
"wrench-tool": { viewBox: "0 0 24 24", paths: ["M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"] },
|
|
52
|
+
"two-people-users-group": { viewBox: "0 0 24 24", paths: ["M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2", "M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8z", "M23 21v-2a4 4 0 0 0-3-3.87", "M16 3.13a4 4 0 0 1 0 7.75"] },
|
|
53
|
+
"soft-organic-blob-decorative-background-": { viewBox: "0 0 160 140", paths: ["M78 8c28-6 52 10 58 34 6 24-6 44-4 62 2 16-14 30-36 32-26 2-48-8-62-28-12-18-22-42-10-58C36 30 52 14 78 8z"] },
|
|
54
|
+
"help-question-circle": { viewBox: "0 0 24 24", paths: ["M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0", "M9.5 9a2.5 2.5 0 0 1 4.6-1.35c.4.66.4 1.5-.1 2.1-.6.75-1.5 1-1.9 1.75-.2.35-.1.9-.1.9", "M12 17h.01"] },
|
|
55
|
+
"external-link-arrow-up-right": { viewBox: "0 0 24 24", paths: ["M7 17L17 7", "M8 7h9v9"] },
|
|
56
|
+
"arrow-left": { viewBox: "0 0 24 24", paths: ["M19 12H5", "m12 19-7-7 7-7"] },
|
|
57
|
+
"chat-bubble": { viewBox: "0 0 24 24", paths: ["M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"] },
|
|
58
|
+
"eye-view": { viewBox: "0 0 24 24", paths: ["M2 12s4-7 10-7 10 7 10 7-4 7-10 7-10-7-10-7z", "M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"] },
|
|
59
|
+
"image-placeholder-dashed-frame": { viewBox: "0 0 72 72", paths: ["M4 4h64v64H4z", "M14 14h20v20H14z", "M38 14h20v20H38z", "M14 38h44v12H14z"] },
|
|
60
|
+
"image-photo-picture": { viewBox: "0 0 24 24", paths: ["M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Z", "M11 9a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z", "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"] },
|
|
61
|
+
"video-film-clapperboard": { viewBox: "0 0 24 24", paths: ["M4 6h10a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2Z", "m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"] },
|
|
62
|
+
"minus-indeterminate": { viewBox: "0 0 24 24", paths: ["M5 12h14"] },
|
|
11
63
|
} as const;
|
|
12
64
|
|
|
13
65
|
export type IconName = keyof typeof ICON_REGISTRY;
|
|
@@ -12,29 +12,35 @@ export interface InputProps
|
|
|
12
12
|
error?: string;
|
|
13
13
|
/** Size variant */
|
|
14
14
|
size?: InputSize;
|
|
15
|
-
/** Leading icon (any inline SVG or element) */
|
|
15
|
+
/** Leading icon (any inline SVG or element) — decorative only */
|
|
16
16
|
leadingIcon?: React.ReactNode;
|
|
17
|
-
/** Trailing icon / adornment */
|
|
17
|
+
/** Trailing icon / adornment — may contain an interactive element (e.g. a password-visibility toggle button) */
|
|
18
18
|
trailingIcon?: React.ReactNode;
|
|
19
19
|
/** Fill full width of its container */
|
|
20
20
|
fullWidth?: boolean;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const sizeClasses: Record<
|
|
23
|
+
const sizeClasses: Record<
|
|
24
|
+
InputSize,
|
|
25
|
+
{ input: string; icon: string; label: string; trailingPad: string }
|
|
26
|
+
> = {
|
|
24
27
|
sm: {
|
|
25
28
|
input: "h-8 px-sm text-body-sm",
|
|
26
29
|
icon: "w-4 h-4",
|
|
27
30
|
label: "text-body-sm",
|
|
31
|
+
trailingPad: "pr-9",
|
|
28
32
|
},
|
|
29
33
|
md: {
|
|
30
34
|
input: "h-10 px-md text-body-md",
|
|
31
35
|
icon: "w-4 h-4",
|
|
32
36
|
label: "text-body-sm",
|
|
37
|
+
trailingPad: "pr-10",
|
|
33
38
|
},
|
|
34
39
|
lg: {
|
|
35
40
|
input: "h-12 px-base text-body-lg",
|
|
36
41
|
icon: "w-5 h-5",
|
|
37
42
|
label: "text-body-md",
|
|
43
|
+
trailingPad: "pr-12",
|
|
38
44
|
},
|
|
39
45
|
};
|
|
40
46
|
|
|
@@ -59,7 +65,12 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
|
59
65
|
const inputId = id ?? generatedId;
|
|
60
66
|
const helperId = `${inputId}-helper`;
|
|
61
67
|
const hasError = Boolean(error);
|
|
62
|
-
const {
|
|
68
|
+
const {
|
|
69
|
+
input: inputSize,
|
|
70
|
+
icon: iconSize,
|
|
71
|
+
label: labelSize,
|
|
72
|
+
trailingPad,
|
|
73
|
+
} = sizeClasses[size];
|
|
63
74
|
|
|
64
75
|
const borderColor = hasError
|
|
65
76
|
? "border-semantic-error focus:ring-semantic-error/30 focus:border-semantic-error"
|
|
@@ -102,7 +113,7 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
|
102
113
|
inputSize,
|
|
103
114
|
borderColor,
|
|
104
115
|
leadingIcon ? "pl-9" : "",
|
|
105
|
-
trailingIcon ?
|
|
116
|
+
trailingIcon ? trailingPad : "",
|
|
106
117
|
disabled
|
|
107
118
|
? "cursor-not-allowed bg-surface-soft text-muted opacity-60"
|
|
108
119
|
: "",
|
|
@@ -114,10 +125,7 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
|
114
125
|
/>
|
|
115
126
|
|
|
116
127
|
{trailingIcon && (
|
|
117
|
-
<span
|
|
118
|
-
aria-hidden="true"
|
|
119
|
-
className={`absolute right-md flex items-center text-muted ${iconSize}`}
|
|
120
|
-
>
|
|
128
|
+
<span className="absolute right-sm flex items-center justify-center text-muted overflow-visible pointer-events-auto">
|
|
121
129
|
{trailingIcon}
|
|
122
130
|
</span>
|
|
123
131
|
)}
|
|
@@ -1,28 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Input } from "./Input";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth={1.5} className="w-full h-full">
|
|
6
|
-
<rect x="2.5" y="4.5" width="15" height="11" rx="1.5" />
|
|
7
|
-
<path d="M2.5 7l7.09 4.5a.9.9 0 0 0 .82 0L17.5 7" />
|
|
8
|
-
</svg>
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
const SearchIcon = () => (
|
|
12
|
-
<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth={1.5} className="w-full h-full">
|
|
13
|
-
<circle cx="9" cy="9" r="5.5" />
|
|
14
|
-
<path d="M14 14l3.5 3.5" strokeLinecap="round" />
|
|
15
|
-
</svg>
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
const EyeIcon = () => (
|
|
19
|
-
<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth={1.5} className="w-full h-full">
|
|
20
|
-
<path d="M2 10s3-6 8-6 8 6 8 6-3 6-8 6-8-6-8-6z" />
|
|
21
|
-
<circle cx="10" cy="10" r="2.5" />
|
|
22
|
-
</svg>
|
|
23
|
-
);
|
|
3
|
+
import { Icon } from "../Icon";
|
|
4
|
+
import { Button } from "../Button";
|
|
24
5
|
|
|
25
6
|
export default function InputPreview() {
|
|
7
|
+
const [showPassword, setShowPassword] = React.useState(false);
|
|
8
|
+
|
|
26
9
|
return (
|
|
27
10
|
<div className="w-full max-w-2xl mx-auto p-lg space-y-xl">
|
|
28
11
|
|
|
@@ -73,20 +56,36 @@ export default function InputPreview() {
|
|
|
73
56
|
<Input
|
|
74
57
|
label="Email address"
|
|
75
58
|
placeholder="you@example.com"
|
|
76
|
-
leadingIcon={<
|
|
59
|
+
leadingIcon={<Icon name="inbox-mail-tray" className="w-full h-full" />}
|
|
77
60
|
fullWidth
|
|
78
61
|
/>
|
|
79
62
|
<Input
|
|
80
63
|
label="Search"
|
|
81
64
|
placeholder="Search anything…"
|
|
82
|
-
leadingIcon={<
|
|
65
|
+
leadingIcon={<Icon name="search-magnifier" className="w-full h-full" />}
|
|
83
66
|
fullWidth
|
|
84
67
|
/>
|
|
85
68
|
<Input
|
|
86
69
|
label="Password"
|
|
87
|
-
type="password"
|
|
70
|
+
type={showPassword ? "text" : "password"}
|
|
88
71
|
placeholder="Enter your password"
|
|
89
|
-
|
|
72
|
+
defaultValue="hunter2"
|
|
73
|
+
trailingIcon={
|
|
74
|
+
<Button
|
|
75
|
+
type="button"
|
|
76
|
+
variant="ghost"
|
|
77
|
+
size="sm"
|
|
78
|
+
className="p-xs rounded-md"
|
|
79
|
+
aria-label={showPassword ? "Hide password" : "Show password"}
|
|
80
|
+
aria-pressed={showPassword}
|
|
81
|
+
onClick={() => setShowPassword((v) => !v)}
|
|
82
|
+
>
|
|
83
|
+
<Icon
|
|
84
|
+
name={showPassword ? "eye-off-hide-password" : "eye-show-password"}
|
|
85
|
+
className="w-5 h-5"
|
|
86
|
+
/>
|
|
87
|
+
</Button>
|
|
88
|
+
}
|
|
90
89
|
fullWidth
|
|
91
90
|
/>
|
|
92
91
|
</div>
|