@designa8/vibedesign-v6 1.20.20 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/fonts/plusjakartasans/PlusJakartaSans-Italic[wght].ttf +0 -0
- package/dist/fonts/plusjakartasans/PlusJakartaSans[wght].ttf +0 -0
- package/dist/index.cjs +12027 -4942
- package/dist/index.js +12089 -5004
- package/dist/styles.css +1393 -97
- package/package.json +116 -1
- package/src/atoms/AgentQuestionCard/AgentQuestionCard.tsx +567 -0
- package/src/atoms/AgentQuestionCard/index.ts +6 -0
- package/src/atoms/AgentQuestionCard/preview.tsx +199 -0
- package/src/atoms/AppLayout/AppLayout.tsx +85 -22
- package/src/atoms/AppLayout/preview.tsx +4 -0
- package/src/atoms/AppSidebar/AppSidebar.tsx +222 -137
- package/src/atoms/AppSidebar/preview.tsx +61 -8
- package/src/atoms/AppSidebarMobile/AppSidebarMobile.tsx +241 -169
- package/src/atoms/AppSidebarMobile/preview.tsx +59 -89
- package/src/atoms/AuthLogin/AuthLogin.tsx +86 -49
- package/src/atoms/AuthLogin/preview.tsx +16 -0
- package/src/atoms/AuthSignUp/AuthSignUp.tsx +206 -126
- package/src/atoms/AuthSignUp/preview.tsx +10 -0
- package/src/atoms/BottomSheet/BottomSheet.tsx +199 -0
- package/src/atoms/BottomSheet/index.ts +2 -0
- package/src/atoms/BottomSheet/preview.tsx +50 -0
- package/src/atoms/Button/Button.tsx +19 -3
- package/src/atoms/Button/preview.tsx +2 -1
- package/src/atoms/ChatHistorySidebar/ChatHistorySidebar.tsx +160 -84
- package/src/atoms/ChatHistorySidebar/preview.tsx +81 -42
- package/src/atoms/ChatScreen/ChatScreen.tsx +298 -33
- package/src/atoms/ChatScreen/preview.tsx +54 -90
- package/src/atoms/Chip/Chip.tsx +81 -33
- package/src/atoms/Chip/preview.tsx +39 -21
- package/src/atoms/CodeEditor/CodeEditor.tsx +10 -4
- package/src/atoms/ComponentActionsSheet/ComponentActionsSheet.tsx +165 -0
- package/src/atoms/ComponentActionsSheet/index.ts +7 -0
- package/src/atoms/ComponentActionsSheet/preview.tsx +67 -0
- package/src/atoms/ComponentCard/ComponentCard.tsx +17 -35
- package/src/atoms/ComponentCard/preview.tsx +9 -9
- package/src/atoms/DesignSystemLoader/DesignSystemLoader.tsx +153 -0
- package/src/atoms/DesignSystemLoader/index.ts +2 -0
- package/src/atoms/DesignSystemLoader/preview.tsx +19 -0
- package/src/atoms/DesignSystemShowcase/DesignSystemShowcase.tsx +410 -0
- package/src/atoms/DesignSystemShowcase/index.ts +6 -0
- package/src/atoms/DesignSystemShowcase/preview.tsx +22 -0
- package/src/atoms/DesignTokensPanel/DesignTokensPanel.data.ts +254 -0
- package/src/atoms/DesignTokensPanel/DesignTokensPanel.tsx +946 -0
- package/src/atoms/DesignTokensPanel/index.ts +9 -0
- package/src/atoms/DesignTokensPanel/preview.tsx +39 -0
- package/src/atoms/ExpandableMessage/ExpandableMessage.tsx +239 -0
- package/src/atoms/ExpandableMessage/fix-link-note.txt +3 -0
- package/src/atoms/ExpandableMessage/index.ts +2 -0
- package/src/atoms/ExpandableMessage/markdown.tsx +310 -0
- package/src/atoms/ExpandableMessage/preview.tsx +83 -0
- package/src/atoms/FilterTabBar/FilterTabBar.tsx +2 -2
- package/src/atoms/FontCombobox/FontCombobox.tsx +655 -0
- package/src/atoms/FontCombobox/index.ts +6 -0
- package/src/atoms/FontCombobox/preview.tsx +111 -0
- package/src/atoms/HomePageTemplate/HomePageTemplate.tsx +894 -96
- package/src/atoms/HomePageTemplate/preview.tsx +4 -0
- package/src/atoms/Icon/Icon.tsx +17 -11
- package/src/atoms/Icon/icons.data.ts +34 -0
- package/src/atoms/Input/Input.tsx +37 -21
- package/src/atoms/LandingHero/LandingHero.tsx +545 -0
- package/src/atoms/LandingHero/index.ts +6 -0
- package/src/atoms/LandingHero/preview.tsx +88 -0
- package/src/atoms/MarketingFooter/MarketingFooter.tsx +215 -0
- package/src/atoms/MarketingFooter/index.ts +7 -0
- package/src/atoms/MarketingFooter/preview.tsx +28 -0
- package/src/atoms/MarketingNavbar/MarketingNavbar.tsx +451 -0
- package/src/atoms/MarketingNavbar/index.ts +7 -0
- package/src/atoms/MarketingNavbar/preview.tsx +109 -0
- package/src/atoms/MobileActionsDrawer/MobileActionsDrawer.tsx +548 -0
- package/src/atoms/MobileActionsDrawer/index.ts +9 -0
- package/src/atoms/MobileActionsDrawer/preview.tsx +109 -0
- package/src/atoms/Modal/Modal.tsx +77 -28
- package/src/atoms/PreviewDock/PreviewDock.tsx +119 -0
- package/src/atoms/PreviewDock/index.ts +2 -0
- package/src/atoms/PreviewDock/preview.tsx +30 -0
- package/src/atoms/PreviewToolbar/PreviewToolbar.tsx +47 -30
- package/src/atoms/PricingCard/PricingCard.tsx +15 -4
- package/src/atoms/PricingPageTemplate/PricingPageTemplate.tsx +109 -89
- package/src/atoms/ProjectSettingsModal/ProjectSettingsModal.tsx +314 -0
- package/src/atoms/ProjectSettingsModal/index.ts +2 -0
- package/src/atoms/ProjectSettingsModal/preview.tsx +130 -0
- package/src/atoms/ProjectSettingsModal/switch.snippet.txt +8 -0
- package/src/atoms/PromptInputBar/PromptInputBar.tsx +750 -302
- package/src/atoms/PromptInputBar/preview.tsx +64 -64
- package/src/atoms/SettingsPageTemplate/SettingsPageTemplate.tsx +272 -0
- package/src/atoms/SettingsPageTemplate/index.ts +2 -0
- package/src/atoms/SettingsPageTemplate/preview.tsx +29 -0
- package/src/atoms/SidebarUpgradeBanner/SidebarUpgradeBanner.tsx +178 -0
- package/src/atoms/SidebarUpgradeBanner/index.ts +2 -0
- package/src/atoms/SidebarUpgradeBanner/preview.tsx +47 -0
- package/src/atoms/SkeletonChip/SkeletonChip.tsx +198 -0
- package/src/atoms/SkeletonChip/index.ts +2 -0
- package/src/atoms/SkeletonChip/preview.tsx +44 -0
- package/src/atoms/TemplateHeader/TemplateHeader.tsx +129 -0
- package/src/atoms/TemplateHeader/index.ts +2 -0
- package/src/atoms/TemplateHeader/preview.tsx +39 -0
- package/src/atoms/TemplateHero/TemplateHero.tsx +286 -0
- package/src/atoms/TemplateHero/index.ts +2 -0
- package/src/atoms/TemplateHero/preview.tsx +32 -0
- package/src/atoms/TemplateSummary/TemplateSummary.tsx +85 -0
- package/src/atoms/TemplateSummary/index.ts +2 -0
- package/src/atoms/TemplateSummary/preview.tsx +10 -0
- package/src/atoms/Toast/Toast.tsx +178 -0
- package/src/atoms/Toast/index.ts +2 -0
- package/src/atoms/Toast/preview.tsx +100 -0
- package/src/atoms/TopNavbar/TopNavbar.tsx +145 -67
- package/src/atoms/TopNavbar/preview.tsx +13 -7
- package/src/atoms/TopupModal/TopupModal.tsx +94 -0
- package/src/atoms/TopupModal/index.ts +2 -0
- package/src/atoms/TopupModal/preview.tsx +22 -0
- package/src/atoms/UpgradeCard/UpgradeCard.tsx +124 -43
- package/src/atoms/UpgradeCard/index.ts +1 -1
- package/src/atoms/UpgradeCard/preview.tsx +7 -14
- package/src/atoms/UpgradeModal/UpgradeModal.tsx +192 -0
- package/src/atoms/UpgradeModal/index.ts +2 -0
- package/src/atoms/UpgradeModal/preview.tsx +41 -0
- package/src/index.ts +23 -0
- package/src/tokens.css +45 -7
- package/dist/fonts/inter/Inter-Italic[opsz,wght].ttf +0 -0
- package/dist/fonts/inter/Inter[opsz,wght].ttf +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BottomSheet } from "./BottomSheet";
|
|
3
|
+
import { Button } from "../Button";
|
|
4
|
+
|
|
5
|
+
export default function Preview() {
|
|
6
|
+
const [open, setOpen] = React.useState(false);
|
|
7
|
+
const [size, setSize] = React.useState<"half" | "auto">("auto");
|
|
8
|
+
|
|
9
|
+
const show = (next: "half" | "auto") => {
|
|
10
|
+
setSize(next);
|
|
11
|
+
setOpen(true);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div className="w-full max-w-3xl mx-auto p-lg space-y-lg">
|
|
16
|
+
<div className="flex flex-wrap gap-sm">
|
|
17
|
+
<Button type="button" variant="secondary" size="sm" onClick={() => show("auto")}>
|
|
18
|
+
Open auto sheet
|
|
19
|
+
</Button>
|
|
20
|
+
<Button type="button" variant="secondary" size="sm" onClick={() => show("half")}>
|
|
21
|
+
Open half sheet
|
|
22
|
+
</Button>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<div className="relative h-[480px] w-full overflow-hidden rounded-lg border border-hairline bg-surface">
|
|
26
|
+
<div className="space-y-sm p-lg">
|
|
27
|
+
<p className="text-heading-sm text-ink">Parent screen</p>
|
|
28
|
+
<p className="text-body-sm text-muted">
|
|
29
|
+
The sheet anchors to this relative container, not the viewport.
|
|
30
|
+
</p>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<BottomSheet open={open} onOpenChange={setOpen} title="Sheet title" size={size}>
|
|
34
|
+
<div className="space-y-sm">
|
|
35
|
+
<p className="text-body-sm text-body">
|
|
36
|
+
Any content goes in the body slot. Drag the handle down more than 30% of the sheet height,
|
|
37
|
+
press Escape, or tap the scrim to close.
|
|
38
|
+
</p>
|
|
39
|
+
{size === "half" &&
|
|
40
|
+
Array.from({ length: 8 }).map((_, i) => (
|
|
41
|
+
<p key={i} className="text-body-sm text-muted">
|
|
42
|
+
Scrollable row {i + 1}
|
|
43
|
+
</p>
|
|
44
|
+
))}
|
|
45
|
+
</div>
|
|
46
|
+
</BottomSheet>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -57,11 +57,11 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
57
57
|
const isDisabled = disabled || loading;
|
|
58
58
|
|
|
59
59
|
const base =
|
|
60
|
-
"inline-flex items-center gap-sm font-weight-heading-sm select-none whitespace-nowrap focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-focus focus-visible:ring-offset-2";
|
|
60
|
+
"inline-flex items-center gap-sm font-weight-heading-sm select-none whitespace-nowrap cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-focus focus-visible:ring-offset-2";
|
|
61
61
|
|
|
62
62
|
const motionClasses = pushEffect
|
|
63
63
|
? "transition-[background-color,color,transform,filter] duration-150 ease-out active:scale-[0.97] active:brightness-95"
|
|
64
|
-
: "transition-colors duration-150";
|
|
64
|
+
: "transition-colors duration-150 ease-out";
|
|
65
65
|
|
|
66
66
|
const classes = [
|
|
67
67
|
base,
|
|
@@ -73,8 +73,24 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
73
73
|
.filter(Boolean)
|
|
74
74
|
.join(" ");
|
|
75
75
|
|
|
76
|
+
// The spinner is decorative; if the caller passes no visible text, the button
|
|
77
|
+
// still needs an accessible name while loading.
|
|
78
|
+
const hasVisibleLabel =
|
|
79
|
+
typeof children === "string"
|
|
80
|
+
? children.trim().length > 0
|
|
81
|
+
: React.Children.count(children) > 0;
|
|
82
|
+
const accessibleLabel =
|
|
83
|
+
rest["aria-label"] ?? (!hasVisibleLabel ? (loading ? "Loading" : "Button") : undefined);
|
|
84
|
+
|
|
76
85
|
return (
|
|
77
|
-
<button
|
|
86
|
+
<button
|
|
87
|
+
ref={ref}
|
|
88
|
+
disabled={isDisabled}
|
|
89
|
+
aria-label={accessibleLabel}
|
|
90
|
+
aria-busy={loading || undefined}
|
|
91
|
+
className={classes}
|
|
92
|
+
{...rest}
|
|
93
|
+
>
|
|
78
94
|
{loading && (
|
|
79
95
|
<Icon name="loading-spinner" className="size-4 animate-spin" aria-hidden="true" />
|
|
80
96
|
)}
|
|
@@ -20,7 +20,8 @@ export default function ButtonPreview() {
|
|
|
20
20
|
<div className="flex flex-col items-center gap-sm">
|
|
21
21
|
<span className="text-body-sm text-muted">Primary Hover</span>
|
|
22
22
|
<button
|
|
23
|
-
|
|
23
|
+
type="button"
|
|
24
|
+
className="inline-flex items-center justify-center gap-sm font-weight-heading-sm cursor-pointer transition-colors duration-150 ease-out px-lg py-sm text-body-md rounded-xl bg-primary-hover text-on-primary border border-transparent select-none whitespace-nowrap focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-focus focus-visible:ring-offset-2"
|
|
24
25
|
>
|
|
25
26
|
Primary
|
|
26
27
|
</button>
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { Button } from "../Button";
|
|
3
3
|
import { Icon } from "../Icon";
|
|
4
4
|
import { Menu, type MenuItem } from "../Menu";
|
|
5
|
+
import { Chip } from "../Chip";
|
|
5
6
|
|
|
6
7
|
/* ─── Types ──────────────────────────────────────────────────────────────── */
|
|
7
8
|
|
|
@@ -10,6 +11,16 @@ export interface ChatHistoryItem {
|
|
|
10
11
|
label: string;
|
|
11
12
|
/** Optional delete callback — a trash icon appears on hover when provided. */
|
|
12
13
|
onDelete?: (id: string) => void;
|
|
14
|
+
/** Where this chat came from. Renders a trailing "Agent" / "Manual" chip. */
|
|
15
|
+
origin?: "agent" | "manual";
|
|
16
|
+
/** ISO date string used to sort the flat, merged history list newest-first. */
|
|
17
|
+
updatedAt?: string;
|
|
18
|
+
/**
|
|
19
|
+
* When true a small primary dot pulses immediately left of the row's label,
|
|
20
|
+
* signalling that this conversation is still thinking. Defaults to false —
|
|
21
|
+
* idle rows render no dot and keep their label flush left.
|
|
22
|
+
*/
|
|
23
|
+
thinking?: boolean;
|
|
13
24
|
}
|
|
14
25
|
|
|
15
26
|
export interface ChatHistorySidebarProps extends React.HTMLAttributes<HTMLElement> {
|
|
@@ -24,28 +35,45 @@ export interface ChatHistorySidebarProps extends React.HTMLAttributes<HTMLElemen
|
|
|
24
35
|
defaultCollapsed?: boolean;
|
|
25
36
|
|
|
26
37
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
38
|
+
* Pre-merged, pre-sorted flat list of chat history rows. When provided,
|
|
39
|
+
* this is rendered as-is (no grouping, no re-sorting) — the caller owns
|
|
40
|
+
* ordering. Prefer this over the legacy `historyItems` /
|
|
41
|
+
* `componentHistoryItems` / `designMdRequestItems` props.
|
|
30
42
|
*/
|
|
31
|
-
historyItems?: ChatHistoryItem[];
|
|
32
|
-
/** Root / non-component chat entries rendered under the "Recents" heading. */
|
|
33
43
|
chatHistoryItems?: ChatHistoryItem[];
|
|
34
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Legacy root / non-component chat entries.
|
|
46
|
+
* @deprecated use `chatHistoryItems` instead. Still honored (merged with
|
|
47
|
+
* `componentHistoryItems` and `designMdRequestItems`, then sorted by
|
|
48
|
+
* `updatedAt` descending) when `chatHistoryItems` is omitted.
|
|
49
|
+
*/
|
|
50
|
+
historyItems?: ChatHistoryItem[];
|
|
51
|
+
/**
|
|
52
|
+
* Legacy chats that produced a generated component.
|
|
53
|
+
* @deprecated merged into the flat list (no separate section) when
|
|
54
|
+
* `chatHistoryItems` is omitted.
|
|
55
|
+
*/
|
|
35
56
|
componentHistoryItems?: ChatHistoryItem[];
|
|
36
57
|
/**
|
|
37
|
-
*
|
|
38
|
-
* (atom-requests and fix-requests)
|
|
39
|
-
*
|
|
58
|
+
* Legacy conversations created by consumer-app DESIGN.md agent calls
|
|
59
|
+
* (atom-requests and fix-requests).
|
|
60
|
+
* @deprecated merged into the flat list (no separate section) when
|
|
61
|
+
* `chatHistoryItems` is omitted.
|
|
40
62
|
*/
|
|
41
63
|
designMdRequestItems?: ChatHistoryItem[];
|
|
42
|
-
/** ID of the currently-active chat
|
|
64
|
+
/** ID of the currently-active chat. */
|
|
43
65
|
activeHistoryId?: string;
|
|
44
|
-
/** Called when a chat row is selected
|
|
66
|
+
/** Called when a chat row is selected. */
|
|
45
67
|
onSelectHistoryItem?: (id: string) => void;
|
|
46
68
|
|
|
47
69
|
onNewChat?: () => void;
|
|
48
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Called when the "Project settings" action is selected. When omitted, the
|
|
73
|
+
* Project settings control is not rendered at all.
|
|
74
|
+
*/
|
|
75
|
+
onProjectSettings?: () => void;
|
|
76
|
+
|
|
49
77
|
/**
|
|
50
78
|
* Initials shown in the avatar circle rendered as the first item in the
|
|
51
79
|
* sidebar's header (above the fold/unfold toggle). Omit to hide the avatar.
|
|
@@ -57,6 +85,27 @@ export interface ChatHistorySidebarProps extends React.HTMLAttributes<HTMLElemen
|
|
|
57
85
|
onHome?: () => void;
|
|
58
86
|
}
|
|
59
87
|
|
|
88
|
+
/* ─── Thinking dot animation ─────────────────────────────────────────────── */
|
|
89
|
+
/* A slow opacity pulse (~1.2s). The keyframes carry only opacity — no color
|
|
90
|
+
or size values — so the dot stays fully token-driven. Motion-reduced users
|
|
91
|
+
get a solid dot. */
|
|
92
|
+
|
|
93
|
+
const THINKING_STYLES = `
|
|
94
|
+
@keyframes chat-history-thinking-pulse {
|
|
95
|
+
0%, 100% { opacity: 1; }
|
|
96
|
+
50% { opacity: 0.25; }
|
|
97
|
+
}
|
|
98
|
+
.chat-history-thinking-dot {
|
|
99
|
+
animation: chat-history-thinking-pulse 1200ms ease-in-out infinite;
|
|
100
|
+
}
|
|
101
|
+
@media (prefers-reduced-motion: reduce) {
|
|
102
|
+
.chat-history-thinking-dot {
|
|
103
|
+
animation: none;
|
|
104
|
+
opacity: 1;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
`;
|
|
108
|
+
|
|
60
109
|
/* ─── Avatar nav trigger ─────────────────────────────────────────────────── */
|
|
61
110
|
/* The circular initials avatar composes the shared Menu molecule in `portal`
|
|
62
111
|
mode so the item list always paints above the sidebar's own clipped
|
|
@@ -155,49 +204,73 @@ interface HistoryRowProps {
|
|
|
155
204
|
onClick?: () => void;
|
|
156
205
|
}
|
|
157
206
|
|
|
207
|
+
/**
|
|
208
|
+
* One row = one rounded surface. The `<li>` owns the only fill (the selected
|
|
209
|
+
* `bg-primary-disabled`). The label hit target is a transparent native button
|
|
210
|
+
* with no border, no hover fill and no radius of its own, so nothing paints a
|
|
211
|
+
* second rectangle over the chip. Title and chip are vertically centred with
|
|
212
|
+
* the source chip inset from the title and from the rounded edge.
|
|
213
|
+
*/
|
|
158
214
|
const HistoryRow: React.FC<HistoryRowProps> = ({ item, active = false, onClick }) => {
|
|
159
215
|
const [hovered, setHovered] = React.useState(false);
|
|
216
|
+
const isAgent = item.origin === "agent";
|
|
217
|
+
const thinking = item.thinking === true;
|
|
160
218
|
|
|
161
219
|
return (
|
|
162
220
|
<li
|
|
163
|
-
className={[
|
|
221
|
+
className={[
|
|
222
|
+
"list-none flex items-center gap-xs rounded-md pr-xs",
|
|
223
|
+
"transition-colors duration-150 ease-out",
|
|
224
|
+
active ? "bg-primary-disabled" : hovered ? "bg-surface-soft" : "bg-transparent",
|
|
225
|
+
].join(" ")}
|
|
164
226
|
onMouseEnter={() => setHovered(true)}
|
|
165
227
|
onMouseLeave={() => setHovered(false)}
|
|
166
228
|
>
|
|
167
|
-
<
|
|
229
|
+
<button
|
|
168
230
|
type="button"
|
|
169
|
-
variant="ghost"
|
|
170
|
-
size="sm"
|
|
171
231
|
aria-current={active ? "page" : undefined}
|
|
172
232
|
onClick={onClick}
|
|
173
233
|
className={[
|
|
174
|
-
"
|
|
175
|
-
|
|
234
|
+
"flex flex-1 min-w-0 items-center gap-xs bg-transparent pl-sm py-xs pr-0 text-left",
|
|
235
|
+
"border-0 shadow-none cursor-pointer rounded-md",
|
|
236
|
+
"transition duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue",
|
|
237
|
+
active ? "text-primary" : "text-body hover:text-ink",
|
|
176
238
|
].join(" ")}
|
|
177
239
|
>
|
|
178
|
-
|
|
240
|
+
{thinking && (
|
|
241
|
+
<span
|
|
242
|
+
aria-hidden="true"
|
|
243
|
+
className="chat-history-thinking-dot size-2 shrink-0 rounded-full bg-primary"
|
|
244
|
+
/>
|
|
245
|
+
)}
|
|
246
|
+
<span dir="auto" className="block min-w-0 truncate text-body-sm">
|
|
179
247
|
{item.label}
|
|
180
248
|
</span>
|
|
181
|
-
</
|
|
249
|
+
</button>
|
|
250
|
+
<Chip
|
|
251
|
+
label={isAgent ? "Agent" : "Manual"}
|
|
252
|
+
variant={isAgent ? "primary" : "default"}
|
|
253
|
+
size="sm"
|
|
254
|
+
className="flex-shrink-0"
|
|
255
|
+
/>
|
|
182
256
|
{item.onDelete && (
|
|
183
|
-
<
|
|
257
|
+
<button
|
|
184
258
|
type="button"
|
|
185
|
-
variant="ghost"
|
|
186
|
-
size="sm"
|
|
187
259
|
aria-label={`Delete ${item.label}`}
|
|
188
260
|
onClick={(e) => {
|
|
189
261
|
e.stopPropagation();
|
|
190
262
|
item.onDelete!(item.id);
|
|
191
263
|
}}
|
|
192
264
|
className={[
|
|
193
|
-
"
|
|
194
|
-
"hover
|
|
265
|
+
"p-xxs rounded-xs bg-transparent border-0 flex-shrink-0 text-muted",
|
|
266
|
+
"cursor-pointer transition duration-200 ease-out hover:text-semantic-error",
|
|
267
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue",
|
|
195
268
|
hovered ? "opacity-100" : "opacity-0",
|
|
196
269
|
].join(" ")}
|
|
197
270
|
tabIndex={hovered ? 0 : -1}
|
|
198
271
|
>
|
|
199
272
|
<Icon name="trash-delete" style={{ width: "14px", height: "14px" }} />
|
|
200
|
-
</
|
|
273
|
+
</button>
|
|
201
274
|
)}
|
|
202
275
|
</li>
|
|
203
276
|
);
|
|
@@ -219,6 +292,7 @@ export const ChatHistorySidebar = React.forwardRef<HTMLElement, ChatHistorySideb
|
|
|
219
292
|
activeHistoryId,
|
|
220
293
|
onSelectHistoryItem,
|
|
221
294
|
onNewChat,
|
|
295
|
+
onProjectSettings,
|
|
222
296
|
avatarInitials,
|
|
223
297
|
onBackToProjects,
|
|
224
298
|
onHome,
|
|
@@ -231,10 +305,29 @@ export const ChatHistorySidebar = React.forwardRef<HTMLElement, ChatHistorySideb
|
|
|
231
305
|
const isControlled = collapsedProp !== undefined;
|
|
232
306
|
const collapsed = isControlled ? collapsedProp : internalCollapsed;
|
|
233
307
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
308
|
+
// A single flat, chronologically-sorted list — no section grouping.
|
|
309
|
+
// When `chatHistoryItems` is supplied the caller already merged + sorted
|
|
310
|
+
// it, so it's rendered verbatim. Otherwise the three legacy lists are
|
|
311
|
+
// merged and sorted by `updatedAt` descending (items missing a date sink
|
|
312
|
+
// to the bottom, in their original relative order).
|
|
313
|
+
const flatList = React.useMemo(() => {
|
|
314
|
+
if (chatHistoryItems) return chatHistoryItems;
|
|
315
|
+
|
|
316
|
+
const merged = [...(historyItems ?? []), ...componentHistoryItems, ...designMdRequestItems];
|
|
317
|
+
return merged
|
|
318
|
+
.map((item, index) => ({ item, index }))
|
|
319
|
+
.sort((a, b) => {
|
|
320
|
+
const at = a.item.updatedAt ? Date.parse(a.item.updatedAt) : NaN;
|
|
321
|
+
const bt = b.item.updatedAt ? Date.parse(b.item.updatedAt) : NaN;
|
|
322
|
+
const aValid = !Number.isNaN(at);
|
|
323
|
+
const bValid = !Number.isNaN(bt);
|
|
324
|
+
if (aValid && bValid) return bt - at;
|
|
325
|
+
if (aValid) return -1;
|
|
326
|
+
if (bValid) return 1;
|
|
327
|
+
return a.index - b.index;
|
|
328
|
+
})
|
|
329
|
+
.map((entry) => entry.item);
|
|
330
|
+
}, [chatHistoryItems, historyItems, componentHistoryItems, designMdRequestItems]);
|
|
238
331
|
|
|
239
332
|
const toggle = () => {
|
|
240
333
|
const next = !collapsed;
|
|
@@ -275,6 +368,8 @@ export const ChatHistorySidebar = React.forwardRef<HTMLElement, ChatHistorySideb
|
|
|
275
368
|
.join(" ")}
|
|
276
369
|
{...rest}
|
|
277
370
|
>
|
|
371
|
+
<style>{THINKING_STYLES}</style>
|
|
372
|
+
|
|
278
373
|
{/* Header — avatar first, then the fold/unfold toggle, with breathing room between them */}
|
|
279
374
|
{collapsed ? (
|
|
280
375
|
<div className="flex flex-col items-center gap-md px-sm pt-md pb-md flex-shrink-0">
|
|
@@ -297,68 +392,49 @@ export const ChatHistorySidebar = React.forwardRef<HTMLElement, ChatHistorySideb
|
|
|
297
392
|
</div>
|
|
298
393
|
)}
|
|
299
394
|
|
|
300
|
-
{/* Primary action — New chat
|
|
395
|
+
{/* Primary action — New chat, and optionally Project settings between it and the history list */}
|
|
301
396
|
<div className="flex-shrink-0 px-xs space-y-xxs pb-sm">
|
|
302
397
|
{collapsed ? (
|
|
303
|
-
|
|
398
|
+
<>
|
|
399
|
+
<RailButton label="New chat" icon={<Icon name="pencil-edit" className="size-[18px]" />} onClick={onNewChat} />
|
|
400
|
+
{onProjectSettings && (
|
|
401
|
+
<RailButton
|
|
402
|
+
label="Project settings"
|
|
403
|
+
icon={<Icon name="settings-gear" className="size-[18px]" />}
|
|
404
|
+
onClick={onProjectSettings}
|
|
405
|
+
/>
|
|
406
|
+
)}
|
|
407
|
+
</>
|
|
304
408
|
) : (
|
|
305
|
-
|
|
409
|
+
<>
|
|
410
|
+
<ExpandedRow label="New chat" icon={<Icon name="pencil-edit" className="size-[18px]" />} onClick={onNewChat} bold />
|
|
411
|
+
{onProjectSettings && (
|
|
412
|
+
<ExpandedRow
|
|
413
|
+
label="Project settings"
|
|
414
|
+
icon={<Icon name="settings-gear" className="size-[18px]" />}
|
|
415
|
+
onClick={onProjectSettings}
|
|
416
|
+
/>
|
|
417
|
+
)}
|
|
418
|
+
</>
|
|
306
419
|
)}
|
|
307
420
|
</div>
|
|
308
421
|
|
|
309
|
-
{/*
|
|
422
|
+
{/* Flat chat history list — only meaningful when expanded, no section headings */}
|
|
310
423
|
{!collapsed && (
|
|
311
|
-
<div className="flex-1 min-h-0 overflow-y-auto overflow-x-hidden px-sm pb-md
|
|
312
|
-
{
|
|
313
|
-
<
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
{
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
</ul>
|
|
326
|
-
) : (
|
|
327
|
-
<p className="text-body-sm text-muted-soft px-sm py-xs">No recent chats yet.</p>
|
|
328
|
-
)}
|
|
329
|
-
</div>
|
|
330
|
-
)}
|
|
331
|
-
|
|
332
|
-
{components.length > 0 && (
|
|
333
|
-
<div className="space-y-xxs">
|
|
334
|
-
<p className="text-caption text-muted-soft px-sm">Components</p>
|
|
335
|
-
<ul className="space-y-xxs" role="list">
|
|
336
|
-
{components.map((item) => (
|
|
337
|
-
<HistoryRow
|
|
338
|
-
key={item.id}
|
|
339
|
-
item={item}
|
|
340
|
-
active={activeHistoryId === item.id}
|
|
341
|
-
onClick={() => onSelectHistoryItem?.(item.id)}
|
|
342
|
-
/>
|
|
343
|
-
))}
|
|
344
|
-
</ul>
|
|
345
|
-
</div>
|
|
346
|
-
)}
|
|
347
|
-
|
|
348
|
-
{designMdRequests.length > 0 && (
|
|
349
|
-
<div className="space-y-xxs">
|
|
350
|
-
<p className="text-caption text-muted-soft px-sm">Design.md requests</p>
|
|
351
|
-
<ul className="space-y-xxs" role="list">
|
|
352
|
-
{designMdRequests.map((item) => (
|
|
353
|
-
<HistoryRow
|
|
354
|
-
key={item.id}
|
|
355
|
-
item={item}
|
|
356
|
-
active={activeHistoryId === item.id}
|
|
357
|
-
onClick={() => onSelectHistoryItem?.(item.id)}
|
|
358
|
-
/>
|
|
359
|
-
))}
|
|
360
|
-
</ul>
|
|
361
|
-
</div>
|
|
424
|
+
<div className="flex-1 min-h-0 overflow-y-auto overflow-x-hidden px-sm pb-md">
|
|
425
|
+
{flatList.length > 0 ? (
|
|
426
|
+
<ul className="space-y-xxs" role="list">
|
|
427
|
+
{flatList.map((item) => (
|
|
428
|
+
<HistoryRow
|
|
429
|
+
key={item.id}
|
|
430
|
+
item={item}
|
|
431
|
+
active={activeHistoryId === item.id}
|
|
432
|
+
onClick={() => onSelectHistoryItem?.(item.id)}
|
|
433
|
+
/>
|
|
434
|
+
))}
|
|
435
|
+
</ul>
|
|
436
|
+
) : (
|
|
437
|
+
<p className="text-body-sm text-muted-soft px-sm py-xs">No chats yet.</p>
|
|
362
438
|
)}
|
|
363
439
|
</div>
|
|
364
440
|
)}
|
|
@@ -1,58 +1,97 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { ChatHistorySidebar
|
|
2
|
+
import { ChatHistorySidebar } from "./ChatHistorySidebar";
|
|
3
|
+
import type { ChatHistoryItem } from "./ChatHistorySidebar";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
// Already merged + sorted by updatedAt descending, mixing agent and manual
|
|
6
|
+
// origins — the sidebar renders this as one flat list, no headings.
|
|
7
|
+
// `thinking: true` shows the pulsing primary dot immediately left of the label.
|
|
8
|
+
const chats: ChatHistoryItem[] = [
|
|
9
|
+
{
|
|
10
|
+
id: "d1",
|
|
11
|
+
label: "Atom request: StatusBadge",
|
|
12
|
+
origin: "agent",
|
|
13
|
+
updatedAt: "2024-06-02T14:20:00Z",
|
|
14
|
+
thinking: true,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: "c1",
|
|
18
|
+
label: "Pricing card with annual toggle",
|
|
19
|
+
origin: "manual",
|
|
20
|
+
updatedAt: "2024-06-01T18:05:00Z",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "r1",
|
|
24
|
+
label: "Plan a weekend trip to Lisbon",
|
|
25
|
+
origin: "manual",
|
|
26
|
+
updatedAt: "2024-05-30T09:00:00Z",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "d2",
|
|
30
|
+
label: "Fix request: Switch thumb animation",
|
|
31
|
+
origin: "agent",
|
|
32
|
+
updatedAt: "2024-05-28T11:45:00Z",
|
|
33
|
+
thinking: true,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: "r2",
|
|
37
|
+
label: "Summarize quarterly earnings report",
|
|
38
|
+
origin: "manual",
|
|
39
|
+
updatedAt: "2024-05-27T08:15:00Z",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: "c2",
|
|
43
|
+
label: "Onboarding checklist widget with a very long chat title that truncates",
|
|
44
|
+
origin: "agent",
|
|
45
|
+
updatedAt: "2024-05-20T16:30:00Z",
|
|
46
|
+
},
|
|
18
47
|
];
|
|
19
48
|
|
|
20
49
|
export default function ChatHistorySidebarPreview() {
|
|
21
50
|
const [collapsed, setCollapsed] = React.useState(false);
|
|
22
|
-
const [activeId, setActiveId] = React.useState("
|
|
51
|
+
const [activeId, setActiveId] = React.useState("c1");
|
|
23
52
|
|
|
24
|
-
const
|
|
53
|
+
const items = React.useMemo(
|
|
54
|
+
() =>
|
|
55
|
+
chats.map((item) => ({
|
|
56
|
+
...item,
|
|
57
|
+
onDelete: (id: string) => setActiveId((current) => (current === id ? "" : current)),
|
|
58
|
+
})),
|
|
59
|
+
[],
|
|
60
|
+
);
|
|
25
61
|
|
|
26
62
|
return (
|
|
27
63
|
<div className="w-full max-w-3xl mx-auto p-lg space-y-lg">
|
|
28
|
-
<div
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
64
|
+
<div>
|
|
65
|
+
<p className="text-body-sm text-muted mb-sm">
|
|
66
|
+
Select any row — the title hit target is transparent, the row owns the single selected fill,
|
|
67
|
+
and the Manual / Agent chip sits inset inside that surface. The first and fourth rows are
|
|
68
|
+
thinking, so their dot pulses.
|
|
69
|
+
</p>
|
|
70
|
+
<div className="flex gap-lg items-stretch" style={{ height: 460 }}>
|
|
71
|
+
<ChatHistorySidebar
|
|
72
|
+
brandName="Acme"
|
|
73
|
+
avatarInitials="JD"
|
|
74
|
+
collapsed={collapsed}
|
|
75
|
+
onCollapsedChange={setCollapsed}
|
|
76
|
+
chatHistoryItems={items}
|
|
77
|
+
activeHistoryId={activeId}
|
|
78
|
+
onSelectHistoryItem={setActiveId}
|
|
79
|
+
onNewChat={() => setActiveId("")}
|
|
80
|
+
onProjectSettings={() => setActiveId("")}
|
|
81
|
+
/>
|
|
82
|
+
<div className="flex-1 flex items-center justify-center rounded-lg border border-hairline-soft text-body-sm text-muted-soft">
|
|
83
|
+
Main content area
|
|
84
|
+
</div>
|
|
43
85
|
</div>
|
|
44
86
|
</div>
|
|
45
87
|
|
|
46
|
-
<div
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
avatarInitials="JD"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/>
|
|
54
|
-
<div className="flex-1 flex items-center justify-center text-body-sm text-muted-soft">
|
|
55
|
-
Empty state — no recent, component, or Design.md chats yet
|
|
88
|
+
<div>
|
|
89
|
+
<p className="text-body-sm text-muted mb-sm">Empty state — no chats yet.</p>
|
|
90
|
+
<div className="flex gap-lg items-stretch" style={{ height: 260 }}>
|
|
91
|
+
<ChatHistorySidebar brandName="Acme" avatarInitials="JD" defaultCollapsed={false} />
|
|
92
|
+
<div className="flex-1 flex items-center justify-center rounded-lg border border-hairline-soft text-body-sm text-muted-soft">
|
|
93
|
+
Collapsed rail on the left
|
|
94
|
+
</div>
|
|
56
95
|
</div>
|
|
57
96
|
</div>
|
|
58
97
|
</div>
|