@vetta-org/theme-ui 0.1.2 → 0.2.0
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/package.json +8 -16
- package/src/activity/ActivityPanelFrame.tsx +1 -1
- package/src/activity/CodePreview.tsx +15 -1
- package/src/activity/MarkdownPreviewView.test.tsx +53 -0
- package/src/activity/MarkdownPreviewView.tsx +86 -10
- package/src/chat/ContextRingView.test.tsx +81 -0
- package/src/chat/ContextRingView.tsx +78 -62
- package/src/chat/HeaderActionBarView.tsx +122 -47
- package/src/chat/HeaderActionOverflowMenu.tsx +11 -20
- package/src/chat/MessageFeedLayoutView.tsx +6 -5
- package/src/chat/MessageInputView.tsx +5 -1
- package/src/chat/index.ts +2 -1
- package/src/chat/message-feed-fade.css +80 -0
- package/src/chat/message-feed-fade.test.tsx +75 -0
- package/src/file-preview/ReadonlyCodeView.tsx +46 -0
- package/src/file-preview/syntax-tokens.css +1 -1
- package/src/image-assets.d.ts +4 -0
- package/src/markdown/FileLinkBadge.tsx +77 -0
- package/src/markdown/MarkdownContent.tsx +12 -5
- package/src/markdown/MarkdownImage.tsx +6 -16
- package/src/markdown/MermaidBlock.tsx +50 -11
- package/src/markdown/image-actions.ts +29 -0
- package/src/markdown/index.ts +1 -0
- package/src/markdown/preview-policy.test.ts +31 -0
- package/src/markdown/preview-policy.ts +33 -0
- package/src/markdown/progressive-chunks.test.ts +43 -0
- package/src/markdown/progressive-chunks.ts +58 -0
- package/src/markdown/rich-labels.ts +6 -0
- package/src/overlays/CommandMenuRow.tsx +43 -12
- package/src/overlays/CommandMenuView.tsx +96 -11
- package/src/overlays/DiagnosticsExportDialogView.tsx +236 -0
- package/src/overlays/MagpieHandoverDialogView.tsx +217 -0
- package/src/overlays/ReleaseNoteMarkdown.test.tsx +24 -0
- package/src/overlays/ReleaseNoteMarkdown.tsx +26 -0
- package/src/overlays/SplashPanel.tsx +4 -4
- package/src/overlays/SplashParts.tsx +6 -2
- package/src/overlays/UpdateRestartDialogView.tsx +65 -0
- package/src/overlays/assets/diagnostics-banner.webp +0 -0
- package/src/overlays/command-menu-types.ts +13 -1
- package/src/overlays/index.ts +12 -0
- package/src/plugin-ui/index.ts +2 -0
- package/src/project/DefaultConversationSectionView.tsx +13 -22
- package/src/project/DefaultSessionRowView.tsx +8 -0
- package/src/settings/ArchivedProjectsSettingsView.tsx +122 -1
- package/src/settings/GeneralSettingsView.tsx +2 -5
- package/src/settings/LauncherSettingsView.test.tsx +95 -0
- package/src/settings/LauncherSettingsView.tsx +273 -0
- package/src/settings/PetActionGalleryView.test.tsx +163 -0
- package/src/settings/PetActionGalleryView.tsx +216 -0
- package/src/settings/PetSettingsView.test.tsx +117 -0
- package/src/settings/PetSettingsView.tsx +86 -22
- package/src/settings/PresetProviderRowView.tsx +37 -98
- package/src/settings/ShortcutsSettingsView.tsx +0 -4
- package/src/settings/SpaceEditorDialogView.tsx +94 -56
- package/src/settings/SpacesSettingsView.tsx +53 -8
- package/src/settings/assets/space-editor-illustration.webp +0 -0
- package/src/settings/index.ts +18 -39
- package/src/shared/SegmentedControl.test.tsx +68 -0
- package/src/shared/SegmentedControl.tsx +10 -2
- package/src/shared/TabBar.tsx +2 -2
- package/src/shared/VettaKbd.tsx +20 -1
- package/src/shared/index.ts +2 -1
- package/src/shared/platform.ts +9 -0
- package/src/sidebar/AddProjectMenuTriggerView.tsx +11 -12
- package/src/sidebar/SettingsMenuTriggerView.tsx +2 -1
- package/src/sidebar/SidebarSectionActionButton.test.tsx +91 -0
- package/src/sidebar/SidebarSectionActionButton.tsx +52 -0
- package/src/styles.css +2 -0
- package/src/settings/AchievementNavigationButtonView.tsx +0 -90
- package/src/settings/AchievementPromotionDialogView.tsx +0 -91
- package/src/settings/AchievementSettingsView.tsx +0 -43
- package/src/settings/PetBubbleStylePreviewView.tsx +0 -44
- package/src/settings/QuickPanelSettingsSectionView.tsx +0 -64
- package/src/settings/achievements/AchievementCurtains.tsx +0 -50
- package/src/settings/achievements/AchievementPromotionBadge3D.tsx +0 -350
- package/src/settings/achievements/AchievementPromotionConfetti.tsx +0 -71
- package/src/settings/achievements/AchievementTitle.tsx +0 -52
- package/src/settings/achievements/index.ts +0 -13
|
@@ -2,7 +2,6 @@ import { motion, useReducedMotion } from "motion/react";
|
|
|
2
2
|
import {
|
|
3
3
|
type ComponentProps,
|
|
4
4
|
type DragEvent,
|
|
5
|
-
Fragment,
|
|
6
5
|
type JSX,
|
|
7
6
|
type ReactNode,
|
|
8
7
|
useEffect,
|
|
@@ -13,15 +12,14 @@ import {
|
|
|
13
12
|
import {
|
|
14
13
|
DropdownMenu,
|
|
15
14
|
DropdownMenuContent,
|
|
16
|
-
DropdownMenuItem,
|
|
17
|
-
DropdownMenuSeparator,
|
|
18
15
|
DropdownMenuTrigger,
|
|
19
16
|
Popover,
|
|
20
17
|
PopoverContent,
|
|
21
18
|
PopoverTrigger,
|
|
22
19
|
} from "@vetta-org/ui";
|
|
23
20
|
import { ButtonGroup, ButtonGroupItem } from "@vetta-org/ui/button-group";
|
|
24
|
-
import {
|
|
21
|
+
import { chromeButtonGroupVariant } from "../shared/platform";
|
|
22
|
+
import { SessionTopItem, SessionTopMenuItems, type SessionTopMenuItem } from "@vetta-org/ui/session-top-item";
|
|
25
23
|
import { cn } from "@vetta-org/ui/utils";
|
|
26
24
|
import { useHeaderCrowded } from "../app-shell/header-crowding";
|
|
27
25
|
import { partitionHeaderActionsForNarrow } from "./header-action-narrow";
|
|
@@ -48,20 +46,34 @@ export interface HeaderActionPopoverApi {
|
|
|
48
46
|
export type HeaderActionBehavior =
|
|
49
47
|
| { readonly type: "click"; readonly onClick: () => void }
|
|
50
48
|
| { readonly type: "menu"; readonly items: readonly SessionTopMenuItem[] }
|
|
51
|
-
| {
|
|
49
|
+
| {
|
|
50
|
+
readonly type: "popover";
|
|
51
|
+
readonly render: (api: HeaderActionPopoverApi) => ReactNode;
|
|
52
|
+
/** 气泡宽度档位,默认 `md`。 */
|
|
53
|
+
readonly size?: "sm" | "md" | "lg";
|
|
54
|
+
/** 气泡容器,默认浮层;`dialog` 为宿主居中对话框。 */
|
|
55
|
+
readonly host?: "popover" | "dialog";
|
|
56
|
+
/** 对话框的标题。 */
|
|
57
|
+
readonly dialogTitle?: string;
|
|
58
|
+
};
|
|
52
59
|
|
|
53
60
|
export interface HeaderActionBarItem {
|
|
54
61
|
/** 全局唯一:内置为 `builtin:<name>`,插件为 `<pluginId>:<actionId>`。 */
|
|
55
62
|
readonly key: string;
|
|
56
63
|
readonly title: string;
|
|
57
64
|
readonly icon: ReactNode;
|
|
65
|
+
/** 图标右侧的文字:只在顶栏上、且顶栏不拥挤时显示(见 `LABELED_TOP_ACTIONS_MAX`)。 */
|
|
66
|
+
readonly label?: string;
|
|
58
67
|
readonly badge?: number | true;
|
|
68
|
+
/** 角标与图标的语义色;`neutral` 与不传同义。 */
|
|
69
|
+
readonly tone?: HeaderActionTone;
|
|
59
70
|
readonly active?: boolean;
|
|
60
71
|
readonly disabled?: boolean;
|
|
72
|
+
/** 禁用原因,取代 `title` 显示。 */
|
|
73
|
+
readonly disabledReason?: string;
|
|
61
74
|
readonly behavior: HeaderActionBehavior;
|
|
62
75
|
/**
|
|
63
76
|
* 处于选中态时,即使被收纳也要在活动面板开关左侧露出一个按钮(如「窗口置顶」:开着却看不到入口很奇怪)。
|
|
64
|
-
* 仅宿主内置动作使用,插件声明里没有这个字段。
|
|
65
77
|
*/
|
|
66
78
|
readonly promoteWhenActive?: boolean;
|
|
67
79
|
/**
|
|
@@ -71,6 +83,42 @@ export interface HeaderActionBarItem {
|
|
|
71
83
|
readonly retainWhenNarrow?: boolean;
|
|
72
84
|
}
|
|
73
85
|
|
|
86
|
+
/** 顶栏与菜单的语义色,与主题的颜色 token 对应。 */
|
|
87
|
+
export type HeaderActionTone = "neutral" | "info" | "success" | "warning" | "danger";
|
|
88
|
+
|
|
89
|
+
/** 真实画面上的颜色;`neutral` 用组件默认色,不输出额外 class。 */
|
|
90
|
+
const TONE_SURFACE: Record<Exclude<HeaderActionTone, "neutral">, { badge: string; icon: string }> = {
|
|
91
|
+
info: { badge: "bg-sky-500", icon: "text-sky-500" },
|
|
92
|
+
success: { badge: "bg-emerald-500", icon: "text-emerald-500" },
|
|
93
|
+
warning: { badge: "bg-amber-500", icon: "text-amber-500" },
|
|
94
|
+
danger: { badge: "bg-red-500", icon: "text-red-500" },
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/** 顶栏上有文字时最多几格(再挤就只能靠图标 + 悬浮提示)。 */
|
|
98
|
+
export const LABELED_TOP_ACTIONS_MAX = 4;
|
|
99
|
+
|
|
100
|
+
function iconToneClass(tone: HeaderActionTone | undefined): string | undefined {
|
|
101
|
+
return tone && tone !== "neutral" ? TONE_SURFACE[tone].icon : undefined;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** 角标底色的 class;`neutral` / 未设时交给宿主默认色(红)。 */
|
|
105
|
+
export function headerActionToneBadgeClass(tone: HeaderActionTone | undefined): string | undefined {
|
|
106
|
+
return tone && tone !== "neutral" ? TONE_SURFACE[tone].badge : undefined;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** 带语义色的角标:与 `ButtonGroupItem` 自带角标同尺寸,只换底色。 */
|
|
110
|
+
function ToneBadge({ badge, tone }: { readonly badge: number | true; readonly tone?: HeaderActionTone }): JSX.Element {
|
|
111
|
+
const color = tone && tone !== "neutral" ? TONE_SURFACE[tone].badge : "bg-red-500";
|
|
112
|
+
if (badge === true) return <span className={`absolute top-1 right-1 size-1.5 rounded-full ${color}`} />;
|
|
113
|
+
return (
|
|
114
|
+
<span
|
|
115
|
+
className={`absolute -top-0.5 -right-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full px-1 text-[9px] leading-none font-semibold text-white tabular-nums ${color}`}
|
|
116
|
+
>
|
|
117
|
+
{badge > 99 ? "99+" : badge}
|
|
118
|
+
</span>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
74
122
|
export type HeaderActionZone = "top" | "tray";
|
|
75
123
|
|
|
76
124
|
export interface HeaderActionBarLabels {
|
|
@@ -116,10 +164,21 @@ const OPAQUE_GLASS =
|
|
|
116
164
|
* 图标统一放进固定方框:插件传来的图标大小各异,不能撑开按钮,也不接收指针事件。
|
|
117
165
|
* `jiggle` 不为空时图标像 iOS 编辑主屏幕那样循环轻微抖动;数值用来错开各图标的节奏,免得齐刷刷同步。
|
|
118
166
|
*/
|
|
119
|
-
function IconBox({
|
|
167
|
+
function IconBox({
|
|
168
|
+
children,
|
|
169
|
+
jiggle,
|
|
170
|
+
tone,
|
|
171
|
+
}: {
|
|
172
|
+
readonly children: ReactNode;
|
|
173
|
+
readonly jiggle?: number;
|
|
174
|
+
/** 语义色:叠在图标本身的颜色上,`neutral` 不输出。 */
|
|
175
|
+
readonly tone?: HeaderActionTone;
|
|
176
|
+
}): JSX.Element {
|
|
120
177
|
const reduceMotion = useReducedMotion();
|
|
121
|
-
const className =
|
|
122
|
-
"pointer-events-none flex size-4 shrink-0 items-center justify-center overflow-hidden text-[14px] [&>*]:max-h-4 [&>*]:max-w-4"
|
|
178
|
+
const className = cn(
|
|
179
|
+
"pointer-events-none flex size-4 shrink-0 items-center justify-center overflow-hidden text-[14px] [&>*]:max-h-4 [&>*]:max-w-4",
|
|
180
|
+
iconToneClass(tone),
|
|
181
|
+
);
|
|
123
182
|
if (jiggle === undefined || reduceMotion) return <span className={className}>{children}</span>;
|
|
124
183
|
const swing = jiggle % 2 === 0 ? 2.5 : -2.5;
|
|
125
184
|
return (
|
|
@@ -144,10 +203,13 @@ function BarItem({
|
|
|
144
203
|
dragProps,
|
|
145
204
|
className,
|
|
146
205
|
jiggle,
|
|
206
|
+
showLabel,
|
|
147
207
|
onStow,
|
|
148
208
|
stowLabel,
|
|
149
209
|
}: {
|
|
150
210
|
readonly item: HeaderActionBarItem;
|
|
211
|
+
/** 顶栏此刻是否给文字留位置(见 `LABELED_TOP_ACTIONS_MAX`)。 */
|
|
212
|
+
readonly showLabel?: boolean;
|
|
151
213
|
/** 调整状态下右上角「−」:收进收纳。 */
|
|
152
214
|
readonly onStow?: () => void;
|
|
153
215
|
readonly stowLabel?: string;
|
|
@@ -156,11 +218,24 @@ function BarItem({
|
|
|
156
218
|
readonly dragProps?: Pick<ComponentProps<"button">, "draggable" | "onDragStart" | "onDragEnd" | "onDragOver" | "onDrop">;
|
|
157
219
|
readonly className?: string;
|
|
158
220
|
}): JSX.Element {
|
|
221
|
+
// 禁用时把原因摆到悬浮提示的首位:只说「不可用」用户没法自救。
|
|
222
|
+
const tooltip = item.disabled && item.disabledReason ? `${item.disabledReason}\n${item.title}` : item.title;
|
|
223
|
+
const tonalBadge =
|
|
224
|
+
item.badge !== undefined && item.tone && item.tone !== "neutral" ? (
|
|
225
|
+
<ToneBadge badge={item.badge} tone={item.tone} />
|
|
226
|
+
) : (
|
|
227
|
+
item.badge
|
|
228
|
+
);
|
|
159
229
|
const common = {
|
|
160
|
-
title:
|
|
230
|
+
title: tooltip,
|
|
161
231
|
"aria-label": item.title,
|
|
162
|
-
|
|
163
|
-
|
|
232
|
+
label: showLabel ? item.label : undefined,
|
|
233
|
+
icon: (
|
|
234
|
+
<IconBox jiggle={jiggle} tone={item.tone}>
|
|
235
|
+
{item.icon}
|
|
236
|
+
</IconBox>
|
|
237
|
+
),
|
|
238
|
+
badge: tonalBadge,
|
|
164
239
|
active: item.active,
|
|
165
240
|
disabled: item.disabled,
|
|
166
241
|
className,
|
|
@@ -174,7 +249,7 @@ function BarItem({
|
|
|
174
249
|
badge={undefined}
|
|
175
250
|
icon={
|
|
176
251
|
<>
|
|
177
|
-
<IconBox jiggle={jiggle}>{item.icon}</IconBox>
|
|
252
|
+
<IconBox jiggle={jiggle} tone={item.tone}>{item.icon}</IconBox>
|
|
178
253
|
{/* 嵌在按钮里,用 span 而不是 button(button 不能嵌 button);点它收纳,不会触发按钮本身。 */}
|
|
179
254
|
<span
|
|
180
255
|
role="button"
|
|
@@ -199,7 +274,15 @@ function BarItem({
|
|
|
199
274
|
const { behavior } = item;
|
|
200
275
|
if (behavior.type === "menu") return <SessionTopItem {...common} menuItems={behavior.items} />;
|
|
201
276
|
if (behavior.type === "popover") {
|
|
202
|
-
return
|
|
277
|
+
return (
|
|
278
|
+
<SessionTopItem
|
|
279
|
+
{...common}
|
|
280
|
+
popoverContent={(api) => behavior.render(api)}
|
|
281
|
+
popoverSize={behavior.size}
|
|
282
|
+
popoverHost={behavior.host}
|
|
283
|
+
dialogTitle={behavior.dialogTitle}
|
|
284
|
+
/>
|
|
285
|
+
);
|
|
203
286
|
}
|
|
204
287
|
return <SessionTopItem {...common} onClick={behavior.onClick} />;
|
|
205
288
|
}
|
|
@@ -209,11 +292,15 @@ interface DropTarget {
|
|
|
209
292
|
readonly index: number;
|
|
210
293
|
}
|
|
211
294
|
|
|
212
|
-
function TileBadge({
|
|
295
|
+
function TileBadge({ item }: { readonly item: HeaderActionBarItem }): JSX.Element | null {
|
|
296
|
+
const { badge, tone } = item;
|
|
213
297
|
if (badge === undefined) return null;
|
|
214
|
-
|
|
298
|
+
const color = tone && tone !== "neutral" ? TONE_SURFACE[tone].badge : "bg-red-500";
|
|
299
|
+
if (badge === true) return <span className={`absolute top-1 right-1 size-1.5 rounded-full ${color}`} />;
|
|
215
300
|
return (
|
|
216
|
-
<span
|
|
301
|
+
<span
|
|
302
|
+
className={`absolute -top-0.5 -right-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full px-1 text-[9px] leading-none font-semibold text-white tabular-nums ${color}`}
|
|
303
|
+
>
|
|
217
304
|
{badge > 99 ? "99+" : badge}
|
|
218
305
|
</span>
|
|
219
306
|
);
|
|
@@ -232,7 +319,7 @@ function TileFace({
|
|
|
232
319
|
return (
|
|
233
320
|
<button
|
|
234
321
|
type="button"
|
|
235
|
-
title={item.title}
|
|
322
|
+
title={item.disabled && item.disabledReason ? `${item.disabledReason}\n${item.title}` : item.title}
|
|
236
323
|
aria-label={item.title}
|
|
237
324
|
disabled={item.disabled}
|
|
238
325
|
data-active={item.active || undefined}
|
|
@@ -240,8 +327,8 @@ function TileFace({
|
|
|
240
327
|
onClick={onClick}
|
|
241
328
|
className="relative flex h-7 w-8 items-center justify-center rounded-full bg-foreground/[0.08] text-foreground outline-none transition-colors hover:bg-foreground/[0.14] focus-visible:ring-2 focus-visible:ring-ring/60 disabled:opacity-40 data-[active]:bg-foreground/[0.22]"
|
|
242
329
|
>
|
|
243
|
-
<IconBox jiggle={jiggle}>{item.icon}</IconBox>
|
|
244
|
-
{jiggle === undefined && <TileBadge
|
|
330
|
+
<IconBox jiggle={jiggle} tone={item.tone}>{item.icon}</IconBox>
|
|
331
|
+
{jiggle === undefined && <TileBadge item={item} />}
|
|
245
332
|
</button>
|
|
246
333
|
);
|
|
247
334
|
}
|
|
@@ -291,37 +378,22 @@ function Tile({
|
|
|
291
378
|
<TileFaceTrigger item={item} />
|
|
292
379
|
</DropdownMenuTrigger>
|
|
293
380
|
<DropdownMenuContent align="center" sideOffset={6} className="min-w-40">
|
|
294
|
-
{behavior.items
|
|
295
|
-
<Fragment key={entry.id}>
|
|
296
|
-
{entry.separatorBefore ? <DropdownMenuSeparator /> : null}
|
|
297
|
-
<DropdownMenuItem
|
|
298
|
-
disabled={entry.disabled}
|
|
299
|
-
onSelect={() => {
|
|
300
|
-
entry.onSelect();
|
|
301
|
-
onClose();
|
|
302
|
-
}}
|
|
303
|
-
className={entry.destructive ? "text-destructive focus:text-destructive" : undefined}
|
|
304
|
-
>
|
|
305
|
-
{entry.icon ? <IconBox>{entry.icon}</IconBox> : null}
|
|
306
|
-
{entry.label}
|
|
307
|
-
</DropdownMenuItem>
|
|
308
|
-
</Fragment>
|
|
309
|
-
))}
|
|
381
|
+
<SessionTopMenuItems items={behavior.items} onClose={onClose} />
|
|
310
382
|
</DropdownMenuContent>
|
|
311
383
|
</DropdownMenu>
|
|
312
384
|
);
|
|
313
385
|
} else if (behavior.type === "popover") {
|
|
386
|
+
const content = behavior.render({ close: onClose });
|
|
387
|
+
const width = behavior.size === "sm" ? "max-w-[min(92vw,16rem)]" : behavior.size === "lg" ? "max-w-[min(92vw,32rem)]" : "max-w-[min(92vw,24rem)]";
|
|
388
|
+
// 托盘里的图标没有文字,气泡是唯一能读内容的地方:dialog 对几百像素宽的托盘托盘并不友好,
|
|
389
|
+
// 这里统一用浮层,只是把声明的宽度档位带上。
|
|
314
390
|
face = (
|
|
315
391
|
<Popover>
|
|
316
392
|
<PopoverTrigger asChild>
|
|
317
393
|
<TileFaceTrigger item={item} />
|
|
318
394
|
</PopoverTrigger>
|
|
319
|
-
<PopoverContent
|
|
320
|
-
|
|
321
|
-
sideOffset={6}
|
|
322
|
-
className="w-max max-h-[min(70vh,32rem)] max-w-[min(92vw,32rem)] overflow-auto"
|
|
323
|
-
>
|
|
324
|
-
{behavior.render({ close: onClose })}
|
|
395
|
+
<PopoverContent align="center" sideOffset={6} className={`w-max max-h-[min(70vh,32rem)] overflow-auto ${width}`}>
|
|
396
|
+
{content}
|
|
325
397
|
</PopoverContent>
|
|
326
398
|
</Popover>
|
|
327
399
|
);
|
|
@@ -375,7 +447,7 @@ function TileFaceTrigger({ item, ...props }: { readonly item: HeaderActionBarIte
|
|
|
375
447
|
return (
|
|
376
448
|
<button
|
|
377
449
|
type="button"
|
|
378
|
-
title={item.title}
|
|
450
|
+
title={item.disabled && item.disabledReason ? `${item.disabledReason}\n${item.title}` : item.title}
|
|
379
451
|
aria-label={item.title}
|
|
380
452
|
{...props}
|
|
381
453
|
disabled={item.disabled}
|
|
@@ -383,8 +455,8 @@ function TileFaceTrigger({ item, ...props }: { readonly item: HeaderActionBarIte
|
|
|
383
455
|
aria-pressed={item.active ? true : undefined}
|
|
384
456
|
className="relative flex h-7 w-8 items-center justify-center rounded-full bg-foreground/[0.08] text-foreground outline-none transition-colors hover:bg-foreground/[0.14] focus-visible:ring-2 focus-visible:ring-ring/60 disabled:opacity-40 data-[active]:bg-foreground/[0.22] data-[state=open]:bg-foreground/[0.1]"
|
|
385
457
|
>
|
|
386
|
-
<IconBox>{item.icon}</IconBox>
|
|
387
|
-
<TileBadge
|
|
458
|
+
<IconBox tone={item.tone}>{item.icon}</IconBox>
|
|
459
|
+
<TileBadge item={item} />
|
|
388
460
|
</button>
|
|
389
461
|
);
|
|
390
462
|
}
|
|
@@ -461,6 +533,8 @@ export function HeaderActionBarView({
|
|
|
461
533
|
}, [open]); // biome-ignore lint/correctness/useExhaustiveDependencies: closeTray 只用稳定的 setState
|
|
462
534
|
|
|
463
535
|
const topFull = top.length >= maxTop;
|
|
536
|
+
// 文字比图标宽一倍:顶栏格子多了或页头已挤窄时只留图标,免得整排被推进「更多」。
|
|
537
|
+
const showLabel = !crowded && top.length <= LABELED_TOP_ACTIONS_MAX;
|
|
464
538
|
// 收纳里的角标不能被藏起来:汇总到小白条上(红色)。
|
|
465
539
|
const trayAlert = tray.some((item) => item.badge !== undefined && item.badge !== 0);
|
|
466
540
|
const draggingFromTop = dragKey !== null && top.some((item) => item.key === dragKey);
|
|
@@ -550,7 +624,7 @@ export function HeaderActionBarView({
|
|
|
550
624
|
/>
|
|
551
625
|
</ButtonGroup>
|
|
552
626
|
) : (
|
|
553
|
-
<ButtonGroup blur={false} onDragOver={overZone("top")} onDrop={dropOn("top")}>
|
|
627
|
+
<ButtonGroup blur={false} variant={chromeButtonGroupVariant} onDragOver={overZone("top")} onDrop={dropOn("top")}>
|
|
554
628
|
{/* 还有空位就在最左边留一个虚线席位(只一个,不把剩余席位都摆出来)。 */}
|
|
555
629
|
{hasFreeSeat && (
|
|
556
630
|
<span
|
|
@@ -573,6 +647,7 @@ export function HeaderActionBarView({
|
|
|
573
647
|
<BarItem
|
|
574
648
|
key={item.key}
|
|
575
649
|
item={item}
|
|
650
|
+
showLabel={showLabel}
|
|
576
651
|
jiggle={editing ? index : undefined}
|
|
577
652
|
stowLabel={labels.moveToTray}
|
|
578
653
|
onStow={() => onMove(item.key, "tray", Number.MAX_SAFE_INTEGER)}
|
|
@@ -719,7 +794,7 @@ export function HeaderActionBarView({
|
|
|
719
794
|
{/* 活动面板开关是个独立的小组,固定在最右,不参与排序与收纳。 */}
|
|
720
795
|
{/* 活动面板开关所在的小组;被收纳却处于选中态的动作(如窗口置顶)在它左边露出来,调整状态下不露(那时所有按钮都不可点)。 */}
|
|
721
796
|
{pinned || beside.length > 0 ? (
|
|
722
|
-
<ButtonGroup blur={false}>
|
|
797
|
+
<ButtonGroup blur={false} variant={chromeButtonGroupVariant}>
|
|
723
798
|
{beside.map((item) => (
|
|
724
799
|
<BarItem key={item.key} item={item} />
|
|
725
800
|
))}
|
|
@@ -3,14 +3,16 @@ import {
|
|
|
3
3
|
DropdownMenu,
|
|
4
4
|
DropdownMenuContent,
|
|
5
5
|
DropdownMenuItem,
|
|
6
|
-
DropdownMenuSeparator,
|
|
7
6
|
DropdownMenuSub,
|
|
8
7
|
DropdownMenuSubContent,
|
|
9
8
|
DropdownMenuSubTrigger,
|
|
10
9
|
DropdownMenuTrigger,
|
|
11
10
|
} from "@vetta-org/ui";
|
|
12
11
|
import { ButtonGroup, ButtonGroupItem } from "@vetta-org/ui/button-group";
|
|
12
|
+
import { chromeButtonGroupVariant } from "../shared/platform";
|
|
13
|
+
import { SessionTopMenuItems } from "@vetta-org/ui/session-top-item";
|
|
13
14
|
import type { HeaderActionBarItem } from "./HeaderActionBarView";
|
|
15
|
+
import { headerActionToneBadgeClass } from "./HeaderActionBarView";
|
|
14
16
|
import { narrowOverflowBadge } from "./header-action-narrow";
|
|
15
17
|
|
|
16
18
|
function MenuIcon({ children }: { readonly children: ReactNode }): JSX.Element {
|
|
@@ -23,13 +25,16 @@ function MenuIcon({ children }: { readonly children: ReactNode }): JSX.Element {
|
|
|
23
25
|
|
|
24
26
|
function OverflowRowBody({ item }: { readonly item: HeaderActionBarItem }): JSX.Element {
|
|
25
27
|
const count = typeof item.badge === "number" && item.badge > 0 ? item.badge : undefined;
|
|
28
|
+
const tone = headerActionToneBadgeClass(item.tone) ?? "bg-red-500";
|
|
26
29
|
return (
|
|
27
30
|
<>
|
|
28
31
|
<MenuIcon>{item.icon}</MenuIcon>
|
|
29
32
|
<span className="min-w-0 flex-1 truncate">{item.title}</span>
|
|
30
|
-
{item.badge === true ? <span className=
|
|
33
|
+
{item.badge === true ? <span className={`size-1.5 shrink-0 rounded-full ${tone}`} /> : null}
|
|
31
34
|
{count !== undefined ? (
|
|
32
|
-
<span
|
|
35
|
+
<span
|
|
36
|
+
className={`flex h-3.5 min-w-3.5 shrink-0 items-center justify-center rounded-full px-1 text-[9px] leading-none font-semibold text-white tabular-nums ${tone}`}
|
|
37
|
+
>
|
|
33
38
|
{count > 99 ? "99+" : count}
|
|
34
39
|
</span>
|
|
35
40
|
) : null}
|
|
@@ -50,6 +55,7 @@ function OverflowEntry({
|
|
|
50
55
|
return (
|
|
51
56
|
<DropdownMenuSub>
|
|
52
57
|
<DropdownMenuSubTrigger
|
|
58
|
+
title={item.disabled ? item.disabledReason : undefined}
|
|
53
59
|
disabled={item.disabled}
|
|
54
60
|
className={activeClass}
|
|
55
61
|
data-header-action-overflow-item={item.key}
|
|
@@ -57,22 +63,7 @@ function OverflowEntry({
|
|
|
57
63
|
<OverflowRowBody item={item} />
|
|
58
64
|
</DropdownMenuSubTrigger>
|
|
59
65
|
<DropdownMenuSubContent className="min-w-40">
|
|
60
|
-
{behavior.items
|
|
61
|
-
<Fragment key={entry.id}>
|
|
62
|
-
{entry.separatorBefore ? <DropdownMenuSeparator /> : null}
|
|
63
|
-
<DropdownMenuItem
|
|
64
|
-
disabled={entry.disabled}
|
|
65
|
-
onSelect={() => {
|
|
66
|
-
entry.onSelect();
|
|
67
|
-
onClose();
|
|
68
|
-
}}
|
|
69
|
-
className={entry.destructive ? "text-destructive focus:text-destructive" : undefined}
|
|
70
|
-
>
|
|
71
|
-
{entry.icon ? <MenuIcon>{entry.icon}</MenuIcon> : null}
|
|
72
|
-
{entry.label}
|
|
73
|
-
</DropdownMenuItem>
|
|
74
|
-
</Fragment>
|
|
75
|
-
))}
|
|
66
|
+
<SessionTopMenuItems items={behavior.items} onClose={onClose} />
|
|
76
67
|
</DropdownMenuSubContent>
|
|
77
68
|
</DropdownMenuSub>
|
|
78
69
|
);
|
|
@@ -116,7 +107,7 @@ export function HeaderActionOverflowMenu({
|
|
|
116
107
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
117
108
|
return (
|
|
118
109
|
<DropdownMenu open={menuOpen} onOpenChange={setMenuOpen}>
|
|
119
|
-
<ButtonGroup blur={false}>
|
|
110
|
+
<ButtonGroup blur={false} variant={chromeButtonGroupVariant}>
|
|
120
111
|
<DropdownMenuTrigger asChild>
|
|
121
112
|
<ButtonGroupItem
|
|
122
113
|
title={label}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cn } from "@vetta-org/ui/utils";
|
|
2
2
|
import { Slot } from "radix-ui";
|
|
3
|
+
import "./message-feed-fade.css";
|
|
3
4
|
import type { ComponentPropsWithoutRef, CSSProperties } from "react";
|
|
4
5
|
import { forwardRef } from "react";
|
|
5
6
|
import { useMessageFeedContext } from "./MessageFeedContext";
|
|
@@ -23,15 +24,15 @@ export const MessageFeedLayoutViewport = createFeedLayoutPart(
|
|
|
23
24
|
);
|
|
24
25
|
export const MessageFeedLayoutVirtualizer = createFeedLayoutPart(
|
|
25
26
|
"Virtualizer",
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
27
|
+
// 上下渐隐(含沉浸式顶栏那一段)写在 message-feed-fade.css:它是两层 mask,
|
|
28
|
+
// 第二层专门把右缘滚动条槽位补成不透明,否则 mask 会连滚动条一起淡出,
|
|
29
|
+
// 滚到最顶或最底时滑块的头部/尾部会被抹掉一截。用 mask 而不是盖一层底色,
|
|
29
30
|
// 毛玻璃 / 自定义背景下也成立,且不需要背景模糊。
|
|
30
31
|
// 静止时的顶部留白不能放在这个滚动容器的 padding 上:Virtuoso 的视口是
|
|
31
32
|
// position:absolute; top:0; height:100%,会盖住 padding,滚到顶时第一条消息仍从窗口顶边开始,被顶栏和渐隐挡住。
|
|
32
33
|
// 留白在列表 Header(MessageFeedLayoutTopInset)。滚到顶时第一条消息从顶栏下沿再留一点空隙开始,不必等到渐隐完全结束。
|
|
33
|
-
//
|
|
34
|
-
"min-h-0 flex-1 pt-4
|
|
34
|
+
// 列表底部留白见 MessageFeedLayoutList。
|
|
35
|
+
"message-feed-fade min-h-0 flex-1 pt-4",
|
|
35
36
|
{ overflowX: "hidden" },
|
|
36
37
|
);
|
|
37
38
|
export const MessageFeedLayoutLeftRail = createFeedLayoutPart(
|
|
@@ -53,9 +53,13 @@ export const MessageInputSurface = forwardRef<
|
|
|
53
53
|
const { focused, topConnected } = useMessageInputContext("Surface");
|
|
54
54
|
const Comp = asChild ? Slot.Root : "div";
|
|
55
55
|
const surfaceClassName = cn(
|
|
56
|
+
// 边框保留,但深浅两色都压淡:浅色白底上原灰线偏硬,深色也偏亮。
|
|
57
|
+
// 聚焦态只比静态态偏一点主色,不再抢视觉,所以与静态态互斥:
|
|
58
|
+
// 否则 dark: 变体在输出里靠后,会盖掉聚焦色。主色浓度压到 10%,
|
|
59
|
+
// 浅色几乎只看出一点冷调,深色也只是比常态略偏蓝。
|
|
56
60
|
"input-card relative z-10 overflow-visible border bg-input-bar-bg shadow-[0_8px_28px_-14px_rgb(0_0_0/0.10)] transition-[border-color,box-shadow,transform] duration-200 dark:shadow-none",
|
|
57
61
|
topConnected ? "rounded-b-[20px] rounded-t-none" : "rounded-[20px]",
|
|
58
|
-
focused ? "border-primary/
|
|
62
|
+
focused ? "border-primary/10" : "border-border/60 dark:border-border/70",
|
|
59
63
|
className,
|
|
60
64
|
);
|
|
61
65
|
|
package/src/chat/index.ts
CHANGED
|
@@ -124,9 +124,10 @@ export type {
|
|
|
124
124
|
HeaderActionBarViewProps,
|
|
125
125
|
HeaderActionBehavior,
|
|
126
126
|
HeaderActionPopoverApi,
|
|
127
|
+
HeaderActionTone,
|
|
127
128
|
HeaderActionZone,
|
|
128
129
|
} from "./HeaderActionBarView";
|
|
129
|
-
export { HeaderActionBarView } from "./HeaderActionBarView";
|
|
130
|
+
export { HeaderActionBarView, headerActionToneBadgeClass, LABELED_TOP_ACTIONS_MAX } from "./HeaderActionBarView";
|
|
130
131
|
export { InlineModelPicker } from "./InlineModelPicker";
|
|
131
132
|
export type { InlineTokenChipProps } from "./InlineTokenChip";
|
|
132
133
|
export { InlineTokenChip } from "./InlineTokenChip";
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/* 会话消息流的上下渐隐。
|
|
2
|
+
*
|
|
3
|
+
* 渐隐要的是「内容还没到底」,不是「滚动条也淡出」:mask 作用在滚动容器上时,
|
|
4
|
+
* Chromium 连它自己的滚动条一起绘制,单层纵向渐变到边缘就把滑块的头部/尾部吃掉,
|
|
5
|
+
* 滚到最顶或最底时最明显——滑块刚贴到边就被渐隐抹掉一截。
|
|
6
|
+
*
|
|
7
|
+
* 但整条滚动条槽位都排除在渐隐之外也不行:沉浸式顶栏下的滚动容器从窗口顶边开始
|
|
8
|
+
* (消息列用负 margin 抵到顶栏下面,好让渐隐铺到毛玻璃底下),槽位一旦恒不透明,
|
|
9
|
+
* 滑块就顶进 titlebar 里,看上去不像属于这个列表。
|
|
10
|
+
*
|
|
11
|
+
* 所以分三层。mask 层按「后写的先画」合成,每层的 mask-composite 描述它怎么叠到
|
|
12
|
+
* 下面的结果上,于是从下往上读是:
|
|
13
|
+
* 3. 槽位纵向轮廓:默认整条不透明;顶栏模式下顶栏那一段(44px)隐去、到 80px 才实心,
|
|
14
|
+
* 滑块就不会在 titlebar 里现身,也不会在滚到底时被渐隐吃掉尾部;
|
|
15
|
+
* 2. 右缘槽位列:只在最后 8px 内为 1,`intersect`(相乘)到上面,把范围收进滚动条;
|
|
16
|
+
* 1. 内容自己的纵向渐隐:`add` 回去,内容区观感与改动前一致。
|
|
17
|
+
* 槽位宽度与全局 `::-webkit-scrollbar { width: 8px }` 一致;内容在纵向渐隐带里本来也
|
|
18
|
+
* 不占这一列(列表自带右内边距),补不透明的只有滚动条本身。
|
|
19
|
+
*
|
|
20
|
+
* 不用 `z-index`:mask 是绘制阶段的遮罩,滚动条无法被抬到它上面。
|
|
21
|
+
*/
|
|
22
|
+
.message-feed-fade {
|
|
23
|
+
--message-feed-scrollbar-gutter: 8px;
|
|
24
|
+
/* 底部 32px 渐隐:文字退出时不会被输入框硬切。 */
|
|
25
|
+
--message-feed-fade-content: linear-gradient(
|
|
26
|
+
to bottom,
|
|
27
|
+
black calc(100% - 32px),
|
|
28
|
+
rgb(0 0 0 / 0.8) calc(100% - 24px),
|
|
29
|
+
rgb(0 0 0 / 0.45) calc(100% - 16px),
|
|
30
|
+
rgb(0 0 0 / 0.15) calc(100% - 8px),
|
|
31
|
+
transparent 100%
|
|
32
|
+
);
|
|
33
|
+
/* 没有沉浸式顶栏时滚动容器本来就从列表顶边开始,槽位整条可见。 */
|
|
34
|
+
--message-feed-fade-gutter: linear-gradient(to bottom, black, black);
|
|
35
|
+
|
|
36
|
+
mask-image:
|
|
37
|
+
var(--message-feed-fade-content),
|
|
38
|
+
linear-gradient(
|
|
39
|
+
to right,
|
|
40
|
+
transparent 0,
|
|
41
|
+
transparent calc(100% - var(--message-feed-scrollbar-gutter)),
|
|
42
|
+
black calc(100% - var(--message-feed-scrollbar-gutter))
|
|
43
|
+
),
|
|
44
|
+
var(--message-feed-fade-gutter);
|
|
45
|
+
/* 最下面一层的关键字不参与合成,占位即可。 */
|
|
46
|
+
mask-composite: add, intersect, intersect;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* 沉浸式顶栏(main[data-header-overlay])下顶栏浮在消息流上:内容在顶栏那一段(28px)内
|
|
50
|
+
完全隐去,再沿一条缓入缓出的曲线在约 70px 内渐显(多段色标近似 ease-in-out,线性渐变
|
|
51
|
+
会在两端出现可见的「硬边」),标题不会与正文叠在一起,像 iOS 的 soft titlebar。
|
|
52
|
+
滚动条槽位跟着让开顶栏(44px,与消息列让出的 pt-11 一致),在 80px 处才完全实心。 */
|
|
53
|
+
[data-header-overlay="true"] .message-feed-fade {
|
|
54
|
+
--message-feed-fade-content: linear-gradient(
|
|
55
|
+
to bottom,
|
|
56
|
+
transparent 0,
|
|
57
|
+
transparent 28px,
|
|
58
|
+
rgb(0 0 0 / 0.04) 36px,
|
|
59
|
+
rgb(0 0 0 / 0.14) 46px,
|
|
60
|
+
rgb(0 0 0 / 0.33) 58px,
|
|
61
|
+
rgb(0 0 0 / 0.58) 70px,
|
|
62
|
+
rgb(0 0 0 / 0.8) 82px,
|
|
63
|
+
rgb(0 0 0 / 0.94) 92px,
|
|
64
|
+
black 100px,
|
|
65
|
+
black calc(100% - 32px),
|
|
66
|
+
rgb(0 0 0 / 0.8) calc(100% - 24px),
|
|
67
|
+
rgb(0 0 0 / 0.45) calc(100% - 16px),
|
|
68
|
+
rgb(0 0 0 / 0.15) calc(100% - 8px),
|
|
69
|
+
transparent 100%
|
|
70
|
+
);
|
|
71
|
+
--message-feed-fade-gutter: linear-gradient(
|
|
72
|
+
to bottom,
|
|
73
|
+
transparent 0,
|
|
74
|
+
transparent 44px,
|
|
75
|
+
rgb(0 0 0 / 0.25) 56px,
|
|
76
|
+
rgb(0 0 0 / 0.55) 66px,
|
|
77
|
+
black 80px,
|
|
78
|
+
black 100%
|
|
79
|
+
);
|
|
80
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
import { MessageFeedLayoutVirtualizer } from "./MessageFeedLayoutView";
|
|
6
|
+
import { MessageFeedRoot } from "./MessageFeedView";
|
|
7
|
+
|
|
8
|
+
const fadeCss = readFileSync(join(import.meta.dirname, "message-feed-fade.css"), "utf8");
|
|
9
|
+
|
|
10
|
+
/** 取出某个选择器的第一条规则体。 */
|
|
11
|
+
function ruleBody(css: string, selector: string): string {
|
|
12
|
+
const start = css.indexOf(`${selector} {`);
|
|
13
|
+
expect(start, `missing rule for ${selector}`).toBeGreaterThanOrEqual(0);
|
|
14
|
+
return css.slice(start, css.indexOf("}", start));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const overlayBody = ruleBody(fadeCss, '[data-header-overlay="true"] .message-feed-fade');
|
|
18
|
+
|
|
19
|
+
describe("message feed edge fade", () => {
|
|
20
|
+
it("puts the fade class on the scroller itself, where the scrollbar is painted", () => {
|
|
21
|
+
const markup = renderToStaticMarkup(
|
|
22
|
+
<MessageFeedRoot>
|
|
23
|
+
<MessageFeedLayoutVirtualizer />
|
|
24
|
+
</MessageFeedRoot>,
|
|
25
|
+
);
|
|
26
|
+
expect(markup).toContain("message-feed-fade");
|
|
27
|
+
expect(markup).toContain('data-message-feed-layout-part="virtualizer"');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* mask 会在绘制阶段连滚动条一起淡出,滚动条无法用 z-index 抬上来(这是滚动条首尾
|
|
32
|
+
* 被吃掉的原因);但整条槽位恒不透明又会让滑块顶进沉浸式顶栏。三层合成同时解掉两件事:
|
|
33
|
+
* 槽位列 ∩ 槽位纵向轮廓,再与内容渐隐相加。
|
|
34
|
+
*/
|
|
35
|
+
it("composites content fade, scrollbar column and gutter profile in that order", () => {
|
|
36
|
+
const body = ruleBody(fadeCss, ".message-feed-fade");
|
|
37
|
+
const maskImage = body.slice(body.indexOf("mask-image:"), body.indexOf("mask-composite"));
|
|
38
|
+
expect(body).toContain("mask-composite: add, intersect, intersect;");
|
|
39
|
+
|
|
40
|
+
// 后写的层先画:内容渐隐在最上(add 回去),槽位列与轮廓依次在下。
|
|
41
|
+
expect(maskImage.indexOf("var(--message-feed-fade-content)")).toBeLessThan(
|
|
42
|
+
maskImage.indexOf("to right"),
|
|
43
|
+
);
|
|
44
|
+
expect(maskImage.indexOf("to right")).toBeLessThan(
|
|
45
|
+
maskImage.indexOf("var(--message-feed-fade-gutter)"),
|
|
46
|
+
);
|
|
47
|
+
expect(maskImage).toContain("var(--message-feed-scrollbar-gutter)");
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("keeps the scrollbar gutter to the very bottom edge", () => {
|
|
51
|
+
const body = ruleBody(fadeCss, ".message-feed-fade");
|
|
52
|
+
// 槽位轮廓默认整条可见,且不带底部渐隐——否则滚到底时滑块尾部又被吃掉。
|
|
53
|
+
expect(body).toContain("--message-feed-fade-gutter: linear-gradient(to bottom, black, black);");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("holds the scrollbar back from the immersive titlebar", () => {
|
|
57
|
+
// 槽位随顶栏让开 44px,到 80px 才实心;顶栏那一段里滑块不会现身。
|
|
58
|
+
expect(overlayBody).toContain("--message-feed-fade-gutter:");
|
|
59
|
+
expect(overlayBody).toContain("transparent 44px");
|
|
60
|
+
expect(overlayBody).toContain("black 80px");
|
|
61
|
+
|
|
62
|
+
const gutter = overlayBody.slice(overlayBody.indexOf("--message-feed-fade-gutter:"));
|
|
63
|
+
expect(gutter).not.toContain("calc(100% - 32px)");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("fades the content's top edge only under the immersive header", () => {
|
|
67
|
+
const base = ruleBody(fadeCss, ".message-feed-fade");
|
|
68
|
+
expect(base).toContain("--message-feed-fade-content: linear-gradient(");
|
|
69
|
+
expect(base).not.toContain("transparent 28px");
|
|
70
|
+
|
|
71
|
+
expect(overlayBody).toContain("--message-feed-fade-content:");
|
|
72
|
+
expect(overlayBody).toContain("transparent 28px");
|
|
73
|
+
expect(overlayBody).toContain("black 100px");
|
|
74
|
+
});
|
|
75
|
+
});
|