PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.3.2
Block Animations, Motion & Scroll Effects – Ghost Kit v3.3.2
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / gutenberg / components / color-palette / index.js

index.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.3.2, at gutenberg/components/color-palette/index.js

54 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients } from '@wordpress/block-editor';
2 import { ColorPalette as WPColorPalette } from '@wordpress/components';
3 import { useSelect } from '@wordpress/data';
4
5 import ApplyFilters from '../apply-filters';
6
7 function useColors() {
8 // New way to get colors and gradients.
9 if (
10 useMultipleOriginColorsAndGradients &&
11 useMultipleOriginColorsAndGradients()
12 ) {
13 return useMultipleOriginColorsAndGradients().colors;
14 }
15
16 // Old way.
17 const { themeColors } = useSelect((select) => {
18 const settings = select('core/block-editor').getSettings();
19
20 return {
21 themeColors: settings.colors,
22 };
23 });
24
25 const colors = [];
26
27 if (themeColors && themeColors.length) {
28 colors.push({ name: 'Theme', colors: themeColors });
29 }
30
31 return colors;
32 }
33
34 export default function ColorPalette(props) {
35 const { value, alpha = false, palette = true, onChange = () => {} } = props;
36
37 const colors = palette ? useColors() : [];
38
39 return (
40 <ApplyFilters name="ghostkit.component.color-palette" props={props}>
41 <WPColorPalette
42 colors={colors}
43 value={value}
44 enableAlpha={alpha}
45 onChange={(val) => {
46 onChange(val);
47 }}
48 __experimentalHasMultipleOrigins
49 __experimentalIsRenderedInSidebar
50 />
51 </ApplyFilters>
52 );
53 }
54