/** * Palette editor modal. * * Opened from a palette card (or the Custom card) in a palette gallery. Seeds * an editable copy of the palette's colours, laid out as a grid of ColorCards * (at least three per row on desktop) so the admin can tweak any role — the * swatch reset returns a card to the palette's original value. Apply commits * the edited set to the working settings tree via the parent's onApply. */ import { useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { Modal, Button } from '@wordpress/components'; import ColorCard from './color-card'; interface RoleField { key: string; label: string; description?: string; } interface PaletteModalProps { title: string; initialColors: Record< string, string >; fields: RoleField[]; onApply: ( colors: Record< string, string > ) => void; onClose: () => void; } export default function PaletteModal( { title, initialColors, fields, onApply, onClose, }: PaletteModalProps ) { const [ colors, setColors ] = useState< Record< string, string > >( initialColors ); // Only render roles the palette actually defines a colour for, in schema // order. const rows = fields.filter( ( field ) => undefined !== initialColors[ field.key ] ); return (

{ __( 'Adjust any colour, then apply. Each swatch shows the role it fills across your site.', 'aureon' ) }

{ rows.map( ( field ) => ( setColors( ( prev ) => ( { ...prev, [ field.key ]: hex, } ) ) } /> ) ) }
); }