/** * Color field โ€” compact label + swatch/hex control for embedding a single * color inside a mixed-field card (e.g. Misc Text's Text Color). Reuses * ColorCard's swatch/picker styling so it stays visually consistent without * the full card chrome (ColorCard owns its own reset button + border). */ import { BaseControl, Dropdown, Button, ColorPicker, } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; interface ColorFieldProps { label: string; value: string; onChange: ( value: string ) => void; /** * Inherited/default color shown when `value` is empty โ€” the field still * stores '' (so it keeps following whatever it inherits), but the swatch, * readout, and picker start from this resolved color instead of looking * blank. Marked with a leading dot so it reads as a default, not a set value. */ fallback?: string; /** Hide the visible label (still used for the toggle's aria-label). */ hideLabel?: boolean; } export default function ColorField( { label, value, onChange, fallback = '', hideLabel = false, }: ColorFieldProps ) { const shown = value || fallback; const isInherited = ! value && !! fallback; return ( { ! hideLabel && ( { label } ) } ( ) } renderContent={ () => (
) } />
); }