import React, { useState, useEffect } from 'react'; import { Dialog, DialogTitle, DialogDescription, DialogRoot } from './Dialog'; import { Button } from './Button'; import { IconButton } from './IconButton'; import type { DesignScheme } from '~/types/design-scheme'; import { defaultDesignScheme, designFeatures, designFonts, paletteRoles } from '~/types/design-scheme'; export interface ColorSchemeDialogProps { designScheme?: DesignScheme; setDesignScheme?: (scheme: DesignScheme) => void; } export const ColorSchemeDialog: React.FC = ({ setDesignScheme, designScheme }) => { const [palette, setPalette] = useState<{ [key: string]: string }>(() => { if (designScheme?.palette) { return { ...defaultDesignScheme.palette, ...designScheme.palette }; } return defaultDesignScheme.palette; }); const [features, setFeatures] = useState(designScheme?.features || defaultDesignScheme.features); const [font, setFont] = useState(designScheme?.font || defaultDesignScheme.font); const [isDialogOpen, setIsDialogOpen] = useState(false); const [activeSection, setActiveSection] = useState<'colors' | 'typography' | 'features'>('colors'); useEffect(() => { if (designScheme) { setPalette(() => ({ ...defaultDesignScheme.palette, ...designScheme.palette })); setFeatures(designScheme.features || defaultDesignScheme.features); setFont(designScheme.font || defaultDesignScheme.font); } else { setPalette(defaultDesignScheme.palette); setFeatures(defaultDesignScheme.features); setFont(defaultDesignScheme.font); } }, [designScheme]); const handleColorChange = (role: string, value: string) => { setPalette((prev) => ({ ...prev, [role]: value })); }; const handleFeatureToggle = (key: string) => { setFeatures((prev) => (prev.includes(key) ? prev.filter((f) => f !== key) : [...prev, key])); }; const handleFontToggle = (key: string) => { setFont((prev) => (prev.includes(key) ? prev.filter((f) => f !== key) : [...prev, key])); }; const handleSave = () => { setDesignScheme?.({ palette, features, font }); setIsDialogOpen(false); }; const handleReset = () => { setPalette(defaultDesignScheme.palette); setFeatures(defaultDesignScheme.features); setFont(defaultDesignScheme.font); }; const renderColorSection = () => (

Color Palette

{paletteRoles.map((role) => (
document.getElementById(`color-input-${role.key}`)?.click()} role="button" tabIndex={0} aria-label={`Change ${role.label} color`} /> handleColorChange(role.key, e.target.value)} className="absolute inset-0 w-full h-full opacity-0 cursor-pointer" tabIndex={-1} />
{role.label}
{role.description}
{palette[role.key]}
))}
); const renderTypographySection = () => (

Typography

{designFonts.map((f) => ( ))}
); const renderFeaturesSection = () => (

Design Features

{designFeatures.map((f) => { const isSelected = features.includes(f.key); return (
); })}
); return (
setIsDialogOpen(!isDialogOpen)}>
Design Palette & Features Customize your color palette, typography, and design features. These preferences will guide the AI in creating designs that match your style.
{/* Navigation Tabs */}
{[ { key: 'colors', label: 'Colors', icon: 'i-ph:palette' }, { key: 'typography', label: 'Typography', icon: 'i-ph:text-aa' }, { key: 'features', label: 'Features', icon: 'i-ph:magic-wand' }, ].map((tab) => ( ))}
{/* Content Area */}
{activeSection === 'colors' && renderColorSection()} {activeSection === 'typography' && renderTypographySection()} {activeSection === 'features' && renderFeaturesSection()}
{/* Action Buttons */}
{Object.keys(palette).length} colors • {font.length} fonts • {features.length} features
); };