'use client'; import { useState } from 'react'; import { X, Download } from 'lucide-react'; import { cn } from '@/lib/utils'; interface ExportDialogProps { isOpen: boolean; onClose: () => void; onExport: (format: 'png' | 'jpeg' | 'webp', quality: number, filename: string) => void; defaultFilename?: string; } export function ExportDialog({ isOpen, onClose, onExport, defaultFilename = 'image', }: ExportDialogProps) { const [format, setFormat] = useState<'png' | 'jpeg' | 'webp'>('png'); const [quality, setQuality] = useState(100); const [filename, setFilename] = useState(defaultFilename); if (!isOpen) return null; const handleExport = () => { onExport(format, quality / 100, filename); onClose(); }; return (
e.stopPropagation()} > {/* Header */}

Export Image

{/* Content */}
{/* Filename */}
setFilename(e.target.value)} className="w-full px-3 py-2 rounded-md border border-border bg-background text-foreground" placeholder="Enter filename" />
{/* Format */}
{(['png', 'jpeg', 'webp'] as const).map((fmt) => ( ))}
{/* Quality (for JPEG/WEBP) */} {(format === 'jpeg' || format === 'webp') && (
{quality}%
setQuality(Number(e.target.value))} className="w-full" />
)} {/* Info */}
{format === 'png' && '• PNG: Lossless, supports transparency'} {format === 'jpeg' && '• JPEG: Lossy, smaller file size, no transparency'} {format === 'webp' && '• WEBP: Modern format, smaller size, supports transparency'}
{/* Footer */}
); }