@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.
Files changed (204) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/add-new-template/add-custom-generic-template-modal.js +84 -0
  3. package/build/components/add-new-template/add-custom-generic-template-modal.js.map +1 -0
  4. package/build/components/add-new-template/add-custom-template-modal.js +204 -0
  5. package/build/components/add-new-template/add-custom-template-modal.js.map +1 -0
  6. package/build/components/add-new-template/new-template.js +91 -33
  7. package/build/components/add-new-template/new-template.js.map +1 -1
  8. package/build/components/add-new-template/utils.js +532 -0
  9. package/build/components/add-new-template/utils.js.map +1 -0
  10. package/build/components/block-editor/index.js +1 -3
  11. package/build/components/block-editor/index.js.map +1 -1
  12. package/build/components/code-editor/index.js +17 -4
  13. package/build/components/code-editor/index.js.map +1 -1
  14. package/build/components/editor/index.js +16 -0
  15. package/build/components/editor/index.js.map +1 -1
  16. package/build/components/error-boundary/index.js +6 -0
  17. package/build/components/error-boundary/index.js.map +1 -1
  18. package/build/components/global-styles/context-menu.js +6 -3
  19. package/build/components/global-styles/context-menu.js.map +1 -1
  20. package/build/components/global-styles/dimensions-panel.js +185 -19
  21. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  22. package/build/components/global-styles/global-styles-provider.js +4 -2
  23. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  24. package/build/components/global-styles/hooks.js +11 -2
  25. package/build/components/global-styles/hooks.js.map +1 -1
  26. package/build/components/global-styles/palette.js +2 -1
  27. package/build/components/global-styles/palette.js.map +1 -1
  28. package/build/components/global-styles/screen-block-list.js +4 -1
  29. package/build/components/global-styles/screen-block-list.js.map +1 -1
  30. package/build/components/global-styles/screen-button-color.js +80 -0
  31. package/build/components/global-styles/screen-button-color.js.map +1 -0
  32. package/build/components/global-styles/screen-color-palette.js +13 -17
  33. package/build/components/global-styles/screen-color-palette.js.map +1 -1
  34. package/build/components/global-styles/screen-colors.js +56 -8
  35. package/build/components/global-styles/screen-colors.js.map +1 -1
  36. package/build/components/global-styles/screen-link-color.js +48 -14
  37. package/build/components/global-styles/screen-link-color.js.map +1 -1
  38. package/build/components/global-styles/screen-root.js +4 -2
  39. package/build/components/global-styles/screen-root.js.map +1 -1
  40. package/build/components/global-styles/screen-typography-element.js +4 -0
  41. package/build/components/global-styles/screen-typography-element.js.map +1 -1
  42. package/build/components/global-styles/screen-typography.js +9 -1
  43. package/build/components/global-styles/screen-typography.js.map +1 -1
  44. package/build/components/global-styles/ui.js +11 -0
  45. package/build/components/global-styles/ui.js.map +1 -1
  46. package/build/components/global-styles/use-global-styles-output.js +282 -35
  47. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  48. package/build/components/global-styles/utils.js +35 -2
  49. package/build/components/global-styles/utils.js.map +1 -1
  50. package/build/components/header/index.js +29 -10
  51. package/build/components/header/index.js.map +1 -1
  52. package/build/components/header/more-menu/site-export.js +4 -1
  53. package/build/components/header/more-menu/site-export.js.map +1 -1
  54. package/build/components/header/undo-redo/redo.js +13 -4
  55. package/build/components/header/undo-redo/redo.js.map +1 -1
  56. package/build/components/header/undo-redo/undo.js +13 -4
  57. package/build/components/header/undo-redo/undo.js.map +1 -1
  58. package/build/components/keyboard-shortcut-help-modal/config.js +17 -0
  59. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  60. package/build/components/keyboard-shortcut-help-modal/index.js +1 -3
  61. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  62. package/build/components/sidebar/template-card/index.js +19 -7
  63. package/build/components/sidebar/template-card/index.js.map +1 -1
  64. package/build/components/sidebar/template-card/template-actions.js +64 -0
  65. package/build/components/sidebar/template-card/template-actions.js.map +1 -0
  66. package/build/components/template-details/edit-template-title.js +11 -3
  67. package/build/components/template-details/edit-template-title.js.map +1 -1
  68. package/build/components/template-details/index.js +1 -20
  69. package/build/components/template-details/index.js.map +1 -1
  70. package/build/hooks/index.js +2 -0
  71. package/build/hooks/index.js.map +1 -1
  72. package/build/hooks/template-part-edit.js +86 -0
  73. package/build/hooks/template-part-edit.js.map +1 -0
  74. package/build/store/selectors.js +4 -1
  75. package/build/store/selectors.js.map +1 -1
  76. package/build-module/components/add-new-template/add-custom-generic-template-modal.js +77 -0
  77. package/build-module/components/add-new-template/add-custom-generic-template-modal.js.map +1 -0
  78. package/build-module/components/add-new-template/add-custom-template-modal.js +189 -0
  79. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -0
  80. package/build-module/components/add-new-template/new-template.js +90 -34
  81. package/build-module/components/add-new-template/new-template.js.map +1 -1
  82. package/build-module/components/add-new-template/utils.js +503 -0
  83. package/build-module/components/add-new-template/utils.js.map +1 -0
  84. package/build-module/components/block-editor/index.js +1 -2
  85. package/build-module/components/block-editor/index.js.map +1 -1
  86. package/build-module/components/code-editor/index.js +18 -5
  87. package/build-module/components/code-editor/index.js.map +1 -1
  88. package/build-module/components/editor/index.js +16 -0
  89. package/build-module/components/editor/index.js.map +1 -1
  90. package/build-module/components/error-boundary/index.js +5 -0
  91. package/build-module/components/error-boundary/index.js.map +1 -1
  92. package/build-module/components/global-styles/context-menu.js +6 -3
  93. package/build-module/components/global-styles/context-menu.js.map +1 -1
  94. package/build-module/components/global-styles/dimensions-panel.js +185 -20
  95. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  96. package/build-module/components/global-styles/global-styles-provider.js +4 -2
  97. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  98. package/build-module/components/global-styles/hooks.js +11 -2
  99. package/build-module/components/global-styles/hooks.js.map +1 -1
  100. package/build-module/components/global-styles/palette.js +2 -1
  101. package/build-module/components/global-styles/palette.js.map +1 -1
  102. package/build-module/components/global-styles/screen-block-list.js +4 -1
  103. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  104. package/build-module/components/global-styles/screen-button-color.js +67 -0
  105. package/build-module/components/global-styles/screen-button-color.js.map +1 -0
  106. package/build-module/components/global-styles/screen-color-palette.js +14 -19
  107. package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
  108. package/build-module/components/global-styles/screen-colors.js +57 -9
  109. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  110. package/build-module/components/global-styles/screen-link-color.js +47 -14
  111. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  112. package/build-module/components/global-styles/screen-root.js +4 -2
  113. package/build-module/components/global-styles/screen-root.js.map +1 -1
  114. package/build-module/components/global-styles/screen-typography-element.js +4 -0
  115. package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
  116. package/build-module/components/global-styles/screen-typography.js +10 -2
  117. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  118. package/build-module/components/global-styles/ui.js +10 -0
  119. package/build-module/components/global-styles/ui.js.map +1 -1
  120. package/build-module/components/global-styles/use-global-styles-output.js +280 -42
  121. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  122. package/build-module/components/global-styles/utils.js +34 -3
  123. package/build-module/components/global-styles/utils.js.map +1 -1
  124. package/build-module/components/header/index.js +31 -11
  125. package/build-module/components/header/index.js.map +1 -1
  126. package/build-module/components/header/more-menu/site-export.js +4 -1
  127. package/build-module/components/header/more-menu/site-export.js.map +1 -1
  128. package/build-module/components/header/undo-redo/redo.js +9 -3
  129. package/build-module/components/header/undo-redo/redo.js.map +1 -1
  130. package/build-module/components/header/undo-redo/undo.js +9 -3
  131. package/build-module/components/header/undo-redo/undo.js.map +1 -1
  132. package/build-module/components/keyboard-shortcut-help-modal/config.js +17 -0
  133. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  134. package/build-module/components/keyboard-shortcut-help-modal/index.js +1 -2
  135. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  136. package/build-module/components/sidebar/template-card/index.js +18 -7
  137. package/build-module/components/sidebar/template-card/index.js.map +1 -1
  138. package/build-module/components/sidebar/template-card/template-actions.js +49 -0
  139. package/build-module/components/sidebar/template-card/template-actions.js.map +1 -0
  140. package/build-module/components/template-details/edit-template-title.js +12 -3
  141. package/build-module/components/template-details/edit-template-title.js.map +1 -1
  142. package/build-module/components/template-details/index.js +2 -21
  143. package/build-module/components/template-details/index.js.map +1 -1
  144. package/build-module/hooks/index.js +1 -0
  145. package/build-module/hooks/index.js.map +1 -1
  146. package/build-module/hooks/template-part-edit.js +67 -0
  147. package/build-module/hooks/template-part-edit.js.map +1 -0
  148. package/build-module/store/selectors.js +5 -2
  149. package/build-module/store/selectors.js.map +1 -1
  150. package/build-style/style-rtl.css +198 -49
  151. package/build-style/style.css +198 -49
  152. package/package.json +29 -29
  153. package/src/components/add-new-template/add-custom-generic-template-modal.js +97 -0
  154. package/src/components/add-new-template/add-custom-template-modal.js +247 -0
  155. package/src/components/add-new-template/new-template.js +158 -70
  156. package/src/components/add-new-template/style.scss +149 -0
  157. package/src/components/add-new-template/utils.js +538 -0
  158. package/src/components/block-editor/index.js +0 -2
  159. package/src/components/code-editor/index.js +15 -5
  160. package/src/components/editor/index.js +11 -0
  161. package/src/components/error-boundary/index.js +5 -0
  162. package/src/components/global-styles/context-menu.js +3 -0
  163. package/src/components/global-styles/dimensions-panel.js +209 -21
  164. package/src/components/global-styles/global-styles-provider.js +8 -9
  165. package/src/components/global-styles/hooks.js +18 -0
  166. package/src/components/global-styles/palette.js +4 -1
  167. package/src/components/global-styles/screen-block-list.js +10 -1
  168. package/src/components/global-styles/screen-button-color.js +102 -0
  169. package/src/components/global-styles/screen-color-palette.js +25 -27
  170. package/src/components/global-styles/screen-colors.js +58 -7
  171. package/src/components/global-styles/screen-link-color.js +65 -23
  172. package/src/components/global-styles/screen-root.js +8 -2
  173. package/src/components/global-styles/screen-typography-element.js +4 -0
  174. package/src/components/global-styles/screen-typography.js +17 -2
  175. package/src/components/global-styles/style.scss +14 -8
  176. package/src/components/global-styles/test/use-global-styles-output.js +313 -16
  177. package/src/components/global-styles/ui.js +13 -0
  178. package/src/components/global-styles/use-global-styles-output.js +344 -38
  179. package/src/components/global-styles/utils.js +36 -2
  180. package/src/components/header/index.js +42 -17
  181. package/src/components/header/more-menu/site-export.js +3 -0
  182. package/src/components/header/style.scss +58 -8
  183. package/src/components/header/undo-redo/redo.js +6 -1
  184. package/src/components/header/undo-redo/undo.js +6 -1
  185. package/src/components/keyboard-shortcut-help-modal/config.js +12 -0
  186. package/src/components/keyboard-shortcut-help-modal/index.js +1 -2
  187. package/src/components/keyboard-shortcut-help-modal/style.scss +0 -5
  188. package/src/components/list/style.scss +0 -8
  189. package/src/components/sidebar/style.scss +4 -0
  190. package/src/components/sidebar/template-card/index.js +15 -6
  191. package/src/components/sidebar/template-card/style.scss +49 -35
  192. package/src/components/sidebar/template-card/template-actions.js +43 -0
  193. package/src/components/template-details/edit-template-title.js +10 -2
  194. package/src/components/template-details/index.js +4 -21
  195. package/src/components/test/error-boundary.js +38 -0
  196. package/src/hooks/index.js +1 -0
  197. package/src/hooks/template-part-edit.js +82 -0
  198. package/src/store/selectors.js +11 -5
  199. package/src/style.scss +0 -1
  200. package/build/components/edit-template-part-menu-button/index.js +0 -90
  201. package/build/components/edit-template-part-menu-button/index.js.map +0 -1
  202. package/build-module/components/edit-template-part-menu-button/index.js +0 -72
  203. package/build-module/components/edit-template-part-menu-button/index.js.map +0 -1
  204. 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
- // Do not show the gap control panel for block-level global styles
47
- // as they do not work on the frontend.
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
- export default function DimensionsPanel( { name } ) {
94
- const showPaddingControl = useHasPadding( name );
95
- const showMarginControl = useHasMargin( name );
96
- const showGapControl = useHasGap( name );
97
- const units = useCustomUnits( {
98
- availableUnits: useSetting( 'spacing.units', name )[ 0 ] || [
99
- '%',
100
- 'px',
101
- 'em',
102
- 'rem',
103
- 'vw',
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 ( ! isObject( object ) || Array.isArray( object ) ) {
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 path={ screenPath }>
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 path={ '/blocks/' + block.name }>
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
- <ToggleGroupControl
30
- className="edit-site-screen-color-palette-toggle"
31
- value={ currentTab }
32
- onChange={ setCurrentTab }
33
- label={ __( 'Select palette type' ) }
34
- hideLabelFromVision
35
- isBlock
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
- <ToggleGroupControlOption
38
- value="solid"
39
- label={ __( 'Solid' ) }
40
- />
41
- <ToggleGroupControlOption
42
- value="gradient"
43
- label={ __( 'Gradient' ) }
44
- />
45
- </ToggleGroupControl>
46
- { currentTab === 'solid' && <ColorPalettePanel name={ name } /> }
47
- { currentTab === 'gradient' && (
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 path={ parentMenu + '/colors/background' }>
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 path={ parentMenu + '/colors/text' }>
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 colorValue={ color } />
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 path={ parentMenu + '/colors/link' }>
92
+ <NavigationButtonAsItem
93
+ path={ parentMenu + '/colors/link' }
94
+ aria-label={ __( 'Colors link styles' ) }
95
+ >
81
96
  <HStack justify="flex-start">
82
- <ColorIndicatorWrapper expanded={ false }>
83
- <ColorIndicator colorValue={ color } />
84
- </ColorIndicatorWrapper>
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>