@vetta-org/theme-ui 0.1.2 → 0.2.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.
Files changed (111) hide show
  1. package/package.json +8 -16
  2. package/src/action-approval/StorageCleanListView.test.tsx +36 -0
  3. package/src/action-approval/StorageCleanListView.tsx +52 -0
  4. package/src/action-approval/index.ts +2 -0
  5. package/src/activity/ActivityPanel.tsx +7 -1
  6. package/src/activity/ActivityPanelFrame.tsx +1 -1
  7. package/src/activity/BackgroundTasksTabPanelView.tsx +18 -2
  8. package/src/activity/BrowserPanelView.tsx +15 -1
  9. package/src/activity/BrowserSelectionView.tsx +199 -0
  10. package/src/activity/CodePreview.tsx +15 -1
  11. package/src/activity/MarkdownPreviewView.test.tsx +53 -0
  12. package/src/activity/MarkdownPreviewView.tsx +86 -10
  13. package/src/activity/index.ts +1 -0
  14. package/src/chat/ContextRingView.test.tsx +81 -0
  15. package/src/chat/ContextRingView.tsx +78 -62
  16. package/src/chat/EditDiffView.tsx +4 -4
  17. package/src/chat/HeaderActionBarView.tsx +135 -48
  18. package/src/chat/HeaderActionOverflowMenu.tsx +11 -20
  19. package/src/chat/MessageFeedLayoutView.tsx +6 -5
  20. package/src/chat/MessageInputView.tsx +5 -1
  21. package/src/chat/index.ts +2 -1
  22. package/src/chat/message-feed-fade.css +80 -0
  23. package/src/chat/message-feed-fade.test.tsx +75 -0
  24. package/src/chat/streaming-reveal.test.ts +1 -74
  25. package/src/chat/streaming-reveal.ts +0 -3
  26. package/src/file-preview/FilePreviewDialogView.tsx +2 -1
  27. package/src/file-preview/ReadonlyCodeView.tsx +46 -0
  28. package/src/file-preview/syntax-tokens.css +1 -1
  29. package/src/image-assets.d.ts +4 -0
  30. package/src/layout/ResizeHandle.tsx +4 -1
  31. package/src/layout/resize-handle-reset.test.tsx +50 -0
  32. package/src/markdown/FileLinkBadge.tsx +77 -0
  33. package/src/markdown/MarkdownContent.tsx +61 -31
  34. package/src/markdown/MarkdownImage.tsx +6 -16
  35. package/src/markdown/MermaidBlock.tsx +50 -11
  36. package/src/markdown/UrlLinkBadge.tsx +84 -0
  37. package/src/markdown/image-actions.ts +29 -0
  38. package/src/markdown/index.ts +2 -0
  39. package/src/markdown/nodes.ts +6 -1
  40. package/src/markdown/preview-policy.test.ts +31 -0
  41. package/src/markdown/preview-policy.ts +33 -0
  42. package/src/markdown/progressive-chunks.test.ts +43 -0
  43. package/src/markdown/progressive-chunks.ts +58 -0
  44. package/src/markdown/rich-labels.ts +9 -0
  45. package/src/markdown/streaming-fade.test.ts +83 -0
  46. package/src/markdown/streaming-fade.tsx +141 -0
  47. package/src/markdown/streaming-reveal.ts +0 -67
  48. package/src/markdown/streaming.ts +64 -131
  49. package/src/overlays/CommandMenuRow.tsx +47 -26
  50. package/src/overlays/CommandMenuView.tsx +107 -15
  51. package/src/overlays/DiagnosticsExportDialogView.tsx +236 -0
  52. package/src/overlays/MagpieHandoverDialogView.tsx +217 -0
  53. package/src/overlays/ReleaseNoteImage.test.tsx +105 -0
  54. package/src/overlays/ReleaseNoteMarkdown.test.tsx +49 -0
  55. package/src/overlays/ReleaseNoteMarkdown.tsx +120 -7
  56. package/src/overlays/SplashPanel.tsx +4 -4
  57. package/src/overlays/SplashParts.tsx +6 -2
  58. package/src/overlays/UpdateCheckerView.tsx +17 -15
  59. package/src/overlays/UpdateRestartDialogView.tsx +76 -2
  60. package/src/overlays/assets/diagnostics-banner.webp +0 -0
  61. package/src/overlays/command-menu-types.ts +15 -1
  62. package/src/overlays/index.ts +13 -0
  63. package/src/plugin-ui/index.ts +4 -0
  64. package/src/project/DefaultConversationSectionView.tsx +17 -22
  65. package/src/project/DefaultSessionRowView.tsx +8 -0
  66. package/src/project/ManageSessionsSplashView.tsx +0 -2
  67. package/src/settings/ArchivedProjectsSettingsView.tsx +122 -1
  68. package/src/settings/GeneralSettingsView.tsx +21 -5
  69. package/src/settings/LauncherSettingsView.test.tsx +95 -0
  70. package/src/settings/LauncherSettingsView.tsx +272 -0
  71. package/src/settings/PetActionGalleryView.test.tsx +163 -0
  72. package/src/settings/PetActionGalleryView.tsx +216 -0
  73. package/src/settings/PetSettingsView.test.tsx +117 -0
  74. package/src/settings/PetSettingsView.tsx +86 -22
  75. package/src/settings/PresetProviderRowView.tsx +37 -98
  76. package/src/settings/ShortcutsSettingsView.tsx +0 -4
  77. package/src/settings/SpaceEditorDialogView.tsx +94 -56
  78. package/src/settings/SpacesSettingsView.tsx +53 -8
  79. package/src/settings/StorageBar.tsx +70 -0
  80. package/src/settings/StorageExplorer.tsx +488 -0
  81. package/src/settings/StorageReadout.tsx +64 -0
  82. package/src/settings/StorageSettingsView.test.tsx +181 -0
  83. package/src/settings/StorageSettingsView.tsx +458 -0
  84. package/src/settings/assets/space-editor-illustration.webp +0 -0
  85. package/src/settings/index.ts +28 -39
  86. package/src/settings/storage-treemap-layout.test.ts +32 -0
  87. package/src/settings/storage-treemap-layout.ts +55 -0
  88. package/src/shared/SegmentedControl.test.tsx +68 -0
  89. package/src/shared/SegmentedControl.tsx +18 -11
  90. package/src/shared/StageDialogContent.test.tsx +61 -0
  91. package/src/shared/StageDialogContent.tsx +80 -0
  92. package/src/shared/TabBar.tsx +2 -2
  93. package/src/shared/VettaKbd.tsx +20 -1
  94. package/src/shared/index.ts +4 -1
  95. package/src/shared/platform.ts +9 -0
  96. package/src/sidebar/AddProjectMenuTriggerView.tsx +13 -12
  97. package/src/sidebar/SettingsMenuTriggerView.tsx +2 -1
  98. package/src/sidebar/SidebarSectionActionButton.test.tsx +91 -0
  99. package/src/sidebar/SidebarSectionActionButton.tsx +52 -0
  100. package/src/styles.css +7 -0
  101. package/src/markdown/streaming.test.ts +0 -57
  102. package/src/settings/AchievementNavigationButtonView.tsx +0 -90
  103. package/src/settings/AchievementPromotionDialogView.tsx +0 -91
  104. package/src/settings/AchievementSettingsView.tsx +0 -43
  105. package/src/settings/PetBubbleStylePreviewView.tsx +0 -44
  106. package/src/settings/QuickPanelSettingsSectionView.tsx +0 -64
  107. package/src/settings/achievements/AchievementCurtains.tsx +0 -50
  108. package/src/settings/achievements/AchievementPromotionBadge3D.tsx +0 -350
  109. package/src/settings/achievements/AchievementPromotionConfetti.tsx +0 -71
  110. package/src/settings/achievements/AchievementTitle.tsx +0 -52
  111. package/src/settings/achievements/index.ts +0 -13
@@ -1,18 +1,3 @@
1
- export type {
2
- AchievementNavigationAssets,
3
- AchievementNavigationButtonViewProps,
4
- } from "./AchievementNavigationButtonView";
5
- export { AchievementNavigationButtonView } from "./AchievementNavigationButtonView";
6
- export type {
7
- AchievementPromotionDialogViewLabels,
8
- AchievementPromotionDialogViewProps,
9
- } from "./AchievementPromotionDialogView";
10
- export { AchievementPromotionDialogView } from "./AchievementPromotionDialogView";
11
- export type {
12
- AchievementSetOptionView,
13
- AchievementSettingsViewProps,
14
- } from "./AchievementSettingsView";
15
- export { AchievementSettingsView } from "./AchievementSettingsView";
16
1
  export type {
17
2
  AppshotPermissionStatusView,
18
3
  AppshotSettingsViewLabels,
@@ -25,22 +10,6 @@ export type {
25
10
  ArchivedProjectsSettingsViewProps,
26
11
  } from "./ArchivedProjectsSettingsView";
27
12
  export { ArchivedProjectsSettingsView } from "./ArchivedProjectsSettingsView";
28
- export type {
29
- AchievementCurtainSideLayout,
30
- AchievementCurtainsAssets,
31
- AchievementCurtainsLayout,
32
- AchievementCurtainsProps,
33
- AchievementPromotionBadge3DProps,
34
- AchievementPromotionConfettiProps,
35
- AchievementTitleLayout,
36
- AchievementTitleProps,
37
- } from "./achievements";
38
- export {
39
- AchievementCurtains,
40
- AchievementPromotionBadge3D,
41
- AchievementPromotionConfetti,
42
- AchievementTitle,
43
- } from "./achievements";
44
13
  export type {
45
14
  BuiltinMcpSecretFieldView,
46
15
  BuiltinMcpSecretsDialogViewLabels,
@@ -99,6 +68,15 @@ export type { ImStatusBadgeStatus, ImStatusBadgeViewProps } from "./ImStatusBadg
99
68
  export { ImStatusBadgeView } from "./ImStatusBadgeView";
100
69
  export type { JsonConfigInputViewProps } from "./JsonConfigInputView";
101
70
  export { JsonConfigInputView } from "./JsonConfigInputView";
71
+ export type {
72
+ LauncherFeatureView,
73
+ LauncherPreviewGroupView,
74
+ LauncherPreviewRowView,
75
+ LauncherPreviewStatusView,
76
+ LauncherSettingsViewLabels,
77
+ LauncherSettingsViewProps,
78
+ } from "./LauncherSettingsView";
79
+ export { LauncherSettingsView } from "./LauncherSettingsView";
102
80
  export { McpDefaultIcon } from "./McpDefaultIcon";
103
81
  export type { McpJsonEditorViewProps } from "./McpJsonEditorView";
104
82
  export { McpJsonEditorView } from "./McpJsonEditorView";
@@ -135,13 +113,18 @@ export type {
135
113
  PermissionsSettingsViewProps,
136
114
  } from "./PermissionsSettingsView";
137
115
  export { PermissionsSettingsView } from "./PermissionsSettingsView";
138
- export type { PetBubbleStylePreviewViewProps } from "./PetBubbleStylePreviewView";
139
- export { PetBubbleStylePreviewView } from "./PetBubbleStylePreviewView";
140
116
  export type {
141
- PetBubbleStyleOptionView,
117
+ PetActionGalleryViewLabels,
118
+ PetActionGalleryViewProps,
119
+ PetActionGroupView,
120
+ PetActionView,
121
+ } from "./PetActionGalleryView";
122
+ export { PetActionGalleryView } from "./PetActionGalleryView";
123
+ export type {
142
124
  PetDecorationView,
143
125
  PetSettingsViewLabels,
144
126
  PetSettingsViewProps,
127
+ PetSizeControlView,
145
128
  } from "./PetSettingsView";
146
129
  export { PetSettingsView } from "./PetSettingsView";
147
130
  export type {
@@ -175,11 +158,6 @@ export type {
175
158
  QrBindDialogViewProps,
176
159
  } from "./QrBindDialogView";
177
160
  export { QrBindDialogView } from "./QrBindDialogView";
178
- export type {
179
- QuickPanelOptionView,
180
- QuickPanelSettingsSectionViewProps,
181
- } from "./QuickPanelSettingsSectionView";
182
- export { QuickPanelSettingsSectionView } from "./QuickPanelSettingsSectionView";
183
161
  export type {
184
162
  RemoteMcpSectionViewLabels,
185
163
  RemoteMcpSectionViewModel,
@@ -219,11 +197,22 @@ export type {
219
197
  } from "./SpaceEditorDialogView";
220
198
  export { SpaceEditorDialogView } from "./SpaceEditorDialogView";
221
199
  export type {
200
+ SpacesFeatureView,
222
201
  SpacesSettingsViewItem,
223
202
  SpacesSettingsViewLabels,
224
203
  SpacesSettingsViewProps,
225
204
  } from "./SpacesSettingsView";
226
205
  export { SpacesSettingsView } from "./SpacesSettingsView";
206
+ export type { StorageEntryView, StorageOwnerView } from "./StorageExplorer";
207
+ export type {
208
+ StorageCleanActionView,
209
+ StorageSettingsViewLabels,
210
+ StorageSettingsViewProps,
211
+ StorageShareKindView,
212
+ StorageShareView,
213
+ StorageTabView,
214
+ } from "./StorageSettingsView";
215
+ export { StorageSettingsView } from "./StorageSettingsView";
227
216
  export type {
228
217
  WebhookEndpointListViewLabels,
229
218
  WebhookEndpointListViewProps,
@@ -0,0 +1,32 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { layoutTreemap } from "./storage-treemap-layout";
3
+
4
+ describe("layoutTreemap", () => {
5
+ it.each([
6
+ ["一项", [5]],
7
+ ["相同大小", Array.from({ length: 13 }, () => 1)],
8
+ ["悬殊", [1000, 400, 90, 30, 8, 4, 3, 2, 1, 1, 1, 1, 1]],
9
+ ])("%s:矩形互不重叠,正好铺满画布", (_name, sizes) => {
10
+ const tiles = layoutTreemap(sizes, 616, 360);
11
+ expect(tiles).toHaveLength(sizes.length);
12
+ expect(tiles.reduce((sum, tile) => sum + tile.width * tile.height, 0)).toBeCloseTo(616 * 360, 3);
13
+ for (const [index, a] of tiles.entries()) {
14
+ expect(a.x + a.width).toBeLessThanOrEqual(616.001);
15
+ expect(a.y + a.height).toBeLessThanOrEqual(360.001);
16
+ for (const b of tiles.slice(index + 1)) {
17
+ const overlapX = Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x);
18
+ const overlapY = Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y);
19
+ expect(Math.min(overlapX, overlapY)).toBeLessThan(0.001);
20
+ }
21
+ }
22
+ });
23
+
24
+ it("面积与占用成正比", () => {
25
+ const [big, small] = layoutTreemap([4, 1], 616, 360).map((tile) => tile.width * tile.height);
26
+ expect((big ?? 0) / (small ?? 1)).toBeCloseTo(4);
27
+ });
28
+
29
+ it("没有占用时不画矩形", () => {
30
+ expect(layoutTreemap([0, 0], 616, 360)).toEqual([]);
31
+ });
32
+ });
@@ -0,0 +1,55 @@
1
+ export interface TreemapTile {
2
+ readonly x: number;
3
+ readonly y: number;
4
+ readonly width: number;
5
+ readonly height: number;
6
+ }
7
+
8
+ /** 再小就点不到;极小的项按这个占比画。 */
9
+ const MIN_SHARE = 0.012;
10
+
11
+ /** 按体积把画布切成矩形(squarified):逐行填入,让每块尽量接近正方形。sizes 从大到小排列时效果最好。 */
12
+ export function layoutTreemap(sizes: readonly number[], width: number, height: number): TreemapTile[] {
13
+ const total = sizes.reduce((sum, size) => sum + size, 0);
14
+ if (sizes.length === 0 || total <= 0) return [];
15
+ const weights = sizes.map((size) => Math.max(size / total, MIN_SHARE));
16
+ const scale = (width * height) / weights.reduce((sum, weight) => sum + weight, 0);
17
+ const areas = weights.map((weight) => weight * scale);
18
+
19
+ const tiles: TreemapTile[] = [];
20
+ let free = { x: 0, y: 0, width, height };
21
+ for (let start = 0; start < areas.length; ) {
22
+ const side = Math.min(free.width, free.height);
23
+ let end = start + 1;
24
+ while (
25
+ end < areas.length &&
26
+ worstRatio(areas.slice(start, end + 1), side) <= worstRatio(areas.slice(start, end), side)
27
+ ) {
28
+ end += 1;
29
+ }
30
+ const row = areas.slice(start, end);
31
+ const thickness = row.reduce((sum, area) => sum + area, 0) / side;
32
+ const horizontal = free.width >= free.height;
33
+ let offset = 0;
34
+ for (const area of row) {
35
+ const length = area / thickness;
36
+ tiles.push(
37
+ horizontal
38
+ ? { x: free.x, y: free.y + offset, width: thickness, height: length }
39
+ : { x: free.x + offset, y: free.y, width: length, height: thickness },
40
+ );
41
+ offset += length;
42
+ }
43
+ free = horizontal
44
+ ? { ...free, x: free.x + thickness, width: free.width - thickness }
45
+ : { ...free, y: free.y + thickness, height: free.height - thickness };
46
+ start = end;
47
+ }
48
+ return tiles;
49
+ }
50
+
51
+ /** 一行里最扁的那块的长宽比。 */
52
+ function worstRatio(row: readonly number[], side: number): number {
53
+ const sum = row.reduce((total, area) => total + area, 0);
54
+ return Math.max((side * side * Math.max(...row)) / (sum * sum), (sum * sum) / (side * side * Math.min(...row)));
55
+ }
@@ -0,0 +1,68 @@
1
+ // @vitest-environment jsdom
2
+
3
+ import { act } from "react";
4
+ import { createRoot, type Root } from "react-dom/client";
5
+ import { afterEach, beforeEach, describe, expect, it } from "vitest";
6
+ import { SegmentedControl } from "./SegmentedControl";
7
+
8
+ type Scope = "all" | "mine" | "empty";
9
+
10
+ describe("SegmentedControl", () => {
11
+ let root: Root;
12
+ let host: HTMLDivElement;
13
+
14
+ function renderControl(value: Scope, onChange: (next: Scope) => void): HTMLElement {
15
+ const items = [
16
+ { key: "all" as Scope, label: "All", count: 12 },
17
+ { key: "mine" as Scope, label: "Mine" },
18
+ // 0 不该显示:计数为 0 的标签栏和没有计数长得一样,免得读成一枚空徽标。
19
+ { key: "empty" as Scope, label: "Empty", count: 0 },
20
+ ];
21
+ act(() => root.render(<SegmentedControl items={items} value={value} onChange={onChange} />));
22
+ return host;
23
+ }
24
+
25
+ beforeEach(() => {
26
+ (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
27
+ host = document.createElement("div");
28
+ document.body.append(host);
29
+ root = createRoot(host);
30
+ });
31
+
32
+ afterEach(() => {
33
+ act(() => root.unmount());
34
+ host.remove();
35
+ });
36
+
37
+ it("renders a per-item count as muted trailing text and skips zero", () => {
38
+ const container = renderControl("all", () => {});
39
+
40
+ const allTab = container.querySelector("button") as HTMLElement;
41
+ expect(allTab.textContent).toBe("All12");
42
+ // 计数是中性量,不能借用未读徽标的告警配色。
43
+ const count = allTab.querySelector("span > span") as HTMLElement;
44
+ expect(count.textContent).toBe("12");
45
+ expect(count.className).toContain("text-muted-foreground");
46
+
47
+ const buttons = container.querySelectorAll("button");
48
+ expect(buttons[1]?.textContent).toBe("Mine");
49
+ expect(buttons[2]?.textContent).toBe("Empty");
50
+ });
51
+
52
+ it("reports the clicked key and highlights the current one", () => {
53
+ const picks: Scope[] = [];
54
+ const container = renderControl("all", (next) => picks.push(next));
55
+ const buttons = container.querySelectorAll("button");
56
+
57
+ expect(buttons[0]?.className).toContain("text-foreground");
58
+ expect(buttons[1]?.className).toContain("text-muted-foreground");
59
+
60
+ act(() => (buttons[1] as HTMLButtonElement).click());
61
+ expect(picks).toEqual(["mine"]);
62
+
63
+ renderControl("mine", () => {});
64
+ const afterSwitch = container.querySelectorAll("button");
65
+ expect(afterSwitch[1]?.className).toContain("text-foreground");
66
+ expect(afterSwitch[0]?.className).toContain("text-muted-foreground");
67
+ });
68
+ });
@@ -9,8 +9,13 @@ export interface SegmentedControlItem<T extends string> {
9
9
  key: T;
10
10
  label: string;
11
11
  icon?: string;
12
- /** 可选未读小红点(>0 显示) */
12
+ /** 可选未读小红点(>0 显示)。表达「有待处理的新内容」,与 count 的语义不同。 */
13
13
  badge?: number;
14
+ /**
15
+ * 可选计数(0 不显示):跟在标题后面的灰字小胶囊,用于「这一栏里有多少条」这类
16
+ * 中性的量,例如变更数、任务数。需要告警语气时用 badge。
17
+ */
18
+ count?: number;
14
19
  }
15
20
 
16
21
  export interface SegmentedControlProps<T extends string> {
@@ -33,12 +38,9 @@ export function SegmentedControl<T extends string>({
33
38
 
34
39
  return (
35
40
  <div
36
- className={cn(
37
- "relative inline-flex shrink-0 rounded-[8px] bg-black/[0.06] p-[2px] dark:bg-white/[0.08]",
38
- className,
39
- )}
41
+ className={cn("relative inline-flex shrink-0 gap-1", className)}
40
42
  >
41
- {items.map(({ key, label, icon, badge }) => {
43
+ {items.map(({ key, label, icon, badge, count }) => {
42
44
  const active = value === key;
43
45
  return (
44
46
  <button
@@ -46,14 +48,14 @@ export function SegmentedControl<T extends string>({
46
48
  type="button"
47
49
  onClick={() => onChange(key)}
48
50
  className={cn(
49
- "relative flex shrink-0 items-center justify-center gap-1 whitespace-nowrap rounded-[6px] px-2.5 py-[3px] text-[11px] font-medium leading-[16px] transition-colors duration-150 select-none",
50
- active ? "text-foreground" : "text-muted-foreground hover:text-foreground/70",
51
+ "relative flex h-7 shrink-0 items-center justify-center whitespace-nowrap rounded-full px-2.5 text-[0.8rem] font-medium outline-none transition-colors duration-150 select-none focus-visible:ring-2 focus-visible:ring-ring",
52
+ active ? "text-foreground" : "text-muted-foreground hover:bg-accent/50 hover:text-foreground",
51
53
  )}
52
54
  >
53
55
  {active && (
54
56
  <motion.span
55
57
  layoutId={`seg-indicator-${layoutId}`}
56
- className="absolute inset-0 rounded-[6px] bg-background shadow-[0_1px_2px_rgba(0,0,0,0.06),0_0_0_0.5px_rgba(0,0,0,0.04)] ring-[0.5px] ring-inset ring-primary/30 dark:bg-white/[0.12] dark:shadow-[0_1px_2px_rgba(0,0,0,0.2)]"
58
+ className="absolute inset-0 rounded-full bg-secondary"
57
59
  transition={
58
60
  suppressLayoutAnimation
59
61
  ? { duration: 0 }
@@ -62,12 +64,17 @@ export function SegmentedControl<T extends string>({
62
64
  />
63
65
  )}
64
66
  <motion.span
65
- className="relative z-10 flex items-center gap-1"
67
+ className="relative z-10 flex items-center gap-1.5"
66
68
  whileTap={{ scale: 0.93 }}
67
69
  transition={{ type: "spring", stiffness: 500, damping: 24 }}
68
70
  >
69
- {icon && <span className={cn(icon, "h-3 w-3")} />}
71
+ {icon && <span className={cn(icon, "h-3.5 w-3.5")} />}
70
72
  {label}
73
+ {count && count > 0 ? (
74
+ <span className="rounded-full bg-background/60 px-1.5 text-[11px] leading-4 tabular-nums text-muted-foreground">
75
+ {count}
76
+ </span>
77
+ ) : null}
71
78
  {badge && badge > 0 ? (
72
79
  <span className="ml-0.5 inline-flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-red-500 px-1 text-[9px] font-semibold leading-none text-white">
73
80
  {badge > 99 ? "99+" : badge}
@@ -0,0 +1,61 @@
1
+ // @vitest-environment jsdom
2
+
3
+ import { Dialog, DialogDescription, DialogTitle, DialogTrigger } from "@vetta-org/ui";
4
+ import { act } from "react";
5
+ import { createRoot, type Root } from "react-dom/client";
6
+ import { afterEach, beforeEach, describe, expect, it } from "vitest";
7
+ import { StageDialogContent } from "./StageDialogContent";
8
+
9
+ /** Uses the `@vetta-org/ui` Dialog parts, the same combination plugins are told to use. */
10
+ describe("StageDialogContent", () => {
11
+ let root: Root;
12
+ let host: HTMLDivElement;
13
+
14
+ function openStage(closeLabel?: string): void {
15
+ act(() =>
16
+ root.render(
17
+ <Dialog>
18
+ <DialogTrigger>Open poster</DialogTrigger>
19
+ <StageDialogContent closeLabel={closeLabel} artwork={<p>Poster</p>}>
20
+ <DialogTitle>Share poster</DialogTitle>
21
+ <DialogDescription>Save it as an image.</DialogDescription>
22
+ </StageDialogContent>
23
+ </Dialog>,
24
+ ),
25
+ );
26
+ act(() => host.querySelector("button")?.click());
27
+ }
28
+
29
+ const stage = () => document.querySelector<HTMLElement>('[role="dialog"]');
30
+ const closeButton = () => stage()?.querySelector<HTMLButtonElement>('button[aria-label="Close poster"]') ?? null;
31
+
32
+ beforeEach(() => {
33
+ (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
34
+ host = document.createElement("div");
35
+ document.body.append(host);
36
+ root = createRoot(host);
37
+ });
38
+
39
+ afterEach(() => {
40
+ act(() => root.unmount());
41
+ host.remove();
42
+ });
43
+
44
+ it("opens from the ui Dialog trigger and closes with the labelled close button", () => {
45
+ openStage("Close poster");
46
+ expect(stage()?.textContent).toContain("Poster");
47
+ expect(stage()?.textContent).toContain("Share poster");
48
+
49
+ act(() => closeButton()?.click());
50
+ expect(stage()).toBeNull();
51
+ });
52
+
53
+ it("shows no close button without a label, and still closes on a backdrop click", () => {
54
+ openStage();
55
+ expect(stage()?.textContent).toContain("Poster");
56
+ expect(stage()?.querySelectorAll('button:not([aria-hidden="true"])')).toHaveLength(0);
57
+
58
+ act(() => stage()?.querySelector<HTMLButtonElement>('button[aria-hidden="true"]')?.click());
59
+ expect(stage()).toBeNull();
60
+ });
61
+ });
@@ -0,0 +1,80 @@
1
+ import { Dialog } from "radix-ui";
2
+ import { type ComponentProps, type ReactNode, useRef } from "react";
3
+
4
+ type ContentProps = ComponentProps<typeof Dialog.Content>;
5
+
6
+ export interface StageDialogContentProps {
7
+ artwork: ReactNode;
8
+ /** Caption column beside the artwork; leave it out to let the artwork stand alone. */
9
+ children?: ReactNode;
10
+ /**
11
+ * Accessible name of the round close button in the top-right corner of the window.
12
+ * Leave it out when the caption column already offers a way to close.
13
+ */
14
+ closeLabel?: string;
15
+ /**
16
+ * Call `preventDefault()` to keep focus off the first control when the stage opens.
17
+ * Focus then lands on the stage itself, so it never stays on the opener outside the modal.
18
+ */
19
+ onOpenAutoFocus?: ContentProps["onOpenAutoFocus"];
20
+ /** Needed when the dialog is opened without a `Dialog.Trigger`, so focus can return to the opener. */
21
+ onCloseAutoFocus?: ContentProps["onCloseAutoFocus"];
22
+ }
23
+
24
+ /**
25
+ * Full-window stage for one piece of artwork: no card, just a blurred backdrop that closes on click.
26
+ * Render it inside a Dialog root, and give it a Dialog title and description (visually hidden is fine).
27
+ */
28
+ export function StageDialogContent({
29
+ artwork,
30
+ children,
31
+ closeLabel,
32
+ onOpenAutoFocus,
33
+ onCloseAutoFocus,
34
+ }: StageDialogContentProps) {
35
+ const contentRef = useRef<HTMLDivElement>(null);
36
+ return (
37
+ <Dialog.Portal>
38
+ <Dialog.Overlay
39
+ data-slot="dialog-overlay"
40
+ className="no-drag fixed inset-0 z-50 bg-background/80 backdrop-blur-md"
41
+ />
42
+ <Dialog.Content
43
+ data-slot="dialog-stage"
44
+ ref={contentRef}
45
+ onOpenAutoFocus={(event) => {
46
+ onOpenAutoFocus?.(event);
47
+ // Radix skips its own container fallback once the event is cancelled.
48
+ if (event.defaultPrevented) contentRef.current?.focus({ preventScroll: true });
49
+ }}
50
+ onCloseAutoFocus={onCloseAutoFocus}
51
+ className="no-drag fixed inset-0 z-50 overflow-y-auto outline-none"
52
+ >
53
+ <Dialog.Close asChild>
54
+ <button type="button" tabIndex={-1} aria-hidden="true" className="fixed inset-0 cursor-default" />
55
+ </Dialog.Close>
56
+ <div className="pointer-events-none relative flex min-h-full items-center justify-center px-8 py-10">
57
+ <div className="flex max-w-full flex-wrap items-start justify-center gap-x-10 gap-y-6">
58
+ <div className="pointer-events-auto min-w-0 max-w-full">{artwork}</div>
59
+ {children ? (
60
+ <div className="pointer-events-auto flex w-[240px] max-w-full flex-col pt-1">{children}</div>
61
+ ) : null}
62
+ </div>
63
+ </div>
64
+ {/* 48px from the top: clears the Windows caption buttons in the same corner. */}
65
+ {closeLabel ? (
66
+ <Dialog.Close asChild>
67
+ <button
68
+ type="button"
69
+ title={closeLabel}
70
+ aria-label={closeLabel}
71
+ className="fixed top-12 right-6 flex h-9 w-9 items-center justify-center rounded-full bg-white text-black shadow-md outline-none transition-transform hover:scale-105 active:scale-95 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
72
+ >
73
+ <span aria-hidden className="icon-[mdi--close] h-5 w-5" />
74
+ </button>
75
+ </Dialog.Close>
76
+ ) : null}
77
+ </Dialog.Content>
78
+ </Dialog.Portal>
79
+ );
80
+ }
@@ -153,7 +153,7 @@ function ActiveTabIndicator({
153
153
  <svg
154
154
  viewBox={`0 0 ${geometry.width} ${geometry.height}`}
155
155
  aria-hidden
156
- className="absolute top-0 overflow-visible fill-muted stroke-border"
156
+ className="absolute top-0 overflow-visible fill-card stroke-border dark:fill-muted"
157
157
  data-connected-tab-outline
158
158
  shapeRendering="geometricPrecision"
159
159
  style={{
@@ -178,7 +178,7 @@ function ActiveTabIndicator({
178
178
  // 否则轮廓整体下移 1px,下探量会多出一像素压到内容卡片上。
179
179
  const indicatorProps = {
180
180
  "aria-hidden": true,
181
- className: "pointer-events-none absolute -inset-x-px -top-px -bottom-px rounded-t-lg bg-muted",
181
+ className: "pointer-events-none absolute -inset-x-px -top-px -bottom-px rounded-t-lg bg-card dark:bg-muted",
182
182
  "data-active-tab-indicator": true,
183
183
  };
184
184
 
@@ -9,6 +9,12 @@ import {
9
9
  } from "./kbd-keys";
10
10
 
11
11
  export type VettaKbdSize = "xs" | "sm";
12
+ /**
13
+ * raised:浮雕键帽(默认);flat:玻璃面板上的线框键帽,只画一圈大圆角细描边,不铺底色、不画投影。
14
+ * flat 的描边和键面符号取同一个前景色,只降不透明度:同色同调才读成一个键帽,
15
+ * 灰色在玻璃底上会发脏;描边要明显淡于符号(符号用实色前景,描边只取五分之一),连续线条比字形笔画显得亮,数值接近时边框会盖过键位。
16
+ */
17
+ export type VettaKbdVariant = "raised" | "flat";
12
18
 
13
19
  export interface VettaKbdProps {
14
20
  /** 快捷键串("mod+shift+k")或键位列表;列表项可写成按平台取值的对象。 */
@@ -16,6 +22,7 @@ export interface VettaKbdProps {
16
22
  /** 强制平台;默认按当前窗口平台判断。 */
17
23
  readonly platform?: VettaKbdPlatform;
18
24
  readonly size?: VettaKbdSize;
25
+ readonly variant?: VettaKbdVariant;
19
26
  /** 键之间显示 "+" 连接符(默认只靠间距分组)。 */
20
27
  readonly separator?: boolean;
21
28
  readonly className?: string;
@@ -33,11 +40,22 @@ const CAP_RAISED = cn(
33
40
  "dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.09),0_1.5px_2px_rgba(0,0,0,0.55)]",
34
41
  );
35
42
 
43
+ const CAP_FLAT = cn(
44
+ "inline-flex shrink-0 items-center justify-center whitespace-nowrap font-medium leading-none",
45
+ "border border-foreground/20 bg-transparent text-foreground",
46
+ );
47
+
36
48
  const SIZE_CLASS: Record<VettaKbdSize, string> = {
37
49
  xs: "h-[18px] min-w-[18px] rounded-[4px] px-1 text-[10px]",
38
50
  sm: "h-[22px] min-w-[22px] rounded-[5px] px-1.5 text-[11px]",
39
51
  };
40
52
 
53
+ // 线框键帽没有底色撑面积,内边距收紧、符号放大、圆角加大,键位才不显得空。
54
+ const FLAT_SIZE_CLASS: Record<VettaKbdSize, string> = {
55
+ xs: "h-[18px] min-w-[18px] rounded-[6px] px-[3px] text-[11px]",
56
+ sm: "h-[22px] min-w-[22px] rounded-[7px] px-[3px] text-[13px]",
57
+ };
58
+
41
59
  /**
42
60
  * 快捷键键帽展示:把 "mod+shift+k" 这类串渲染成一组浮雕键帽。
43
61
  *
@@ -48,6 +66,7 @@ export function VettaKbd({
48
66
  keys,
49
67
  platform,
50
68
  size = "xs",
69
+ variant = "raised",
51
70
  separator = false,
52
71
  className,
53
72
  }: VettaKbdProps): JSX.Element | null {
@@ -71,7 +90,7 @@ export function VettaKbd({
71
90
  +
72
91
  </span>
73
92
  )}
74
- <kbd aria-hidden="true" className={cn(CAP_RAISED, SIZE_CLASS[size])}>
93
+ <kbd aria-hidden="true" className={variant === "flat" ? cn(CAP_FLAT, FLAT_SIZE_CLASS[size]) : cn(CAP_RAISED, SIZE_CLASS[size])}>
75
94
  {label}
76
95
  </kbd>
77
96
  </Fragment>
@@ -28,11 +28,14 @@ export {
28
28
  export type { MultiplierTagProps } from "./MultiplierTag";
29
29
  export { fmtMultiplier, MultiplierTag } from "./MultiplierTag";
30
30
  export { readTableCells, toCsv, toMarkdown } from "./markdown-table-clipboard";
31
+ export { chromeButtonGroupVariant } from "./platform";
31
32
  export { getProviderIcon, PROVIDER_ICONS, ProviderIcon } from "./provider-icon";
32
33
  export type { ScrollFadeProps } from "./ScrollFade";
33
34
  export { ScrollFade } from "./ScrollFade";
34
35
  export type { SegmentedControlItem, SegmentedControlProps } from "./SegmentedControl";
35
36
  export { SegmentedControl } from "./SegmentedControl";
37
+ export type { StageDialogContentProps } from "./StageDialogContent";
38
+ export { StageDialogContent } from "./StageDialogContent";
36
39
  export type { SyntaxHighlightedCodeProps } from "./SyntaxHighlightedCode";
37
40
  export { SyntaxHighlightedCode } from "./SyntaxHighlightedCode";
38
41
  export type { TabBarDragEvent, TabBarItem, TabBarProps } from "./TabBar";
@@ -40,5 +43,5 @@ export { TabBar } from "./TabBar";
40
43
  export type { TimePickerProps } from "./TimePicker";
41
44
  export { TimePicker } from "./TimePicker";
42
45
  export { useDelayedUnmount } from "./useDelayedUnmount";
43
- export type { VettaKbdProps, VettaKbdSize } from "./VettaKbd";
46
+ export type { VettaKbdProps, VettaKbdSize, VettaKbdVariant } from "./VettaKbd";
44
47
  export { VettaKbd } from "./VettaKbd";
@@ -0,0 +1,9 @@
1
+ import type { ButtonGroupVariant } from "@vetta-org/ui/button-group";
2
+ import { detectKbdPlatform } from "./kbd-keys";
3
+
4
+ /**
5
+ * 侧边栏底部与标题栏右侧这两处常驻按钮组的外观。
6
+ * Windows 的窗口 chrome 由 DWM 平涂,常驻的胶囊底贴在纯色墙面上会显得像一块贴片,
7
+ * 所以那里用幽灵按钮组,只有悬停 / 选中项有底色;其余平台维持玻璃(openvetta/open-vetta#88)。
8
+ */
9
+ export const chromeButtonGroupVariant: ButtonGroupVariant = detectKbdPlatform() === "windows" ? "ghost" : "glass";
@@ -1,5 +1,6 @@
1
1
  import { Button } from "@vetta-org/ui/button";
2
2
  import { forwardRef, type ComponentPropsWithoutRef, type JSX } from "react";
3
+ import { SidebarSectionActionButton } from "./SidebarSectionActionButton";
3
4
 
4
5
  function cn(...parts: Array<string | false | null | undefined>): string {
5
6
  return parts.filter(Boolean).join(" ");
@@ -9,11 +10,15 @@ export interface AddProjectMenuTriggerViewProps extends ComponentPropsWithoutRef
9
10
  label: string;
10
11
  open: boolean;
11
12
  variant: "icon" | "navItem" | "primary" | "secondary";
13
+ /** 仅 `icon` 变体生效:还没有项目时常驻引导,有项目后改为悬停标题行才出现。 */
14
+ reveal?: "hover" | "always";
15
+ /** 仅 `icon` 变体生效:与同一标题行上的其他「+」区分时换图标。 */
16
+ iconClassName?: string;
12
17
  }
13
18
 
14
19
  // 作为 PopoverTrigger asChild 的子节点:需要转发 ref 并透传 Radix 注入的属性。
15
20
  export const AddProjectMenuTriggerView = forwardRef<HTMLButtonElement, AddProjectMenuTriggerViewProps>(
16
- function AddProjectMenuTriggerView({ label, open, variant, ...props }, ref): JSX.Element {
21
+ function AddProjectMenuTriggerView({ iconClassName = "icon-[solar--add-linear]", label, open, reveal = "hover", variant, ...props }, ref): JSX.Element {
17
22
  if (variant === "secondary") {
18
23
  return (
19
24
  <Button variant="secondary" size="lg" className="no-drag w-full text-[13px]" ref={ref}
@@ -43,18 +48,14 @@ export const AddProjectMenuTriggerView = forwardRef<HTMLButtonElement, AddProjec
43
48
  }
44
49
 
45
50
  return (
46
- <button
47
- type="button"
48
- title={label}
51
+ <SidebarSectionActionButton
49
52
  ref={ref}
50
- {...props}
51
- className={cn(
52
- "flex items-center justify-center rounded-md p-1.5 text-foreground transition-opacity hover:bg-accent",
53
- open ? "opacity-100" : "opacity-0 group-hover:opacity-60 group-hover:hover:opacity-100",
54
- )}
55
- >
56
- <span className="icon-[solar--add-linear] h-4 w-4" />
57
- </button>
53
+ {...props}
54
+ expanded={open}
55
+ iconClassName={iconClassName}
56
+ label={label}
57
+ reveal={reveal}
58
+ />
58
59
  );
59
60
  },
60
61
  );
@@ -1,5 +1,6 @@
1
1
  import { forwardRef, type ComponentPropsWithoutRef, type JSX } from "react";
2
2
  import { ButtonGroup, ButtonGroupItem } from "@vetta-org/ui/button-group";
3
+ import { chromeButtonGroupVariant } from "../shared/platform";
3
4
  import { cn } from "@vetta-org/ui/utils";
4
5
 
5
6
  export interface SettingsMenuTriggerViewProps extends ComponentPropsWithoutRef<"button"> {
@@ -21,7 +22,7 @@ export const SettingsMenuTriggerView = forwardRef<HTMLButtonElement, SettingsMen
21
22
  const label = clawOnline && clawTitle ? `${settingsFallbackLabel} · ${clawTitle}` : settingsFallbackLabel;
22
23
 
23
24
  return (
24
- <ButtonGroup blur={false} className="no-drag shrink-0">
25
+ <ButtonGroup blur={false} variant={chromeButtonGroupVariant} className="no-drag shrink-0">
25
26
  <ButtonGroupItem
26
27
  ref={ref}
27
28
  active={Boolean(active)}