@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.
Files changed (78) hide show
  1. package/package.json +8 -16
  2. package/src/activity/ActivityPanelFrame.tsx +1 -1
  3. package/src/activity/CodePreview.tsx +15 -1
  4. package/src/activity/MarkdownPreviewView.test.tsx +53 -0
  5. package/src/activity/MarkdownPreviewView.tsx +86 -10
  6. package/src/chat/ContextRingView.test.tsx +81 -0
  7. package/src/chat/ContextRingView.tsx +78 -62
  8. package/src/chat/HeaderActionBarView.tsx +122 -47
  9. package/src/chat/HeaderActionOverflowMenu.tsx +11 -20
  10. package/src/chat/MessageFeedLayoutView.tsx +6 -5
  11. package/src/chat/MessageInputView.tsx +5 -1
  12. package/src/chat/index.ts +2 -1
  13. package/src/chat/message-feed-fade.css +80 -0
  14. package/src/chat/message-feed-fade.test.tsx +75 -0
  15. package/src/file-preview/ReadonlyCodeView.tsx +46 -0
  16. package/src/file-preview/syntax-tokens.css +1 -1
  17. package/src/image-assets.d.ts +4 -0
  18. package/src/markdown/FileLinkBadge.tsx +77 -0
  19. package/src/markdown/MarkdownContent.tsx +12 -5
  20. package/src/markdown/MarkdownImage.tsx +6 -16
  21. package/src/markdown/MermaidBlock.tsx +50 -11
  22. package/src/markdown/image-actions.ts +29 -0
  23. package/src/markdown/index.ts +1 -0
  24. package/src/markdown/preview-policy.test.ts +31 -0
  25. package/src/markdown/preview-policy.ts +33 -0
  26. package/src/markdown/progressive-chunks.test.ts +43 -0
  27. package/src/markdown/progressive-chunks.ts +58 -0
  28. package/src/markdown/rich-labels.ts +6 -0
  29. package/src/overlays/CommandMenuRow.tsx +43 -12
  30. package/src/overlays/CommandMenuView.tsx +96 -11
  31. package/src/overlays/DiagnosticsExportDialogView.tsx +236 -0
  32. package/src/overlays/MagpieHandoverDialogView.tsx +217 -0
  33. package/src/overlays/ReleaseNoteMarkdown.test.tsx +24 -0
  34. package/src/overlays/ReleaseNoteMarkdown.tsx +26 -0
  35. package/src/overlays/SplashPanel.tsx +4 -4
  36. package/src/overlays/SplashParts.tsx +6 -2
  37. package/src/overlays/UpdateRestartDialogView.tsx +65 -0
  38. package/src/overlays/assets/diagnostics-banner.webp +0 -0
  39. package/src/overlays/command-menu-types.ts +13 -1
  40. package/src/overlays/index.ts +12 -0
  41. package/src/plugin-ui/index.ts +2 -0
  42. package/src/project/DefaultConversationSectionView.tsx +13 -22
  43. package/src/project/DefaultSessionRowView.tsx +8 -0
  44. package/src/settings/ArchivedProjectsSettingsView.tsx +122 -1
  45. package/src/settings/GeneralSettingsView.tsx +2 -5
  46. package/src/settings/LauncherSettingsView.test.tsx +95 -0
  47. package/src/settings/LauncherSettingsView.tsx +273 -0
  48. package/src/settings/PetActionGalleryView.test.tsx +163 -0
  49. package/src/settings/PetActionGalleryView.tsx +216 -0
  50. package/src/settings/PetSettingsView.test.tsx +117 -0
  51. package/src/settings/PetSettingsView.tsx +86 -22
  52. package/src/settings/PresetProviderRowView.tsx +37 -98
  53. package/src/settings/ShortcutsSettingsView.tsx +0 -4
  54. package/src/settings/SpaceEditorDialogView.tsx +94 -56
  55. package/src/settings/SpacesSettingsView.tsx +53 -8
  56. package/src/settings/assets/space-editor-illustration.webp +0 -0
  57. package/src/settings/index.ts +18 -39
  58. package/src/shared/SegmentedControl.test.tsx +68 -0
  59. package/src/shared/SegmentedControl.tsx +10 -2
  60. package/src/shared/TabBar.tsx +2 -2
  61. package/src/shared/VettaKbd.tsx +20 -1
  62. package/src/shared/index.ts +2 -1
  63. package/src/shared/platform.ts +9 -0
  64. package/src/sidebar/AddProjectMenuTriggerView.tsx +11 -12
  65. package/src/sidebar/SettingsMenuTriggerView.tsx +2 -1
  66. package/src/sidebar/SidebarSectionActionButton.test.tsx +91 -0
  67. package/src/sidebar/SidebarSectionActionButton.tsx +52 -0
  68. package/src/styles.css +2 -0
  69. package/src/settings/AchievementNavigationButtonView.tsx +0 -90
  70. package/src/settings/AchievementPromotionDialogView.tsx +0 -91
  71. package/src/settings/AchievementSettingsView.tsx +0 -43
  72. package/src/settings/PetBubbleStylePreviewView.tsx +0 -44
  73. package/src/settings/QuickPanelSettingsSectionView.tsx +0 -64
  74. package/src/settings/achievements/AchievementCurtains.tsx +0 -50
  75. package/src/settings/achievements/AchievementPromotionBadge3D.tsx +0 -350
  76. package/src/settings/achievements/AchievementPromotionConfetti.tsx +0 -71
  77. package/src/settings/achievements/AchievementTitle.tsx +0 -52
  78. package/src/settings/achievements/index.ts +0 -13
@@ -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> {
@@ -38,7 +43,7 @@ export function SegmentedControl<T extends string>({
38
43
  className,
39
44
  )}
40
45
  >
41
- {items.map(({ key, label, icon, badge }) => {
46
+ {items.map(({ key, label, icon, badge, count }) => {
42
47
  const active = value === key;
43
48
  return (
44
49
  <button
@@ -68,6 +73,9 @@ export function SegmentedControl<T extends string>({
68
73
  >
69
74
  {icon && <span className={cn(icon, "h-3 w-3")} />}
70
75
  {label}
76
+ {count && count > 0 ? (
77
+ <span className="text-[10px] font-medium tabular-nums text-muted-foreground">{count}</span>
78
+ ) : null}
71
79
  {badge && badge > 0 ? (
72
80
  <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
81
  {badge > 99 ? "99+" : badge}
@@ -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,6 +28,7 @@ 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";
@@ -40,5 +41,5 @@ export { TabBar } from "./TabBar";
40
41
  export type { TimePickerProps } from "./TimePicker";
41
42
  export { TimePicker } from "./TimePicker";
42
43
  export { useDelayedUnmount } from "./useDelayedUnmount";
43
- export type { VettaKbdProps, VettaKbdSize } from "./VettaKbd";
44
+ export type { VettaKbdProps, VettaKbdSize, VettaKbdVariant } from "./VettaKbd";
44
45
  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,13 @@ 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";
12
15
  }
13
16
 
14
17
  // 作为 PopoverTrigger asChild 的子节点:需要转发 ref 并透传 Radix 注入的属性。
15
18
  export const AddProjectMenuTriggerView = forwardRef<HTMLButtonElement, AddProjectMenuTriggerViewProps>(
16
- function AddProjectMenuTriggerView({ label, open, variant, ...props }, ref): JSX.Element {
19
+ function AddProjectMenuTriggerView({ label, open, reveal = "hover", variant, ...props }, ref): JSX.Element {
17
20
  if (variant === "secondary") {
18
21
  return (
19
22
  <Button variant="secondary" size="lg" className="no-drag w-full text-[13px]" ref={ref}
@@ -43,18 +46,14 @@ export const AddProjectMenuTriggerView = forwardRef<HTMLButtonElement, AddProjec
43
46
  }
44
47
 
45
48
  return (
46
- <button
47
- type="button"
48
- title={label}
49
+ <SidebarSectionActionButton
49
50
  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>
51
+ {...props}
52
+ expanded={open}
53
+ iconClassName="icon-[solar--add-linear]"
54
+ label={label}
55
+ reveal={reveal}
56
+ />
58
57
  );
59
58
  },
60
59
  );
@@ -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)}
@@ -0,0 +1,91 @@
1
+ // @vitest-environment jsdom
2
+
3
+ import { act, createRef, type JSX } from "react";
4
+ import { createRoot, type Root } from "react-dom/client";
5
+ import { afterEach, describe, expect, it } from "vitest";
6
+ import { SidebarSectionActionButton } from "./SidebarSectionActionButton";
7
+
8
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
9
+
10
+ const mounted: Array<{ root: Root; container: HTMLDivElement }> = [];
11
+
12
+ afterEach(() => {
13
+ for (const { root, container } of mounted.splice(0)) {
14
+ act(() => root.unmount());
15
+ container.remove();
16
+ }
17
+ });
18
+
19
+ function mount(element: JSX.Element): HTMLButtonElement {
20
+ const container = document.createElement("div");
21
+ document.body.append(container);
22
+ const root = createRoot(container);
23
+ mounted.push({ root, container });
24
+ act(() => root.render(element));
25
+ return container.querySelector("button") as HTMLButtonElement;
26
+ }
27
+
28
+ describe("SidebarSectionActionButton", () => {
29
+ it("is a named, non-submitting button that forwards its ref and host attributes", () => {
30
+ const ref = createRef<HTMLButtonElement>();
31
+ const button = mount(
32
+ <SidebarSectionActionButton
33
+ ref={ref}
34
+ aria-haspopup="menu"
35
+ className="shrink-0"
36
+ iconClassName="icon-[solar--menu-dots-bold]"
37
+ label="View options"
38
+ />,
39
+ );
40
+
41
+ expect(ref.current).toBe(button);
42
+ expect(button.type).toBe("button");
43
+ expect(button.getAttribute("aria-label")).toBe("View options");
44
+ expect(button.getAttribute("aria-haspopup")).toBe("menu");
45
+ expect(button.classList.contains("shrink-0")).toBe(true);
46
+ });
47
+
48
+ it("exposes the open state to assistive technology only when it triggers a menu", () => {
49
+ const menuTrigger = (expanded: boolean) =>
50
+ mount(
51
+ <SidebarSectionActionButton
52
+ aria-haspopup="menu"
53
+ expanded={expanded}
54
+ iconClassName="icon-[solar--menu-dots-bold]"
55
+ label="View options"
56
+ />,
57
+ );
58
+ expect(menuTrigger(false).getAttribute("aria-expanded")).toBe("false");
59
+ expect(menuTrigger(true).getAttribute("aria-expanded")).toBe("true");
60
+ expect(
61
+ mount(<SidebarSectionActionButton expanded iconClassName="icon-[solar--add-linear]" label="Add" />).hasAttribute(
62
+ "aria-expanded",
63
+ ),
64
+ ).toBe(false);
65
+ });
66
+
67
+ it("stays hidden until its row is hovered or it takes keyboard focus, unless it is always shown", () => {
68
+ const hover = mount(<SidebarSectionActionButton iconClassName="icon-[solar--add-linear]" label="Add" />);
69
+ expect(hover.dataset.reveal).toBe("hover");
70
+ expect(hover.classList).toContain("opacity-0");
71
+ expect(hover.classList).toContain("group-hover:opacity-60");
72
+ expect(hover.classList).toContain("focus-visible:opacity-100");
73
+
74
+ const always = mount(<SidebarSectionActionButton iconClassName="icon-[solar--add-linear]" label="Add" reveal="always" />);
75
+ expect(always.dataset.reveal).toBe("always");
76
+ expect(always.classList).not.toContain("opacity-0");
77
+
78
+ const open = mount(<SidebarSectionActionButton expanded iconClassName="icon-[solar--add-linear]" label="Add" />);
79
+ expect(open.classList).toContain("opacity-100");
80
+ expect(open.classList).not.toContain("opacity-0");
81
+ });
82
+
83
+ it("reports whether its menu is open", () => {
84
+ expect(
85
+ mount(<SidebarSectionActionButton iconClassName="icon-[solar--add-linear]" label="Add" />).dataset.state,
86
+ ).toBe("closed");
87
+ expect(
88
+ mount(<SidebarSectionActionButton expanded iconClassName="icon-[solar--add-linear]" label="Add" />).dataset.state,
89
+ ).toBe("open");
90
+ });
91
+ });
@@ -0,0 +1,52 @@
1
+ import { cn } from "@vetta-org/ui/utils";
2
+ import { forwardRef, type ComponentPropsWithoutRef, type JSX } from "react";
3
+
4
+ export interface SidebarSectionActionButtonProps extends Omit<ComponentPropsWithoutRef<"button">, "children"> {
5
+ /** iconify class,例如 `icon-[solar--add-linear]`。 */
6
+ iconClassName: string;
7
+ /** 可访问名称,同时作为悬停提示。 */
8
+ label: string;
9
+ /**
10
+ * `hover`:只在所在 `group` 被悬停时出现;`always`:常驻显示。
11
+ * 两者都在自身悬停时提到全亮。
12
+ */
13
+ reveal?: "hover" | "always";
14
+ /** 关联的菜单或弹层正打开,保持全亮;作为菜单触发器(`aria-haspopup="menu"`)时同步为 `aria-expanded`。 */
15
+ expanded?: boolean;
16
+ }
17
+
18
+ /**
19
+ * 侧栏分区标题行(项目、对话)右侧的图标按钮。
20
+ * 需要作为 Popover/Dropdown 的 `asChild` 触发器时会被注入 ref 与事件,故原样转发。
21
+ */
22
+ export const SidebarSectionActionButton = forwardRef<HTMLButtonElement, SidebarSectionActionButtonProps>(
23
+ function SidebarSectionActionButton(
24
+ { className, expanded = false, iconClassName, label, reveal = "hover", type = "button", ...props },
25
+ ref,
26
+ ): JSX.Element {
27
+ return (
28
+ <button
29
+ ref={ref}
30
+ type={type}
31
+ title={label}
32
+ aria-label={label}
33
+ aria-expanded={props["aria-haspopup"] === "menu" ? expanded : undefined}
34
+ data-state={expanded ? "open" : "closed"}
35
+ data-reveal={reveal}
36
+ className={cn(
37
+ // 键盘聚焦时也要可见,不能只靠悬停才露出。
38
+ "flex items-center justify-center rounded-md p-1.5 text-foreground transition-opacity hover:bg-accent focus-visible:opacity-100",
39
+ expanded
40
+ ? "opacity-100"
41
+ : reveal === "always"
42
+ ? "opacity-60 hover:opacity-100"
43
+ : "opacity-0 group-hover:opacity-60 group-hover:hover:opacity-100",
44
+ className,
45
+ )}
46
+ {...props}
47
+ >
48
+ <span aria-hidden="true" className={cn(iconClassName, "h-4 w-4")} />
49
+ </button>
50
+ );
51
+ },
52
+ );
package/src/styles.css CHANGED
@@ -5,6 +5,8 @@
5
5
  @import "./file-preview/syntax-tokens.css";
6
6
  /* Command Menu 的一次性装饰动效(组件侧也会 side-effect import)。 */
7
7
  @import "./overlays/command-menu.css";
8
+ /* 会话消息流的上下渐隐:两层 mask 把滚动条槽位排除在渐隐之外。 */
9
+ @import "./chat/message-feed-fade.css";
8
10
 
9
11
  @keyframes pulse {
10
12
  0%,
@@ -1,90 +0,0 @@
1
- import type { JSX } from "react";
2
- import { Button } from "@vetta-org/ui";
3
- import { cn } from "@vetta-org/ui";
4
-
5
- export interface AchievementNavigationAssets {
6
- readonly activeBackground: string;
7
- readonly disabledBackground: string;
8
- readonly activeArrow: string;
9
- readonly disabledArrow: string;
10
- }
11
-
12
- export interface AchievementNavigationButtonViewProps {
13
- readonly disabled: boolean;
14
- readonly direction: "previous" | "next";
15
- readonly label: string;
16
- readonly onClick: () => void;
17
- readonly assets: AchievementNavigationAssets;
18
- }
19
-
20
- export function AchievementNavigationButtonView({
21
- disabled,
22
- direction,
23
- label,
24
- onClick,
25
- assets,
26
- }: AchievementNavigationButtonViewProps): JSX.Element {
27
- const previous = direction === "previous";
28
-
29
- return (
30
- <Button
31
- variant="ghost"
32
- disabled={disabled}
33
- aria-label={label}
34
- title={label}
35
- className={cn(
36
- "absolute top-1/2 z-30 h-[120px] w-[60px] rounded-none border-0 bg-transparent p-0 hover:bg-transparent disabled:opacity-100",
37
- previous ? "left-16" : "right-16",
38
- )}
39
- style={{
40
- transform: "translateY(-50%)",
41
- pointerEvents: "auto",
42
- cursor: disabled ? "default" : "pointer",
43
- }}
44
- onClick={onClick}
45
- >
46
- <img
47
- aria-hidden="true"
48
- alt=""
49
- draggable={false}
50
- src={assets.activeBackground}
51
- className={cn(
52
- "pointer-events-none absolute inset-0 h-full w-full object-contain transition-opacity duration-150",
53
- disabled ? "opacity-0" : "opacity-100",
54
- )}
55
- />
56
- <img
57
- aria-hidden="true"
58
- alt=""
59
- draggable={false}
60
- src={assets.disabledBackground}
61
- className={cn(
62
- "pointer-events-none absolute inset-0 h-full w-full object-contain transition-opacity duration-150",
63
- disabled ? "opacity-100" : "opacity-0",
64
- )}
65
- />
66
- <img
67
- aria-hidden="true"
68
- alt=""
69
- draggable={false}
70
- src={assets.activeArrow}
71
- className={cn(
72
- "pointer-events-none relative z-10 w-10 object-contain transition-opacity duration-150",
73
- previous && "rotate-180",
74
- disabled ? "opacity-0" : "opacity-100",
75
- )}
76
- />
77
- <img
78
- aria-hidden="true"
79
- alt=""
80
- draggable={false}
81
- src={assets.disabledArrow}
82
- className={cn(
83
- "pointer-events-none absolute left-1/2 top-1/2 z-10 w-10 -translate-x-1/2 -translate-y-1/2 object-contain transition-opacity duration-150",
84
- previous && "rotate-180",
85
- disabled ? "opacity-100" : "opacity-0",
86
- )}
87
- />
88
- </Button>
89
- );
90
- }
@@ -1,91 +0,0 @@
1
- import { useCallback, useRef, useState, type JSX, type ReactNode } from "react";
2
- import { Dialog, DialogContent, DialogDescription, DialogTitle } from "@vetta-org/ui";
3
-
4
- export interface AchievementPromotionDialogViewLabels {
5
- readonly title: string;
6
- readonly stageName: string;
7
- }
8
-
9
- export interface AchievementPromotionDialogViewProps {
10
- readonly onComplete: () => void;
11
- readonly labels: AchievementPromotionDialogViewLabels;
12
- /** 3D badge + confetti stay host-provided (or theme achievements slots). */
13
- readonly renderBadge: (handlers: {
14
- onCelebrate: () => void;
15
- onComplete: () => void;
16
- onHideText: () => void;
17
- onRevealText: () => void;
18
- }) => ReactNode;
19
- readonly renderConfetti: (triggerToken: number) => ReactNode;
20
- }
21
-
22
- export function AchievementPromotionDialogView({
23
- onComplete,
24
- labels,
25
- renderBadge,
26
- renderConfetti,
27
- }: AchievementPromotionDialogViewProps): JSX.Element {
28
- const [confettiTriggerToken, setConfettiTriggerToken] = useState(0);
29
- const [textVisible, setTextVisible] = useState(false);
30
- const textRef = useRef<HTMLDivElement>(null);
31
-
32
- const revealText = useCallback(() => {
33
- textRef.current?.animate(
34
- [
35
- { opacity: 0, transform: "translateY(16px)" },
36
- { opacity: 1, transform: "translateY(0)" },
37
- ],
38
- {
39
- duration: 500,
40
- easing: "cubic-bezier(0.22, 1, 0.36, 1)",
41
- },
42
- );
43
- setTextVisible(true);
44
- }, []);
45
- const hideText = useCallback(() => {
46
- setTextVisible(false);
47
- }, []);
48
- const celebrate = useCallback(() => {
49
- setConfettiTriggerToken((token) => token + 1);
50
- }, []);
51
-
52
- return (
53
- <Dialog open onOpenChange={(open) => !open && onComplete()}>
54
- <DialogContent
55
- className="h-[min(680px,calc(100vh-2rem))] overflow-visible border-transparent bg-transparent p-0 sm:max-w-[760px]"
56
- overlayClassName="bg-transparent supports-backdrop-filter:backdrop-blur-none"
57
- showCloseButton={false}
58
- onEscapeKeyDown={(event) => event.preventDefault()}
59
- onPointerDownOutside={(event) => event.preventDefault()}
60
- >
61
- <div
62
- ref={textRef}
63
- className={`pointer-events-none absolute inset-x-0 bottom-12 z-20 text-center transition-opacity ease-out ${
64
- textVisible ? "opacity-100" : "opacity-0"
65
- }`}
66
- style={{
67
- WebkitTextStroke: "2px var(--background)",
68
- paintOrder: "stroke fill",
69
- transitionDuration: textVisible ? "500ms" : "950ms",
70
- }}
71
- >
72
- <DialogTitle className="text-[20px] font-semibold text-primary">{labels.title}</DialogTitle>
73
- <DialogDescription className="mt-2 text-[15px] text-foreground">
74
- {labels.stageName}
75
- </DialogDescription>
76
- </div>
77
- <div className="relative z-10 h-full w-full">
78
- {renderBadge({
79
- onCelebrate: celebrate,
80
- onComplete,
81
- onHideText: hideText,
82
- onRevealText: revealText,
83
- })}
84
- </div>
85
- <div className="pointer-events-none absolute inset-0 z-15">
86
- {renderConfetti(confettiTriggerToken)}
87
- </div>
88
- </DialogContent>
89
- </Dialog>
90
- );
91
- }
@@ -1,43 +0,0 @@
1
- import type { JSX, ReactNode } from "react";
2
- import { MotionSelect } from "./MotionSelect";
3
-
4
- export interface AchievementSetOptionView {
5
- readonly id: string;
6
- readonly label: string;
7
- }
8
-
9
- export interface AchievementSettingsViewProps {
10
- readonly setSelectorLabel: string;
11
- readonly selectedSetId: string;
12
- readonly setOptions: readonly AchievementSetOptionView[];
13
- readonly onSelectSetId: (id: string) => void;
14
- readonly carousel: ReactNode;
15
- readonly promotionDialog: ReactNode;
16
- }
17
-
18
- export function AchievementSettingsView({
19
- setSelectorLabel,
20
- selectedSetId,
21
- setOptions,
22
- onSelectSetId,
23
- carousel,
24
- promotionDialog,
25
- }: AchievementSettingsViewProps): JSX.Element {
26
- return (
27
- <>
28
- <div className="mx-auto w-full max-w-[920px] px-8 pb-28 pt-4">
29
- <div className="mb-4 flex items-center justify-end gap-2">
30
- <span className="text-[12px] text-muted-foreground">{setSelectorLabel}</span>
31
- <MotionSelect
32
- value={selectedSetId}
33
- onValueChange={onSelectSetId}
34
- options={setOptions.map((set) => ({ value: set.id, label: set.label }))}
35
- aria-label={setSelectorLabel}
36
- />
37
- </div>
38
- {carousel}
39
- </div>
40
- {promotionDialog}
41
- </>
42
- );
43
- }