@designa8/vibedesign-v6 1.6.7
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 +66 -0
- package/dist/fonts/inter/Inter-Italic[opsz,wght].ttf +0 -0
- package/dist/fonts/inter/Inter[opsz,wght].ttf +0 -0
- package/dist/index.cjs +3231 -0
- package/dist/index.js +3201 -0
- package/dist/styles.css +1810 -0
- package/package.json +109 -0
- package/src/atoms/AppLayout/AppLayout.tsx +537 -0
- package/src/atoms/AppLayout/index.ts +2 -0
- package/src/atoms/AppLayout/preview.tsx +75 -0
- package/src/atoms/AppSidebar/AppSidebar.tsx +399 -0
- package/src/atoms/AppSidebar/index.ts +2 -0
- package/src/atoms/AppSidebar/preview.tsx +214 -0
- package/src/atoms/AuthScreen/AuthScreen.tsx +226 -0
- package/src/atoms/AuthScreen/index.ts +2 -0
- package/src/atoms/AuthScreen/preview.tsx +10 -0
- package/src/atoms/Button/Button.tsx +71 -0
- package/src/atoms/Button/index.ts +2 -0
- package/src/atoms/Button/preview.tsx +71 -0
- package/src/atoms/ChatScreen/ChatScreen.tsx +629 -0
- package/src/atoms/ChatScreen/index.ts +2 -0
- package/src/atoms/ChatScreen/preview.tsx +239 -0
- package/src/atoms/Chip/Chip.tsx +121 -0
- package/src/atoms/Chip/index.ts +2 -0
- package/src/atoms/Chip/preview.tsx +99 -0
- package/src/atoms/FilterTabBar/FilterTabBar.tsx +95 -0
- package/src/atoms/FilterTabBar/index.ts +2 -0
- package/src/atoms/FilterTabBar/preview.tsx +92 -0
- package/src/atoms/Input/Input.tsx +139 -0
- package/src/atoms/Input/index.ts +2 -0
- package/src/atoms/Input/preview.tsx +97 -0
- package/src/atoms/Modal/Modal.tsx +144 -0
- package/src/atoms/Modal/index.ts +2 -0
- package/src/atoms/Modal/preview.tsx +111 -0
- package/src/atoms/NavItem/NavItem.tsx +316 -0
- package/src/atoms/NavItem/index.ts +2 -0
- package/src/atoms/NavItem/preview.tsx +125 -0
- package/src/atoms/PromptInputBar/PromptInputBar.tsx +626 -0
- package/src/atoms/PromptInputBar/index.ts +2 -0
- package/src/atoms/PromptInputBar/preview.tsx +85 -0
- package/src/atoms/TopNavbar/TopNavbar.tsx +400 -0
- package/src/atoms/TopNavbar/index.ts +2 -0
- package/src/atoms/TopNavbar/preview.tsx +117 -0
- package/src/atoms/UpgradeCard/UpgradeCard.tsx +65 -0
- package/src/atoms/UpgradeCard/index.ts +2 -0
- package/src/atoms/UpgradeCard/preview.tsx +25 -0
- package/src/atoms/WorkspaceMenu/WorkspaceMenu.tsx +216 -0
- package/src/atoms/WorkspaceMenu/index.ts +2 -0
- package/src/atoms/WorkspaceMenu/preview.tsx +44 -0
- package/src/index.ts +16 -0
- package/src/tokens.css +165 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ChatScreen, ChatMessage } from "./ChatScreen";
|
|
3
|
+
import { Button } from "../Button";
|
|
4
|
+
import { Input } from "../Input";
|
|
5
|
+
|
|
6
|
+
const DEMO_MODELS = [
|
|
7
|
+
{ id: "gpt-4o", name: "GPT-4o", tier: "Pro", description: "Most capable model" },
|
|
8
|
+
{ id: "gpt-4o-mini", name: "GPT-4o mini", tier: "Free", description: "Fast and efficient" },
|
|
9
|
+
{ id: "claude-3-5", name: "Claude 3.5 Sonnet", tier: "Pro", description: "Great for coding" },
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
/** A minimal custom footer to demo the renderFooter prop */
|
|
13
|
+
const CustomFooter: React.FC = () => (
|
|
14
|
+
<div className="w-full px-lg py-md border-t border-hairline-soft bg-surface-soft flex items-center gap-md">
|
|
15
|
+
<Input
|
|
16
|
+
placeholder="Custom footer input…"
|
|
17
|
+
size="sm"
|
|
18
|
+
fullWidth
|
|
19
|
+
/>
|
|
20
|
+
<Button size="sm">Send</Button>
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
// ─── Messages for the live-agent demo ────────────────────────────────────────
|
|
25
|
+
|
|
26
|
+
const LIVE_AGENT_MESSAGES: ChatMessage[] = [
|
|
27
|
+
{
|
|
28
|
+
id: "1",
|
|
29
|
+
role: "user",
|
|
30
|
+
content: "Build a NavBar organism with logo, links, and a CTA button.",
|
|
31
|
+
userInitials: "JD",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: "2",
|
|
35
|
+
role: "ai",
|
|
36
|
+
content: "Here's my plan for building the NavBar organism:",
|
|
37
|
+
plan: {
|
|
38
|
+
title: "Plan",
|
|
39
|
+
tasks: [
|
|
40
|
+
{ id: "p1", label: "Inspect existing Button and NavItem atoms", status: "done" },
|
|
41
|
+
{
|
|
42
|
+
id: "p2",
|
|
43
|
+
label: "Write NavBar.tsx component",
|
|
44
|
+
status: "in_progress",
|
|
45
|
+
currentTool: "Writing atom",
|
|
46
|
+
},
|
|
47
|
+
{ id: "p3", label: "Write preview.tsx with variants", status: "pending" },
|
|
48
|
+
{ id: "p4", label: "Verify and fix lint issues", status: "pending" },
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
inFlight: true,
|
|
52
|
+
currentToolLabel: "Writing atom",
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
// ─── Messages showing all four task statuses ─────────────────────────────────
|
|
57
|
+
|
|
58
|
+
const MIXED_STATUS_MESSAGES: ChatMessage[] = [
|
|
59
|
+
{
|
|
60
|
+
id: "1",
|
|
61
|
+
role: "user",
|
|
62
|
+
content: "Add dark-mode support to the existing design tokens.",
|
|
63
|
+
userInitials: "MK",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "2",
|
|
67
|
+
role: "ai",
|
|
68
|
+
content: "Running through the token update process:",
|
|
69
|
+
plan: {
|
|
70
|
+
title: "Token update",
|
|
71
|
+
tasks: [
|
|
72
|
+
{ id: "t1", label: "Read current design tokens", status: "done" },
|
|
73
|
+
{ id: "t2", label: "Patch dark-mode color overrides", status: "done" },
|
|
74
|
+
{
|
|
75
|
+
id: "t3",
|
|
76
|
+
label: "Regenerate theme CSS variables",
|
|
77
|
+
status: "failed",
|
|
78
|
+
},
|
|
79
|
+
{ id: "t4", label: "Verify preview renders correctly", status: "pending" },
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
inFlight: false,
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
// ─── Messages demonstrating postContent ──────────────────────────────────────
|
|
87
|
+
|
|
88
|
+
const POST_CONTENT_MESSAGES: ChatMessage[] = [
|
|
89
|
+
{
|
|
90
|
+
id: "1",
|
|
91
|
+
role: "user",
|
|
92
|
+
content: "Build a Tabs organism with active-state underline.",
|
|
93
|
+
userInitials: "AL",
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: "2",
|
|
97
|
+
role: "ai",
|
|
98
|
+
content: "Here's the plan to build the Tabs organism:",
|
|
99
|
+
plan: {
|
|
100
|
+
title: "Plan",
|
|
101
|
+
tasks: [
|
|
102
|
+
{ id: "s1", label: "Read design tokens and existing atoms", status: "done" },
|
|
103
|
+
{ id: "s2", label: "Write Tabs.tsx with keyboard navigation", status: "done" },
|
|
104
|
+
{ id: "s3", label: "Write preview.tsx with three tab variants", status: "done" },
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
postContent:
|
|
108
|
+
"All three tasks are complete. The Tabs atom is live in your workspace — open the preview to see the active underline in action and try switching tabs with the arrow keys.",
|
|
109
|
+
},
|
|
110
|
+
];
|
|
111
|
+
|
|
112
|
+
export default function ChatScreenPreview() {
|
|
113
|
+
const [modelId, setModelId] = React.useState("gpt-4o");
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<div className="w-full max-w-3xl mx-auto p-lg space-y-lg">
|
|
117
|
+
|
|
118
|
+
{/* 0. Empty state — default built-in (messages={[]}) */}
|
|
119
|
+
<div>
|
|
120
|
+
<p className="text-caption text-muted mb-sm">
|
|
121
|
+
Empty state — messages={"{[]}"} shows illustration + default copy
|
|
122
|
+
</p>
|
|
123
|
+
<div className="rounded-xl border border-hairline overflow-hidden" style={{ height: "420px" }}>
|
|
124
|
+
<ChatScreen
|
|
125
|
+
messages={[]}
|
|
126
|
+
models={DEMO_MODELS}
|
|
127
|
+
selectedModelId={modelId}
|
|
128
|
+
onModelChange={setModelId}
|
|
129
|
+
/>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
|
|
133
|
+
{/* 0b. Empty state — custom title + description */}
|
|
134
|
+
<div>
|
|
135
|
+
<p className="text-caption text-muted mb-sm">
|
|
136
|
+
Empty state — custom emptyTitle + emptyDescription props
|
|
137
|
+
</p>
|
|
138
|
+
<div className="rounded-xl border border-hairline overflow-hidden" style={{ height: "360px" }}>
|
|
139
|
+
<ChatScreen
|
|
140
|
+
messages={[]}
|
|
141
|
+
emptyTitle="No messages yet"
|
|
142
|
+
emptyDescription="Send your first message to get started building your design system."
|
|
143
|
+
models={DEMO_MODELS}
|
|
144
|
+
selectedModelId={modelId}
|
|
145
|
+
onModelChange={setModelId}
|
|
146
|
+
/>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
|
|
150
|
+
{/* 0c. Empty state — custom emptyState node */}
|
|
151
|
+
<div>
|
|
152
|
+
<p className="text-caption text-muted mb-sm">
|
|
153
|
+
Empty state — emptyState prop replaces built-in content entirely
|
|
154
|
+
</p>
|
|
155
|
+
<div className="rounded-xl border border-hairline overflow-hidden" style={{ height: "320px" }}>
|
|
156
|
+
<ChatScreen
|
|
157
|
+
messages={[]}
|
|
158
|
+
emptyState={
|
|
159
|
+
<div className="flex flex-col items-center gap-md text-center px-xl">
|
|
160
|
+
<span className="text-xxl">🎨</span>
|
|
161
|
+
<p className="text-heading-sm font-weight-heading-sm text-ink">Custom empty state</p>
|
|
162
|
+
<p className="text-body-sm text-muted">You can pass any React node via the emptyState prop.</p>
|
|
163
|
+
</div>
|
|
164
|
+
}
|
|
165
|
+
models={DEMO_MODELS}
|
|
166
|
+
selectedModelId={modelId}
|
|
167
|
+
onModelChange={setModelId}
|
|
168
|
+
/>
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
|
|
172
|
+
{/* 1. Live-agent: inFlight + in_progress task + currentToolLabel */}
|
|
173
|
+
<div>
|
|
174
|
+
<p className="text-caption text-muted mb-sm">
|
|
175
|
+
Live agent — inFlight bubble with spinner + in_progress task row (avatar center-aligned)
|
|
176
|
+
</p>
|
|
177
|
+
<div className="rounded-xl border border-hairline overflow-hidden" style={{ height: "480px" }}>
|
|
178
|
+
<ChatScreen
|
|
179
|
+
messages={LIVE_AGENT_MESSAGES}
|
|
180
|
+
models={DEMO_MODELS}
|
|
181
|
+
selectedModelId={modelId}
|
|
182
|
+
onModelChange={setModelId}
|
|
183
|
+
/>
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
{/* 2. postContent — text rendered after the plan card */}
|
|
188
|
+
<div>
|
|
189
|
+
<p className="text-caption text-muted mb-sm">
|
|
190
|
+
postContent prop — additional text rendered below the plan card
|
|
191
|
+
</p>
|
|
192
|
+
<div className="rounded-xl border border-hairline overflow-hidden" style={{ height: "440px" }}>
|
|
193
|
+
<ChatScreen
|
|
194
|
+
messages={POST_CONTENT_MESSAGES}
|
|
195
|
+
models={DEMO_MODELS}
|
|
196
|
+
selectedModelId={modelId}
|
|
197
|
+
onModelChange={setModelId}
|
|
198
|
+
/>
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
{/* 3. Mixed statuses: done, failed, pending-hidden */}
|
|
203
|
+
<div>
|
|
204
|
+
<p className="text-caption text-muted mb-sm">
|
|
205
|
+
Mixed task statuses — done (strikethrough), failed (red ✕), pending hidden
|
|
206
|
+
</p>
|
|
207
|
+
<div className="rounded-xl border border-hairline overflow-hidden" style={{ height: "400px" }}>
|
|
208
|
+
<ChatScreen
|
|
209
|
+
messages={MIXED_STATUS_MESSAGES}
|
|
210
|
+
models={DEMO_MODELS}
|
|
211
|
+
selectedModelId={modelId}
|
|
212
|
+
onModelChange={setModelId}
|
|
213
|
+
/>
|
|
214
|
+
</div>
|
|
215
|
+
</div>
|
|
216
|
+
|
|
217
|
+
{/* 4. Default message list + model selector (userInitials "DU") */}
|
|
218
|
+
<div>
|
|
219
|
+
<p className="text-caption text-muted mb-sm">Default message list + model selector (userInitials="DU") with postContent after plan card</p>
|
|
220
|
+
<div className="rounded-xl border border-hairline overflow-hidden" style={{ height: "520px" }}>
|
|
221
|
+
<ChatScreen
|
|
222
|
+
models={DEMO_MODELS}
|
|
223
|
+
selectedModelId={modelId}
|
|
224
|
+
onModelChange={setModelId}
|
|
225
|
+
/>
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
|
|
229
|
+
{/* 5. renderFooter — replaces the default PromptInputBar section entirely */}
|
|
230
|
+
<div>
|
|
231
|
+
<p className="text-caption text-muted mb-sm">renderFooter prop replaces the default PromptInputBar</p>
|
|
232
|
+
<div className="rounded-xl border border-hairline overflow-hidden" style={{ height: "360px" }}>
|
|
233
|
+
<ChatScreen renderFooter={<CustomFooter />} />
|
|
234
|
+
</div>
|
|
235
|
+
</div>
|
|
236
|
+
|
|
237
|
+
</div>
|
|
238
|
+
);
|
|
239
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Button } from "../Button";
|
|
3
|
+
|
|
4
|
+
export type ChipVariant = "default" | "primary" | "success" | "warning" | "error";
|
|
5
|
+
export type ChipSize = "sm" | "md" | "lg";
|
|
6
|
+
|
|
7
|
+
export interface ChipProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
8
|
+
/** Display label of the chip */
|
|
9
|
+
label: string;
|
|
10
|
+
/** Visual style variant */
|
|
11
|
+
variant?: ChipVariant;
|
|
12
|
+
/** Size of the chip */
|
|
13
|
+
size?: ChipSize;
|
|
14
|
+
/** Optional leading icon element */
|
|
15
|
+
icon?: React.ReactNode;
|
|
16
|
+
/** If provided, renders a dismiss (×) button and calls this handler on click */
|
|
17
|
+
onDismiss?: () => void;
|
|
18
|
+
/** Disabled state — mutes colors and prevents interactions */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const variantClasses: Record<ChipVariant, string> = {
|
|
23
|
+
default: "bg-surface-strong text-body border border-hairline",
|
|
24
|
+
primary: "bg-primary text-on-primary border border-primary",
|
|
25
|
+
success:
|
|
26
|
+
"bg-[var(--color-semantic-success-soft)] text-[var(--color-semantic-success)] border border-[var(--color-semantic-success)]",
|
|
27
|
+
warning:
|
|
28
|
+
"bg-[var(--color-semantic-warning-soft)] text-[var(--color-semantic-warning)] border border-[var(--color-semantic-warning)]",
|
|
29
|
+
error:
|
|
30
|
+
"bg-[var(--color-semantic-error-soft)] text-[var(--color-semantic-error)] border border-[var(--color-semantic-error)]",
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const sizeClasses: Record<
|
|
34
|
+
ChipSize,
|
|
35
|
+
{ chip: string; text: string; icon: string; dismissSize: "sm" }
|
|
36
|
+
> = {
|
|
37
|
+
sm: { chip: "h-6 px-xs gap-xs rounded-xs", text: "text-caption", icon: "w-3 h-3", dismissSize: "sm" },
|
|
38
|
+
md: { chip: "h-8 px-sm gap-xs rounded-sm", text: "text-body-sm", icon: "w-4 h-4", dismissSize: "sm" },
|
|
39
|
+
lg: { chip: "h-10 px-md gap-sm rounded-md", text: "text-body-md", icon: "w-5 h-5", dismissSize: "sm" },
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** Inline close icon used inside the dismiss Button */
|
|
43
|
+
const CloseIcon = ({ className }: { className?: string }) => (
|
|
44
|
+
<svg
|
|
45
|
+
viewBox="0 0 16 16"
|
|
46
|
+
fill="none"
|
|
47
|
+
stroke="currentColor"
|
|
48
|
+
strokeWidth={2.5}
|
|
49
|
+
strokeLinecap="round"
|
|
50
|
+
className={className}
|
|
51
|
+
aria-hidden="true"
|
|
52
|
+
>
|
|
53
|
+
<line x1="4" y1="4" x2="12" y2="12" />
|
|
54
|
+
<line x1="12" y1="4" x2="4" y2="12" />
|
|
55
|
+
</svg>
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
export const Chip = React.forwardRef<HTMLSpanElement, ChipProps>(
|
|
59
|
+
(
|
|
60
|
+
{
|
|
61
|
+
label,
|
|
62
|
+
variant = "default",
|
|
63
|
+
size = "md",
|
|
64
|
+
icon,
|
|
65
|
+
onDismiss,
|
|
66
|
+
disabled = false,
|
|
67
|
+
className = "",
|
|
68
|
+
...props
|
|
69
|
+
},
|
|
70
|
+
ref
|
|
71
|
+
) => {
|
|
72
|
+
const sz = sizeClasses[size];
|
|
73
|
+
const vr = variantClasses[variant];
|
|
74
|
+
|
|
75
|
+
const disabledStyles = disabled ? "opacity-50 pointer-events-none select-none" : "";
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<span
|
|
79
|
+
ref={ref}
|
|
80
|
+
role="status"
|
|
81
|
+
aria-label={label}
|
|
82
|
+
className={[
|
|
83
|
+
"inline-flex items-center font-medium whitespace-nowrap transition-colors",
|
|
84
|
+
sz.chip,
|
|
85
|
+
vr,
|
|
86
|
+
disabledStyles,
|
|
87
|
+
className,
|
|
88
|
+
]
|
|
89
|
+
.filter(Boolean)
|
|
90
|
+
.join(" ")}
|
|
91
|
+
{...props}
|
|
92
|
+
>
|
|
93
|
+
{icon && (
|
|
94
|
+
<span
|
|
95
|
+
className={`${sz.icon} flex-shrink-0 flex items-center justify-center`}
|
|
96
|
+
aria-hidden="true"
|
|
97
|
+
>
|
|
98
|
+
{icon}
|
|
99
|
+
</span>
|
|
100
|
+
)}
|
|
101
|
+
|
|
102
|
+
<span className={sz.text}>{label}</span>
|
|
103
|
+
|
|
104
|
+
{onDismiss && (
|
|
105
|
+
<Button
|
|
106
|
+
variant="ghost"
|
|
107
|
+
size={sz.dismissSize}
|
|
108
|
+
onClick={onDismiss}
|
|
109
|
+
disabled={disabled}
|
|
110
|
+
aria-label={`Remove ${label}`}
|
|
111
|
+
className="!p-0 !h-4 !w-4 !min-w-0 opacity-60 hover:opacity-100 rounded-full flex-shrink-0"
|
|
112
|
+
>
|
|
113
|
+
<CloseIcon className="w-3 h-3" />
|
|
114
|
+
</Button>
|
|
115
|
+
)}
|
|
116
|
+
</span>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
Chip.displayName = "Chip";
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { Chip } from "./Chip";
|
|
3
|
+
|
|
4
|
+
const TagIcon = () => (
|
|
5
|
+
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth={1.75} strokeLinecap="round" strokeLinejoin="round" className="w-full h-full">
|
|
6
|
+
<path d="M2 2h5l7 7-5 5-7-7V2z" />
|
|
7
|
+
<circle cx="5" cy="5" r="1" fill="currentColor" stroke="none" />
|
|
8
|
+
</svg>
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
const StarIcon = () => (
|
|
12
|
+
<svg viewBox="0 0 16 16" fill="currentColor" className="w-full h-full">
|
|
13
|
+
<path d="M8 1l1.8 3.6L14 5.3l-3 2.9.7 4.1L8 10.4l-3.7 1.9.7-4.1-3-2.9 4.2-.7z" />
|
|
14
|
+
</svg>
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export default function ChipPreview() {
|
|
18
|
+
const [tags, setTags] = useState(["Design", "React", "TypeScript", "Figma"]);
|
|
19
|
+
|
|
20
|
+
const removeTag = (tag: string) => setTags((prev) => prev.filter((t) => t !== tag));
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div className="w-full max-w-3xl mx-auto p-lg space-y-xl">
|
|
24
|
+
|
|
25
|
+
{/* Variants */}
|
|
26
|
+
<section className="space-y-sm">
|
|
27
|
+
<p className="text-caption text-muted uppercase tracking-wide">Variants</p>
|
|
28
|
+
<div className="flex flex-wrap gap-sm items-center">
|
|
29
|
+
<Chip label="Default" variant="default" />
|
|
30
|
+
<Chip label="Primary" variant="primary" />
|
|
31
|
+
<Chip label="Success" variant="success" />
|
|
32
|
+
<Chip label="Warning" variant="warning" />
|
|
33
|
+
<Chip label="Error" variant="error" />
|
|
34
|
+
</div>
|
|
35
|
+
</section>
|
|
36
|
+
|
|
37
|
+
{/* Sizes */}
|
|
38
|
+
<section className="space-y-sm">
|
|
39
|
+
<p className="text-caption text-muted uppercase tracking-wide">Sizes</p>
|
|
40
|
+
<div className="flex flex-wrap gap-sm items-center">
|
|
41
|
+
<Chip label="Small" size="sm" variant="primary" />
|
|
42
|
+
<Chip label="Medium" size="md" variant="primary" />
|
|
43
|
+
<Chip label="Large" size="lg" variant="primary" />
|
|
44
|
+
</div>
|
|
45
|
+
</section>
|
|
46
|
+
|
|
47
|
+
{/* With Icons */}
|
|
48
|
+
<section className="space-y-sm">
|
|
49
|
+
<p className="text-caption text-muted uppercase tracking-wide">With Leading Icon</p>
|
|
50
|
+
<div className="flex flex-wrap gap-sm items-center">
|
|
51
|
+
<Chip label="Tag" variant="default" icon={<TagIcon />} />
|
|
52
|
+
<Chip label="Featured" variant="primary" icon={<StarIcon />} />
|
|
53
|
+
<Chip label="Success" variant="success" icon={<StarIcon />} />
|
|
54
|
+
<Chip label="Warning" variant="warning" icon={<TagIcon />} />
|
|
55
|
+
<Chip label="Error" variant="error" icon={<StarIcon />} />
|
|
56
|
+
</div>
|
|
57
|
+
</section>
|
|
58
|
+
|
|
59
|
+
{/* Dismissible tags */}
|
|
60
|
+
<section className="space-y-sm">
|
|
61
|
+
<p className="text-caption text-muted uppercase tracking-wide">Dismissible (click × to remove)</p>
|
|
62
|
+
<div className="flex flex-wrap gap-sm items-center">
|
|
63
|
+
{tags.map((tag) => (
|
|
64
|
+
<Chip
|
|
65
|
+
key={tag}
|
|
66
|
+
label={tag}
|
|
67
|
+
variant="default"
|
|
68
|
+
onDismiss={() => removeTag(tag)}
|
|
69
|
+
/>
|
|
70
|
+
))}
|
|
71
|
+
{tags.length === 0 && (
|
|
72
|
+
<span className="text-body-sm text-muted italic">All tags removed</span>
|
|
73
|
+
)}
|
|
74
|
+
</div>
|
|
75
|
+
</section>
|
|
76
|
+
|
|
77
|
+
{/* Dismissible + icon */}
|
|
78
|
+
<section className="space-y-sm">
|
|
79
|
+
<p className="text-caption text-muted uppercase tracking-wide">Dismissible + Icon</p>
|
|
80
|
+
<div className="flex flex-wrap gap-sm items-center">
|
|
81
|
+
<Chip label="Design" variant="primary" icon={<TagIcon />} onDismiss={() => {}} />
|
|
82
|
+
<Chip label="Approved" variant="success" icon={<StarIcon />} onDismiss={() => {}} />
|
|
83
|
+
<Chip label="Overdue" variant="error" icon={<TagIcon />} onDismiss={() => {}} />
|
|
84
|
+
</div>
|
|
85
|
+
</section>
|
|
86
|
+
|
|
87
|
+
{/* Disabled */}
|
|
88
|
+
<section className="space-y-sm">
|
|
89
|
+
<p className="text-caption text-muted uppercase tracking-wide">Disabled State</p>
|
|
90
|
+
<div className="flex flex-wrap gap-sm items-center">
|
|
91
|
+
<Chip label="Default" variant="default" disabled />
|
|
92
|
+
<Chip label="Primary" variant="primary" disabled />
|
|
93
|
+
<Chip label="Error" variant="error" disabled onDismiss={() => {}} />
|
|
94
|
+
</div>
|
|
95
|
+
</section>
|
|
96
|
+
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Button } from "../Button";
|
|
3
|
+
|
|
4
|
+
export interface FilterTab {
|
|
5
|
+
/** Unique identifier for this tab */
|
|
6
|
+
value: string;
|
|
7
|
+
/** Display label — optional when icon is provided */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Icon rendered before the label (or alone when no label is given) */
|
|
10
|
+
icon?: React.ReactNode;
|
|
11
|
+
/** Optional count badge */
|
|
12
|
+
count?: number;
|
|
13
|
+
/** Accessible label required when the tab is icon-only */
|
|
14
|
+
"aria-label"?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface FilterTabBarProps
|
|
18
|
+
extends Omit<React.ComponentPropsWithoutRef<"div">, "onChange"> {
|
|
19
|
+
tabs: FilterTab[];
|
|
20
|
+
value: string;
|
|
21
|
+
onChange: (value: string) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const FilterTabBar = React.forwardRef<HTMLDivElement, FilterTabBarProps>(
|
|
25
|
+
({ tabs, value, onChange, className = "", ...rest }, ref) => {
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
ref={ref}
|
|
29
|
+
role="tablist"
|
|
30
|
+
aria-label="Filter tabs"
|
|
31
|
+
className={[
|
|
32
|
+
"inline-flex items-center gap-xs p-xs",
|
|
33
|
+
"bg-surface border border-hairline rounded-xl shadow-sm",
|
|
34
|
+
className,
|
|
35
|
+
]
|
|
36
|
+
.filter(Boolean)
|
|
37
|
+
.join(" ")}
|
|
38
|
+
{...rest}
|
|
39
|
+
>
|
|
40
|
+
{tabs.map((tab) => {
|
|
41
|
+
const isActive = tab.value === value;
|
|
42
|
+
const iconOnly = !!tab.icon && !tab.label;
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Button
|
|
46
|
+
key={tab.value}
|
|
47
|
+
role="tab"
|
|
48
|
+
aria-selected={isActive}
|
|
49
|
+
aria-label={tab["aria-label"]}
|
|
50
|
+
variant={isActive ? "primary" : "ghost"}
|
|
51
|
+
size="sm"
|
|
52
|
+
onClick={() => onChange(tab.value)}
|
|
53
|
+
// Square padding for icon-only tabs
|
|
54
|
+
className={[
|
|
55
|
+
"transition-[background-color,color,box-shadow] duration-200 ease-in-out",
|
|
56
|
+
iconOnly ? "!px-xs aspect-square" : "",
|
|
57
|
+
]
|
|
58
|
+
.filter(Boolean)
|
|
59
|
+
.join(" ")}
|
|
60
|
+
>
|
|
61
|
+
{tab.icon && (
|
|
62
|
+
<span className="inline-flex items-center justify-center size-4 shrink-0">
|
|
63
|
+
{tab.icon}
|
|
64
|
+
</span>
|
|
65
|
+
)}
|
|
66
|
+
|
|
67
|
+
{tab.label && <span>{tab.label}</span>}
|
|
68
|
+
|
|
69
|
+
{tab.count !== undefined && (
|
|
70
|
+
<span
|
|
71
|
+
className={[
|
|
72
|
+
"inline-flex items-center justify-center",
|
|
73
|
+
"min-w-[1.25rem] h-5 px-xs rounded-sm",
|
|
74
|
+
"text-caption leading-none",
|
|
75
|
+
"transition-[background-color,color] duration-200 ease-in-out",
|
|
76
|
+
isActive
|
|
77
|
+
? "bg-primary-active text-on-primary"
|
|
78
|
+
: "bg-surface-strong text-muted",
|
|
79
|
+
]
|
|
80
|
+
.filter(Boolean)
|
|
81
|
+
.join(" ")}
|
|
82
|
+
aria-label={`${tab.count} items`}
|
|
83
|
+
>
|
|
84
|
+
{tab.count}
|
|
85
|
+
</span>
|
|
86
|
+
)}
|
|
87
|
+
</Button>
|
|
88
|
+
);
|
|
89
|
+
})}
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
FilterTabBar.displayName = "FilterTabBar";
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { FilterTabBar, FilterTab } from "./FilterTabBar";
|
|
3
|
+
|
|
4
|
+
/* ── Inline SVG icons ─────────────────────────────────────── */
|
|
5
|
+
const IconGrid = () => (
|
|
6
|
+
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" className="size-4">
|
|
7
|
+
<rect x="1" y="1" width="6" height="6" rx="1" />
|
|
8
|
+
<rect x="9" y="1" width="6" height="6" rx="1" />
|
|
9
|
+
<rect x="1" y="9" width="6" height="6" rx="1" />
|
|
10
|
+
<rect x="9" y="9" width="6" height="6" rx="1" />
|
|
11
|
+
</svg>
|
|
12
|
+
);
|
|
13
|
+
const IconList = () => (
|
|
14
|
+
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" className="size-4">
|
|
15
|
+
<line x1="3" y1="4" x2="13" y2="4" />
|
|
16
|
+
<line x1="3" y1="8" x2="13" y2="8" />
|
|
17
|
+
<line x1="3" y1="12" x2="13" y2="12" />
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
20
|
+
const IconColumns = () => (
|
|
21
|
+
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" className="size-4">
|
|
22
|
+
<rect x="1" y="2" width="4" height="12" rx="1" />
|
|
23
|
+
<rect x="6" y="2" width="4" height="12" rx="1" />
|
|
24
|
+
<rect x="11" y="2" width="4" height="12" rx="1" />
|
|
25
|
+
</svg>
|
|
26
|
+
);
|
|
27
|
+
const IconStar = () => (
|
|
28
|
+
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" className="size-4">
|
|
29
|
+
<polygon points="8,1 10,6 15,6 11,9.5 12.5,15 8,12 3.5,15 5,9.5 1,6 6,6" />
|
|
30
|
+
</svg>
|
|
31
|
+
);
|
|
32
|
+
const IconClock = () => (
|
|
33
|
+
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" className="size-4">
|
|
34
|
+
<circle cx="8" cy="8" r="6.5" />
|
|
35
|
+
<polyline points="8,4 8,8 11,10" />
|
|
36
|
+
</svg>
|
|
37
|
+
);
|
|
38
|
+
const IconArchive = () => (
|
|
39
|
+
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" className="size-4">
|
|
40
|
+
<rect x="1" y="3" width="14" height="3" rx="1" />
|
|
41
|
+
<path d="M2 6v7a1 1 0 001 1h10a1 1 0 001-1V6" />
|
|
42
|
+
<line x1="6" y1="9" x2="10" y2="9" />
|
|
43
|
+
</svg>
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
/* ── Tab data ─────────────────────────────────────────────── */
|
|
47
|
+
const iconOnlyTabs: FilterTab[] = [
|
|
48
|
+
{ value: "grid", icon: <IconGrid />, "aria-label": "Grid view" },
|
|
49
|
+
{ value: "list", icon: <IconList />, "aria-label": "List view" },
|
|
50
|
+
{ value: "columns", icon: <IconColumns />, "aria-label": "Columns view" },
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
const iconLabelTabs: FilterTab[] = [
|
|
54
|
+
{ value: "starred", icon: <IconStar />, label: "Starred", count: 4 },
|
|
55
|
+
{ value: "recent", icon: <IconClock />, label: "Recent", count: 12 },
|
|
56
|
+
{ value: "archived", icon: <IconArchive />, label: "Archived", count: 2 },
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
const labelOnlyTabs: FilterTab[] = [
|
|
60
|
+
{ value: "all", label: "All", count: 11 },
|
|
61
|
+
{ value: "atoms", label: "Atoms", count: 5 },
|
|
62
|
+
{ value: "molecules", label: "Molecules", count: 2 },
|
|
63
|
+
{ value: "organisms", label: "Organisms", count: 4 },
|
|
64
|
+
{ value: "icons", label: "Icons", count: 0 },
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
export default function FilterTabBarPreview() {
|
|
68
|
+
const [view, setView] = useState("grid");
|
|
69
|
+
const [scope, setScope] = useState("starred");
|
|
70
|
+
const [kind, setKind] = useState("all");
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<div className="w-full max-w-3xl mx-auto p-lg space-y-xl">
|
|
74
|
+
|
|
75
|
+
<div>
|
|
76
|
+
<p className="text-caption text-muted uppercase tracking-wide mb-sm">Icon only</p>
|
|
77
|
+
<FilterTabBar tabs={iconOnlyTabs} value={view} onChange={setView} />
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<div>
|
|
81
|
+
<p className="text-caption text-muted uppercase tracking-wide mb-sm">Icon + label + count</p>
|
|
82
|
+
<FilterTabBar tabs={iconLabelTabs} value={scope} onChange={setScope} />
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<div>
|
|
86
|
+
<p className="text-caption text-muted uppercase tracking-wide mb-sm">Label + count (original)</p>
|
|
87
|
+
<FilterTabBar tabs={labelOnlyTabs} value={kind} onChange={setKind} />
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
}
|