@wordpress/edit-site 5.1.0 → 5.2.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 (180) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/LICENSE.md +1 -1
  3. package/build/components/add-new-template/new-template-part.js +21 -1
  4. package/build/components/add-new-template/new-template-part.js.map +1 -1
  5. package/build/components/add-new-template/utils.js +9 -1
  6. package/build/components/add-new-template/utils.js.map +1 -1
  7. package/build/components/block-editor/editor-canvas.js +0 -1
  8. package/build/components/block-editor/editor-canvas.js.map +1 -1
  9. package/build/components/block-editor/index.js +15 -51
  10. package/build/components/block-editor/index.js.map +1 -1
  11. package/build/components/block-editor/resize-handle.js +2 -1
  12. package/build/components/block-editor/resize-handle.js.map +1 -1
  13. package/build/components/editor/index.js +1 -1
  14. package/build/components/editor/index.js.map +1 -1
  15. package/build/components/global-styles/block-preview-panel.js +8 -2
  16. package/build/components/global-styles/block-preview-panel.js.map +1 -1
  17. package/build/components/global-styles/border-panel.js +5 -4
  18. package/build/components/global-styles/border-panel.js.map +1 -1
  19. package/build/components/global-styles/context-menu.js +9 -1
  20. package/build/components/global-styles/context-menu.js.map +1 -1
  21. package/build/components/global-styles/dimensions-panel.js +16 -11
  22. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  23. package/build/components/global-styles/screen-background-color.js +6 -5
  24. package/build/components/global-styles/screen-background-color.js.map +1 -1
  25. package/build/components/global-styles/screen-block-list.js +4 -1
  26. package/build/components/global-styles/screen-block-list.js.map +1 -1
  27. package/build/components/global-styles/screen-border.js +9 -3
  28. package/build/components/global-styles/screen-border.js.map +1 -1
  29. package/build/components/global-styles/screen-button-color.js +3 -2
  30. package/build/components/global-styles/screen-button-color.js.map +1 -1
  31. package/build/components/global-styles/screen-colors.js +50 -26
  32. package/build/components/global-styles/screen-colors.js.map +1 -1
  33. package/build/components/global-styles/screen-heading-color.js +8 -7
  34. package/build/components/global-styles/screen-heading-color.js.map +1 -1
  35. package/build/components/global-styles/screen-layout.js +9 -3
  36. package/build/components/global-styles/screen-layout.js.map +1 -1
  37. package/build/components/global-styles/screen-link-color.js +8 -7
  38. package/build/components/global-styles/screen-link-color.js.map +1 -1
  39. package/build/components/global-styles/screen-text-color.js +4 -3
  40. package/build/components/global-styles/screen-text-color.js.map +1 -1
  41. package/build/components/global-styles/screen-typography.js +8 -2
  42. package/build/components/global-styles/screen-typography.js.map +1 -1
  43. package/build/components/global-styles/screen-variations.js +71 -0
  44. package/build/components/global-styles/screen-variations.js.map +1 -0
  45. package/build/components/global-styles/typography-panel.js +9 -8
  46. package/build/components/global-styles/typography-panel.js.map +1 -1
  47. package/build/components/global-styles/ui.js +85 -18
  48. package/build/components/global-styles/ui.js.map +1 -1
  49. package/build/components/global-styles/use-global-styles-output.js +119 -33
  50. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  51. package/build/components/global-styles/utils.js +49 -2
  52. package/build/components/global-styles/utils.js.map +1 -1
  53. package/build/components/global-styles/variations-panel.js +85 -0
  54. package/build/components/global-styles/variations-panel.js.map +1 -0
  55. package/build/components/layout/index.js +81 -8
  56. package/build/components/layout/index.js.map +1 -1
  57. package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js +2 -0
  58. package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +1 -1
  59. package/build/components/site-hub/index.js +9 -9
  60. package/build/components/site-hub/index.js.map +1 -1
  61. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +54 -0
  62. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -0
  63. package/build/components/template-details/edit-template-title.js +1 -0
  64. package/build/components/template-details/edit-template-title.js.map +1 -1
  65. package/build/components/template-details/template-part-area-selector.js +1 -0
  66. package/build/components/template-details/template-part-area-selector.js.map +1 -1
  67. package/build/hooks/push-changes-to-global-styles/index.js +3 -3
  68. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  69. package/build/store/reducer.js +1 -1
  70. package/build/store/reducer.js.map +1 -1
  71. package/build-module/components/add-new-template/new-template-part.js +20 -1
  72. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  73. package/build-module/components/add-new-template/utils.js +5 -0
  74. package/build-module/components/add-new-template/utils.js.map +1 -1
  75. package/build-module/components/block-editor/editor-canvas.js +0 -1
  76. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  77. package/build-module/components/block-editor/index.js +17 -49
  78. package/build-module/components/block-editor/index.js.map +1 -1
  79. package/build-module/components/block-editor/resize-handle.js +2 -1
  80. package/build-module/components/block-editor/resize-handle.js.map +1 -1
  81. package/build-module/components/editor/index.js +1 -1
  82. package/build-module/components/editor/index.js.map +1 -1
  83. package/build-module/components/global-styles/block-preview-panel.js +8 -2
  84. package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
  85. package/build-module/components/global-styles/border-panel.js +5 -4
  86. package/build-module/components/global-styles/border-panel.js.map +1 -1
  87. package/build-module/components/global-styles/context-menu.js +7 -1
  88. package/build-module/components/global-styles/context-menu.js.map +1 -1
  89. package/build-module/components/global-styles/dimensions-panel.js +16 -11
  90. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  91. package/build-module/components/global-styles/screen-background-color.js +6 -5
  92. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  93. package/build-module/components/global-styles/screen-block-list.js +3 -1
  94. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  95. package/build-module/components/global-styles/screen-border.js +8 -3
  96. package/build-module/components/global-styles/screen-border.js.map +1 -1
  97. package/build-module/components/global-styles/screen-button-color.js +3 -2
  98. package/build-module/components/global-styles/screen-button-color.js.map +1 -1
  99. package/build-module/components/global-styles/screen-colors.js +49 -26
  100. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  101. package/build-module/components/global-styles/screen-heading-color.js +8 -7
  102. package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
  103. package/build-module/components/global-styles/screen-layout.js +8 -3
  104. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  105. package/build-module/components/global-styles/screen-link-color.js +8 -7
  106. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  107. package/build-module/components/global-styles/screen-text-color.js +4 -3
  108. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  109. package/build-module/components/global-styles/screen-typography.js +7 -2
  110. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  111. package/build-module/components/global-styles/screen-variations.js +54 -0
  112. package/build-module/components/global-styles/screen-variations.js.map +1 -0
  113. package/build-module/components/global-styles/typography-panel.js +9 -8
  114. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  115. package/build-module/components/global-styles/ui.js +84 -19
  116. package/build-module/components/global-styles/ui.js.map +1 -1
  117. package/build-module/components/global-styles/use-global-styles-output.js +121 -35
  118. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  119. package/build-module/components/global-styles/utils.js +47 -2
  120. package/build-module/components/global-styles/utils.js.map +1 -1
  121. package/build-module/components/global-styles/variations-panel.js +68 -0
  122. package/build-module/components/global-styles/variations-panel.js.map +1 -0
  123. package/build-module/components/layout/index.js +81 -10
  124. package/build-module/components/layout/index.js.map +1 -1
  125. package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js +2 -0
  126. package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +1 -1
  127. package/build-module/components/site-hub/index.js +10 -9
  128. package/build-module/components/site-hub/index.js.map +1 -1
  129. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +43 -0
  130. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -0
  131. package/build-module/components/template-details/edit-template-title.js +1 -0
  132. package/build-module/components/template-details/edit-template-title.js.map +1 -1
  133. package/build-module/components/template-details/template-part-area-selector.js +1 -0
  134. package/build-module/components/template-details/template-part-area-selector.js.map +1 -1
  135. package/build-module/hooks/push-changes-to-global-styles/index.js +3 -3
  136. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  137. package/build-module/store/reducer.js +1 -1
  138. package/build-module/store/reducer.js.map +1 -1
  139. package/build-style/style-rtl.css +93 -21
  140. package/build-style/style.css +93 -21
  141. package/package.json +30 -30
  142. package/src/components/add-new-template/new-template-part.js +23 -1
  143. package/src/components/add-new-template/utils.js +14 -0
  144. package/src/components/block-editor/editor-canvas.js +0 -1
  145. package/src/components/block-editor/index.js +11 -54
  146. package/src/components/block-editor/resize-handle.js +6 -2
  147. package/src/components/block-editor/style.scss +43 -7
  148. package/src/components/editor/index.js +1 -1
  149. package/src/components/global-styles/block-preview-panel.js +14 -2
  150. package/src/components/global-styles/border-panel.js +8 -4
  151. package/src/components/global-styles/context-menu.js +6 -0
  152. package/src/components/global-styles/dimensions-panel.js +32 -15
  153. package/src/components/global-styles/screen-background-color.js +12 -5
  154. package/src/components/global-styles/screen-block-list.js +6 -1
  155. package/src/components/global-styles/screen-border.js +7 -4
  156. package/src/components/global-styles/screen-button-color.js +2 -2
  157. package/src/components/global-styles/screen-colors.js +82 -21
  158. package/src/components/global-styles/screen-heading-color.js +7 -7
  159. package/src/components/global-styles/screen-layout.js +10 -4
  160. package/src/components/global-styles/screen-link-color.js +19 -7
  161. package/src/components/global-styles/screen-text-color.js +7 -3
  162. package/src/components/global-styles/screen-typography.js +11 -4
  163. package/src/components/global-styles/screen-variations.js +47 -0
  164. package/src/components/global-styles/style.scss +9 -0
  165. package/src/components/global-styles/test/use-global-styles-output.js +1 -1
  166. package/src/components/global-styles/typography-panel.js +31 -8
  167. package/src/components/global-styles/ui.js +101 -13
  168. package/src/components/global-styles/use-global-styles-output.js +137 -14
  169. package/src/components/global-styles/utils.js +46 -2
  170. package/src/components/global-styles/variations-panel.js +78 -0
  171. package/src/components/layout/index.js +107 -19
  172. package/src/components/layout/style.scss +30 -5
  173. package/src/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js +2 -0
  174. package/src/components/sidebar-edit-mode/navigation-menu-sidebar/style.scss +4 -0
  175. package/src/components/site-hub/index.js +120 -109
  176. package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +40 -0
  177. package/src/components/template-details/edit-template-title.js +1 -0
  178. package/src/components/template-details/template-part-area-selector.js +1 -0
  179. package/src/hooks/push-changes-to-global-styles/index.js +3 -3
  180. package/src/store/reducer.js +1 -1
@@ -11,6 +11,7 @@ import {
11
11
  __unstableMotion as motion,
12
12
  __unstableAnimatePresence as AnimatePresence,
13
13
  __unstableUseNavigateRegions as useNavigateRegions,
14
+ ResizableBox,
14
15
  } from '@wordpress/components';
15
16
  import {
16
17
  useReducedMotion,
@@ -18,7 +19,7 @@ import {
18
19
  useResizeObserver,
19
20
  } from '@wordpress/compose';
20
21
  import { __ } from '@wordpress/i18n';
21
- import { useState, useEffect } from '@wordpress/element';
22
+ import { useState, useEffect, useRef } from '@wordpress/element';
22
23
  import { NavigableRegion } from '@wordpress/interface';
23
24
  import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
24
25
 
@@ -35,13 +36,28 @@ import getIsListPage from '../../utils/get-is-list-page';
35
36
  import Header from '../header-edit-mode';
36
37
  import useInitEditedEntityFromURL from '../sync-state-with-url/use-init-edited-entity-from-url';
37
38
  import SiteHub from '../site-hub';
39
+ import ResizeHandle from '../block-editor/resize-handle';
40
+ import useSyncCanvasModeWithURL from '../sync-state-with-url/use-sync-canvas-mode-with-url';
38
41
 
39
42
  const ANIMATION_DURATION = 0.5;
43
+ const emptyResizeHandleStyles = {
44
+ position: undefined,
45
+ userSelect: undefined,
46
+ cursor: undefined,
47
+ width: undefined,
48
+ height: undefined,
49
+ top: undefined,
50
+ right: undefined,
51
+ bottom: undefined,
52
+ left: undefined,
53
+ };
40
54
 
41
55
  export default function Layout( { onError } ) {
42
56
  // This ensures the edited entity id and type are initialized properly.
43
57
  useInitEditedEntityFromURL();
58
+ useSyncCanvasModeWithURL();
44
59
 
60
+ const hubRef = useRef();
45
61
  const { params } = useLocation();
46
62
  const isListPage = getIsListPage( params );
47
63
  const isEditorPage = ! isListPage;
@@ -86,6 +102,14 @@ export default function Layout( { onError } ) {
86
102
  // Ideally this effect could be removed if we move the "isMobileCanvasVisible" into the store.
87
103
  const [ canvasResizer, canvasSize ] = useResizeObserver();
88
104
  const [ fullResizer, fullSize ] = useResizeObserver();
105
+ const [ forcedWidth, setForcedWidth ] = useState( null );
106
+ const [ isResizing, setIsResizing ] = useState( false );
107
+ const isResizingEnabled = ! isMobileViewport && canvasMode === 'view';
108
+ const defaultSidebarWidth = isMobileViewport ? '100vw' : 360;
109
+ let canvasWidth = isResizing ? '100%' : fullSize.width;
110
+ if ( showFrame && ! isResizing ) {
111
+ canvasWidth = canvasSize.width - canvasPadding;
112
+ }
89
113
  useEffect( () => {
90
114
  if ( canvasMode === 'view' && isMobileViewport ) {
91
115
  setIsMobileCanvasVisible( false );
@@ -96,6 +120,13 @@ export default function Layout( { onError } ) {
96
120
  }
97
121
  }, [ canvasMode, isMobileViewport ] );
98
122
 
123
+ // Synchronizing the URL with the store value of canvasMode happens in an effect
124
+ // This condition ensures the component is only rendered after the synchronization happens
125
+ // which prevents any animations due to potential canvasMode value change.
126
+ if ( canvasMode === 'init' ) {
127
+ return null;
128
+ }
129
+
99
130
  return (
100
131
  <>
101
132
  { fullResizer }
@@ -112,7 +143,14 @@ export default function Layout( { onError } ) {
112
143
  ) }
113
144
  >
114
145
  <SiteHub
146
+ ref={ hubRef }
115
147
  className="edit-site-layout__hub"
148
+ style={ {
149
+ width:
150
+ isResizingEnabled && forcedWidth
151
+ ? forcedWidth - 48
152
+ : undefined,
153
+ } }
116
154
  isMobileCanvasVisible={ isMobileCanvasVisible }
117
155
  setIsMobileCanvasVisible={ setIsMobileCanvasVisible }
118
156
  />
@@ -149,7 +187,7 @@ export default function Layout( { onError } ) {
149
187
  <div className="edit-site-layout__content">
150
188
  <AnimatePresence initial={ false }>
151
189
  { showSidebar && (
152
- <NavigableRegion
190
+ <ResizableBox
153
191
  as={ motion.div }
154
192
  initial={ {
155
193
  opacity: 0,
@@ -162,22 +200,73 @@ export default function Layout( { onError } ) {
162
200
  } }
163
201
  transition={ {
164
202
  type: 'tween',
165
- duration: disableMotion
166
- ? 0
167
- : ANIMATION_DURATION,
203
+ duration:
204
+ disableMotion || isResizing
205
+ ? 0
206
+ : ANIMATION_DURATION,
168
207
  ease: 'easeOut',
169
208
  } }
209
+ size={ {
210
+ height: '100%',
211
+ width:
212
+ isResizingEnabled && forcedWidth
213
+ ? forcedWidth
214
+ : defaultSidebarWidth,
215
+ } }
170
216
  className="edit-site-layout__sidebar"
171
- ariaLabel={ __( 'Navigation sidebar' ) }
217
+ enable={ {
218
+ right: isResizingEnabled,
219
+ } }
220
+ onResizeStop={ ( event, direction, elt ) => {
221
+ setForcedWidth( elt.clientWidth );
222
+ setIsResizing( false );
223
+ } }
224
+ onResizeStart={ () => {
225
+ setIsResizing( true );
226
+ } }
227
+ onResize={ ( event, direction, elt ) => {
228
+ // This is a performance optimization
229
+ // We set the width imperatively to avoid re-rendering
230
+ // the whole component while resizing.
231
+ hubRef.current.style.width =
232
+ elt.clientWidth - 48 + 'px';
233
+ } }
234
+ handleComponent={ {
235
+ right: (
236
+ <ResizeHandle
237
+ direction="right"
238
+ variation="separator"
239
+ />
240
+ ),
241
+ } }
242
+ handleClasses={ undefined }
243
+ handleStyles={ {
244
+ right: emptyResizeHandleStyles,
245
+ } }
246
+ minWidth={ isResizingEnabled ? 320 : undefined }
247
+ maxWidth={
248
+ isResizingEnabled && fullSize
249
+ ? fullSize.width - 360
250
+ : undefined
251
+ }
172
252
  >
173
- <Sidebar />
174
- </NavigableRegion>
253
+ <NavigableRegion
254
+ ariaLabel={ __( 'Navigation sidebar' ) }
255
+ >
256
+ <Sidebar />
257
+ </NavigableRegion>
258
+ </ResizableBox>
175
259
  ) }
176
260
  </AnimatePresence>
177
261
 
178
262
  { showCanvas && (
179
263
  <div
180
- className="edit-site-layout__canvas-container"
264
+ className={ classnames(
265
+ 'edit-site-layout__canvas-container',
266
+ {
267
+ 'is-resizing': isResizing,
268
+ }
269
+ ) }
181
270
  style={ {
182
271
  paddingTop: showFrame ? canvasPadding : 0,
183
272
  paddingBottom: showFrame ? canvasPadding : 0,
@@ -191,9 +280,10 @@ export default function Layout( { onError } ) {
191
280
  className="edit-site-layout__canvas"
192
281
  transition={ {
193
282
  type: 'tween',
194
- duration: disableMotion
195
- ? 0
196
- : ANIMATION_DURATION,
283
+ duration:
284
+ disableMotion || isResizing
285
+ ? 0
286
+ : ANIMATION_DURATION,
197
287
  ease: 'easeOut',
198
288
  } }
199
289
  >
@@ -206,16 +296,14 @@ export default function Layout( { onError } ) {
206
296
  } }
207
297
  initial={ false }
208
298
  animate={ {
209
- width: showFrame
210
- ? canvasSize.width -
211
- canvasPadding
212
- : fullSize.width,
299
+ width: canvasWidth,
213
300
  } }
214
301
  transition={ {
215
302
  type: 'tween',
216
- duration: disableMotion
217
- ? 0
218
- : ANIMATION_DURATION,
303
+ duration:
304
+ disableMotion || isResizing
305
+ ? 0
306
+ : ANIMATION_DURATION,
219
307
  ease: 'easeOut',
220
308
  } }
221
309
  >
@@ -63,6 +63,7 @@ $hub-height: $grid-unit-20 * 2 + $button-size;
63
63
  .edit-site-layout__content {
64
64
  flex-grow: 1;
65
65
  display: flex;
66
+ gap: $canvas-padding;
66
67
 
67
68
  // Hide scrollbars during the edit/view animation.
68
69
  overflow: hidden;
@@ -70,9 +71,7 @@ $hub-height: $grid-unit-20 * 2 + $button-size;
70
71
 
71
72
  .edit-site-layout__sidebar {
72
73
  z-index: z-index(".edit-site-layout__sidebar");
73
- overflow-y: auto;
74
74
  width: 100vw;
75
- @include custom-scrollbars-on-hover;
76
75
 
77
76
  @include break-medium {
78
77
  width: $nav-sidebar-width;
@@ -80,17 +79,39 @@ $hub-height: $grid-unit-20 * 2 + $button-size;
80
79
 
81
80
  // This is only necessary for the exit animation
82
81
  .edit-site-layout.is-full-canvas & {
83
- position: fixed;
82
+ position: fixed !important;
84
83
  height: 100vh;
85
84
  left: 0;
86
85
  top: 0;
87
86
  }
87
+
88
+ .resizable-editor__drag-handle.is-right {
89
+ right: math.div(-$grid-unit-15, 2);
90
+ }
91
+
92
+ > div {
93
+ overflow-y: auto;
94
+ min-height: 100%;
95
+ @include custom-scrollbars-on-hover;
96
+ }
88
97
  }
89
98
 
90
99
  .edit-site-layout__canvas-container {
91
100
  position: relative;
92
101
  flex-grow: 1;
93
102
  z-index: z-index(".edit-site-layout__canvas-container");
103
+
104
+ &.is-resizing::after {
105
+ // This covers the whole content which ensures mouse up triggers
106
+ // even if the content is "inert".
107
+ position: absolute;
108
+ top: 0;
109
+ left: 0;
110
+ right: 0;
111
+ bottom: 0;
112
+ content: "";
113
+ z-index: z-index(".edit-site-layout__canvas-container.is-resizing::after");
114
+ }
94
115
  }
95
116
 
96
117
  .edit-site-layout__canvas {
@@ -99,12 +120,13 @@ $hub-height: $grid-unit-20 * 2 + $button-size;
99
120
  left: 0;
100
121
  bottom: 0;
101
122
  width: 100%;
102
- box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.8), 0 8px 10px -6px rgba(0, 0, 0, 0.8);
103
123
 
104
124
  & > div {
105
125
  color: $gray-900;
106
126
  background: $white;
127
+ box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.8), 0 8px 10px -6px rgba(0, 0, 0, 0.8);
107
128
  }
129
+
108
130
  @include break-medium {
109
131
  top: $canvas-padding;
110
132
  bottom: $canvas-padding;
@@ -125,7 +147,10 @@ $hub-height: $grid-unit-20 * 2 + $button-size;
125
147
  top: 0;
126
148
  bottom: 0;
127
149
  width: 100%;
128
- border-radius: 0;
150
+
151
+ & > div {
152
+ border-radius: 0;
153
+ }
129
154
  }
130
155
  }
131
156
 
@@ -180,6 +180,8 @@ export default function NavigationInspector() {
180
180
  ) }
181
181
  { hasResolvedNavigationMenus && hasMoreThanOneNavigationMenu && (
182
182
  <SelectControl
183
+ __nextHasNoMarginBottom
184
+ className="edit-site-navigation-inspector__select-menu"
183
185
  aria-controls={
184
186
  // aria-controls should only apply when referenced element is in DOM
185
187
  hasLoadedInnerBlocks ? navMenuListId : undefined
@@ -22,6 +22,10 @@
22
22
  .block-editor-list-view-block__menu-cell {
23
23
  padding-right: 0;
24
24
  }
25
+
26
+ .edit-site-navigation-inspector__select-menu {
27
+ margin-bottom: $grid-unit-10;
28
+ }
25
29
  }
26
30
 
27
31
  .edit-site-navigation-inspector__placeholder {
@@ -17,6 +17,7 @@ import { useReducedMotion, useViewportMatch } from '@wordpress/compose';
17
17
  import { __ } from '@wordpress/i18n';
18
18
  import { store as blockEditorStore } from '@wordpress/block-editor';
19
19
  import { store as coreStore } from '@wordpress/core-data';
20
+ import { forwardRef } from '@wordpress/element';
20
21
 
21
22
  /**
22
23
  * Internal dependencies
@@ -29,122 +30,132 @@ import useEditedEntityRecord from '../use-edited-entity-record';
29
30
 
30
31
  const HUB_ANIMATION_DURATION = 0.3;
31
32
 
32
- function SiteHub( {
33
- className,
34
- isMobileCanvasVisible,
35
- setIsMobileCanvasVisible,
36
- } ) {
37
- const { params } = useLocation();
38
- const isListPage = getIsListPage( params );
39
- const isEditorPage = ! isListPage;
40
- const { canvasMode, dashboardLink, entityConfig } = useSelect(
41
- ( select ) => {
42
- select( editSiteStore ).getEditedPostType();
43
- const { __unstableGetCanvasMode, getSettings, getEditedPostType } =
44
- select( editSiteStore );
45
- return {
46
- canvasMode: __unstableGetCanvasMode(),
47
- dashboardLink: getSettings().__experimentalDashboardLink,
48
- entityConfig: select( coreStore ).getEntityConfig(
49
- 'postType',
50
- getEditedPostType()
51
- ),
52
- };
53
- },
54
- []
55
- );
56
- const disableMotion = useReducedMotion();
57
- const isMobileViewport = useViewportMatch( 'medium', '<' );
58
- const { __unstableSetCanvasMode } = useDispatch( editSiteStore );
59
- const { clearSelectedBlock } = useDispatch( blockEditorStore );
60
- const showEditButton =
61
- ( isEditorPage && canvasMode === 'view' && ! isMobileViewport ) ||
62
- ( isMobileViewport && canvasMode === 'view' && isMobileCanvasVisible );
63
- const isBackToDashboardButton =
64
- ( ! isMobileViewport && canvasMode === 'view' ) ||
65
- ( isMobileViewport && ! isMobileCanvasVisible );
66
- const showLabels = canvasMode !== 'edit';
67
- const siteIconButtonProps = isBackToDashboardButton
68
- ? {
69
- href: dashboardLink || 'index.php',
70
- 'aria-label': __( 'Go back to the dashboard' ),
71
- }
72
- : {
73
- label: __( 'Open Navigation Sidebar' ),
74
- onClick: () => {
75
- clearSelectedBlock();
76
- setIsMobileCanvasVisible( false );
77
- __unstableSetCanvasMode( 'view' );
78
- },
79
- };
80
- const { getTitle } = useEditedEntityRecord();
33
+ const SiteHub = forwardRef(
34
+ ( { isMobileCanvasVisible, setIsMobileCanvasVisible, ...props }, ref ) => {
35
+ const { params } = useLocation();
36
+ const isListPage = getIsListPage( params );
37
+ const isEditorPage = ! isListPage;
38
+ const { canvasMode, dashboardLink, entityConfig } = useSelect(
39
+ ( select ) => {
40
+ select( editSiteStore ).getEditedPostType();
41
+ const {
42
+ __unstableGetCanvasMode,
43
+ getSettings,
44
+ getEditedPostType,
45
+ } = select( editSiteStore );
46
+ return {
47
+ canvasMode: __unstableGetCanvasMode(),
48
+ dashboardLink: getSettings().__experimentalDashboardLink,
49
+ entityConfig: select( coreStore ).getEntityConfig(
50
+ 'postType',
51
+ getEditedPostType()
52
+ ),
53
+ };
54
+ },
55
+ []
56
+ );
57
+ const disableMotion = useReducedMotion();
58
+ const isMobileViewport = useViewportMatch( 'medium', '<' );
59
+ const { __unstableSetCanvasMode } = useDispatch( editSiteStore );
60
+ const { clearSelectedBlock } = useDispatch( blockEditorStore );
61
+ const showEditButton =
62
+ ( isEditorPage && canvasMode === 'view' && ! isMobileViewport ) ||
63
+ ( isMobileViewport &&
64
+ canvasMode === 'view' &&
65
+ isMobileCanvasVisible );
66
+ const isBackToDashboardButton =
67
+ ( ! isMobileViewport && canvasMode === 'view' ) ||
68
+ ( isMobileViewport && ! isMobileCanvasVisible );
69
+ const showLabels = canvasMode !== 'edit';
70
+ const siteIconButtonProps = isBackToDashboardButton
71
+ ? {
72
+ href: dashboardLink || 'index.php',
73
+ 'aria-label': __( 'Go back to the dashboard' ),
74
+ }
75
+ : {
76
+ label: __( 'Open Navigation Sidebar' ),
77
+ onClick: () => {
78
+ clearSelectedBlock();
79
+ setIsMobileCanvasVisible( false );
80
+ __unstableSetCanvasMode( 'view' );
81
+ },
82
+ };
83
+ const { getTitle } = useEditedEntityRecord();
81
84
 
82
- return (
83
- <motion.div
84
- className={ classnames( 'edit-site-site-hub', className ) }
85
- layout
86
- transition={ {
87
- type: 'tween',
88
- duration: disableMotion ? 0 : HUB_ANIMATION_DURATION,
89
- ease: 'easeOut',
90
- } }
91
- >
92
- <HStack
93
- justify="flex-start"
94
- className="edit-site-site-hub__text-content"
85
+ return (
86
+ <motion.div
87
+ ref={ ref }
88
+ { ...props }
89
+ className={ classnames(
90
+ 'edit-site-site-hub',
91
+ props.className
92
+ ) }
93
+ layout
94
+ transition={ {
95
+ type: 'tween',
96
+ duration: disableMotion ? 0 : HUB_ANIMATION_DURATION,
97
+ ease: 'easeOut',
98
+ } }
95
99
  >
96
- <motion.div
97
- className="edit-site-site-hub__view-mode-toggle-container"
98
- layout
99
- transition={ {
100
- type: 'tween',
101
- duration: disableMotion ? 0 : HUB_ANIMATION_DURATION,
102
- ease: 'easeOut',
103
- } }
100
+ <HStack
101
+ justify="flex-start"
102
+ className="edit-site-site-hub__text-content"
104
103
  >
104
+ <motion.div
105
+ className="edit-site-site-hub__view-mode-toggle-container"
106
+ layout
107
+ transition={ {
108
+ type: 'tween',
109
+ duration: disableMotion
110
+ ? 0
111
+ : HUB_ANIMATION_DURATION,
112
+ ease: 'easeOut',
113
+ } }
114
+ >
115
+ <Button
116
+ { ...siteIconButtonProps }
117
+ className="edit-site-layout__view-mode-toggle"
118
+ >
119
+ <SiteIcon className="edit-site-layout__view-mode-toggle-icon" />
120
+ </Button>
121
+ </motion.div>
122
+
123
+ { showLabels && (
124
+ <VStack spacing={ 0 }>
125
+ <div className="edit-site-site-hub__title">
126
+ { getTitle() }
127
+ </div>
128
+ <div className="edit-site-site-hub__post-type">
129
+ { entityConfig?.label }
130
+ </div>
131
+ </VStack>
132
+ ) }
133
+ </HStack>
134
+
135
+ { showEditButton && (
105
136
  <Button
106
- { ...siteIconButtonProps }
107
- className="edit-site-layout__view-mode-toggle"
137
+ className="edit-site-site-hub__edit-button"
138
+ label={ __( 'Open the editor' ) }
139
+ onClick={ () => {
140
+ __unstableSetCanvasMode( 'edit' );
141
+ } }
142
+ variant="primary"
108
143
  >
109
- <SiteIcon className="edit-site-layout__view-mode-toggle-icon" />
144
+ { __( 'Edit' ) }
110
145
  </Button>
111
- </motion.div>
112
-
113
- { showLabels && (
114
- <VStack spacing={ 0 }>
115
- <div className="edit-site-site-hub__title">
116
- { getTitle() }
117
- </div>
118
- <div className="edit-site-site-hub__post-type">
119
- { entityConfig?.label }
120
- </div>
121
- </VStack>
122
146
  ) }
123
- </HStack>
124
-
125
- { showEditButton && (
126
- <Button
127
- className="edit-site-site-hub__edit-button"
128
- label={ __( 'Open the editor' ) }
129
- onClick={ () => {
130
- __unstableSetCanvasMode( 'edit' );
131
- } }
132
- variant="primary"
133
- >
134
- { __( 'Edit' ) }
135
- </Button>
136
- ) }
137
147
 
138
- { isMobileViewport && ! isMobileCanvasVisible && (
139
- <Button
140
- onClick={ () => setIsMobileCanvasVisible( true ) }
141
- variant="primary"
142
- >
143
- { __( 'View Editor' ) }
144
- </Button>
145
- ) }
146
- </motion.div>
147
- );
148
- }
148
+ { isMobileViewport && ! isMobileCanvasVisible && (
149
+ <Button
150
+ onClick={ () => setIsMobileCanvasVisible( true ) }
151
+ variant="primary"
152
+ >
153
+ { __( 'View Editor' ) }
154
+ </Button>
155
+ ) }
156
+ </motion.div>
157
+ );
158
+ }
159
+ );
149
160
 
150
161
  export default SiteHub;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useEffect, useRef } from '@wordpress/element';
5
+ import { useSelect, useDispatch } from '@wordpress/data';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { store as editSiteStore } from '../../store';
11
+ import { useLocation, useHistory } from '../routes';
12
+
13
+ export default function useSyncCanvasModeWithURL() {
14
+ const history = useHistory();
15
+ const { params } = useLocation();
16
+ const canvasMode = useSelect(
17
+ ( select ) => select( editSiteStore ).__unstableGetCanvasMode(),
18
+ []
19
+ );
20
+ const { __unstableSetCanvasMode } = useDispatch( editSiteStore );
21
+ const currentCanvasMode = useRef( canvasMode );
22
+ const { canvas: canvasInUrl = 'view' } = params;
23
+ const currentCanvasInUrl = useRef( canvasInUrl );
24
+ useEffect( () => {
25
+ currentCanvasMode.current = canvasMode;
26
+ if ( currentCanvasMode !== currentCanvasInUrl ) {
27
+ history.push( {
28
+ ...params,
29
+ canvas: canvasMode,
30
+ } );
31
+ }
32
+ }, [ canvasMode ] );
33
+
34
+ useEffect( () => {
35
+ currentCanvasInUrl.current = canvasInUrl;
36
+ if ( canvasInUrl !== currentCanvasMode.current ) {
37
+ __unstableSetCanvasMode( canvasInUrl );
38
+ }
39
+ }, [ canvasInUrl ] );
40
+ }
@@ -17,6 +17,7 @@ export default function EditTemplateTitle( { template } ) {
17
17
 
18
18
  return (
19
19
  <TextControl
20
+ __nextHasNoMarginBottom
20
21
  label={ __( 'Title' ) }
21
22
  value={ forceEmpty ? '' : title }
22
23
  help={
@@ -28,6 +28,7 @@ export default function TemplatePartAreaSelector( { id } ) {
28
28
 
29
29
  return (
30
30
  <SelectControl
31
+ __nextHasNoMarginBottom
31
32
  label={ __( 'Area' ) }
32
33
  labelPosition="top"
33
34
  options={ areaOptions }
@@ -97,7 +97,7 @@ function PushChangesToGlobalStylesControl( {
97
97
  createSuccessNotice(
98
98
  sprintf(
99
99
  // translators: %s: Title of the block e.g. 'Heading'.
100
- __( 'Pushed styles to all %s blocks.' ),
100
+ __( '%s styles applied.' ),
101
101
  getBlockType( name ).title
102
102
  ),
103
103
  {
@@ -124,7 +124,7 @@ function PushChangesToGlobalStylesControl( {
124
124
  help={ sprintf(
125
125
  // translators: %s: Title of the block e.g. 'Heading'.
126
126
  __(
127
- 'Move this block’s typography, spacing, dimensions, and color styles to all %s blocks.'
127
+ 'Apply this block’s typography, spacing, dimensions, and color styles to all %s blocks.'
128
128
  ),
129
129
  getBlockType( name ).title
130
130
  ) }
@@ -137,7 +137,7 @@ function PushChangesToGlobalStylesControl( {
137
137
  disabled={ changes.length === 0 }
138
138
  onClick={ pushChanges }
139
139
  >
140
- { __( 'Push changes to Global Styles' ) }
140
+ { __( 'Apply globally' ) }
141
141
  </Button>
142
142
  </BaseControl>
143
143
  );
@@ -131,7 +131,7 @@ export function saveViewPanel( state = false, action ) {
131
131
  * @param {Object} state Current state.
132
132
  * @param {Object} action Dispatched action.
133
133
  */
134
- function canvasMode( state = 'view', action ) {
134
+ function canvasMode( state = 'init', action ) {
135
135
  switch ( action.type ) {
136
136
  case 'SET_CANVAS_MODE':
137
137
  return action.mode;