@wordpress/edit-site 4.8.0 → 4.11.0
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/CHANGELOG.md +6 -0
- package/build/components/add-new-template/add-custom-generic-template-modal.js +84 -0
- package/build/components/add-new-template/add-custom-generic-template-modal.js.map +1 -0
- package/build/components/add-new-template/add-custom-template-modal.js +204 -0
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -0
- package/build/components/add-new-template/new-template.js +91 -33
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/add-new-template/utils.js +532 -0
- package/build/components/add-new-template/utils.js.map +1 -0
- package/build/components/block-editor/index.js +1 -3
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/code-editor/index.js +17 -4
- package/build/components/code-editor/index.js.map +1 -1
- package/build/components/editor/index.js +16 -0
- package/build/components/editor/index.js.map +1 -1
- package/build/components/error-boundary/index.js +6 -0
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/global-styles/context-menu.js +6 -3
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +185 -19
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +4 -2
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/hooks.js +11 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/palette.js +2 -1
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +4 -1
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-button-color.js +80 -0
- package/build/components/global-styles/screen-button-color.js.map +1 -0
- package/build/components/global-styles/screen-color-palette.js +13 -17
- package/build/components/global-styles/screen-color-palette.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +56 -8
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +48 -14
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-root.js +4 -2
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-typography-element.js +4 -0
- package/build/components/global-styles/screen-typography-element.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +9 -1
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/ui.js +11 -0
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +282 -35
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +35 -2
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/header/index.js +29 -10
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/more-menu/site-export.js +4 -1
- package/build/components/header/more-menu/site-export.js.map +1 -1
- package/build/components/header/undo-redo/redo.js +13 -4
- package/build/components/header/undo-redo/redo.js.map +1 -1
- package/build/components/header/undo-redo/undo.js +13 -4
- package/build/components/header/undo-redo/undo.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +17 -0
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +1 -3
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/sidebar/template-card/index.js +19 -7
- package/build/components/sidebar/template-card/index.js.map +1 -1
- package/build/components/sidebar/template-card/template-actions.js +64 -0
- package/build/components/sidebar/template-card/template-actions.js.map +1 -0
- package/build/components/template-details/edit-template-title.js +11 -3
- package/build/components/template-details/edit-template-title.js.map +1 -1
- package/build/components/template-details/index.js +1 -20
- package/build/components/template-details/index.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/template-part-edit.js +86 -0
- package/build/hooks/template-part-edit.js.map +1 -0
- package/build/store/selectors.js +4 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-generic-template-modal.js +77 -0
- package/build-module/components/add-new-template/add-custom-generic-template-modal.js.map +1 -0
- package/build-module/components/add-new-template/add-custom-template-modal.js +189 -0
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -0
- package/build-module/components/add-new-template/new-template.js +90 -34
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +503 -0
- package/build-module/components/add-new-template/utils.js.map +1 -0
- package/build-module/components/block-editor/index.js +1 -2
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/code-editor/index.js +18 -5
- package/build-module/components/code-editor/index.js.map +1 -1
- package/build-module/components/editor/index.js +16 -0
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +5 -0
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +6 -3
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +185 -20
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +4 -2
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +11 -2
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/palette.js +2 -1
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +4 -1
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-button-color.js +67 -0
- package/build-module/components/global-styles/screen-button-color.js.map +1 -0
- package/build-module/components/global-styles/screen-color-palette.js +14 -19
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +57 -9
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +47 -14
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +4 -2
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-typography-element.js +4 -0
- package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +10 -2
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/ui.js +10 -0
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +280 -42
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +34 -3
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/header/index.js +31 -11
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/more-menu/site-export.js +4 -1
- package/build-module/components/header/more-menu/site-export.js.map +1 -1
- package/build-module/components/header/undo-redo/redo.js +9 -3
- package/build-module/components/header/undo-redo/redo.js.map +1 -1
- package/build-module/components/header/undo-redo/undo.js +9 -3
- package/build-module/components/header/undo-redo/undo.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +17 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +1 -2
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/sidebar/template-card/index.js +18 -7
- package/build-module/components/sidebar/template-card/index.js.map +1 -1
- package/build-module/components/sidebar/template-card/template-actions.js +49 -0
- package/build-module/components/sidebar/template-card/template-actions.js.map +1 -0
- package/build-module/components/template-details/edit-template-title.js +12 -3
- package/build-module/components/template-details/edit-template-title.js.map +1 -1
- package/build-module/components/template-details/index.js +2 -21
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/template-part-edit.js +67 -0
- package/build-module/hooks/template-part-edit.js.map +1 -0
- package/build-module/store/selectors.js +5 -2
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +198 -49
- package/build-style/style.css +198 -49
- package/package.json +29 -29
- package/src/components/add-new-template/add-custom-generic-template-modal.js +97 -0
- package/src/components/add-new-template/add-custom-template-modal.js +247 -0
- package/src/components/add-new-template/new-template.js +158 -70
- package/src/components/add-new-template/style.scss +149 -0
- package/src/components/add-new-template/utils.js +538 -0
- package/src/components/block-editor/index.js +0 -2
- package/src/components/code-editor/index.js +15 -5
- package/src/components/editor/index.js +11 -0
- package/src/components/error-boundary/index.js +5 -0
- package/src/components/global-styles/context-menu.js +3 -0
- package/src/components/global-styles/dimensions-panel.js +209 -21
- package/src/components/global-styles/global-styles-provider.js +8 -9
- package/src/components/global-styles/hooks.js +18 -0
- package/src/components/global-styles/palette.js +4 -1
- package/src/components/global-styles/screen-block-list.js +10 -1
- package/src/components/global-styles/screen-button-color.js +102 -0
- package/src/components/global-styles/screen-color-palette.js +25 -27
- package/src/components/global-styles/screen-colors.js +58 -7
- package/src/components/global-styles/screen-link-color.js +65 -23
- package/src/components/global-styles/screen-root.js +8 -2
- package/src/components/global-styles/screen-typography-element.js +4 -0
- package/src/components/global-styles/screen-typography.js +17 -2
- package/src/components/global-styles/style.scss +14 -8
- package/src/components/global-styles/test/use-global-styles-output.js +313 -16
- package/src/components/global-styles/ui.js +13 -0
- package/src/components/global-styles/use-global-styles-output.js +344 -38
- package/src/components/global-styles/utils.js +36 -2
- package/src/components/header/index.js +42 -17
- package/src/components/header/more-menu/site-export.js +3 -0
- package/src/components/header/style.scss +58 -8
- package/src/components/header/undo-redo/redo.js +6 -1
- package/src/components/header/undo-redo/undo.js +6 -1
- package/src/components/keyboard-shortcut-help-modal/config.js +12 -0
- package/src/components/keyboard-shortcut-help-modal/index.js +1 -2
- package/src/components/keyboard-shortcut-help-modal/style.scss +0 -5
- package/src/components/list/style.scss +0 -8
- package/src/components/sidebar/style.scss +4 -0
- package/src/components/sidebar/template-card/index.js +15 -6
- package/src/components/sidebar/template-card/style.scss +49 -35
- package/src/components/sidebar/template-card/template-actions.js +43 -0
- package/src/components/template-details/edit-template-title.js +10 -2
- package/src/components/template-details/index.js +4 -21
- package/src/components/test/error-boundary.js +38 -0
- package/src/hooks/index.js +1 -0
- package/src/hooks/template-part-edit.js +82 -0
- package/src/store/selectors.js +11 -5
- package/src/style.scss +0 -1
- package/build/components/edit-template-part-menu-button/index.js +0 -90
- package/build/components/edit-template-part-menu-button/index.js.map +0 -1
- package/build-module/components/edit-template-part-menu-button/index.js +0 -72
- package/build-module/components/edit-template-part-menu-button/index.js.map +0 -1
- package/src/components/edit-template-part-menu-button/index.js +0 -82
|
@@ -6,10 +6,13 @@ import {
|
|
|
6
6
|
__experimentalToolsPanel as ToolsPanel,
|
|
7
7
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
8
8
|
__experimentalBoxControl as BoxControl,
|
|
9
|
+
__experimentalHStack as HStack,
|
|
9
10
|
__experimentalUnitControl as UnitControl,
|
|
10
11
|
__experimentalUseCustomUnits as useCustomUnits,
|
|
12
|
+
__experimentalView as View,
|
|
11
13
|
} from '@wordpress/components';
|
|
12
14
|
import { __experimentalUseCustomSides as useCustomSides } from '@wordpress/block-editor';
|
|
15
|
+
import { Icon, positionCenter, stretchWide } from '@wordpress/icons';
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* Internal dependencies
|
|
@@ -19,11 +22,27 @@ import { getSupportedGlobalStylesPanels, useSetting, useStyle } from './hooks';
|
|
|
19
22
|
const AXIAL_SIDES = [ 'horizontal', 'vertical' ];
|
|
20
23
|
|
|
21
24
|
export function useHasDimensionsPanel( name ) {
|
|
25
|
+
const hasContentSize = useHasContentSize( name );
|
|
26
|
+
const hasWideSize = useHasWideSize( name );
|
|
22
27
|
const hasPadding = useHasPadding( name );
|
|
23
28
|
const hasMargin = useHasMargin( name );
|
|
24
29
|
const hasGap = useHasGap( name );
|
|
25
30
|
|
|
26
|
-
return hasPadding || hasMargin || hasGap;
|
|
31
|
+
return hasContentSize || hasWideSize || hasPadding || hasMargin || hasGap;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function useHasContentSize( name ) {
|
|
35
|
+
const supports = getSupportedGlobalStylesPanels( name );
|
|
36
|
+
const [ settings ] = useSetting( 'layout.contentSize', name );
|
|
37
|
+
|
|
38
|
+
return settings && supports.includes( 'contentSize' );
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function useHasWideSize( name ) {
|
|
42
|
+
const supports = getSupportedGlobalStylesPanels( name );
|
|
43
|
+
const [ settings ] = useSetting( 'layout.wideSize', name );
|
|
44
|
+
|
|
45
|
+
return settings && supports.includes( 'wideSize' );
|
|
27
46
|
}
|
|
28
47
|
|
|
29
48
|
function useHasPadding( name ) {
|
|
@@ -43,13 +62,8 @@ function useHasMargin( name ) {
|
|
|
43
62
|
function useHasGap( name ) {
|
|
44
63
|
const supports = getSupportedGlobalStylesPanels( name );
|
|
45
64
|
const [ settings ] = useSetting( 'spacing.blockGap', name );
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// See: https://github.com/WordPress/gutenberg/pull/39845.
|
|
49
|
-
// We can revert this condition when they're working again.
|
|
50
|
-
return !! name
|
|
51
|
-
? false
|
|
52
|
-
: settings && supports.includes( '--wp--style--block-gap' );
|
|
65
|
+
|
|
66
|
+
return settings && supports.includes( 'blockGap' );
|
|
53
67
|
}
|
|
54
68
|
|
|
55
69
|
function filterValuesBySides( values, sides ) {
|
|
@@ -90,20 +104,50 @@ function splitStyleValue( value ) {
|
|
|
90
104
|
return value;
|
|
91
105
|
}
|
|
92
106
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
// Props for managing `layout.contentSize`.
|
|
108
|
+
function useContentSizeProps( name ) {
|
|
109
|
+
const [ contentSizeValue, setContentSizeValue ] = useSetting(
|
|
110
|
+
'layout.contentSize',
|
|
111
|
+
name
|
|
112
|
+
);
|
|
113
|
+
const [ userSetContentSizeValue ] = useSetting(
|
|
114
|
+
'layout.contentSize',
|
|
115
|
+
name,
|
|
116
|
+
'user'
|
|
117
|
+
);
|
|
118
|
+
const hasUserSetContentSizeValue = () => !! userSetContentSizeValue;
|
|
119
|
+
const resetContentSizeValue = () => setContentSizeValue( '' );
|
|
120
|
+
return {
|
|
121
|
+
contentSizeValue,
|
|
122
|
+
setContentSizeValue,
|
|
123
|
+
hasUserSetContentSizeValue,
|
|
124
|
+
resetContentSizeValue,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
106
127
|
|
|
128
|
+
// Props for managing `layout.wideSize`.
|
|
129
|
+
function useWideSizeProps( name ) {
|
|
130
|
+
const [ wideSizeValue, setWideSizeValue ] = useSetting(
|
|
131
|
+
'layout.wideSize',
|
|
132
|
+
name
|
|
133
|
+
);
|
|
134
|
+
const [ userSetWideSizeValue ] = useSetting(
|
|
135
|
+
'layout.wideSize',
|
|
136
|
+
name,
|
|
137
|
+
'user'
|
|
138
|
+
);
|
|
139
|
+
const hasUserSetWideSizeValue = () => !! userSetWideSizeValue;
|
|
140
|
+
const resetWideSizeValue = () => setWideSizeValue( '' );
|
|
141
|
+
return {
|
|
142
|
+
wideSizeValue,
|
|
143
|
+
setWideSizeValue,
|
|
144
|
+
hasUserSetWideSizeValue,
|
|
145
|
+
resetWideSizeValue,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Props for managing `spacing.padding`.
|
|
150
|
+
function usePaddingProps( name ) {
|
|
107
151
|
const [ rawPadding, setRawPadding ] = useStyle( 'spacing.padding', name );
|
|
108
152
|
const paddingValues = splitStyleValue( rawPadding );
|
|
109
153
|
const paddingSides = useCustomSides( name, 'padding' );
|
|
@@ -119,6 +163,18 @@ export default function DimensionsPanel( { name } ) {
|
|
|
119
163
|
const hasPaddingValue = () =>
|
|
120
164
|
!! paddingValues && Object.keys( paddingValues ).length;
|
|
121
165
|
|
|
166
|
+
return {
|
|
167
|
+
paddingValues,
|
|
168
|
+
paddingSides,
|
|
169
|
+
isAxialPadding,
|
|
170
|
+
setPaddingValues,
|
|
171
|
+
resetPaddingValue,
|
|
172
|
+
hasPaddingValue,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Props for managing `spacing.margin`.
|
|
177
|
+
function useMarginProps( name ) {
|
|
122
178
|
const [ rawMargin, setRawMargin ] = useStyle( 'spacing.margin', name );
|
|
123
179
|
const marginValues = splitStyleValue( rawMargin );
|
|
124
180
|
const marginSides = useCustomSides( name, 'margin' );
|
|
@@ -134,18 +190,150 @@ export default function DimensionsPanel( { name } ) {
|
|
|
134
190
|
const hasMarginValue = () =>
|
|
135
191
|
!! marginValues && Object.keys( marginValues ).length;
|
|
136
192
|
|
|
193
|
+
return {
|
|
194
|
+
marginValues,
|
|
195
|
+
marginSides,
|
|
196
|
+
isAxialMargin,
|
|
197
|
+
setMarginValues,
|
|
198
|
+
resetMarginValue,
|
|
199
|
+
hasMarginValue,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Props for managing `spacing.blockGap`.
|
|
204
|
+
function useBlockGapProps( name ) {
|
|
137
205
|
const [ gapValue, setGapValue ] = useStyle( 'spacing.blockGap', name );
|
|
138
206
|
const resetGapValue = () => setGapValue( undefined );
|
|
139
207
|
const hasGapValue = () => !! gapValue;
|
|
208
|
+
return {
|
|
209
|
+
gapValue,
|
|
210
|
+
setGapValue,
|
|
211
|
+
resetGapValue,
|
|
212
|
+
hasGapValue,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export default function DimensionsPanel( { name } ) {
|
|
217
|
+
const showContentSizeControl = useHasContentSize( name );
|
|
218
|
+
const showWideSizeControl = useHasWideSize( name );
|
|
219
|
+
const showPaddingControl = useHasPadding( name );
|
|
220
|
+
const showMarginControl = useHasMargin( name );
|
|
221
|
+
const showGapControl = useHasGap( name );
|
|
222
|
+
const units = useCustomUnits( {
|
|
223
|
+
availableUnits: useSetting( 'spacing.units', name )[ 0 ] || [
|
|
224
|
+
'%',
|
|
225
|
+
'px',
|
|
226
|
+
'em',
|
|
227
|
+
'rem',
|
|
228
|
+
'vw',
|
|
229
|
+
],
|
|
230
|
+
} );
|
|
231
|
+
|
|
232
|
+
// Props for managing `layout.contentSize`.
|
|
233
|
+
const {
|
|
234
|
+
contentSizeValue,
|
|
235
|
+
setContentSizeValue,
|
|
236
|
+
hasUserSetContentSizeValue,
|
|
237
|
+
resetContentSizeValue,
|
|
238
|
+
} = useContentSizeProps( name );
|
|
239
|
+
|
|
240
|
+
// Props for managing `layout.wideSize`.
|
|
241
|
+
const {
|
|
242
|
+
wideSizeValue,
|
|
243
|
+
setWideSizeValue,
|
|
244
|
+
hasUserSetWideSizeValue,
|
|
245
|
+
resetWideSizeValue,
|
|
246
|
+
} = useWideSizeProps( name );
|
|
247
|
+
|
|
248
|
+
// Props for managing `spacing.padding`.
|
|
249
|
+
const {
|
|
250
|
+
paddingValues,
|
|
251
|
+
paddingSides,
|
|
252
|
+
isAxialPadding,
|
|
253
|
+
setPaddingValues,
|
|
254
|
+
resetPaddingValue,
|
|
255
|
+
hasPaddingValue,
|
|
256
|
+
} = usePaddingProps( name );
|
|
257
|
+
|
|
258
|
+
// Props for managing `spacing.margin`.
|
|
259
|
+
const {
|
|
260
|
+
marginValues,
|
|
261
|
+
marginSides,
|
|
262
|
+
isAxialMargin,
|
|
263
|
+
setMarginValues,
|
|
264
|
+
resetMarginValue,
|
|
265
|
+
hasMarginValue,
|
|
266
|
+
} = useMarginProps( name );
|
|
267
|
+
|
|
268
|
+
// Props for managing `spacing.blockGap`.
|
|
269
|
+
const { gapValue, setGapValue, resetGapValue, hasGapValue } =
|
|
270
|
+
useBlockGapProps( name );
|
|
140
271
|
|
|
141
272
|
const resetAll = () => {
|
|
142
273
|
resetPaddingValue();
|
|
143
274
|
resetMarginValue();
|
|
144
275
|
resetGapValue();
|
|
276
|
+
resetContentSizeValue();
|
|
277
|
+
resetWideSizeValue();
|
|
145
278
|
};
|
|
146
279
|
|
|
147
280
|
return (
|
|
148
281
|
<ToolsPanel label={ __( 'Dimensions' ) } resetAll={ resetAll }>
|
|
282
|
+
{ ( showContentSizeControl || showWideSizeControl ) && (
|
|
283
|
+
<span className="span-columns">
|
|
284
|
+
{ __( 'Set the width of the main content area.' ) }
|
|
285
|
+
</span>
|
|
286
|
+
) }
|
|
287
|
+
{ showContentSizeControl && (
|
|
288
|
+
<ToolsPanelItem
|
|
289
|
+
className="single-column"
|
|
290
|
+
label={ __( 'Content size' ) }
|
|
291
|
+
hasValue={ hasUserSetContentSizeValue }
|
|
292
|
+
onDeselect={ resetContentSizeValue }
|
|
293
|
+
isShownByDefault={ true }
|
|
294
|
+
>
|
|
295
|
+
<HStack alignment="flex-end" justify="flex-start">
|
|
296
|
+
<UnitControl
|
|
297
|
+
label={ __( 'Content' ) }
|
|
298
|
+
labelPosition="top"
|
|
299
|
+
__unstableInputWidth="80px"
|
|
300
|
+
value={ contentSizeValue || '' }
|
|
301
|
+
onChange={ ( nextContentSize ) => {
|
|
302
|
+
setContentSizeValue( nextContentSize );
|
|
303
|
+
} }
|
|
304
|
+
units={ units }
|
|
305
|
+
/>
|
|
306
|
+
<View>
|
|
307
|
+
<Icon icon={ positionCenter } />
|
|
308
|
+
</View>
|
|
309
|
+
</HStack>
|
|
310
|
+
</ToolsPanelItem>
|
|
311
|
+
) }
|
|
312
|
+
{ showWideSizeControl && (
|
|
313
|
+
<ToolsPanelItem
|
|
314
|
+
className="single-column"
|
|
315
|
+
label={ __( 'Wide size' ) }
|
|
316
|
+
hasValue={ hasUserSetWideSizeValue }
|
|
317
|
+
onDeselect={ resetWideSizeValue }
|
|
318
|
+
isShownByDefault={ true }
|
|
319
|
+
>
|
|
320
|
+
<HStack alignment="flex-end" justify="flex-start">
|
|
321
|
+
<UnitControl
|
|
322
|
+
label={ __( 'Wide' ) }
|
|
323
|
+
labelPosition="top"
|
|
324
|
+
__unstableInputWidth="80px"
|
|
325
|
+
value={ wideSizeValue || '' }
|
|
326
|
+
onChange={ ( nextWideSize ) => {
|
|
327
|
+
setWideSizeValue( nextWideSize );
|
|
328
|
+
} }
|
|
329
|
+
units={ units }
|
|
330
|
+
/>
|
|
331
|
+
<View>
|
|
332
|
+
<Icon icon={ stretchWide } />
|
|
333
|
+
</View>
|
|
334
|
+
</HStack>
|
|
335
|
+
</ToolsPanelItem>
|
|
336
|
+
) }
|
|
149
337
|
{ showPaddingControl && (
|
|
150
338
|
<ToolsPanelItem
|
|
151
339
|
hasValue={ hasPaddingValue }
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
mergeWith,
|
|
6
|
-
pickBy,
|
|
7
|
-
isEmpty,
|
|
8
|
-
isObject,
|
|
9
|
-
identity,
|
|
10
|
-
mapValues,
|
|
11
|
-
} from 'lodash';
|
|
4
|
+
import { mergeWith, pickBy, isEmpty, mapValues } from 'lodash';
|
|
12
5
|
|
|
13
6
|
/**
|
|
14
7
|
* WordPress dependencies
|
|
@@ -22,6 +15,8 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
22
15
|
*/
|
|
23
16
|
import { GlobalStylesContext } from './context';
|
|
24
17
|
|
|
18
|
+
const identity = ( x ) => x;
|
|
19
|
+
|
|
25
20
|
function mergeTreesCustomizer( _, srcValue ) {
|
|
26
21
|
// We only pass as arrays the presets,
|
|
27
22
|
// in which case we want the new array of values
|
|
@@ -36,7 +31,11 @@ export function mergeBaseAndUserConfigs( base, user ) {
|
|
|
36
31
|
}
|
|
37
32
|
|
|
38
33
|
const cleanEmptyObject = ( object ) => {
|
|
39
|
-
if (
|
|
34
|
+
if (
|
|
35
|
+
object === null ||
|
|
36
|
+
typeof object !== 'object' ||
|
|
37
|
+
Array.isArray( object )
|
|
38
|
+
) {
|
|
40
39
|
return object;
|
|
41
40
|
}
|
|
42
41
|
const cleanedNestedObjects = pickBy(
|
|
@@ -159,6 +159,7 @@ const ROOT_BLOCK_SUPPORTS = [
|
|
|
159
159
|
'backgroundColor',
|
|
160
160
|
'color',
|
|
161
161
|
'linkColor',
|
|
162
|
+
'buttonColor',
|
|
162
163
|
'fontFamily',
|
|
163
164
|
'fontSize',
|
|
164
165
|
'fontStyle',
|
|
@@ -167,6 +168,8 @@ const ROOT_BLOCK_SUPPORTS = [
|
|
|
167
168
|
'textDecoration',
|
|
168
169
|
'textTransform',
|
|
169
170
|
'padding',
|
|
171
|
+
'contentSize',
|
|
172
|
+
'wideSize',
|
|
170
173
|
];
|
|
171
174
|
|
|
172
175
|
export function getSupportedGlobalStylesPanels( name ) {
|
|
@@ -181,6 +184,21 @@ export function getSupportedGlobalStylesPanels( name ) {
|
|
|
181
184
|
}
|
|
182
185
|
|
|
183
186
|
const supportKeys = [];
|
|
187
|
+
|
|
188
|
+
// Check for blockGap support.
|
|
189
|
+
// Block spacing support doesn't map directly to a single style property, so needs to be handled separately.
|
|
190
|
+
// Also, only allow `blockGap` support if serialization has not been skipped, to be sure global spacing can be applied.
|
|
191
|
+
if (
|
|
192
|
+
blockType?.supports?.spacing?.blockGap &&
|
|
193
|
+
blockType?.supports?.spacing?.__experimentalSkipSerialization !==
|
|
194
|
+
true &&
|
|
195
|
+
! blockType?.supports?.spacing?.__experimentalSkipSerialization?.some?.(
|
|
196
|
+
( spacingType ) => spacingType === 'blockGap'
|
|
197
|
+
)
|
|
198
|
+
) {
|
|
199
|
+
supportKeys.push( 'blockGap' );
|
|
200
|
+
}
|
|
201
|
+
|
|
184
202
|
Object.keys( STYLE_PROPERTY ).forEach( ( styleName ) => {
|
|
185
203
|
if ( ! STYLE_PROPERTY[ styleName ].support ) {
|
|
186
204
|
return;
|
|
@@ -58,7 +58,10 @@ function Palette( { name } ) {
|
|
|
58
58
|
<VStack spacing={ 3 }>
|
|
59
59
|
<Subtitle>{ __( 'Palette' ) }</Subtitle>
|
|
60
60
|
<ItemGroup isBordered isSeparated>
|
|
61
|
-
<NavigationButtonAsItem
|
|
61
|
+
<NavigationButtonAsItem
|
|
62
|
+
path={ screenPath }
|
|
63
|
+
aria-label={ __( 'Color palettes' ) }
|
|
64
|
+
>
|
|
62
65
|
<HStack
|
|
63
66
|
direction={
|
|
64
67
|
colors.length === 0 ? 'row-reverse' : 'row'
|
|
@@ -60,8 +60,17 @@ function BlockMenuItem( { block } ) {
|
|
|
60
60
|
return null;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
const navigationButtonLabel = sprintf(
|
|
64
|
+
// translators: %s: is the name of a block e.g., 'Image' or 'Table'.
|
|
65
|
+
__( '%s block styles' ),
|
|
66
|
+
block.title
|
|
67
|
+
);
|
|
68
|
+
|
|
63
69
|
return (
|
|
64
|
-
<NavigationButtonAsItem
|
|
70
|
+
<NavigationButtonAsItem
|
|
71
|
+
path={ '/blocks/' + block.name }
|
|
72
|
+
aria-label={ navigationButtonLabel }
|
|
73
|
+
>
|
|
65
74
|
<HStack justify="flex-start">
|
|
66
75
|
<BlockIcon icon={ block.icon } />
|
|
67
76
|
<FlexItem>{ block.title }</FlexItem>
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { __experimentalColorGradientControl as ColorGradientControl } from '@wordpress/block-editor';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import ScreenHeader from './header';
|
|
11
|
+
import {
|
|
12
|
+
getSupportedGlobalStylesPanels,
|
|
13
|
+
useSetting,
|
|
14
|
+
useStyle,
|
|
15
|
+
useColorsPerOrigin,
|
|
16
|
+
} from './hooks';
|
|
17
|
+
|
|
18
|
+
function ScreenButtonColor( { name } ) {
|
|
19
|
+
const supports = getSupportedGlobalStylesPanels( name );
|
|
20
|
+
const [ solids ] = useSetting( 'color.palette', name );
|
|
21
|
+
const [ areCustomSolidsEnabled ] = useSetting( 'color.custom', name );
|
|
22
|
+
|
|
23
|
+
const colorsPerOrigin = useColorsPerOrigin( name );
|
|
24
|
+
|
|
25
|
+
const [ isBackgroundEnabled ] = useSetting( 'color.background', name );
|
|
26
|
+
|
|
27
|
+
const hasButtonColor =
|
|
28
|
+
supports.includes( 'buttonColor' ) &&
|
|
29
|
+
isBackgroundEnabled &&
|
|
30
|
+
( solids.length > 0 || areCustomSolidsEnabled );
|
|
31
|
+
|
|
32
|
+
const [ buttonTextColor, setButtonTextColor ] = useStyle(
|
|
33
|
+
'elements.button.color.text',
|
|
34
|
+
name
|
|
35
|
+
);
|
|
36
|
+
const [ userButtonTextColor ] = useStyle(
|
|
37
|
+
'elements.button.color.text',
|
|
38
|
+
name,
|
|
39
|
+
'user'
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const [ buttonBgColor, setButtonBgColor ] = useStyle(
|
|
43
|
+
'elements.button.color.background',
|
|
44
|
+
name
|
|
45
|
+
);
|
|
46
|
+
const [ userButtonBgColor ] = useStyle(
|
|
47
|
+
'elements.button.color.background',
|
|
48
|
+
name,
|
|
49
|
+
'user'
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
if ( ! hasButtonColor ) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<>
|
|
58
|
+
<ScreenHeader
|
|
59
|
+
title={ __( 'Buttons' ) }
|
|
60
|
+
description={ __(
|
|
61
|
+
'Set the default colors used for buttons across the site.'
|
|
62
|
+
) }
|
|
63
|
+
/>
|
|
64
|
+
|
|
65
|
+
<h4 className="edit-site-global-styles-section-title">
|
|
66
|
+
{ __( 'Text color' ) }
|
|
67
|
+
</h4>
|
|
68
|
+
|
|
69
|
+
<ColorGradientControl
|
|
70
|
+
className="edit-site-screen-button-color__control"
|
|
71
|
+
colors={ colorsPerOrigin }
|
|
72
|
+
disableCustomColors={ ! areCustomSolidsEnabled }
|
|
73
|
+
__experimentalHasMultipleOrigins
|
|
74
|
+
showTitle={ false }
|
|
75
|
+
enableAlpha
|
|
76
|
+
__experimentalIsRenderedInSidebar
|
|
77
|
+
colorValue={ buttonTextColor }
|
|
78
|
+
onColorChange={ setButtonTextColor }
|
|
79
|
+
clearable={ buttonTextColor === userButtonTextColor }
|
|
80
|
+
/>
|
|
81
|
+
|
|
82
|
+
<h4 className="edit-site-global-styles-section-title">
|
|
83
|
+
{ __( 'Background color' ) }
|
|
84
|
+
</h4>
|
|
85
|
+
|
|
86
|
+
<ColorGradientControl
|
|
87
|
+
className="edit-site-screen-button-color__control"
|
|
88
|
+
colors={ colorsPerOrigin }
|
|
89
|
+
disableCustomColors={ ! areCustomSolidsEnabled }
|
|
90
|
+
__experimentalHasMultipleOrigins
|
|
91
|
+
showTitle={ false }
|
|
92
|
+
enableAlpha
|
|
93
|
+
__experimentalIsRenderedInSidebar
|
|
94
|
+
colorValue={ buttonBgColor }
|
|
95
|
+
onColorChange={ setButtonBgColor }
|
|
96
|
+
clearable={ buttonBgColor === userButtonBgColor }
|
|
97
|
+
/>
|
|
98
|
+
</>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export default ScreenButtonColor;
|
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
6
|
-
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
7
|
-
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
8
|
-
} from '@wordpress/components';
|
|
9
|
-
import { useState } from '@wordpress/element';
|
|
5
|
+
import { TabPanel } from '@wordpress/components';
|
|
10
6
|
|
|
11
7
|
/**
|
|
12
8
|
* Internal dependencies
|
|
@@ -16,8 +12,6 @@ import GradientPalettePanel from './gradients-palette-panel';
|
|
|
16
12
|
import ScreenHeader from './header';
|
|
17
13
|
|
|
18
14
|
function ScreenColorPalette( { name } ) {
|
|
19
|
-
const [ currentTab, setCurrentTab ] = useState( 'solid' );
|
|
20
|
-
|
|
21
15
|
return (
|
|
22
16
|
<>
|
|
23
17
|
<ScreenHeader
|
|
@@ -26,27 +20,31 @@ function ScreenColorPalette( { name } ) {
|
|
|
26
20
|
'Palettes are used to provide default color options for blocks and various design tools. Here you can edit the colors with their labels.'
|
|
27
21
|
) }
|
|
28
22
|
/>
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
<TabPanel
|
|
24
|
+
tabs={ [
|
|
25
|
+
{
|
|
26
|
+
name: 'solid',
|
|
27
|
+
title: 'Solid color',
|
|
28
|
+
value: 'solid',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'gradient',
|
|
32
|
+
title: 'Gradient',
|
|
33
|
+
value: 'gradient',
|
|
34
|
+
},
|
|
35
|
+
] }
|
|
36
36
|
>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
<GradientPalettePanel name={ name } />
|
|
49
|
-
) }
|
|
37
|
+
{ ( tab ) => (
|
|
38
|
+
<>
|
|
39
|
+
{ tab.value === 'solid' && (
|
|
40
|
+
<ColorPalettePanel name={ name } />
|
|
41
|
+
) }
|
|
42
|
+
{ tab.value === 'gradient' && (
|
|
43
|
+
<GradientPalettePanel name={ name } />
|
|
44
|
+
) }
|
|
45
|
+
</>
|
|
46
|
+
) }
|
|
47
|
+
</TabPanel>
|
|
50
48
|
</>
|
|
51
49
|
);
|
|
52
50
|
}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
__experimentalItemGroup as ItemGroup,
|
|
7
7
|
__experimentalHStack as HStack,
|
|
8
8
|
__experimentalVStack as VStack,
|
|
9
|
+
__experimentalZStack as ZStack,
|
|
9
10
|
FlexItem,
|
|
10
11
|
ColorIndicator,
|
|
11
12
|
} from '@wordpress/components';
|
|
@@ -33,11 +34,15 @@ function BackgroundColorItem( { name, parentMenu } ) {
|
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
return (
|
|
36
|
-
<NavigationButtonAsItem
|
|
37
|
+
<NavigationButtonAsItem
|
|
38
|
+
path={ parentMenu + '/colors/background' }
|
|
39
|
+
aria-label={ __( 'Colors background styles' ) }
|
|
40
|
+
>
|
|
37
41
|
<HStack justify="flex-start">
|
|
38
42
|
<ColorIndicatorWrapper expanded={ false }>
|
|
39
43
|
<ColorIndicator
|
|
40
44
|
colorValue={ gradientValue ?? backgroundColor }
|
|
45
|
+
data-testid="background-color-indicator"
|
|
41
46
|
/>
|
|
42
47
|
</ColorIndicatorWrapper>
|
|
43
48
|
<FlexItem>{ __( 'Background' ) }</FlexItem>
|
|
@@ -56,10 +61,16 @@ function TextColorItem( { name, parentMenu } ) {
|
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
return (
|
|
59
|
-
<NavigationButtonAsItem
|
|
64
|
+
<NavigationButtonAsItem
|
|
65
|
+
path={ parentMenu + '/colors/text' }
|
|
66
|
+
aria-label={ __( 'Colors text styles' ) }
|
|
67
|
+
>
|
|
60
68
|
<HStack justify="flex-start">
|
|
61
69
|
<ColorIndicatorWrapper expanded={ false }>
|
|
62
|
-
<ColorIndicator
|
|
70
|
+
<ColorIndicator
|
|
71
|
+
colorValue={ color }
|
|
72
|
+
data-testid="text-color-indicator"
|
|
73
|
+
/>
|
|
63
74
|
</ColorIndicatorWrapper>
|
|
64
75
|
<FlexItem>{ __( 'Text' ) }</FlexItem>
|
|
65
76
|
</HStack>
|
|
@@ -71,23 +82,59 @@ function LinkColorItem( { name, parentMenu } ) {
|
|
|
71
82
|
const supports = getSupportedGlobalStylesPanels( name );
|
|
72
83
|
const hasSupport = supports.includes( 'linkColor' );
|
|
73
84
|
const [ color ] = useStyle( 'elements.link.color.text', name );
|
|
85
|
+
const [ colorHover ] = useStyle( 'elements.link.:hover.color.text', name );
|
|
74
86
|
|
|
75
87
|
if ( ! hasSupport ) {
|
|
76
88
|
return null;
|
|
77
89
|
}
|
|
78
90
|
|
|
79
91
|
return (
|
|
80
|
-
<NavigationButtonAsItem
|
|
92
|
+
<NavigationButtonAsItem
|
|
93
|
+
path={ parentMenu + '/colors/link' }
|
|
94
|
+
aria-label={ __( 'Colors link styles' ) }
|
|
95
|
+
>
|
|
81
96
|
<HStack justify="flex-start">
|
|
82
|
-
<
|
|
83
|
-
<
|
|
84
|
-
|
|
97
|
+
<ZStack isLayered={ false } offset={ -8 }>
|
|
98
|
+
<ColorIndicatorWrapper expanded={ false }>
|
|
99
|
+
<ColorIndicator colorValue={ color } />
|
|
100
|
+
</ColorIndicatorWrapper>
|
|
101
|
+
<ColorIndicatorWrapper expanded={ false }>
|
|
102
|
+
<ColorIndicator colorValue={ colorHover } />
|
|
103
|
+
</ColorIndicatorWrapper>
|
|
104
|
+
</ZStack>
|
|
85
105
|
<FlexItem>{ __( 'Links' ) }</FlexItem>
|
|
86
106
|
</HStack>
|
|
87
107
|
</NavigationButtonAsItem>
|
|
88
108
|
);
|
|
89
109
|
}
|
|
90
110
|
|
|
111
|
+
function ButtonColorItem( { name, parentMenu } ) {
|
|
112
|
+
const supports = getSupportedGlobalStylesPanels( name );
|
|
113
|
+
const hasSupport = supports.includes( 'buttonColor' );
|
|
114
|
+
const [ color ] = useStyle( 'elements.button.color.text', name );
|
|
115
|
+
const [ bgColor ] = useStyle( 'elements.button.color.background', name );
|
|
116
|
+
|
|
117
|
+
if ( ! hasSupport ) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<NavigationButtonAsItem path={ parentMenu + '/colors/button' }>
|
|
123
|
+
<HStack justify="flex-start">
|
|
124
|
+
<ZStack isLayered={ false } offset={ -8 }>
|
|
125
|
+
<ColorIndicatorWrapper expanded={ false }>
|
|
126
|
+
<ColorIndicator colorValue={ bgColor } />
|
|
127
|
+
</ColorIndicatorWrapper>
|
|
128
|
+
<ColorIndicatorWrapper expanded={ false }>
|
|
129
|
+
<ColorIndicator colorValue={ color } />
|
|
130
|
+
</ColorIndicatorWrapper>
|
|
131
|
+
</ZStack>
|
|
132
|
+
<FlexItem>{ __( 'Buttons' ) }</FlexItem>
|
|
133
|
+
</HStack>
|
|
134
|
+
</NavigationButtonAsItem>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
91
138
|
function ScreenColors( { name } ) {
|
|
92
139
|
const parentMenu = name === undefined ? '' : '/blocks/' + name;
|
|
93
140
|
|
|
@@ -119,6 +166,10 @@ function ScreenColors( { name } ) {
|
|
|
119
166
|
name={ name }
|
|
120
167
|
parentMenu={ parentMenu }
|
|
121
168
|
/>
|
|
169
|
+
<ButtonColorItem
|
|
170
|
+
name={ name }
|
|
171
|
+
parentMenu={ parentMenu }
|
|
172
|
+
/>
|
|
122
173
|
</ItemGroup>
|
|
123
174
|
</VStack>
|
|
124
175
|
</VStack>
|