import React, { useState, useEffect } from "react"; import { SketchPicker, ColorResult } from "react-color"; import { BrandingConfig, defaultBrandingConfig, popularFonts } from "../src/config/branding.config"; interface CustomizationPanelProps { active?: boolean; } export const CustomizationPanel: React.FC = ({ active }) => { const [config, setConfig] = useState(defaultBrandingConfig); const [showPrimaryPicker, setShowPrimaryPicker] = useState(false); const [showSecondaryPicker, setShowSecondaryPicker] = useState(false); const [showBackgroundPicker, setShowBackgroundPicker] = useState(false); useEffect(() => { // Send initial config to preview window.postMessage( { type: "CUSTOMIZATION_UPDATE", config: config, }, "*" ); }, [config]); const handleColorChange = (colorType: "primary" | "secondary" | "background") => ( color: ColorResult ) => { const newConfig = { ...config, colors: { ...config.colors, [colorType]: color.hex, }, }; setConfig(newConfig); window.postMessage( { type: "CUSTOMIZATION_UPDATE", config: newConfig, }, "*" ); }; const handleFontChange = (font: string) => { const newConfig = { ...config, font: { family: font, }, }; setConfig(newConfig); window.postMessage( { type: "CUSTOMIZATION_UPDATE", config: newConfig, }, "*" ); }; if (!active) return null; return (

Customize Branding

{/* Font Selector */}
{/* Primary Color Picker */}
{ setShowPrimaryPicker(!showPrimaryPicker); setShowSecondaryPicker(false); setShowBackgroundPicker(false); }} style={{ width: "100%", height: "40px", backgroundColor: config.colors.primary, border: "1px solid #ddd", borderRadius: "4px", cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center", color: "#fff", fontWeight: "bold", }} > {config.colors.primary}
{showPrimaryPicker && (
)}
{/* Secondary Color Picker */}
{ setShowSecondaryPicker(!showSecondaryPicker); setShowPrimaryPicker(false); setShowBackgroundPicker(false); }} style={{ width: "100%", height: "40px", backgroundColor: config.colors.secondary, border: "1px solid #ddd", borderRadius: "4px", cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center", color: "#fff", fontWeight: "bold", }} > {config.colors.secondary}
{showSecondaryPicker && (
)}
{/* Background Color Picker */}
{ setShowBackgroundPicker(!showBackgroundPicker); setShowPrimaryPicker(false); setShowSecondaryPicker(false); }} style={{ width: "100%", height: "40px", backgroundColor: config.colors.background, border: "1px solid #ddd", borderRadius: "4px", cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center", color: config.colors.background === "#F5F5F5" ? "#333" : "#fff", fontWeight: "bold", }} > {config.colors.background}
{showBackgroundPicker && (
)}
); };