import { useState } from "react"; import type { Hotspot, HotspotAction } from "../types/annotations"; interface HotspotEditorProps { hotspots: Hotspot[]; selectedHotspotId: string | null; placingMode: boolean; currentFrame: number; totalFrames: number; onSelectHotspot: (id: string) => void; onDeleteHotspot: (id: string) => void; onTogglePlacingMode: () => void; onUpdateHotspot: (id: string, updater: (hotspot: Hotspot) => Hotspot) => void; } const buildDefaultAction = (type: HotspotAction["type"]): HotspotAction => { if (type === "tooltip") return { type: "tooltip", text: "" }; if (type === "seek") return { type: "seek", targetFrame: 0 }; return { type: "url", href: "", newTab: true }; }; // Linear-style numeric stepper const Stepper = ({ value, onChange, min = 0, max = 100, suffix = "", }: { value: number; onChange: (v: number) => void; min?: number; max?: number; suffix?: string; }) => (
{Math.round(value)} {suffix}
); // Linear-style property row const PropertyRow = ({ label, children }: { label: string; children: React.ReactNode }) => (
{label} {children}
); function HotspotEditor({ hotspots, selectedHotspotId, placingMode, currentFrame, totalFrames, onDeleteHotspot, onSelectHotspot, onTogglePlacingMode, onUpdateHotspot, }: HotspotEditorProps) { const selectedHotspot = hotspots.find((h) => h.id === selectedHotspotId) ?? null; const [showAdvanced, setShowAdvanced] = useState(false); const update = (field: keyof Hotspot, value: number | string) => { if (!selectedHotspot) return; onUpdateHotspot(selectedHotspot.id, (c) => ({ ...c, [field]: value })); }; // List view - Linear style if (!selectedHotspot) { return (
{/* Add button */} {/* Hotspot list */} {hotspots.length > 0 && (
{hotspots.map((hotspot, idx) => ( ))}
)} {hotspots.length === 0 && !placingMode && (

Add interactive hotspots to highlight important areas.

)}
); } // Editor view - Linear style return (
{/* Back header */} {/* Action type */}
{(["tooltip", "url", "seek"] as const).map((type) => ( ))}
{/* Style */}
{( [ { style: "pulse" as const, label: "Hotspot" }, { style: "circle" as const, label: "Pin" }, { style: "rectangle" as const, label: "Area" }, ] as const ).map(({ style, label }) => ( ))}
{/* Action content - Linear style */} {selectedHotspot.action.type === "tooltip" && (