@wordpress/edit-site 3.0.27 → 4.0.1-next.f435e9e01b.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 (240) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +7 -1
  4. package/build/components/add-new-template/new-template-part.js +1 -4
  5. package/build/components/add-new-template/new-template-part.js.map +1 -1
  6. package/build/components/block-editor/resizable-editor.js +1 -0
  7. package/build/components/block-editor/resizable-editor.js.map +1 -1
  8. package/build/components/code-editor/code-editor-text-area.js +95 -0
  9. package/build/components/code-editor/code-editor-text-area.js.map +1 -0
  10. package/build/components/code-editor/index.js +79 -0
  11. package/build/components/code-editor/index.js.map +1 -0
  12. package/build/components/editor/index.js +28 -8
  13. package/build/components/editor/index.js.map +1 -1
  14. package/build/components/error-boundary/index.js +27 -11
  15. package/build/components/error-boundary/index.js.map +1 -1
  16. package/build/components/global-styles/border-panel.js +81 -22
  17. package/build/components/global-styles/border-panel.js.map +1 -1
  18. package/build/components/global-styles/context-menu.js +4 -6
  19. package/build/components/global-styles/context-menu.js.map +1 -1
  20. package/build/components/global-styles/global-styles-provider.js +1 -0
  21. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  22. package/build/components/global-styles/header.js +2 -7
  23. package/build/components/global-styles/header.js.map +1 -1
  24. package/build/components/global-styles/navigation-button.js +35 -12
  25. package/build/components/global-styles/navigation-button.js.map +1 -1
  26. package/build/components/global-styles/palette.js +3 -3
  27. package/build/components/global-styles/palette.js.map +1 -1
  28. package/build/components/global-styles/preview.js +46 -15
  29. package/build/components/global-styles/preview.js.map +1 -1
  30. package/build/components/global-styles/screen-background-color.js +1 -3
  31. package/build/components/global-styles/screen-background-color.js.map +1 -1
  32. package/build/components/global-styles/screen-block-list.js +2 -3
  33. package/build/components/global-styles/screen-block-list.js.map +1 -1
  34. package/build/components/global-styles/screen-block.js +0 -1
  35. package/build/components/global-styles/screen-block.js.map +1 -1
  36. package/build/components/global-styles/screen-color-palette.js +0 -2
  37. package/build/components/global-styles/screen-color-palette.js.map +1 -1
  38. package/build/components/global-styles/screen-colors.js +5 -6
  39. package/build/components/global-styles/screen-colors.js.map +1 -1
  40. package/build/components/global-styles/screen-layout.js +0 -2
  41. package/build/components/global-styles/screen-layout.js.map +1 -1
  42. package/build/components/global-styles/screen-link-color.js +0 -2
  43. package/build/components/global-styles/screen-link-color.js.map +1 -1
  44. package/build/components/global-styles/screen-root.js +22 -3
  45. package/build/components/global-styles/screen-root.js.map +1 -1
  46. package/build/components/global-styles/screen-style-variations.js +138 -0
  47. package/build/components/global-styles/screen-style-variations.js.map +1 -0
  48. package/build/components/global-styles/screen-text-color.js +0 -2
  49. package/build/components/global-styles/screen-text-color.js.map +1 -1
  50. package/build/components/global-styles/screen-typography-element.js +0 -2
  51. package/build/components/global-styles/screen-typography-element.js.map +1 -1
  52. package/build/components/global-styles/screen-typography.js +2 -3
  53. package/build/components/global-styles/screen-typography.js.map +1 -1
  54. package/build/components/global-styles/ui.js +31 -14
  55. package/build/components/global-styles/ui.js.map +1 -1
  56. package/build/components/header/index.js +12 -4
  57. package/build/components/header/index.js.map +1 -1
  58. package/build/components/header/mode-switcher/index.js +78 -0
  59. package/build/components/header/mode-switcher/index.js.map +1 -0
  60. package/build/components/header/more-menu/copy-content-menu-item.js +74 -0
  61. package/build/components/header/more-menu/copy-content-menu-item.js.map +1 -0
  62. package/build/components/header/more-menu/index.js +6 -2
  63. package/build/components/header/more-menu/index.js.map +1 -1
  64. package/build/components/keyboard-shortcuts/index.js +17 -1
  65. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  66. package/build/components/list/actions/index.js +5 -4
  67. package/build/components/list/actions/index.js.map +1 -1
  68. package/build/components/list/actions/rename-menu-item.js +3 -3
  69. package/build/components/list/actions/rename-menu-item.js.map +1 -1
  70. package/build/components/routes/redirect-to-homepage.js +3 -22
  71. package/build/components/routes/redirect-to-homepage.js.map +1 -1
  72. package/build/components/secondary-sidebar/inserter-sidebar.js +13 -3
  73. package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
  74. package/build/components/secondary-sidebar/list-view-sidebar.js +7 -5
  75. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  76. package/build/components/sidebar/default-sidebar.js +4 -2
  77. package/build/components/sidebar/default-sidebar.js.map +1 -1
  78. package/build/components/sidebar/global-styles-sidebar.js +1 -0
  79. package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
  80. package/build/components/template-part-converter/convert-to-template-part.js +1 -4
  81. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  82. package/build/index.js +2 -16
  83. package/build/index.js.map +1 -1
  84. package/build/store/actions.js +29 -9
  85. package/build/store/actions.js.map +1 -1
  86. package/build/store/defaults.js +2 -1
  87. package/build/store/defaults.js.map +1 -1
  88. package/build/store/reducer.js +11 -0
  89. package/build/store/reducer.js.map +1 -1
  90. package/build/store/selectors.js +13 -0
  91. package/build/store/selectors.js.map +1 -1
  92. package/build-module/components/add-new-template/new-template-part.js +1 -4
  93. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  94. package/build-module/components/block-editor/resizable-editor.js +1 -0
  95. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  96. package/build-module/components/code-editor/code-editor-text-area.js +83 -0
  97. package/build-module/components/code-editor/code-editor-text-area.js.map +1 -0
  98. package/build-module/components/code-editor/index.js +62 -0
  99. package/build-module/components/code-editor/index.js.map +1 -0
  100. package/build-module/components/editor/index.js +27 -9
  101. package/build-module/components/editor/index.js.map +1 -1
  102. package/build-module/components/error-boundary/index.js +26 -9
  103. package/build-module/components/error-boundary/index.js.map +1 -1
  104. package/build-module/components/global-styles/border-panel.js +82 -23
  105. package/build-module/components/global-styles/border-panel.js.map +1 -1
  106. package/build-module/components/global-styles/context-menu.js +1 -1
  107. package/build-module/components/global-styles/context-menu.js.map +1 -1
  108. package/build-module/components/global-styles/global-styles-provider.js +1 -1
  109. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  110. package/build-module/components/global-styles/header.js +2 -5
  111. package/build-module/components/global-styles/header.js.map +1 -1
  112. package/build-module/components/global-styles/navigation-button.js +35 -10
  113. package/build-module/components/global-styles/navigation-button.js.map +1 -1
  114. package/build-module/components/global-styles/palette.js +2 -2
  115. package/build-module/components/global-styles/palette.js.map +1 -1
  116. package/build-module/components/global-styles/preview.js +45 -15
  117. package/build-module/components/global-styles/preview.js.map +1 -1
  118. package/build-module/components/global-styles/screen-background-color.js +1 -3
  119. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  120. package/build-module/components/global-styles/screen-block-list.js +1 -2
  121. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  122. package/build-module/components/global-styles/screen-block.js +0 -1
  123. package/build-module/components/global-styles/screen-block.js.map +1 -1
  124. package/build-module/components/global-styles/screen-color-palette.js +0 -2
  125. package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
  126. package/build-module/components/global-styles/screen-colors.js +2 -3
  127. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  128. package/build-module/components/global-styles/screen-layout.js +0 -2
  129. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  130. package/build-module/components/global-styles/screen-link-color.js +0 -2
  131. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  132. package/build-module/components/global-styles/screen-root.js +21 -4
  133. package/build-module/components/global-styles/screen-root.js.map +1 -1
  134. package/build-module/components/global-styles/screen-style-variations.js +119 -0
  135. package/build-module/components/global-styles/screen-style-variations.js.map +1 -0
  136. package/build-module/components/global-styles/screen-text-color.js +0 -2
  137. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  138. package/build-module/components/global-styles/screen-typography-element.js +0 -2
  139. package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
  140. package/build-module/components/global-styles/screen-typography.js +1 -2
  141. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  142. package/build-module/components/global-styles/ui.js +29 -14
  143. package/build-module/components/global-styles/ui.js.map +1 -1
  144. package/build-module/components/header/index.js +13 -5
  145. package/build-module/components/header/index.js.map +1 -1
  146. package/build-module/components/header/mode-switcher/index.js +65 -0
  147. package/build-module/components/header/mode-switcher/index.js.map +1 -0
  148. package/build-module/components/header/more-menu/copy-content-menu-item.js +59 -0
  149. package/build-module/components/header/more-menu/copy-content-menu-item.js.map +1 -0
  150. package/build-module/components/header/more-menu/index.js +4 -2
  151. package/build-module/components/header/more-menu/index.js.map +1 -1
  152. package/build-module/components/keyboard-shortcuts/index.js +17 -1
  153. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  154. package/build-module/components/list/actions/index.js +5 -4
  155. package/build-module/components/list/actions/index.js.map +1 -1
  156. package/build-module/components/list/actions/rename-menu-item.js +3 -3
  157. package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
  158. package/build-module/components/routes/redirect-to-homepage.js +3 -22
  159. package/build-module/components/routes/redirect-to-homepage.js.map +1 -1
  160. package/build-module/components/secondary-sidebar/inserter-sidebar.js +14 -4
  161. package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
  162. package/build-module/components/secondary-sidebar/list-view-sidebar.js +7 -5
  163. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  164. package/build-module/components/sidebar/default-sidebar.js +4 -2
  165. package/build-module/components/sidebar/default-sidebar.js.map +1 -1
  166. package/build-module/components/sidebar/global-styles-sidebar.js +1 -0
  167. package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
  168. package/build-module/components/template-part-converter/convert-to-template-part.js +1 -4
  169. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  170. package/build-module/index.js +2 -14
  171. package/build-module/index.js.map +1 -1
  172. package/build-module/store/actions.js +25 -9
  173. package/build-module/store/actions.js.map +1 -1
  174. package/build-module/store/defaults.js +2 -1
  175. package/build-module/store/defaults.js.map +1 -1
  176. package/build-module/store/reducer.js +11 -0
  177. package/build-module/store/reducer.js.map +1 -1
  178. package/build-module/store/selectors.js +11 -0
  179. package/build-module/store/selectors.js.map +1 -1
  180. package/build-style/style-rtl.css +148 -68
  181. package/build-style/style.css +148 -68
  182. package/package.json +28 -30
  183. package/src/components/add-new-template/new-template-part.js +1 -7
  184. package/src/components/block-editor/resizable-editor.js +1 -0
  185. package/src/components/block-editor/style.scss +10 -18
  186. package/src/components/code-editor/code-editor-text-area.js +79 -0
  187. package/src/components/code-editor/index.js +65 -0
  188. package/src/components/code-editor/style.scss +100 -0
  189. package/src/components/editor/index.js +41 -10
  190. package/src/components/error-boundary/index.js +28 -11
  191. package/src/components/global-styles/border-panel.js +106 -42
  192. package/src/components/global-styles/context-menu.js +1 -1
  193. package/src/components/global-styles/global-styles-provider.js +1 -2
  194. package/src/components/global-styles/header.js +3 -5
  195. package/src/components/global-styles/navigation-button.js +31 -10
  196. package/src/components/global-styles/palette.js +6 -2
  197. package/src/components/global-styles/preview.js +46 -18
  198. package/src/components/global-styles/screen-background-color.js +1 -3
  199. package/src/components/global-styles/screen-block-list.js +1 -2
  200. package/src/components/global-styles/screen-block.js +1 -1
  201. package/src/components/global-styles/screen-color-palette.js +0 -2
  202. package/src/components/global-styles/screen-colors.js +2 -3
  203. package/src/components/global-styles/screen-layout.js +1 -5
  204. package/src/components/global-styles/screen-link-color.js +0 -2
  205. package/src/components/global-styles/screen-root.js +32 -3
  206. package/src/components/global-styles/screen-style-variations.js +130 -0
  207. package/src/components/global-styles/screen-text-color.js +0 -2
  208. package/src/components/global-styles/screen-typography-element.js +0 -4
  209. package/src/components/global-styles/screen-typography.js +2 -3
  210. package/src/components/global-styles/style.scss +24 -25
  211. package/src/components/global-styles/ui.js +55 -25
  212. package/src/components/header/document-actions/style.scss +1 -9
  213. package/src/components/header/index.js +10 -2
  214. package/src/components/header/mode-switcher/index.js +67 -0
  215. package/src/components/header/more-menu/copy-content-menu-item.js +53 -0
  216. package/src/components/header/more-menu/index.js +4 -0
  217. package/src/components/header/style.scss +2 -1
  218. package/src/components/keyboard-shortcuts/index.js +17 -1
  219. package/src/components/list/actions/index.js +5 -4
  220. package/src/components/list/actions/rename-menu-item.js +3 -3
  221. package/src/components/routes/redirect-to-homepage.js +4 -27
  222. package/src/components/secondary-sidebar/inserter-sidebar.js +14 -3
  223. package/src/components/secondary-sidebar/list-view-sidebar.js +12 -5
  224. package/src/components/secondary-sidebar/style.scss +0 -4
  225. package/src/components/sidebar/default-sidebar.js +2 -0
  226. package/src/components/sidebar/global-styles-sidebar.js +1 -0
  227. package/src/components/sidebar/style.scss +21 -14
  228. package/src/components/template-part-converter/convert-to-template-part.js +1 -6
  229. package/src/index.js +2 -18
  230. package/src/store/actions.js +25 -10
  231. package/src/store/defaults.js +1 -0
  232. package/src/store/reducer.js +6 -0
  233. package/src/store/selectors.js +11 -0
  234. package/src/store/test/actions.js +2 -2
  235. package/src/style.scss +1 -0
  236. package/build/components/error-boundary/warning.js +0 -70
  237. package/build/components/error-boundary/warning.js.map +0 -1
  238. package/build-module/components/error-boundary/warning.js +0 -60
  239. package/build-module/components/error-boundary/warning.js.map +0 -1
  240. package/src/components/error-boundary/warning.js +0 -59
@@ -7,7 +7,8 @@ import {
7
7
  __experimentalColorGradientControl as ColorGradientControl,
8
8
  } from '@wordpress/block-editor';
9
9
  import {
10
- PanelBody,
10
+ __experimentalToolsPanel as ToolsPanel,
11
+ __experimentalToolsPanelItem as ToolsPanelItem,
11
12
  __experimentalUnitControl as UnitControl,
12
13
  __experimentalUseCustomUnits as useCustomUnits,
13
14
  } from '@wordpress/components';
@@ -68,6 +69,18 @@ function useHasBorderWidthControl( name ) {
68
69
  }
69
70
 
70
71
  export default function BorderPanel( { name } ) {
72
+ // To better reflect if the user has customized a value we need to
73
+ // ensure the style value being checked is from the `user` origin.
74
+ const [ userBorderStyles ] = useStyle( 'border', name, 'user' );
75
+ const createHasValueCallback = ( feature ) => () =>
76
+ !! userBorderStyles?.[ feature ];
77
+
78
+ const createResetCallback = ( setStyle ) => () => setStyle( undefined );
79
+
80
+ const handleOnChange = ( setStyle ) => ( value ) => {
81
+ setStyle( value || undefined );
82
+ };
83
+
71
84
  const units = useCustomUnits( {
72
85
  availableUnits: useSetting( 'spacing.units' )[ 0 ] || [
73
86
  'px',
@@ -77,70 +90,121 @@ export default function BorderPanel( { name } ) {
77
90
  } );
78
91
 
79
92
  // Border width.
80
- const hasBorderWidth = useHasBorderWidthControl( name );
93
+ const showBorderWidth = useHasBorderWidthControl( name );
81
94
  const [ borderWidthValue, setBorderWidth ] = useStyle(
82
95
  'border.width',
83
96
  name
84
97
  );
85
98
 
86
99
  // Border style.
87
- const hasBorderStyle = useHasBorderStyleControl( name );
100
+ const showBorderStyle = useHasBorderStyleControl( name );
88
101
  const [ borderStyle, setBorderStyle ] = useStyle( 'border.style', name );
89
102
 
90
103
  // Border color.
104
+ const showBorderColor = useHasBorderColorControl( name );
105
+ const [ borderColor, setBorderColor ] = useStyle( 'border.color', name );
91
106
  const [ colors = EMPTY_ARRAY ] = useSetting( 'color.palette' );
92
107
  const disableCustomColors = ! useSetting( 'color.custom' )[ 0 ];
93
108
  const disableCustomGradients = ! useSetting( 'color.customGradient' )[ 0 ];
94
- const hasBorderColor = useHasBorderColorControl( name );
95
- const [ borderColor, setBorderColor ] = useStyle( 'border.color', name );
96
109
 
97
110
  // Border radius.
98
- const hasBorderRadius = useHasBorderRadiusControl( name );
111
+ const showBorderRadius = useHasBorderRadiusControl( name );
99
112
  const [ borderRadiusValues, setBorderRadius ] = useStyle(
100
113
  'border.radius',
101
114
  name
102
115
  );
116
+ const hasBorderRadius = () => {
117
+ const borderValues = userBorderStyles?.radius;
118
+ if ( typeof borderValues === 'object' ) {
119
+ return Object.entries( borderValues ).some( Boolean );
120
+ }
121
+ return !! borderValues;
122
+ };
123
+
124
+ const resetAll = () => {
125
+ setBorderColor( undefined );
126
+ setBorderRadius( undefined );
127
+ setBorderStyle( undefined );
128
+ setBorderWidth( undefined );
129
+ };
130
+
131
+ // When we set a border color or width ensure we have a style so the user
132
+ // can see a visible border.
133
+ const handleOnChangeWithStyle = ( setStyle ) => ( value ) => {
134
+ if ( !! value && ! borderStyle ) {
135
+ setBorderStyle( 'solid' );
136
+ }
137
+
138
+ setStyle( value || undefined );
139
+ };
103
140
 
104
141
  return (
105
- <PanelBody title={ __( 'Border' ) } initialOpen={ true }>
106
- { ( hasBorderWidth || hasBorderStyle ) && (
107
- <div className="edit-site-global-styles-sidebar__border-controls-row">
108
- { hasBorderWidth && (
109
- <UnitControl
110
- value={ borderWidthValue }
111
- label={ __( 'Width' ) }
112
- min={ MIN_BORDER_WIDTH }
113
- onChange={ ( value ) => {
114
- setBorderWidth( value || undefined );
115
- } }
116
- units={ units }
117
- />
118
- ) }
119
- { hasBorderStyle && (
120
- <BorderStyleControl
121
- value={ borderStyle }
122
- onChange={ setBorderStyle }
123
- />
124
- ) }
125
- </div>
142
+ <ToolsPanel label={ __( 'Border' ) } resetAll={ resetAll }>
143
+ { showBorderWidth && (
144
+ <ToolsPanelItem
145
+ className="single-column"
146
+ hasValue={ createHasValueCallback( 'width' ) }
147
+ label={ __( 'Width' ) }
148
+ onDeselect={ createResetCallback( setBorderWidth ) }
149
+ isShownByDefault={ true }
150
+ >
151
+ <UnitControl
152
+ value={ borderWidthValue }
153
+ label={ __( 'Width' ) }
154
+ min={ MIN_BORDER_WIDTH }
155
+ onChange={ handleOnChangeWithStyle( setBorderWidth ) }
156
+ units={ units }
157
+ />
158
+ </ToolsPanelItem>
159
+ ) }
160
+ { showBorderStyle && (
161
+ <ToolsPanelItem
162
+ className="single-column"
163
+ hasValue={ createHasValueCallback( 'style' ) }
164
+ label={ __( 'Style' ) }
165
+ onDeselect={ createResetCallback( setBorderStyle ) }
166
+ isShownByDefault={ true }
167
+ >
168
+ <BorderStyleControl
169
+ value={ borderStyle }
170
+ onChange={ handleOnChange( setBorderStyle ) }
171
+ />
172
+ </ToolsPanelItem>
126
173
  ) }
127
- { hasBorderColor && (
128
- <ColorGradientControl
174
+ { showBorderColor && (
175
+ <ToolsPanelItem
176
+ hasValue={ createHasValueCallback( 'color' ) }
129
177
  label={ __( 'Color' ) }
130
- colorValue={ borderColor }
131
- colors={ colors }
132
- gradients={ undefined }
133
- disableCustomColors={ disableCustomColors }
134
- disableCustomGradients={ disableCustomGradients }
135
- onColorChange={ setBorderColor }
136
- />
178
+ onDeselect={ createResetCallback( setBorderColor ) }
179
+ isShownByDefault={ true }
180
+ >
181
+ <ColorGradientControl
182
+ label={ __( 'Color' ) }
183
+ colorValue={ borderColor }
184
+ colors={ colors }
185
+ gradients={ undefined }
186
+ disableCustomColors={ disableCustomColors }
187
+ disableCustomGradients={ disableCustomGradients }
188
+ onColorChange={ handleOnChangeWithStyle(
189
+ setBorderColor
190
+ ) }
191
+ clearable={ false }
192
+ />
193
+ </ToolsPanelItem>
137
194
  ) }
138
- { hasBorderRadius && (
139
- <BorderRadiusControl
140
- values={ borderRadiusValues }
141
- onChange={ setBorderRadius }
142
- />
195
+ { showBorderRadius && (
196
+ <ToolsPanelItem
197
+ hasValue={ hasBorderRadius }
198
+ label={ __( 'Radius' ) }
199
+ onDeselect={ createResetCallback( setBorderRadius ) }
200
+ isShownByDefault={ true }
201
+ >
202
+ <BorderRadiusControl
203
+ values={ borderRadiusValues }
204
+ onChange={ handleOnChange( setBorderRadius ) }
205
+ />
206
+ </ToolsPanelItem>
143
207
  ) }
144
- </PanelBody>
208
+ </ToolsPanel>
145
209
  );
146
210
  }
@@ -12,7 +12,7 @@ import { useHasBorderPanel } from './border-panel';
12
12
  import { useHasColorPanel } from './color-utils';
13
13
  import { useHasDimensionsPanel } from './dimensions-panel';
14
14
  import { useHasTypographyPanel } from './typography-panel';
15
- import NavigationButton from './navigation-button';
15
+ import { NavigationButton } from './navigation-button';
16
16
 
17
17
  function ContextMenu( { name, parentMenu = '' } ) {
18
18
  const hasTypographyPanel = useHasTypographyPanel( name );
@@ -31,7 +31,7 @@ function mergeTreesCustomizer( _, srcValue ) {
31
31
  }
32
32
  }
33
33
 
34
- function mergeBaseAndUserConfigs( base, user ) {
34
+ export function mergeBaseAndUserConfigs( base, user ) {
35
35
  return mergeWith( {}, base, user, mergeTreesCustomizer );
36
36
  }
37
37
 
@@ -67,7 +67,6 @@ function useGlobalStylesUserConfig() {
67
67
 
68
68
  const { getEditedEntityRecord } = useSelect( coreStore );
69
69
  const { editEntityRecord } = useDispatch( coreStore );
70
-
71
70
  const config = useMemo( () => {
72
71
  return {
73
72
  settings: settings ?? {},
@@ -14,15 +14,14 @@ import { chevronRight, chevronLeft, Icon } from '@wordpress/icons';
14
14
  /**
15
15
  * Internal dependencies
16
16
  */
17
- import NavigationButton from './navigation-button';
17
+ import { NavigationBackButton } from './navigation-button';
18
18
 
19
- function ScreenHeader( { back, title, description } ) {
19
+ function ScreenHeader( { title, description } ) {
20
20
  return (
21
21
  <VStack spacing={ 2 }>
22
22
  <HStack spacing={ 2 }>
23
23
  <View>
24
- <NavigationButton
25
- path={ back }
24
+ <NavigationBackButton
26
25
  icon={
27
26
  <Icon
28
27
  icon={ isRTL() ? chevronRight : chevronLeft }
@@ -30,7 +29,6 @@ function ScreenHeader( { back, title, description } ) {
30
29
  />
31
30
  }
32
31
  size="small"
33
- isBack
34
32
  aria-label={ __( 'Navigate to the previous view' ) }
35
33
  />
36
34
  </View>
@@ -9,16 +9,9 @@ import {
9
9
  } from '@wordpress/components';
10
10
  import { Icon } from '@wordpress/icons';
11
11
 
12
- function NavigationButton( {
13
- path,
14
- icon,
15
- children,
16
- isBack = false,
17
- ...props
18
- } ) {
19
- const navigator = useNavigator();
12
+ function GenericNavigationButton( { icon, children, ...props } ) {
20
13
  return (
21
- <Item onClick={ () => navigator.push( path, { isBack } ) } { ...props }>
14
+ <Item { ...props }>
22
15
  { icon && (
23
16
  <HStack justify="flex-start">
24
17
  <FlexItem>
@@ -32,4 +25,32 @@ function NavigationButton( {
32
25
  );
33
26
  }
34
27
 
35
- export default NavigationButton;
28
+ function NavigationButton( { path, ...props } ) {
29
+ const { goTo } = useNavigator();
30
+
31
+ const dataAttrName = 'data-navigator-focusable-id';
32
+ const dataAttrValue = path;
33
+
34
+ const dataAttrCssSelector = `[${ dataAttrName }="${ dataAttrValue }"]`;
35
+
36
+ const buttonProps = {
37
+ ...props,
38
+ [ dataAttrName ]: dataAttrValue,
39
+ };
40
+
41
+ return (
42
+ <GenericNavigationButton
43
+ onClick={ () =>
44
+ goTo( path, { focusTargetSelector: dataAttrCssSelector } )
45
+ }
46
+ { ...buttonProps }
47
+ />
48
+ );
49
+ }
50
+
51
+ function NavigationBackButton( { ...props } ) {
52
+ const { goBack } = useNavigator();
53
+ return <GenericNavigationButton onClick={ goBack } { ...props } />;
54
+ }
55
+
56
+ export { NavigationButton, NavigationBackButton };
@@ -17,7 +17,7 @@ import { useMemo } from '@wordpress/element';
17
17
  * Internal dependencies
18
18
  */
19
19
  import Subtitle from './subtitle';
20
- import NavigationButton from './navigation-button';
20
+ import { NavigationButton } from './navigation-button';
21
21
  import { useSetting } from './hooks';
22
22
 
23
23
  const EMPTY_COLORS = [];
@@ -59,7 +59,11 @@ function Palette( { name } ) {
59
59
  <Subtitle>{ __( 'Palette' ) }</Subtitle>
60
60
  <ItemGroup isBordered isSeparated>
61
61
  <NavigationButton path={ screenPath }>
62
- <HStack isReversed={ colors.length === 0 }>
62
+ <HStack
63
+ direction={
64
+ colors.length === 0 ? 'row-reverse' : 'row'
65
+ }
66
+ >
63
67
  <FlexBlock>
64
68
  <ZStack isLayered={ false } offset={ -8 }>
65
69
  { colors.slice( 0, 5 ).map( ( { color } ) => (
@@ -2,41 +2,69 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import {
5
- __experimentalHStack as HStack,
6
- __experimentalVStack as VStack,
7
- Card,
8
- ColorIndicator,
9
- } from '@wordpress/components';
5
+ __unstableIframe as Iframe,
6
+ __unstableEditorStyles as EditorStyles,
7
+ } from '@wordpress/block-editor';
10
8
 
11
9
  /**
12
10
  * Internal dependencies
13
11
  */
14
12
  import { useStyle } from './hooks';
13
+ import { useGlobalStylesOutput } from './use-global-styles-output';
15
14
 
16
- const StylesPreview = () => {
15
+ const StylesPreview = ( { height = 150 } ) => {
17
16
  const [ fontFamily = 'serif' ] = useStyle( 'typography.fontFamily' );
18
17
  const [ textColor = 'black' ] = useStyle( 'color.text' );
19
18
  const [ linkColor = 'blue' ] = useStyle( 'elements.link.color.text' );
20
19
  const [ backgroundColor = 'white' ] = useStyle( 'color.background' );
21
20
  const [ gradientValue ] = useStyle( 'color.gradient' );
21
+ const [ styles ] = useGlobalStylesOutput();
22
22
 
23
23
  return (
24
- <Card
25
- className="edit-site-global-styles-preview"
26
- style={ { background: gradientValue ?? backgroundColor } }
24
+ <Iframe
25
+ className="edit-site-global-styles-preview__iframe"
26
+ head={ <EditorStyles styles={ styles } /> }
27
+ style={ { height } }
27
28
  >
28
- <HStack spacing={ 5 }>
29
+ <div
30
+ style={ {
31
+ display: 'flex',
32
+ gap: 20,
33
+ alignItems: 'center',
34
+ justifyContent: 'center',
35
+ height: '100%',
36
+ transform: `scale(${ height / 150 })`,
37
+ background: gradientValue ?? backgroundColor,
38
+ cursor: 'pointer',
39
+ } }
40
+ >
41
+ <div style={ { fontFamily, fontSize: '80px' } }>Aa</div>
29
42
  <div
30
- style={ { fontFamily, fontSize: '80px', color: textColor } }
43
+ style={ {
44
+ display: 'flex',
45
+ gap: 20,
46
+ flexDirection: 'column',
47
+ } }
31
48
  >
32
- Aa
49
+ <div
50
+ style={ {
51
+ height: 40,
52
+ width: 40,
53
+ background: textColor,
54
+ borderRadius: 20,
55
+ } }
56
+ />{ ' ' }
57
+ <div
58
+ style={ {
59
+ height: 40,
60
+ width: 40,
61
+ background: linkColor,
62
+ borderRadius: 20,
63
+ } }
64
+ />
33
65
  </div>
34
- <VStack spacing={ 2 }>
35
- <ColorIndicator colorValue={ textColor } />
36
- <ColorIndicator colorValue={ linkColor } />
37
- </VStack>
38
- </HStack>
39
- </Card>
66
+ </div>
67
+ </Iframe>
40
68
  );
41
69
  };
42
70
 
@@ -17,7 +17,6 @@ import {
17
17
  } from './hooks';
18
18
 
19
19
  function ScreenBackgroundColor( { name } ) {
20
- const parentMenu = name === undefined ? '' : '/blocks/' + name;
21
20
  const supports = getSupportedGlobalStylesPanels( name );
22
21
  const [ solids ] = useSetting( 'color.palette', name );
23
22
  const [ gradients ] = useSetting( 'color.gradients', name );
@@ -86,10 +85,9 @@ function ScreenBackgroundColor( { name } ) {
86
85
  return (
87
86
  <>
88
87
  <ScreenHeader
89
- back={ parentMenu + '/colors' }
90
88
  title={ __( 'Background' ) }
91
89
  description={ __(
92
- 'Set a background color or gradient for the whole website.'
90
+ 'Set a background color or gradient for the whole site.'
93
91
  ) }
94
92
  />
95
93
  <ColorGradientControl
@@ -17,7 +17,7 @@ import { useHasColorPanel } from './color-utils';
17
17
  import { useHasDimensionsPanel } from './dimensions-panel';
18
18
  import { useHasTypographyPanel } from './typography-panel';
19
19
  import ScreenHeader from './header';
20
- import NavigationButton from './navigation-button';
20
+ import { NavigationButton } from './navigation-button';
21
21
 
22
22
  function BlockMenuItem( { block } ) {
23
23
  const hasTypographyPanel = useHasTypographyPanel( block.name );
@@ -48,7 +48,6 @@ function ScreenBlockList() {
48
48
  return (
49
49
  <>
50
50
  <ScreenHeader
51
- back="/"
52
51
  title={ __( 'Blocks' ) }
53
52
  description={ __(
54
53
  'Customize the appearance of specific blocks and for the whole site.'
@@ -14,7 +14,7 @@ function ScreenBlock( { name } ) {
14
14
 
15
15
  return (
16
16
  <>
17
- <ScreenHeader back="/blocks" title={ blockType.title } />
17
+ <ScreenHeader title={ blockType.title } />
18
18
  <ContextMenu parentMenu={ '/blocks/' + name } name={ name } />
19
19
  </>
20
20
  );
@@ -17,12 +17,10 @@ import ScreenHeader from './header';
17
17
 
18
18
  function ScreenColorPalette( { name } ) {
19
19
  const [ currentTab, setCurrentTab ] = useState( 'solid' );
20
- const parentMenu = name === undefined ? '' : '/blocks/' + name;
21
20
 
22
21
  return (
23
22
  <>
24
23
  <ScreenHeader
25
- back={ parentMenu + '/colors' }
26
24
  title={ __( 'Palette' ) }
27
25
  description={ __(
28
26
  'Palettes are used to provide default color options for blocks and various design tools. Here you can edit the colors with their labels.'
@@ -15,7 +15,7 @@ import {
15
15
  */
16
16
  import ScreenHeader from './header';
17
17
  import Palette from './palette';
18
- import NavigationButton from './navigation-button';
18
+ import { NavigationButton } from './navigation-button';
19
19
  import { getSupportedGlobalStylesPanels, useStyle } from './hooks';
20
20
  import Subtitle from './subtitle';
21
21
 
@@ -93,10 +93,9 @@ function ScreenColors( { name } ) {
93
93
  return (
94
94
  <>
95
95
  <ScreenHeader
96
- back={ parentMenu ? parentMenu : '/' }
97
96
  title={ __( 'Colors' ) }
98
97
  description={ __(
99
- 'Manage palettes and the default color of different global elements on the website.'
98
+ 'Manage palettes and the default color of different global elements on the site.'
100
99
  ) }
101
100
  />
102
101
 
@@ -11,16 +11,12 @@ import DimensionsPanel, { useHasDimensionsPanel } from './dimensions-panel';
11
11
  import ScreenHeader from './header';
12
12
 
13
13
  function ScreenLayout( { name } ) {
14
- const parentMenu = name === undefined ? '' : '/blocks/' + name;
15
14
  const hasBorderPanel = useHasBorderPanel( name );
16
15
  const hasDimensionsPanel = useHasDimensionsPanel( name );
17
16
 
18
17
  return (
19
18
  <>
20
- <ScreenHeader
21
- back={ parentMenu ? parentMenu : '/' }
22
- title={ __( 'Layout' ) }
23
- />
19
+ <ScreenHeader title={ __( 'Layout' ) } />
24
20
  { hasDimensionsPanel && <DimensionsPanel name={ name } /> }
25
21
  { hasBorderPanel && <BorderPanel name={ name } /> }
26
22
  </>
@@ -16,7 +16,6 @@ import {
16
16
  } from './hooks';
17
17
 
18
18
  function ScreenLinkColor( { name } ) {
19
- const parentMenu = name === undefined ? '' : '/blocks/' + name;
20
19
  const supports = getSupportedGlobalStylesPanels( name );
21
20
  const [ solids ] = useSetting( 'color.palette', name );
22
21
  const [ areCustomSolidsEnabled ] = useSetting( 'color.custom', name );
@@ -47,7 +46,6 @@ function ScreenLinkColor( { name } ) {
47
46
  return (
48
47
  <>
49
48
  <ScreenHeader
50
- back={ parentMenu + '/colors' }
51
49
  title={ __( 'Links' ) }
52
50
  description={ __(
53
51
  'Set the default color used for links across the site.'
@@ -5,6 +5,7 @@ import {
5
5
  __experimentalItemGroup as ItemGroup,
6
6
  __experimentalItem as Item,
7
7
  __experimentalHStack as HStack,
8
+ __experimentalVStack as VStack,
8
9
  FlexItem,
9
10
  CardBody,
10
11
  Card,
@@ -12,19 +13,47 @@ import {
12
13
  } from '@wordpress/components';
13
14
  import { isRTL, __ } from '@wordpress/i18n';
14
15
  import { chevronLeft, chevronRight, Icon } from '@wordpress/icons';
16
+ import { useSelect } from '@wordpress/data';
17
+ import { store as coreStore } from '@wordpress/core-data';
15
18
 
16
19
  /**
17
20
  * Internal dependencies
18
21
  */
19
- import StylesPreview from './preview';
20
- import NavigationButton from './navigation-button';
22
+ import { NavigationButton } from './navigation-button';
21
23
  import ContextMenu from './context-menu';
24
+ import StylesPreview from './preview';
22
25
 
23
26
  function ScreenRoot() {
27
+ const { variations } = useSelect( ( select ) => {
28
+ return {
29
+ variations: select(
30
+ coreStore
31
+ ).__experimentalGetCurrentThemeGlobalStylesVariations(),
32
+ };
33
+ }, [] );
34
+
24
35
  return (
25
36
  <Card size="small">
26
37
  <CardBody>
27
- <StylesPreview />
38
+ <VStack spacing={ 2 }>
39
+ <Card>
40
+ <StylesPreview />
41
+ </Card>
42
+ { !! variations?.length && (
43
+ <NavigationButton path="/variations">
44
+ <HStack justify="space-between">
45
+ <FlexItem>{ __( 'Other styles' ) }</FlexItem>
46
+ <FlexItem>
47
+ <Icon
48
+ icon={
49
+ isRTL() ? chevronLeft : chevronRight
50
+ }
51
+ />
52
+ </FlexItem>
53
+ </HStack>
54
+ </NavigationButton>
55
+ ) }
56
+ </VStack>
28
57
  </CardBody>
29
58
 
30
59
  <CardBody>