import { useState } from 'react'; import { Check, Copy, Download, RotateCcw, Settings, X } from 'lucide-react'; import { buildBloggerSingleHtml, buildBloggerThemeXml } from '../bloggerTemplate'; import { COLOR_PRESETS, normalizeHex, SITE_CONFIG } from '../config'; interface ThemeSettingsDrawerProps { currentColor: string; onChangeColor: (hex: string) => void; onResetColor: () => void; } export function ThemeSettingsDrawer({ currentColor, onChangeColor, onResetColor, }: ThemeSettingsDrawerProps) { const [isOpen, setIsOpen] = useState(false); const [hexInput, setHexInput] = useState(currentColor); const [copiedMode, setCopiedMode] = useState<'xml' | 'html' | null>(null); const handleHexChange = (value: string) => { setHexInput(value); const valid = normalizeHex(value); if (valid) { onChangeColor(valid); } }; const handlePresetClick = (hex: string) => { setHexInput(hex); onChangeColor(hex); }; const handleReset = () => { setHexInput(SITE_CONFIG.defaultColor); onResetColor(); }; const downloadFile = (content: string, filename: string, mime: string) => { const blob = new Blob([content], { type: mime }); const url = URL.createObjectURL(blob); const link = document.createElement('a'); link.href = url; link.download = filename; document.body.appendChild(link); link.click(); document.body.removeChild(link); URL.revokeObjectURL(url); }; const handleDownloadThemeXml = () => { const xml = buildBloggerThemeXml(currentColor, window.location.origin); downloadFile(xml, 'khatiana-ghee-blogger-theme.xml', 'application/xml;charset=utf-8'); }; const handleCopyThemeXml = async () => { const xml = buildBloggerThemeXml(currentColor, window.location.origin); try { await navigator.clipboard.writeText(xml); setCopiedMode('xml'); window.setTimeout(() => setCopiedMode(null), 2200); } catch { handleDownloadThemeXml(); } }; const handleCopyHtml5 = async () => { const html = buildBloggerSingleHtml(currentColor, window.location.origin); try { await navigator.clipboard.writeText(html); setCopiedMode('html'); window.setTimeout(() => setCopiedMode(null), 2200); } catch { downloadFile(html, 'khatiana-ghee-landing.html', 'text/html;charset=utf-8'); } }; return ( <> {/* Small Settings Button */}
{ setHexInput(currentColor); setIsOpen((prev) => !prev); }} aria-label="থিম সেটিংস ও কালার পরিবর্তন" aria-expanded={isOpen} className="fixed left-4 bottom-[72px] md:bottom-6 z-40 w-11 h-11 rounded-full bg-white text-stone-800 border border-stone-200 shadow-lg flex items-center justify-center hover:bg-stone-50 transition-transform duration-150 active:scale-95 cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)]" >
{/* Settings Panel */} {isOpen && ( )} > ); }