refactor(canvas): 提取摄像机控制弹窗为独立组件
将原有的CameraToolsPopover组件抽离为CanvasCameraControlPopover独立文件,移除冗余的内部组件定义,统一代码结构,提升可维护性。同时调整lucide-react中图标的size类名保持视觉统一。
This commit is contained in:
1 parent
cd29657dd2
commit
8ce76f3d96
2 files changed
+56
-48
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import { useState } from "react";
|
||||
import { Camera } from "lucide-react";
|
||||
|
||||
import { AppModal } from "@/components/ui/product/app-modal/app-modal";
|
||||
import type { CanvasTheme } from "@/lib/canvas-theme";
|
||||
import type { CameraControlOptions } from "@/lib/canvas/camera-prompt-library";
|
||||
import { CanvasNodeCameraPanel } from "./canvas-node-camera-dialog";
|
||||
|
||||
type CanvasCameraControlPopoverProps = {
|
||||
cameraControl?: CameraControlOptions;
|
||||
onCameraControlChange: (options: CameraControlOptions) => void;
|
||||
theme: CanvasTheme;
|
||||
compact?: boolean;
|
||||
};
|
||||
|
||||
export function CanvasCameraControlPopover({ cameraControl, onCameraControlChange, theme, compact = false }: CanvasCameraControlPopoverProps) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const cameraEnabled = cameraControl?.enabled === true;
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
className={`canvas-node-composer-camera-tools-trigger inline-flex shrink-0 items-center gap-1 rounded-full px-1.5 text-[var(--fs-tiny)] transition-colors ${compact ? "is-compact h-7" : "h-8"}`}
|
||||
style={{
|
||||
background: cameraEnabled ? `${theme.node.activeStroke}66` : theme.node.fill,
|
||||
color: cameraEnabled ? theme.node.panel : theme.node.text,
|
||||
}}
|
||||
aria-pressed={cameraEnabled}
|
||||
aria-label="摄像机控制"
|
||||
title={`摄像机控制${cameraEnabled ? " · 已启用" : ""}`}
|
||||
onClick={() => setOpen(true)}
|
||||
>
|
||||
<Camera className="size-3.5" />
|
||||
{!compact ? <span>摄像机</span> : null}
|
||||
</button>
|
||||
{open ? (
|
||||
<AppModal title="摄像机控制" open centered footer={null} width={780} flush onCancel={() => setOpen(false)}>
|
||||
<CanvasNodeCameraPanel
|
||||
cameraControl={cameraControl}
|
||||
onClose={() => setOpen(false)}
|
||||
onConfirm={(options) => {
|
||||
onCameraControlChange(options);
|
||||
setOpen(false);
|
||||
}}
|
||||
/>
|
||||
</AppModal>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user