import { useState } from 'react' import { toast } from 'sonner' import { Check } from 'lucide-react' import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog' import { Button } from '@/components/ui/button' import { THEMES, THEME_ORDER, type ThemeId } from '@/utils/themes' import { useThemeStore } from '@/stores/themeStore' import { useCanvasStore } from '@/stores/canvasStore' // Node-type accent colors to display as preview swatches const PREVIEW_TYPES = ['isp', 'server', 'proxmox', 'switch', 'iot'] as const interface ThemeCardProps { themeId: ThemeId selected: boolean onClick: () => void } function ThemeCard({ themeId, selected, onClick }: ThemeCardProps) { const preset = THEMES[themeId] const c = preset.colors return ( ) } interface ThemeModalProps { open: boolean onClose: () => void } export function ThemeModal({ open, onClose }: ThemeModalProps) { const { activeTheme, setTheme } = useThemeStore() const { markUnsaved } = useCanvasStore() // Capture the theme that was active when the modal opened const [originalTheme] = useState(activeTheme) const [selected, setSelected] = useState(activeTheme) const handleSelect = (id: ThemeId) => { setSelected(id) // Live-preview the selected theme on the canvas setTheme(id) } const handleApply = () => { setTheme(selected) markUnsaved() onClose() toast.info('Style applied — save your canvas to make it permanent', { duration: 5000, }) } const handleCancel = () => { // Revert to the original theme setTheme(originalTheme) onClose() } return ( { if (!o) handleCancel() }}> Choose Canvas Style
{THEME_ORDER.map((id) => ( handleSelect(id)} /> ))}
) }