@designa8/vibedesign-v6 1.15.3 → 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.
Files changed (63) hide show
  1. package/README.md +1 -1
  2. package/dist/index.cjs +3232 -1994
  3. package/dist/index.js +3242 -2004
  4. package/dist/styles.css +266 -28
  5. package/package.json +51 -1
  6. package/src/atoms/AppLayout/AppLayout.tsx +401 -395
  7. package/src/atoms/AppLayout/preview.tsx +29 -0
  8. package/src/atoms/AppSidebar/AppSidebar.tsx +182 -94
  9. package/src/atoms/AppSidebar/preview.tsx +20 -59
  10. package/src/atoms/AppSidebarMobile/AppSidebarMobile.tsx +27 -73
  11. package/src/atoms/AppSidebarMobile/preview.tsx +18 -18
  12. package/src/atoms/AuthLogin/AuthLogin.tsx +200 -0
  13. package/src/atoms/AuthLogin/index.ts +2 -0
  14. package/src/atoms/AuthLogin/preview.tsx +22 -0
  15. package/src/atoms/AuthScreen/AuthScreen.tsx +7 -7
  16. package/src/atoms/AuthSignUp/AuthSignUp.tsx +243 -0
  17. package/src/atoms/AuthSignUp/index.ts +2 -0
  18. package/src/atoms/AuthSignUp/preview.tsx +22 -0
  19. package/src/atoms/BillingToggle/BillingToggle.tsx +65 -0
  20. package/src/atoms/BillingToggle/index.ts +2 -0
  21. package/src/atoms/BillingToggle/preview.tsx +23 -0
  22. package/src/atoms/Button/Button.tsx +33 -17
  23. package/src/atoms/Button/preview.tsx +16 -0
  24. package/src/atoms/ChatHistorySidebar/ChatHistorySidebar.tsx +370 -0
  25. package/src/atoms/ChatHistorySidebar/index.ts +2 -0
  26. package/src/atoms/ChatHistorySidebar/preview.tsx +60 -0
  27. package/src/atoms/ChatScreen/ChatScreen.tsx +331 -134
  28. package/src/atoms/ChatScreen/preview.tsx +123 -2
  29. package/src/atoms/Checkbox/Checkbox.tsx +89 -0
  30. package/src/atoms/Checkbox/index.ts +2 -0
  31. package/src/atoms/Checkbox/preview.tsx +60 -0
  32. package/src/atoms/Dropdown/Dropdown.tsx +195 -0
  33. package/src/atoms/Dropdown/index.ts +2 -0
  34. package/src/atoms/Dropdown/preview.tsx +56 -0
  35. package/src/atoms/FaqAccordionItem/FaqAccordionItem.tsx +60 -0
  36. package/src/atoms/FaqAccordionItem/index.ts +2 -0
  37. package/src/atoms/FaqAccordionItem/preview.tsx +26 -0
  38. package/src/atoms/FilterTabBar/FilterTabBar.tsx +8 -22
  39. package/src/atoms/HomePageTemplate/HomePageTemplate.tsx +20 -33
  40. package/src/atoms/HomePageTemplate/preview.tsx +2 -2
  41. package/src/atoms/Icon/Icon.tsx +7 -5
  42. package/src/atoms/Icon/icons.data.ts +51 -0
  43. package/src/atoms/Input/Input.tsx +17 -9
  44. package/src/atoms/Input/preview.tsx +24 -25
  45. package/src/atoms/Menu/Menu.tsx +320 -0
  46. package/src/atoms/Menu/index.ts +2 -0
  47. package/src/atoms/Menu/preview.tsx +63 -0
  48. package/src/atoms/Modal/Modal.tsx +43 -37
  49. package/src/atoms/Modal/preview.tsx +13 -0
  50. package/src/atoms/NavItem/NavItem.tsx +33 -45
  51. package/src/atoms/NavItem/preview.tsx +21 -26
  52. package/src/atoms/PreviewToolbar/PreviewToolbar.tsx +144 -192
  53. package/src/atoms/PreviewToolbar/preview.tsx +24 -4
  54. package/src/atoms/PricingCard/PricingCard.tsx +164 -0
  55. package/src/atoms/PricingCard/index.ts +2 -0
  56. package/src/atoms/PricingCard/preview.tsx +45 -0
  57. package/src/atoms/PricingPageTemplate/PricingPageTemplate.tsx +219 -0
  58. package/src/atoms/PricingPageTemplate/index.ts +2 -0
  59. package/src/atoms/PricingPageTemplate/preview.tsx +10 -0
  60. package/src/atoms/PromptInputBar/PromptInputBar.tsx +117 -158
  61. package/src/atoms/WorkspaceMenu/WorkspaceMenu.tsx +41 -167
  62. package/src/index.ts +10 -0
  63. package/src/tokens.css +5 -0
@@ -1,5 +1,11 @@
1
1
  import React from "react";
2
2
  import { ChatScreen, ChatMessage } from "./ChatScreen";
3
+ import { PromptInputBarModel } from "../PromptInputBar";
4
+
5
+ const DEMO_MODELS: PromptInputBarModel[] = [
6
+ { id: "fast", name: "Fast", tier: "Standard", description: "Quick responses for everyday edits" },
7
+ { id: "pro", name: "Pro", tier: "Pro", description: "Deeper reasoning for complex components" },
8
+ ];
3
9
 
4
10
  const messagesWithTimeline: ChatMessage[] = [
5
11
  {
@@ -47,10 +53,125 @@ const messagesWithTimeline: ChatMessage[] = [
47
53
  },
48
54
  ];
49
55
 
56
+ const messagesWithImages: ChatMessage[] = [
57
+ {
58
+ id: "1",
59
+ role: "user",
60
+ content: "Here's the hero shot for the landing page, can you match this look?",
61
+ userInitials: "ME",
62
+ images: [{ src: "https://picsum.photos/seed/hero1/800/500", alt: "Landing page hero reference" }],
63
+ },
64
+ {
65
+ id: "2",
66
+ role: "ai",
67
+ content: "Got it — matching the crop and spacing from that reference now.",
68
+ },
69
+ {
70
+ id: "3",
71
+ role: "user",
72
+ content: "",
73
+ userInitials: "ME",
74
+ images: [
75
+ { src: "https://picsum.photos/seed/mosaic1/600/600", alt: "Screenshot 1" },
76
+ { src: "https://picsum.photos/seed/mosaic2/600/600", alt: "Screenshot 2" },
77
+ { src: "https://picsum.photos/seed/mosaic3/600/400", alt: "Screenshot 3" },
78
+ { src: "https://picsum.photos/seed/mosaic4/600/400", alt: "Screenshot 4" },
79
+ ],
80
+ },
81
+ {
82
+ id: "4",
83
+ role: "ai",
84
+ content: "Here are a few more style directions to compare side by side.",
85
+ images: [
86
+ { src: "https://picsum.photos/seed/style1/600/600", alt: "Style 1" },
87
+ { src: "https://picsum.photos/seed/style2/600/600", alt: "Style 2" },
88
+ { src: "https://picsum.photos/seed/style3/600/400", alt: "Style 3" },
89
+ { src: "https://picsum.photos/seed/style4/600/400", alt: "Style 4" },
90
+ { src: "https://picsum.photos/seed/style5/600/400", alt: "Style 5" },
91
+ { src: "https://picsum.photos/seed/style6/600/400", alt: "Style 6" },
92
+ ],
93
+ },
94
+ ];
95
+
96
+ const messagesWithSuggestions: ChatMessage[] = [
97
+ {
98
+ id: "1",
99
+ role: "user",
100
+ content: "Can you suggest a design for our new pricing page?",
101
+ userInitials: "ME",
102
+ },
103
+ {
104
+ id: "2",
105
+ role: "ai",
106
+ content: "Here's a mockup I put together for the pricing page:",
107
+ suggestedImage: {
108
+ src: "https://picsum.photos/seed/mockup1/900/600",
109
+ alt: "Pricing page mockup",
110
+ ctaLabel: "Create this design",
111
+ onCta: () => console.log("create single design"),
112
+ },
113
+ },
114
+ {
115
+ id: "3",
116
+ role: "user",
117
+ content: "Can I see a few options for the dashboard layout?",
118
+ userInitials: "ME",
119
+ },
120
+ {
121
+ id: "4",
122
+ role: "ai",
123
+ content: "Sure — here are three directions, tap the thumbnail to compare them full-screen:",
124
+ suggestedImage: {
125
+ src: "https://picsum.photos/seed/board1/900/600",
126
+ alt: "Dashboard layout options",
127
+ ctaLabel: "Create this design",
128
+ options: [
129
+ { id: "opt-a", src: "https://picsum.photos/seed/optA/900/700", label: "Option A — Card grid" },
130
+ { id: "opt-b", src: "https://picsum.photos/seed/optB/900/700", label: "Option B — Sidebar nav" },
131
+ { id: "opt-c", src: "https://picsum.photos/seed/optC/900/700", label: "Option C — Split view" },
132
+ ],
133
+ onSelectOption: (id) => console.log("selected design option", id),
134
+ },
135
+ },
136
+ ];
137
+
50
138
  export default function Preview() {
139
+ const [suggestDesigns1, setSuggestDesigns1] = React.useState(false);
140
+ const [suggestDesigns2, setSuggestDesigns2] = React.useState(false);
141
+ const [suggestDesigns3, setSuggestDesigns3] = React.useState(true);
142
+
51
143
  return (
52
- <div className="w-full max-w-3xl mx-auto" style={{ height: 640 }}>
53
- <ChatScreen messages={messagesWithTimeline} placeholder="Ask anything…" />
144
+ <div className="w-full max-w-3xl mx-auto space-y-xl">
145
+ <div style={{ height: 640 }}>
146
+ <ChatScreen
147
+ messages={messagesWithTimeline}
148
+ placeholder="Ask anything…"
149
+ models={DEMO_MODELS}
150
+ selectedModelId="fast"
151
+ suggestDesigns={suggestDesigns1}
152
+ onSuggestDesignsChange={setSuggestDesigns1}
153
+ />
154
+ </div>
155
+ <div style={{ height: 640 }}>
156
+ <ChatScreen
157
+ messages={messagesWithImages}
158
+ placeholder="Ask anything…"
159
+ models={DEMO_MODELS}
160
+ selectedModelId="pro"
161
+ suggestDesigns={suggestDesigns2}
162
+ onSuggestDesignsChange={setSuggestDesigns2}
163
+ />
164
+ </div>
165
+ <div style={{ height: 640 }}>
166
+ <ChatScreen
167
+ messages={messagesWithSuggestions}
168
+ placeholder="Ask anything…"
169
+ models={DEMO_MODELS}
170
+ selectedModelId="fast"
171
+ suggestDesigns={suggestDesigns3}
172
+ onSuggestDesignsChange={setSuggestDesigns3}
173
+ />
174
+ </div>
54
175
  </div>
55
176
  );
56
177
  }
@@ -0,0 +1,89 @@
1
+ import * as React from "react";
2
+ import { Icon } from "../Icon";
3
+
4
+ export interface CheckboxProps
5
+ extends Omit<React.ComponentPropsWithoutRef<"input">, "size" | "type"> {
6
+ /** Visual size of the checkbox box. */
7
+ size?: "sm" | "md" | "lg";
8
+ /** Label text rendered next to the box. Omit for a bare checkbox. */
9
+ label?: string;
10
+ /** Additional helper/description text under the label. */
11
+ description?: string;
12
+ }
13
+
14
+ const SIZE_BOX: Record<NonNullable<CheckboxProps["size"]>, string> = {
15
+ sm: "size-4",
16
+ md: "size-5",
17
+ lg: "size-6",
18
+ };
19
+
20
+ const SIZE_ICON: Record<NonNullable<CheckboxProps["size"]>, string> = {
21
+ sm: "size-3",
22
+ md: "size-3.5",
23
+ lg: "size-4",
24
+ };
25
+
26
+ const SIZE_LABEL: Record<NonNullable<CheckboxProps["size"]>, string> = {
27
+ sm: "text-body-sm",
28
+ md: "text-body-md",
29
+ lg: "text-body-md",
30
+ };
31
+
32
+ export const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
33
+ (
34
+ {
35
+ size = "md",
36
+ label,
37
+ description,
38
+ className,
39
+ disabled,
40
+ id,
41
+ ...props
42
+ },
43
+ ref
44
+ ) => {
45
+ const generatedId = React.useId();
46
+ const inputId = id ?? generatedId;
47
+
48
+ return (
49
+ <label
50
+ htmlFor={inputId}
51
+ className={`inline-flex items-start gap-sm ${
52
+ disabled ? "cursor-not-allowed opacity-disabled" : "cursor-pointer"
53
+ } ${className ?? ""}`}
54
+ >
55
+ <span className="relative inline-flex shrink-0 items-center justify-center">
56
+ <input
57
+ ref={ref}
58
+ id={inputId}
59
+ type="checkbox"
60
+ disabled={disabled}
61
+ className="peer sr-only"
62
+ {...props}
63
+ />
64
+ <span
65
+ aria-hidden="true"
66
+ className={`${SIZE_BOX[size]} inline-flex items-center justify-center rounded-xs border border-hairline-strong bg-canvas transition-colors peer-checked:border-primary peer-checked:bg-primary peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-primary-focus peer-disabled:border-hairline peer-disabled:bg-surface-soft`}
67
+ >
68
+ <Icon
69
+ name="check-checkmark"
70
+ className={`${SIZE_ICON[size]} text-on-primary opacity-0 peer-checked:opacity-100 [.peer:checked~span_&]:opacity-100 scale-90 peer-checked:scale-100 transition-all`}
71
+ />
72
+ </span>
73
+ </span>
74
+ {(label || description) && (
75
+ <span className="flex flex-col gap-xxs">
76
+ {label && (
77
+ <span className={`${SIZE_LABEL[size]} text-ink`}>{label}</span>
78
+ )}
79
+ {description && (
80
+ <span className="text-body-sm text-muted">{description}</span>
81
+ )}
82
+ </span>
83
+ )}
84
+ </label>
85
+ );
86
+ }
87
+ );
88
+
89
+ Checkbox.displayName = "Checkbox";
@@ -0,0 +1,2 @@
1
+ export { Checkbox } from "./Checkbox";
2
+ export type { CheckboxProps } from "./Checkbox";
@@ -0,0 +1,60 @@
1
+ import * as React from "react";
2
+ import { Checkbox } from "./Checkbox";
3
+
4
+ export default function CheckboxPreview() {
5
+ const [subscribe, setSubscribe] = React.useState(true);
6
+ const [terms, setTerms] = React.useState(false);
7
+ const [notify, setNotify] = React.useState(false);
8
+
9
+ return (
10
+ <div className="w-full max-w-3xl mx-auto p-lg space-y-lg">
11
+ <div className="space-y-md">
12
+ <p className="text-caption uppercase tracking-wide text-muted">
13
+ Sizes
14
+ </p>
15
+ <div className="flex items-center gap-xl">
16
+ <Checkbox
17
+ size="sm"
18
+ label="Small"
19
+ checked={subscribe}
20
+ onChange={(e) => setSubscribe(e.target.checked)}
21
+ />
22
+ <Checkbox
23
+ size="md"
24
+ label="Medium"
25
+ checked={terms}
26
+ onChange={(e) => setTerms(e.target.checked)}
27
+ />
28
+ <Checkbox
29
+ size="lg"
30
+ label="Large"
31
+ checked={notify}
32
+ onChange={(e) => setNotify(e.target.checked)}
33
+ />
34
+ </div>
35
+ </div>
36
+
37
+ <div className="space-y-md">
38
+ <p className="text-caption uppercase tracking-wide text-muted">
39
+ With description
40
+ </p>
41
+ <Checkbox
42
+ label="Email notifications"
43
+ description="Get notified when someone comments on your posts."
44
+ checked={notify}
45
+ onChange={(e) => setNotify(e.target.checked)}
46
+ />
47
+ </div>
48
+
49
+ <div className="space-y-md">
50
+ <p className="text-caption uppercase tracking-wide text-muted">
51
+ Disabled
52
+ </p>
53
+ <div className="flex items-center gap-xl">
54
+ <Checkbox label="Disabled unchecked" disabled />
55
+ <Checkbox label="Disabled checked" disabled defaultChecked />
56
+ </div>
57
+ </div>
58
+ </div>
59
+ );
60
+ }
@@ -0,0 +1,195 @@
1
+ import * as React from "react";
2
+ import { Icon } from "../Icon";
3
+ import { Button } from "../Button";
4
+
5
+ export interface DropdownOption {
6
+ label: string;
7
+ value: string;
8
+ }
9
+
10
+ export interface DropdownProps {
11
+ /** Options rendered in the floating list. */
12
+ options: DropdownOption[];
13
+ /** Currently selected value. */
14
+ value?: string;
15
+ /** Placeholder shown when nothing is selected. */
16
+ placeholder?: string;
17
+ /** Called with the newly selected value. */
18
+ onChange?: (value: string) => void;
19
+ /** Disables the control entirely. */
20
+ disabled?: boolean;
21
+ /** Optional label rendered above the trigger. */
22
+ label?: string;
23
+ /** Extra classes on the root element. */
24
+ className?: string;
25
+ id?: string;
26
+ }
27
+
28
+ export const Dropdown = React.forwardRef<HTMLDivElement, DropdownProps>(
29
+ (
30
+ {
31
+ options,
32
+ value,
33
+ placeholder = "Selected option",
34
+ onChange,
35
+ disabled = false,
36
+ label,
37
+ className = "",
38
+ id,
39
+ },
40
+ ref
41
+ ) => {
42
+ const [open, setOpen] = React.useState(false);
43
+ const [highlighted, setHighlighted] = React.useState<number>(-1);
44
+ const rootRef = React.useRef<HTMLDivElement>(null);
45
+ const listRef = React.useRef<HTMLUListElement>(null);
46
+ const reactId = React.useId();
47
+ const triggerId = id ?? `dropdown-${reactId}`;
48
+ const listboxId = `${triggerId}-listbox`;
49
+
50
+ const selectedOption = options.find((o) => o.value === value);
51
+
52
+ React.useImperativeHandle(ref, () => rootRef.current as HTMLDivElement);
53
+
54
+ React.useEffect(() => {
55
+ if (!open) return;
56
+ const handlePointerDown = (e: PointerEvent) => {
57
+ if (!rootRef.current?.contains(e.target as Node)) {
58
+ setOpen(false);
59
+ }
60
+ };
61
+ document.addEventListener("pointerdown", handlePointerDown);
62
+ return () => document.removeEventListener("pointerdown", handlePointerDown);
63
+ }, [open]);
64
+
65
+ const openList = () => {
66
+ if (disabled) return;
67
+ const idx = options.findIndex((o) => o.value === value);
68
+ setHighlighted(idx >= 0 ? idx : 0);
69
+ setOpen(true);
70
+ };
71
+
72
+ const closeList = () => setOpen(false);
73
+
74
+ const commit = (idx: number) => {
75
+ const opt = options[idx];
76
+ if (!opt) return;
77
+ onChange?.(opt.value);
78
+ closeList();
79
+ };
80
+
81
+ const handleTriggerKeyDown = (e: React.KeyboardEvent) => {
82
+ if (disabled) return;
83
+ if (!open && (e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "Enter" || e.key === " ")) {
84
+ e.preventDefault();
85
+ openList();
86
+ return;
87
+ }
88
+ if (open) {
89
+ if (e.key === "ArrowDown") {
90
+ e.preventDefault();
91
+ setHighlighted((h) => Math.min(h + 1, options.length - 1));
92
+ } else if (e.key === "ArrowUp") {
93
+ e.preventDefault();
94
+ setHighlighted((h) => Math.max(h - 1, 0));
95
+ } else if (e.key === "Enter" || e.key === " ") {
96
+ e.preventDefault();
97
+ commit(highlighted);
98
+ } else if (e.key === "Escape") {
99
+ e.preventDefault();
100
+ closeList();
101
+ } else if (e.key === "Tab") {
102
+ closeList();
103
+ }
104
+ }
105
+ };
106
+
107
+ return (
108
+ <div ref={rootRef} className={`relative w-full ${className}`}>
109
+ {label ? (
110
+ <label
111
+ htmlFor={triggerId}
112
+ className="mb-xs block text-caption font-weight-caption uppercase tracking-wide text-muted"
113
+ >
114
+ {label}
115
+ </label>
116
+ ) : null}
117
+
118
+ <Button
119
+ type="button"
120
+ id={triggerId}
121
+ role="combobox"
122
+ aria-haspopup="listbox"
123
+ aria-expanded={open}
124
+ aria-controls={listboxId}
125
+ disabled={disabled}
126
+ onClick={() => (open ? closeList() : openList())}
127
+ onKeyDown={handleTriggerKeyDown}
128
+ variant="bare"
129
+ size="auto"
130
+ pushEffect={false}
131
+ className={[
132
+ "w-full justify-between rounded-lg border px-base py-sm text-body-md",
133
+ disabled
134
+ ? "cursor-not-allowed border-hairline-soft bg-surface-soft text-muted-soft"
135
+ : open
136
+ ? "border-primary bg-surface-soft text-ink ring-2 ring-primary-focus"
137
+ : "border-hairline bg-surface-soft text-ink hover:border-hairline-strong",
138
+ ].join(" ")}
139
+ >
140
+ <span className={selectedOption ? "text-ink" : "text-muted"}>
141
+ {selectedOption ? selectedOption.label : placeholder}
142
+ </span>
143
+ <span
144
+ className={[
145
+ "flex size-7 shrink-0 items-center justify-center rounded-full",
146
+ disabled ? "bg-surface-strong" : open ? "bg-primary-focus/15" : "bg-surface-strong",
147
+ ].join(" ")}
148
+ >
149
+ <Icon
150
+ name="chevron-down"
151
+ className={[
152
+ "size-4 shrink-0 transition-transform duration-150",
153
+ disabled ? "text-muted-soft" : "text-ink",
154
+ open ? "rotate-180" : "rotate-0",
155
+ ].join(" ")}
156
+ />
157
+ </span>
158
+ </Button>
159
+
160
+ {open && !disabled ? (
161
+ <ul
162
+ ref={listRef}
163
+ id={listboxId}
164
+ role="listbox"
165
+ aria-labelledby={triggerId}
166
+ className="absolute left-0 right-0 top-[calc(100%+8px)] z-10 max-h-64 overflow-auto rounded-lg border border-hairline-soft bg-canvas p-xs shadow-card"
167
+ >
168
+ {options.map((opt, idx) => {
169
+ const isSelected = opt.value === value;
170
+ const isHighlighted = idx === highlighted;
171
+ return (
172
+ <li
173
+ key={opt.value}
174
+ role="option"
175
+ aria-selected={isSelected}
176
+ onMouseEnter={() => setHighlighted(idx)}
177
+ onClick={() => commit(idx)}
178
+ className={[
179
+ "flex cursor-pointer items-center justify-between gap-sm rounded-md px-sm py-sm text-body-md text-ink transition-colors",
180
+ isHighlighted ? "bg-surface-soft" : "bg-transparent",
181
+ ].join(" ")}
182
+ >
183
+ <span>{opt.label}</span>
184
+ {isSelected ? <Icon name="check-checkmark" className="size-4 shrink-0 text-primary" /> : null}
185
+ </li>
186
+ );
187
+ })}
188
+ </ul>
189
+ ) : null}
190
+ </div>
191
+ );
192
+ }
193
+ );
194
+
195
+ Dropdown.displayName = "Dropdown";
@@ -0,0 +1,2 @@
1
+ export { Dropdown } from "./Dropdown";
2
+ export type { DropdownProps, DropdownOption } from "./Dropdown";
@@ -0,0 +1,56 @@
1
+ import * as React from "react";
2
+ import { Dropdown } from "./Dropdown";
3
+
4
+ const OPTIONS = [
5
+ { label: "Option one", value: "one" },
6
+ { label: "Option two", value: "two" },
7
+ { label: "Option three", value: "three" },
8
+ { label: "Option four", value: "four" },
9
+ ];
10
+
11
+ const CREDIT_OPTIONS = [
12
+ { label: "100 credits", value: "100", meta: "$25 /mo" },
13
+ { label: "200 credits", value: "200", meta: "$50 /mo" },
14
+ { label: "1,200 credits", value: "1200", meta: "$294 /mo", badge: "Save 2%" },
15
+ { label: "2,000 credits", value: "2000", meta: "$480 /mo", badge: "Save 4%" },
16
+ ];
17
+
18
+ export default function DropdownPreview() {
19
+ const [defaultValue, setDefaultValue] = React.useState<string | undefined>(undefined);
20
+ const [openValue, setOpenValue] = React.useState<string | undefined>("two");
21
+ const [selectedValue, setSelectedValue] = React.useState<string | undefined>("three");
22
+ const [creditValue, setCreditValue] = React.useState<string>("100");
23
+
24
+ return (
25
+ <div className="w-full max-w-3xl mx-auto p-lg space-y-xl">
26
+ <div>
27
+ <p className="mb-xs text-caption font-weight-caption uppercase tracking-wide text-muted">Default</p>
28
+ <Dropdown options={OPTIONS} value={defaultValue} onChange={setDefaultValue} />
29
+ </div>
30
+
31
+ <div>
32
+ <p className="mb-xs text-caption font-weight-caption uppercase tracking-wide text-muted">
33
+ Interactive (try selecting an option)
34
+ </p>
35
+ <Dropdown options={OPTIONS} value={openValue} onChange={setOpenValue} />
36
+ </div>
37
+
38
+ <div>
39
+ <p className="mb-xs text-caption font-weight-caption uppercase tracking-wide text-muted">Pre-selected</p>
40
+ <Dropdown options={OPTIONS} value={selectedValue} onChange={setSelectedValue} />
41
+ </div>
42
+
43
+ <div>
44
+ <p className="mb-xs text-caption font-weight-caption uppercase tracking-wide text-muted">
45
+ Rich rows (badge + meta), e.g. a credits picker
46
+ </p>
47
+ <Dropdown options={CREDIT_OPTIONS} value={creditValue} onChange={setCreditValue} />
48
+ </div>
49
+
50
+ <div>
51
+ <p className="mb-xs text-caption font-weight-caption uppercase tracking-wide text-muted">Disabled</p>
52
+ <Dropdown options={OPTIONS} value={undefined} disabled />
53
+ </div>
54
+ </div>
55
+ );
56
+ }
@@ -0,0 +1,60 @@
1
+ import React from "react";
2
+ import { Button } from "../Button";
3
+ import { Icon } from "../Icon";
4
+
5
+ export interface FaqAccordionItemProps
6
+ extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"> {
7
+ /** The question text shown in the row header. */
8
+ question: string;
9
+ /** The answer text revealed when expanded. */
10
+ answer: string;
11
+ /** Whether this item is currently expanded. */
12
+ open: boolean;
13
+ /** Called when the row header is clicked, with the new open state. */
14
+ onToggle: () => void;
15
+ }
16
+
17
+ export const FaqAccordionItem = React.forwardRef<HTMLDivElement, FaqAccordionItemProps>(
18
+ ({ question, answer, open, onToggle, className, ...rest }, ref) => {
19
+ const contentId = React.useId();
20
+
21
+ return (
22
+ <div
23
+ ref={ref}
24
+ className={["rounded-md border border-hairline bg-canvas", className].filter(Boolean).join(" ")}
25
+ {...rest}
26
+ >
27
+ <Button
28
+ type="button"
29
+ variant="ghost"
30
+ pushEffect={false}
31
+ aria-expanded={open}
32
+ aria-controls={contentId}
33
+ onClick={onToggle}
34
+ className="!w-full !justify-between !gap-md !px-md !py-sm !rounded-md !text-left !border-0"
35
+ >
36
+ <span className="text-body-sm font-weight-heading-sm text-ink">{question}</span>
37
+ <Icon
38
+ name="chevron-down"
39
+ className={[
40
+ "size-4 flex-shrink-0 text-muted transition-transform duration-200",
41
+ open ? "rotate-180" : "rotate-0",
42
+ ].join(" ")}
43
+ />
44
+ </Button>
45
+
46
+ <div
47
+ id={contentId}
48
+ className="grid overflow-hidden transition-all duration-200 ease-in-out"
49
+ style={{ gridTemplateRows: open ? "1fr" : "0fr", opacity: open ? 1 : 0 }}
50
+ >
51
+ <div className="min-h-0 overflow-hidden">
52
+ <p className="px-md pb-sm text-body-sm text-muted">{answer}</p>
53
+ </div>
54
+ </div>
55
+ </div>
56
+ );
57
+ },
58
+ );
59
+
60
+ FaqAccordionItem.displayName = "FaqAccordionItem";
@@ -0,0 +1,2 @@
1
+ export { FaqAccordionItem } from "./FaqAccordionItem";
2
+ export type { FaqAccordionItemProps } from "./FaqAccordionItem";
@@ -0,0 +1,26 @@
1
+ import React, { useState } from "react";
2
+ import { FaqAccordionItem } from "./FaqAccordionItem";
3
+
4
+ const FAQS = [
5
+ { q: "Can I change plans anytime?", a: "Yes — you can upgrade, downgrade, or cancel your plan at any time from your account settings. Changes take effect on your next billing cycle." },
6
+ { q: "Is there a free trial for Pro?", a: "Pro comes with a 14-day free trial, no credit card required. You can cancel anytime during the trial with no charge." },
7
+ { q: "What payment methods do you accept?", a: "We accept all major credit cards, as well as invoicing for Enterprise plans." },
8
+ ];
9
+
10
+ export default function FaqAccordionItemPreview() {
11
+ const [openIndex, setOpenIndex] = useState<number | null>(0);
12
+
13
+ return (
14
+ <div className="w-full max-w-3xl mx-auto p-lg space-y-sm">
15
+ {FAQS.map((item, i) => (
16
+ <FaqAccordionItem
17
+ key={item.q}
18
+ question={item.q}
19
+ answer={item.a}
20
+ open={openIndex === i}
21
+ onToggle={() => setOpenIndex(openIndex === i ? null : i)}
22
+ />
23
+ ))}
24
+ </div>
25
+ );
26
+ }