'use client'; import { useState } from 'react'; import { ColorPicker } from '@/components/color/ColorPicker'; import { PaletteGrid } from '@/components/color/PaletteGrid'; import { ExportMenu } from '@/components/tools/ExportMenu'; import { Button } from '@/components/ui/button'; import { Select } from '@/components/ui/select'; import { useGeneratePalette } from '@/lib/api/queries'; import { Loader2, Palette } from 'lucide-react'; import { toast } from 'sonner'; type HarmonyType = | 'monochromatic' | 'analogous' | 'complementary' | 'split-complementary' | 'triadic' | 'tetradic'; export default function HarmonyPage() { const [baseColor, setBaseColor] = useState('#ff0099'); const [harmonyType, setHarmonyType] = useState('complementary'); const [palette, setPalette] = useState([]); const paletteMutation = useGeneratePalette(); const generateHarmony = async () => { try { const result = await paletteMutation.mutateAsync({ base: baseColor, scheme: harmonyType, }); // Combine primary and secondary colors into flat array const colors = [result.palette.primary, ...result.palette.secondary]; setPalette(colors); toast.success(`Generated ${harmonyType} harmony palette`); } catch (error) { toast.error('Failed to generate harmony palette'); console.error(error); } }; const harmonyDescriptions: Record = { monochromatic: 'Single color with variations', analogous: 'Colors adjacent on the color wheel (±30°)', complementary: 'Colors opposite on the color wheel (180°)', 'split-complementary': 'Base color + two colors flanking its complement', triadic: 'Three colors evenly spaced on the color wheel (120°)', tetradic: 'Four colors evenly spaced on the color wheel (90°)', }; return (

Harmony Palette Generator

Create color harmonies based on color theory principles

{/* Controls */}

Base Color

Harmony Type

{harmonyDescriptions[harmonyType]}

{/* Results */}
{palette.length > 0 && ( <>

Generated Palette ({palette.length} colors)

)} {palette.length === 0 && (

Select a harmony type and click Generate to create your palette

)}
); }