/**
 * External dependencies.
 */
import { memo } from '@wordpress/element';
import { __ } from '@wordpress/i18n';

/**
 * Internal dependencies.
 */
import InspectorColor from '@spectra-components/inspector-color';



/**
 * Element Sub-settings: Color settings for label.
 *
 * @param {Object} props The element props.
 * @since 2.0.0
 * @return {Element} The rendered block settings.
 */
const ColorSettings = memo( ( props ) => {

	// Destructure the required props.
	const {
		clientId,
		setAttributes,
		attributes: {
			textColor,
			backgroundColor,
		},
	} = props;

	return(
		<InspectorColor
			settings={ [
				{
					colorValue: textColor,
					label: __( 'Text', 'spectra-pro' ),
					onColorChange: ( value ) => setAttributes( { textColor: value } ),
					resetAllFilter: () => setAttributes( { textColor: undefined } ),
				},
				{
					colorValue: backgroundColor,
					label: __( 'Background Color', 'spectra-pro' ),
					onColorChange: ( value ) => setAttributes( { backgroundColor: value } ),
					resetAllFilter: () => setAttributes( { backgroundColor: undefined } ),
				},
			] }
			panelId={ clientId }
		/>
	);
} );

/**
 * The Editor settings for this block.
 *
 * @param {Object} props The element props.
 * @since 2.0.0
 * @return {Element} The rendered settings.
 */
const Settings = ( props ) => (
	<>
		<ColorSettings { ...{ ...props } } />
	</>
);

export default memo( Settings );