/** * WordPress dependencies */ import { BaseControl } from '@safe-wordpress/components'; import { useInstanceId } from '@safe-wordpress/compose'; import { _x } from '@safe-wordpress/i18n'; /** * External dependencies */ import { css } from '@nelio/popups/css'; import type { Color } from '@nelio/popups/types'; /** * Internal dependencies */ import { ColorIndicator } from './color-indicator'; import { ColorPicker } from './color-picker'; export type ColorControlProps = { readonly label?: string; readonly setLabel?: string; readonly color?: Color; readonly onChange: ( color: Color ) => void; }; export const ColorControl = ( props: ColorControlProps ): JSX.Element => { const { label, setLabel, color, onChange } = props; const instanceId = useInstanceId( ColorControl ); if ( ! label ) { return (
{ color && }
); } return ( } >
); }; const Label = ( { label, color, }: { label: string; color?: Color; } ): JSX.Element => { if ( ! color ) { return { label }; } return (
{ label }
); }; // ====== // STYLES // ====== const WRAPPER_STYLE = css( { display: 'flex', flexDirection: 'row', justifyContent: 'flex-end', } );