Add color setting component
[MAILPOET-2604]
This commit is contained in:
committed by
Veljko V
parent
48bd3aed4a
commit
b87ced1eb6
50
assets/js/src/form_editor/components/color_settings.tsx
Normal file
50
assets/js/src/form_editor/components/color_settings.tsx
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import {
|
||||||
|
ColorIndicator,
|
||||||
|
ColorPalette,
|
||||||
|
} from '@wordpress/components';
|
||||||
|
import { useSelect } from '@wordpress/data';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
name: string,
|
||||||
|
value: string|undefined
|
||||||
|
onChange: (value: string|undefined) => any
|
||||||
|
}
|
||||||
|
|
||||||
|
const ColorSettings = ({
|
||||||
|
name,
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
}: Props) => {
|
||||||
|
const { settingsColors } = useSelect(
|
||||||
|
(select) => {
|
||||||
|
const { getSettings } = select('core/block-editor');
|
||||||
|
return {
|
||||||
|
settingsColors: getSettings().colors,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h3 className="mailpoet-styles-settings-heading">
|
||||||
|
{name}
|
||||||
|
{
|
||||||
|
value !== undefined
|
||||||
|
&& (
|
||||||
|
<ColorIndicator
|
||||||
|
colorValue={value}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</h3>
|
||||||
|
<ColorPalette
|
||||||
|
value={value}
|
||||||
|
onChange={onChange}
|
||||||
|
colors={settingsColors}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ColorSettings;
|
Reference in New Issue
Block a user