@wordpress/block-editor 8.0.6 → 8.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/block-tools/block-selection-button.js +7 -1
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +6 -69
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/colors-gradients/use-common-single-multiple-selects.js +21 -0
- package/build/components/colors-gradients/use-common-single-multiple-selects.js.map +1 -0
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +98 -0
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -0
- package/build/hooks/border-color.js +11 -12
- package/build/hooks/border-color.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +7 -1
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +5 -71
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/colors-gradients/use-common-single-multiple-selects.js +11 -0
- package/build-module/components/colors-gradients/use-common-single-multiple-selects.js.map +1 -0
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +85 -0
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -0
- package/build-module/hooks/border-color.js +10 -12
- package/build-module/hooks/border-color.js.map +1 -1
- package/package.json +3 -3
- package/src/components/block-tools/block-selection-button.js +5 -1
- package/src/components/colors-gradients/panel-color-gradient-settings.js +4 -92
- package/src/components/colors-gradients/use-common-single-multiple-selects.js +11 -0
- package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +107 -0
- package/src/hooks/border-color.js +14 -9
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useMemo } from '@wordpress/element';
|
|
5
|
+
import { _x } from '@wordpress/i18n';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import useSetting from '../use-setting';
|
|
11
|
+
import useCommonSingleMultipleSelects from './use-common-single-multiple-selects';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves color and gradient related settings.
|
|
15
|
+
*
|
|
16
|
+
* The arrays for colors and gradients are made up of color palettes from each
|
|
17
|
+
* origin i.e. "Core", "Theme", and "User".
|
|
18
|
+
*
|
|
19
|
+
* @return {Object} Color and gradient related settings.
|
|
20
|
+
*/
|
|
21
|
+
export default function useMultipleOriginColorsAndGradients() {
|
|
22
|
+
const colorGradientSettings = useCommonSingleMultipleSelects();
|
|
23
|
+
const customColors = useSetting( 'color.palette.custom' );
|
|
24
|
+
const themeColors = useSetting( 'color.palette.theme' );
|
|
25
|
+
const defaultColors = useSetting( 'color.palette.default' );
|
|
26
|
+
const shouldDisplayDefaultColors = useSetting( 'color.defaultPalette' );
|
|
27
|
+
|
|
28
|
+
colorGradientSettings.colors = useMemo( () => {
|
|
29
|
+
const result = [];
|
|
30
|
+
if ( themeColors && themeColors.length ) {
|
|
31
|
+
result.push( {
|
|
32
|
+
name: _x(
|
|
33
|
+
'Theme',
|
|
34
|
+
'Indicates this palette comes from the theme.'
|
|
35
|
+
),
|
|
36
|
+
colors: themeColors,
|
|
37
|
+
} );
|
|
38
|
+
}
|
|
39
|
+
if (
|
|
40
|
+
shouldDisplayDefaultColors &&
|
|
41
|
+
defaultColors &&
|
|
42
|
+
defaultColors.length
|
|
43
|
+
) {
|
|
44
|
+
result.push( {
|
|
45
|
+
name: _x(
|
|
46
|
+
'Default',
|
|
47
|
+
'Indicates this palette comes from WordPress.'
|
|
48
|
+
),
|
|
49
|
+
colors: defaultColors,
|
|
50
|
+
} );
|
|
51
|
+
}
|
|
52
|
+
if ( customColors && customColors.length ) {
|
|
53
|
+
result.push( {
|
|
54
|
+
name: _x(
|
|
55
|
+
'Custom',
|
|
56
|
+
'Indicates this palette comes from the theme.'
|
|
57
|
+
),
|
|
58
|
+
colors: customColors,
|
|
59
|
+
} );
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}, [ defaultColors, themeColors, customColors ] );
|
|
63
|
+
|
|
64
|
+
const customGradients = useSetting( 'color.gradients.custom' );
|
|
65
|
+
const themeGradients = useSetting( 'color.gradients.theme' );
|
|
66
|
+
const defaultGradients = useSetting( 'color.gradients.default' );
|
|
67
|
+
const shouldDisplayDefaultGradients = useSetting(
|
|
68
|
+
'color.defaultGradients'
|
|
69
|
+
);
|
|
70
|
+
colorGradientSettings.gradients = useMemo( () => {
|
|
71
|
+
const result = [];
|
|
72
|
+
if ( themeGradients && themeGradients.length ) {
|
|
73
|
+
result.push( {
|
|
74
|
+
name: _x(
|
|
75
|
+
'Theme',
|
|
76
|
+
'Indicates this palette comes from the theme.'
|
|
77
|
+
),
|
|
78
|
+
gradients: themeGradients,
|
|
79
|
+
} );
|
|
80
|
+
}
|
|
81
|
+
if (
|
|
82
|
+
shouldDisplayDefaultGradients &&
|
|
83
|
+
defaultGradients &&
|
|
84
|
+
defaultGradients.length
|
|
85
|
+
) {
|
|
86
|
+
result.push( {
|
|
87
|
+
name: _x(
|
|
88
|
+
'Default',
|
|
89
|
+
'Indicates this palette comes from WordPress.'
|
|
90
|
+
),
|
|
91
|
+
gradients: defaultGradients,
|
|
92
|
+
} );
|
|
93
|
+
}
|
|
94
|
+
if ( customGradients && customGradients.length ) {
|
|
95
|
+
result.push( {
|
|
96
|
+
name: _x(
|
|
97
|
+
'Custom',
|
|
98
|
+
'Indicates this palette is created by the user.'
|
|
99
|
+
),
|
|
100
|
+
gradients: customGradients,
|
|
101
|
+
} );
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}, [ customGradients, themeGradients, defaultGradients ] );
|
|
105
|
+
|
|
106
|
+
return colorGradientSettings;
|
|
107
|
+
}
|
|
@@ -15,6 +15,7 @@ import { useState } from '@wordpress/element';
|
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
17
|
import ColorGradientControl from '../components/colors-gradients/control';
|
|
18
|
+
import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
|
|
18
19
|
import {
|
|
19
20
|
getColorClassName,
|
|
20
21
|
getColorObjectByColorValue,
|
|
@@ -46,13 +47,15 @@ export function BorderColorEdit( props ) {
|
|
|
46
47
|
attributes: { borderColor, style },
|
|
47
48
|
setAttributes,
|
|
48
49
|
} = props;
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
50
|
+
const colorGradientSettings = useMultipleOriginColorsAndGradients();
|
|
51
|
+
const availableColors = colorGradientSettings.colors.reduce(
|
|
52
|
+
( colors, origin ) => colors.concat( origin.colors ),
|
|
53
|
+
[]
|
|
54
|
+
);
|
|
52
55
|
const [ colorValue, setColorValue ] = useState(
|
|
53
56
|
() =>
|
|
54
57
|
getColorObjectByAttributeValues(
|
|
55
|
-
|
|
58
|
+
availableColors,
|
|
56
59
|
borderColor,
|
|
57
60
|
style?.border?.color
|
|
58
61
|
)?.color
|
|
@@ -61,7 +64,10 @@ export function BorderColorEdit( props ) {
|
|
|
61
64
|
const onChangeColor = ( value ) => {
|
|
62
65
|
setColorValue( value );
|
|
63
66
|
|
|
64
|
-
const colorObject = getColorObjectByColorValue(
|
|
67
|
+
const colorObject = getColorObjectByColorValue(
|
|
68
|
+
availableColors,
|
|
69
|
+
value
|
|
70
|
+
);
|
|
65
71
|
const newStyle = {
|
|
66
72
|
...style,
|
|
67
73
|
border: {
|
|
@@ -83,11 +89,10 @@ export function BorderColorEdit( props ) {
|
|
|
83
89
|
<ColorGradientControl
|
|
84
90
|
label={ __( 'Color' ) }
|
|
85
91
|
colorValue={ colorValue }
|
|
86
|
-
colors={ colors }
|
|
87
|
-
gradients={ undefined }
|
|
88
|
-
disableCustomColors={ disableCustomColors }
|
|
89
|
-
disableCustomGradients={ disableCustomGradients }
|
|
90
92
|
onColorChange={ onChangeColor }
|
|
93
|
+
clearable={ false }
|
|
94
|
+
__experimentalHasMultipleOrigins
|
|
95
|
+
{ ...colorGradientSettings }
|
|
91
96
|
/>
|
|
92
97
|
);
|
|
93
98
|
}
|