@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.
- package/CHANGELOG.md +2 -0
- package/LICENSE.md +1 -1
- package/build/components/add-new-template/new-template-part.js +21 -1
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/utils.js +9 -1
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +0 -1
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/block-editor/index.js +15 -51
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/resize-handle.js +2 -1
- package/build/components/block-editor/resize-handle.js.map +1 -1
- package/build/components/editor/index.js +1 -1
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/block-preview-panel.js +8 -2
- package/build/components/global-styles/block-preview-panel.js.map +1 -1
- package/build/components/global-styles/border-panel.js +5 -4
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/context-menu.js +9 -1
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +16 -11
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +6 -5
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +4 -1
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-border.js +9 -3
- package/build/components/global-styles/screen-border.js.map +1 -1
- package/build/components/global-styles/screen-button-color.js +3 -2
- package/build/components/global-styles/screen-button-color.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +50 -26
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-heading-color.js +8 -7
- package/build/components/global-styles/screen-heading-color.js.map +1 -1
- package/build/components/global-styles/screen-layout.js +9 -3
- package/build/components/global-styles/screen-layout.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +8 -7
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +4 -3
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +8 -2
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/screen-variations.js +71 -0
- package/build/components/global-styles/screen-variations.js.map +1 -0
- package/build/components/global-styles/typography-panel.js +9 -8
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +85 -18
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +119 -33
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +49 -2
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/global-styles/variations-panel.js +85 -0
- package/build/components/global-styles/variations-panel.js.map +1 -0
- package/build/components/layout/index.js +81 -8
- package/build/components/layout/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js +2 -0
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +1 -1
- package/build/components/site-hub/index.js +9 -9
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +54 -0
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -0
- package/build/components/template-details/edit-template-title.js +1 -0
- package/build/components/template-details/edit-template-title.js.map +1 -1
- package/build/components/template-details/template-part-area-selector.js +1 -0
- package/build/components/template-details/template-part-area-selector.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +3 -3
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/store/reducer.js +1 -1
- package/build/store/reducer.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +20 -1
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +5 -0
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +0 -1
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/index.js +17 -49
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/block-editor/resize-handle.js +2 -1
- package/build-module/components/block-editor/resize-handle.js.map +1 -1
- package/build-module/components/editor/index.js +1 -1
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/block-preview-panel.js +8 -2
- package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +5 -4
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +7 -1
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +16 -11
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +6 -5
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +3 -1
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-border.js +8 -3
- package/build-module/components/global-styles/screen-border.js.map +1 -1
- package/build-module/components/global-styles/screen-button-color.js +3 -2
- package/build-module/components/global-styles/screen-button-color.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +49 -26
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-heading-color.js +8 -7
- package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
- package/build-module/components/global-styles/screen-layout.js +8 -3
- package/build-module/components/global-styles/screen-layout.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +8 -7
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +4 -3
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +7 -2
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/screen-variations.js +54 -0
- package/build-module/components/global-styles/screen-variations.js.map +1 -0
- package/build-module/components/global-styles/typography-panel.js +9 -8
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +84 -19
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +121 -35
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +47 -2
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/global-styles/variations-panel.js +68 -0
- package/build-module/components/global-styles/variations-panel.js.map +1 -0
- package/build-module/components/layout/index.js +81 -10
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js +2 -0
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +1 -1
- package/build-module/components/site-hub/index.js +10 -9
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +43 -0
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -0
- package/build-module/components/template-details/edit-template-title.js +1 -0
- package/build-module/components/template-details/edit-template-title.js.map +1 -1
- package/build-module/components/template-details/template-part-area-selector.js +1 -0
- package/build-module/components/template-details/template-part-area-selector.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +3 -3
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/store/reducer.js +1 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-style/style-rtl.css +93 -21
- package/build-style/style.css +93 -21
- package/package.json +30 -30
- package/src/components/add-new-template/new-template-part.js +23 -1
- package/src/components/add-new-template/utils.js +14 -0
- package/src/components/block-editor/editor-canvas.js +0 -1
- package/src/components/block-editor/index.js +11 -54
- package/src/components/block-editor/resize-handle.js +6 -2
- package/src/components/block-editor/style.scss +43 -7
- package/src/components/editor/index.js +1 -1
- package/src/components/global-styles/block-preview-panel.js +14 -2
- package/src/components/global-styles/border-panel.js +8 -4
- package/src/components/global-styles/context-menu.js +6 -0
- package/src/components/global-styles/dimensions-panel.js +32 -15
- package/src/components/global-styles/screen-background-color.js +12 -5
- package/src/components/global-styles/screen-block-list.js +6 -1
- package/src/components/global-styles/screen-border.js +7 -4
- package/src/components/global-styles/screen-button-color.js +2 -2
- package/src/components/global-styles/screen-colors.js +82 -21
- package/src/components/global-styles/screen-heading-color.js +7 -7
- package/src/components/global-styles/screen-layout.js +10 -4
- package/src/components/global-styles/screen-link-color.js +19 -7
- package/src/components/global-styles/screen-text-color.js +7 -3
- package/src/components/global-styles/screen-typography.js +11 -4
- package/src/components/global-styles/screen-variations.js +47 -0
- package/src/components/global-styles/style.scss +9 -0
- package/src/components/global-styles/test/use-global-styles-output.js +1 -1
- package/src/components/global-styles/typography-panel.js +31 -8
- package/src/components/global-styles/ui.js +101 -13
- package/src/components/global-styles/use-global-styles-output.js +137 -14
- package/src/components/global-styles/utils.js +46 -2
- package/src/components/global-styles/variations-panel.js +78 -0
- package/src/components/layout/index.js +107 -19
- package/src/components/layout/style.scss +30 -5
- package/src/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js +2 -0
- package/src/components/sidebar-edit-mode/navigation-menu-sidebar/style.scss +4 -0
- package/src/components/site-hub/index.js +120 -109
- package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +40 -0
- package/src/components/template-details/edit-template-title.js +1 -0
- package/src/components/template-details/template-part-area-selector.js +1 -0
- package/src/hooks/push-changes-to-global-styles/index.js +3 -3
- 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
|
-
<
|
|
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:
|
|
166
|
-
|
|
167
|
-
|
|
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
|
-
|
|
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
|
-
<
|
|
174
|
-
|
|
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=
|
|
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:
|
|
195
|
-
|
|
196
|
-
|
|
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:
|
|
210
|
-
? canvasSize.width -
|
|
211
|
-
canvasPadding
|
|
212
|
-
: fullSize.width,
|
|
299
|
+
width: canvasWidth,
|
|
213
300
|
} }
|
|
214
301
|
transition={ {
|
|
215
302
|
type: 'tween',
|
|
216
|
-
duration:
|
|
217
|
-
|
|
218
|
-
|
|
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
|
-
|
|
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
|
|
@@ -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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
select( editSiteStore );
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
107
|
-
|
|
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
|
-
|
|
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
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
+
}
|
|
@@ -97,7 +97,7 @@ function PushChangesToGlobalStylesControl( {
|
|
|
97
97
|
createSuccessNotice(
|
|
98
98
|
sprintf(
|
|
99
99
|
// translators: %s: Title of the block e.g. 'Heading'.
|
|
100
|
-
__( '
|
|
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
|
-
'
|
|
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
|
-
{ __( '
|
|
140
|
+
{ __( 'Apply globally' ) }
|
|
141
141
|
</Button>
|
|
142
142
|
</BaseControl>
|
|
143
143
|
);
|
package/src/store/reducer.js
CHANGED
|
@@ -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 = '
|
|
134
|
+
function canvasMode( state = 'init', action ) {
|
|
135
135
|
switch ( action.type ) {
|
|
136
136
|
case 'SET_CANVAS_MODE':
|
|
137
137
|
return action.mode;
|