@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
|
@@ -7,7 +7,7 @@ import classnames from 'classnames';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
10
|
-
import { useCallback, useMemo, useRef
|
|
10
|
+
import { useCallback, useMemo, useRef } from '@wordpress/element';
|
|
11
11
|
import {
|
|
12
12
|
useEntityBlockEditor,
|
|
13
13
|
__experimentalFetchMedia as fetchMedia,
|
|
@@ -19,12 +19,10 @@ import {
|
|
|
19
19
|
__experimentalLinkControl,
|
|
20
20
|
BlockInspector,
|
|
21
21
|
BlockTools,
|
|
22
|
-
|
|
23
|
-
__unstableBlockSettingsMenuFirstItem,
|
|
22
|
+
__unstableUseClipboardHandler as useClipboardHandler,
|
|
24
23
|
__unstableUseTypingObserver as useTypingObserver,
|
|
25
24
|
BlockEditorKeyboardShortcuts,
|
|
26
25
|
store as blockEditorStore,
|
|
27
|
-
__unstableBlockNameContext,
|
|
28
26
|
} from '@wordpress/block-editor';
|
|
29
27
|
import {
|
|
30
28
|
useMergeRefs,
|
|
@@ -32,9 +30,6 @@ import {
|
|
|
32
30
|
useResizeObserver,
|
|
33
31
|
} from '@wordpress/compose';
|
|
34
32
|
import { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';
|
|
35
|
-
import { listView } from '@wordpress/icons';
|
|
36
|
-
import { ToolbarButton, ToolbarGroup } from '@wordpress/components';
|
|
37
|
-
import { __ } from '@wordpress/i18n';
|
|
38
33
|
|
|
39
34
|
/**
|
|
40
35
|
* Internal dependencies
|
|
@@ -43,7 +38,6 @@ import TemplatePartConverter from '../template-part-converter';
|
|
|
43
38
|
import NavigateToLink from '../navigate-to-link';
|
|
44
39
|
import { SidebarInspectorFill } from '../sidebar-edit-mode';
|
|
45
40
|
import { store as editSiteStore } from '../../store';
|
|
46
|
-
import BlockInspectorButton from './block-inspector-button';
|
|
47
41
|
import BackButton from './back-button';
|
|
48
42
|
import ResizableEditor from './resizable-editor';
|
|
49
43
|
import EditorCanvas from './editor-canvas';
|
|
@@ -55,19 +49,20 @@ const LAYOUT = {
|
|
|
55
49
|
alignments: [],
|
|
56
50
|
};
|
|
57
51
|
|
|
58
|
-
export default function BlockEditor(
|
|
52
|
+
export default function BlockEditor() {
|
|
53
|
+
const { setPage, setIsInserterOpened } = useDispatch( editSiteStore );
|
|
59
54
|
const { storedSettings, templateType, canvasMode } = useSelect(
|
|
60
55
|
( select ) => {
|
|
61
56
|
const { getSettings, getEditedPostType, __unstableGetCanvasMode } =
|
|
62
57
|
select( editSiteStore );
|
|
63
58
|
|
|
64
59
|
return {
|
|
65
|
-
storedSettings: getSettings(
|
|
60
|
+
storedSettings: getSettings( setIsInserterOpened ),
|
|
66
61
|
templateType: getEditedPostType(),
|
|
67
62
|
canvasMode: __unstableGetCanvasMode(),
|
|
68
63
|
};
|
|
69
64
|
},
|
|
70
|
-
[
|
|
65
|
+
[ setIsInserterOpened ]
|
|
71
66
|
);
|
|
72
67
|
|
|
73
68
|
const settingsBlockPatterns =
|
|
@@ -137,10 +132,13 @@ export default function BlockEditor( { setIsInserterOpen } ) {
|
|
|
137
132
|
'postType',
|
|
138
133
|
templateType
|
|
139
134
|
);
|
|
140
|
-
const { setPage } = useDispatch( editSiteStore );
|
|
141
135
|
|
|
142
136
|
const contentRef = useRef();
|
|
143
|
-
const mergedRefs = useMergeRefs( [
|
|
137
|
+
const mergedRefs = useMergeRefs( [
|
|
138
|
+
contentRef,
|
|
139
|
+
useClipboardHandler(),
|
|
140
|
+
useTypingObserver(),
|
|
141
|
+
] );
|
|
144
142
|
const isMobileViewport = useViewportMatch( 'small', '<' );
|
|
145
143
|
const { clearSelectedBlock } = useDispatch( blockEditorStore );
|
|
146
144
|
const [ resizeObserver, sizes ] = useResizeObserver();
|
|
@@ -156,33 +154,6 @@ export default function BlockEditor( { setIsInserterOpen } ) {
|
|
|
156
154
|
const showBlockAppender =
|
|
157
155
|
( isTemplatePart && hasBlocks ) || isViewMode ? false : undefined;
|
|
158
156
|
|
|
159
|
-
// eslint-disable-next-line @wordpress/data-no-store-string-literals
|
|
160
|
-
const { enableComplementaryArea } = useDispatch( 'core/interface' );
|
|
161
|
-
|
|
162
|
-
const NavMenuSidebarToggle = () => (
|
|
163
|
-
<ToolbarGroup>
|
|
164
|
-
<ToolbarButton
|
|
165
|
-
className="components-toolbar__control"
|
|
166
|
-
label={ __( 'Open navigation list view' ) }
|
|
167
|
-
onClick={ () =>
|
|
168
|
-
enableComplementaryArea(
|
|
169
|
-
'core/edit-site',
|
|
170
|
-
'edit-site/block-inspector'
|
|
171
|
-
)
|
|
172
|
-
}
|
|
173
|
-
icon={ listView }
|
|
174
|
-
/>
|
|
175
|
-
</ToolbarGroup>
|
|
176
|
-
);
|
|
177
|
-
|
|
178
|
-
let MaybeNavMenuSidebarToggle = Fragment;
|
|
179
|
-
const isOffCanvasNavigationEditorEnabled =
|
|
180
|
-
window?.__experimentalEnableOffCanvasNavigationEditor === true;
|
|
181
|
-
|
|
182
|
-
if ( isOffCanvasNavigationEditorEnabled ) {
|
|
183
|
-
MaybeNavMenuSidebarToggle = NavMenuSidebarToggle;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
157
|
return (
|
|
187
158
|
<BlockEditorProvider
|
|
188
159
|
settings={ settings }
|
|
@@ -249,20 +220,6 @@ export default function BlockEditor( { setIsInserterOpen } ) {
|
|
|
249
220
|
/>
|
|
250
221
|
</EditorCanvas>
|
|
251
222
|
</ResizableEditor>
|
|
252
|
-
<__unstableBlockSettingsMenuFirstItem>
|
|
253
|
-
{ ( { onClose } ) => (
|
|
254
|
-
<BlockInspectorButton onClick={ onClose } />
|
|
255
|
-
) }
|
|
256
|
-
</__unstableBlockSettingsMenuFirstItem>
|
|
257
|
-
<__unstableBlockToolbarLastItem>
|
|
258
|
-
<__unstableBlockNameContext.Consumer>
|
|
259
|
-
{ ( blockName ) =>
|
|
260
|
-
blockName === 'core/navigation' && (
|
|
261
|
-
<MaybeNavMenuSidebarToggle />
|
|
262
|
-
)
|
|
263
|
-
}
|
|
264
|
-
</__unstableBlockNameContext.Consumer>
|
|
265
|
-
</__unstableBlockToolbarLastItem>
|
|
266
223
|
</BlockTools>
|
|
267
224
|
)
|
|
268
225
|
}
|
|
@@ -7,7 +7,11 @@ import { VisuallyHidden } from '@wordpress/components';
|
|
|
7
7
|
|
|
8
8
|
const DELTA_DISTANCE = 20; // The distance to resize per keydown in pixels.
|
|
9
9
|
|
|
10
|
-
export default function ResizeHandle( {
|
|
10
|
+
export default function ResizeHandle( {
|
|
11
|
+
variation = 'default',
|
|
12
|
+
direction,
|
|
13
|
+
resizeWidthBy,
|
|
14
|
+
} ) {
|
|
11
15
|
function handleKeyDown( event ) {
|
|
12
16
|
const { keyCode } = event;
|
|
13
17
|
|
|
@@ -27,7 +31,7 @@ export default function ResizeHandle( { direction, resizeWidthBy } ) {
|
|
|
27
31
|
return (
|
|
28
32
|
<>
|
|
29
33
|
<button
|
|
30
|
-
className={ `resizable-editor__drag-handle is-${ direction }` }
|
|
34
|
+
className={ `resizable-editor__drag-handle is-${ direction } is-variation-${ variation }` }
|
|
31
35
|
aria-label={ __( 'Drag to resize' ) }
|
|
32
36
|
aria-describedby={ `resizable-editor__resize-help-${ direction }` }
|
|
33
37
|
onKeyDown={ handleKeyDown }
|
|
@@ -78,21 +78,50 @@
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
.resizable-editor__drag-handle {
|
|
81
|
-
$height: 100px;
|
|
82
81
|
position: absolute;
|
|
83
82
|
top: 0;
|
|
84
83
|
bottom: 0;
|
|
85
84
|
padding: 0;
|
|
86
85
|
margin: auto 0;
|
|
87
|
-
width: $grid-unit-
|
|
88
|
-
height: $height;
|
|
86
|
+
width: $grid-unit-15;
|
|
89
87
|
appearance: none;
|
|
90
88
|
cursor: ew-resize;
|
|
91
89
|
outline: none;
|
|
92
|
-
background:
|
|
93
|
-
border-radius:
|
|
90
|
+
background: none;
|
|
91
|
+
border-radius: $radius-block-ui;
|
|
94
92
|
border: 0;
|
|
95
93
|
|
|
94
|
+
&.is-variation-default {
|
|
95
|
+
height: 100px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&.is-variation-separator {
|
|
99
|
+
height: 100%;
|
|
100
|
+
|
|
101
|
+
&::after {
|
|
102
|
+
width: 1px;
|
|
103
|
+
border-radius: 0;
|
|
104
|
+
background: $gray-800;
|
|
105
|
+
left: auto;
|
|
106
|
+
right: 50%;
|
|
107
|
+
transition: all ease 0.2s;
|
|
108
|
+
transition-delay: 0.1s;
|
|
109
|
+
@include reduce-motion;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
&::after {
|
|
114
|
+
position: absolute;
|
|
115
|
+
top: 0;
|
|
116
|
+
left: $grid-unit-05;
|
|
117
|
+
right: 0;
|
|
118
|
+
bottom: 0;
|
|
119
|
+
content: "";
|
|
120
|
+
width: $grid-unit-05;
|
|
121
|
+
background: $gray-600;
|
|
122
|
+
border-radius: $radius-block-ui;
|
|
123
|
+
}
|
|
124
|
+
|
|
96
125
|
&.is-left {
|
|
97
126
|
left: -$grid-unit-20;
|
|
98
127
|
}
|
|
@@ -103,10 +132,17 @@
|
|
|
103
132
|
|
|
104
133
|
&:hover,
|
|
105
134
|
&:active {
|
|
106
|
-
|
|
135
|
+
opacity: 1;
|
|
136
|
+
&.is-variation-default::after {
|
|
137
|
+
background: $gray-400;
|
|
138
|
+
}
|
|
139
|
+
&.is-variation-separator::after {
|
|
140
|
+
width: 2px;
|
|
141
|
+
background: var(--wp-admin-theme-color);
|
|
142
|
+
}
|
|
107
143
|
}
|
|
108
144
|
|
|
109
|
-
&:focus {
|
|
145
|
+
&:focus::after {
|
|
110
146
|
box-shadow: 0 0 0 1px $gray-800, 0 0 0 calc(var(--wp-admin-border-width-focus) + 1px) var(--wp-admin-theme-color);
|
|
111
147
|
}
|
|
112
148
|
}
|
|
@@ -6,13 +6,25 @@ import { getBlockType, getBlockFromExample } from '@wordpress/blocks';
|
|
|
6
6
|
import { useResizeObserver } from '@wordpress/compose';
|
|
7
7
|
import { __experimentalSpacer as Spacer } from '@wordpress/components';
|
|
8
8
|
|
|
9
|
-
const BlockPreviewPanel = ( { name } ) => {
|
|
9
|
+
const BlockPreviewPanel = ( { name, variation = '' } ) => {
|
|
10
10
|
const [
|
|
11
11
|
containerResizeListener,
|
|
12
12
|
{ width: containerWidth, height: containerHeight },
|
|
13
13
|
] = useResizeObserver();
|
|
14
14
|
const blockExample = getBlockType( name )?.example;
|
|
15
|
-
const
|
|
15
|
+
const blockExampleWithVariation = {
|
|
16
|
+
...blockExample,
|
|
17
|
+
attributes: {
|
|
18
|
+
...blockExample?.attributes,
|
|
19
|
+
className: variation,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
const blocks =
|
|
23
|
+
blockExample &&
|
|
24
|
+
getBlockFromExample(
|
|
25
|
+
name,
|
|
26
|
+
variation ? blockExampleWithVariation : blockExample
|
|
27
|
+
);
|
|
16
28
|
const viewportWidth = blockExample?.viewportWidth || containerWidth;
|
|
17
29
|
const minHeight = containerHeight;
|
|
18
30
|
|
|
@@ -94,11 +94,15 @@ function applyAllFallbackStyles( border ) {
|
|
|
94
94
|
return applyFallbackStyle( border );
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
export default function BorderPanel( { name } ) {
|
|
97
|
+
export default function BorderPanel( { name, variationPath = '' } ) {
|
|
98
98
|
// To better reflect if the user has customized a value we need to
|
|
99
99
|
// ensure the style value being checked is from the `user` origin.
|
|
100
|
-
const [ userBorderStyles ] = useStyle(
|
|
101
|
-
|
|
100
|
+
const [ userBorderStyles ] = useStyle(
|
|
101
|
+
`${ variationPath }border`,
|
|
102
|
+
name,
|
|
103
|
+
'user'
|
|
104
|
+
);
|
|
105
|
+
const [ border, setBorder ] = useStyle( `${ variationPath }border`, name );
|
|
102
106
|
const colors = useColorsPerOrigin( name );
|
|
103
107
|
|
|
104
108
|
const showBorderColor = useHasBorderColorControl( name );
|
|
@@ -108,7 +112,7 @@ export default function BorderPanel( { name } ) {
|
|
|
108
112
|
// Border radius.
|
|
109
113
|
const showBorderRadius = useHasBorderRadiusControl( name );
|
|
110
114
|
const [ borderRadiusValues, setBorderRadius ] = useStyle(
|
|
111
|
-
|
|
115
|
+
`${ variationPath }border.radius`,
|
|
112
116
|
name
|
|
113
117
|
);
|
|
114
118
|
const hasBorderRadius = () => {
|
|
@@ -12,7 +12,9 @@ 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 { useHasVariationsPanel } from './variations-panel';
|
|
15
16
|
import { NavigationButtonAsItem } from './navigation-button';
|
|
17
|
+
import { ScreenVariations } from './screen-variations';
|
|
16
18
|
|
|
17
19
|
function ContextMenu( { name, parentMenu = '' } ) {
|
|
18
20
|
const hasTypographyPanel = useHasTypographyPanel( name );
|
|
@@ -20,6 +22,7 @@ function ContextMenu( { name, parentMenu = '' } ) {
|
|
|
20
22
|
const hasBorderPanel = useHasBorderPanel( name );
|
|
21
23
|
const hasDimensionsPanel = useHasDimensionsPanel( name );
|
|
22
24
|
const hasLayoutPanel = hasDimensionsPanel;
|
|
25
|
+
const hasVariationsPanel = useHasVariationsPanel( name, parentMenu );
|
|
23
26
|
|
|
24
27
|
return (
|
|
25
28
|
<ItemGroup>
|
|
@@ -59,6 +62,9 @@ function ContextMenu( { name, parentMenu = '' } ) {
|
|
|
59
62
|
{ __( 'Layout' ) }
|
|
60
63
|
</NavigationButtonAsItem>
|
|
61
64
|
) }
|
|
65
|
+
{ hasVariationsPanel && (
|
|
66
|
+
<ScreenVariations name={ name } path={ parentMenu } />
|
|
67
|
+
) }
|
|
62
68
|
</ItemGroup>
|
|
63
69
|
);
|
|
64
70
|
}
|
|
@@ -197,8 +197,11 @@ function useWideSizeProps( name ) {
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
// Props for managing `spacing.padding`.
|
|
200
|
-
function usePaddingProps( name ) {
|
|
201
|
-
const [ rawPadding, setRawPadding ] = useStyle(
|
|
200
|
+
function usePaddingProps( name, variationPath = '' ) {
|
|
201
|
+
const [ rawPadding, setRawPadding ] = useStyle(
|
|
202
|
+
variationPath + 'spacing.padding',
|
|
203
|
+
name
|
|
204
|
+
);
|
|
202
205
|
const paddingValues = splitStyleValue( rawPadding );
|
|
203
206
|
const paddingSides = useCustomSides( name, 'padding' );
|
|
204
207
|
const isAxialPadding =
|
|
@@ -210,7 +213,11 @@ function usePaddingProps( name ) {
|
|
|
210
213
|
setRawPadding( padding );
|
|
211
214
|
};
|
|
212
215
|
const resetPaddingValue = () => setPaddingValues( {} );
|
|
213
|
-
const [ userSetPaddingValue ] = useStyle(
|
|
216
|
+
const [ userSetPaddingValue ] = useStyle(
|
|
217
|
+
variationPath + 'spacing.padding',
|
|
218
|
+
name,
|
|
219
|
+
'user'
|
|
220
|
+
);
|
|
214
221
|
// The `hasPaddingValue` check does not need a parsed value, as `userSetPaddingValue` will be `undefined` if not set.
|
|
215
222
|
const hasPaddingValue = () => !! userSetPaddingValue;
|
|
216
223
|
|
|
@@ -225,8 +232,11 @@ function usePaddingProps( name ) {
|
|
|
225
232
|
}
|
|
226
233
|
|
|
227
234
|
// Props for managing `spacing.margin`.
|
|
228
|
-
function useMarginProps( name ) {
|
|
229
|
-
const [ rawMargin, setRawMargin ] = useStyle(
|
|
235
|
+
function useMarginProps( name, variationPath = '' ) {
|
|
236
|
+
const [ rawMargin, setRawMargin ] = useStyle(
|
|
237
|
+
variationPath + 'spacing.margin',
|
|
238
|
+
name
|
|
239
|
+
);
|
|
230
240
|
const marginValues = splitStyleValue( rawMargin );
|
|
231
241
|
const marginSides = useCustomSides( name, 'margin' );
|
|
232
242
|
const isAxialMargin =
|
|
@@ -252,14 +262,21 @@ function useMarginProps( name ) {
|
|
|
252
262
|
}
|
|
253
263
|
|
|
254
264
|
// Props for managing `spacing.blockGap`.
|
|
255
|
-
function useBlockGapProps( name ) {
|
|
256
|
-
const [ gapValue, setGapValue ] = useStyle(
|
|
265
|
+
function useBlockGapProps( name, variationPath = '' ) {
|
|
266
|
+
const [ gapValue, setGapValue ] = useStyle(
|
|
267
|
+
variationPath + 'spacing.blockGap',
|
|
268
|
+
name
|
|
269
|
+
);
|
|
257
270
|
const gapValues = splitGapValue( gapValue );
|
|
258
271
|
const gapSides = useCustomSides( name, 'blockGap' );
|
|
259
272
|
const isAxialGap =
|
|
260
273
|
gapSides && gapSides.some( ( side ) => AXIAL_SIDES.includes( side ) );
|
|
261
274
|
const resetGapValue = () => setGapValue( undefined );
|
|
262
|
-
const [ userSetGapValue ] = useStyle(
|
|
275
|
+
const [ userSetGapValue ] = useStyle(
|
|
276
|
+
variationPath + 'spacing.blockGap',
|
|
277
|
+
name,
|
|
278
|
+
'user'
|
|
279
|
+
);
|
|
263
280
|
const hasGapValue = () => !! userSetGapValue;
|
|
264
281
|
const setGapValues = ( nextBoxGapValue ) => {
|
|
265
282
|
if ( ! nextBoxGapValue ) {
|
|
@@ -288,9 +305,9 @@ function useBlockGapProps( name ) {
|
|
|
288
305
|
}
|
|
289
306
|
|
|
290
307
|
// Props for managing `dimensions.minHeight`.
|
|
291
|
-
function useMinHeightProps( name ) {
|
|
308
|
+
function useMinHeightProps( name, variationPath = '' ) {
|
|
292
309
|
const [ minHeightValue, setMinHeightValue ] = useStyle(
|
|
293
|
-
'dimensions.minHeight',
|
|
310
|
+
variationPath + 'dimensions.minHeight',
|
|
294
311
|
name
|
|
295
312
|
);
|
|
296
313
|
const resetMinHeightValue = () => setMinHeightValue( undefined );
|
|
@@ -303,7 +320,7 @@ function useMinHeightProps( name ) {
|
|
|
303
320
|
};
|
|
304
321
|
}
|
|
305
322
|
|
|
306
|
-
export default function DimensionsPanel( { name } ) {
|
|
323
|
+
export default function DimensionsPanel( { name, variationPath = '' } ) {
|
|
307
324
|
const showContentSizeControl = useHasContentSize( name );
|
|
308
325
|
const showWideSizeControl = useHasWideSize( name );
|
|
309
326
|
const showPaddingControl = useHasPadding( name );
|
|
@@ -345,7 +362,7 @@ export default function DimensionsPanel( { name } ) {
|
|
|
345
362
|
setPaddingValues,
|
|
346
363
|
resetPaddingValue,
|
|
347
364
|
hasPaddingValue,
|
|
348
|
-
} = usePaddingProps( name );
|
|
365
|
+
} = usePaddingProps( name, variationPath );
|
|
349
366
|
|
|
350
367
|
// Props for managing `spacing.margin`.
|
|
351
368
|
const {
|
|
@@ -355,7 +372,7 @@ export default function DimensionsPanel( { name } ) {
|
|
|
355
372
|
setMarginValues,
|
|
356
373
|
resetMarginValue,
|
|
357
374
|
hasMarginValue,
|
|
358
|
-
} = useMarginProps( name );
|
|
375
|
+
} = useMarginProps( name, variationPath );
|
|
359
376
|
|
|
360
377
|
// Props for managing `spacing.blockGap`.
|
|
361
378
|
const {
|
|
@@ -367,7 +384,7 @@ export default function DimensionsPanel( { name } ) {
|
|
|
367
384
|
setGapValues,
|
|
368
385
|
resetGapValue,
|
|
369
386
|
hasGapValue,
|
|
370
|
-
} = useBlockGapProps( name );
|
|
387
|
+
} = useBlockGapProps( name, variationPath );
|
|
371
388
|
|
|
372
389
|
// Props for managing `dimensions.minHeight`.
|
|
373
390
|
const {
|
|
@@ -375,7 +392,7 @@ export default function DimensionsPanel( { name } ) {
|
|
|
375
392
|
setMinHeightValue,
|
|
376
393
|
resetMinHeightValue,
|
|
377
394
|
hasMinHeightValue,
|
|
378
|
-
} = useMinHeightProps( name );
|
|
395
|
+
} = useMinHeightProps( name, variationPath );
|
|
379
396
|
|
|
380
397
|
const resetAll = () => {
|
|
381
398
|
resetPaddingValue();
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
useStyle,
|
|
17
17
|
} from './hooks';
|
|
18
18
|
|
|
19
|
-
function ScreenBackgroundColor( { name } ) {
|
|
19
|
+
function ScreenBackgroundColor( { name, variationPath = '' } ) {
|
|
20
20
|
const supports = getSupportedGlobalStylesPanels( name );
|
|
21
21
|
const [ solids ] = useSetting( 'color.palette', name );
|
|
22
22
|
const [ gradients ] = useSetting( 'color.gradients', name );
|
|
@@ -39,16 +39,23 @@ function ScreenBackgroundColor( { name } ) {
|
|
|
39
39
|
supports.includes( 'background' ) &&
|
|
40
40
|
( gradients.length > 0 || areCustomGradientsEnabled );
|
|
41
41
|
const [ backgroundColor, setBackgroundColor ] = useStyle(
|
|
42
|
-
'color.background',
|
|
42
|
+
variationPath + 'color.background',
|
|
43
43
|
name
|
|
44
44
|
);
|
|
45
45
|
const [ userBackgroundColor ] = useStyle(
|
|
46
|
-
'color.background',
|
|
46
|
+
variationPath + 'color.background',
|
|
47
|
+
name,
|
|
48
|
+
'user'
|
|
49
|
+
);
|
|
50
|
+
const [ gradient, setGradient ] = useStyle(
|
|
51
|
+
variationPath + 'color.gradient',
|
|
52
|
+
name
|
|
53
|
+
);
|
|
54
|
+
const [ userGradient ] = useStyle(
|
|
55
|
+
variationPath + 'color.gradient',
|
|
47
56
|
name,
|
|
48
57
|
'user'
|
|
49
58
|
);
|
|
50
|
-
const [ gradient, setGradient ] = useStyle( 'color.gradient', name );
|
|
51
|
-
const [ userGradient ] = useStyle( 'color.gradient', name, 'user' );
|
|
52
59
|
|
|
53
60
|
if ( ! hasBackgroundColor && ! hasGradientColor ) {
|
|
54
61
|
return null;
|
|
@@ -21,6 +21,7 @@ import { useHasBorderPanel } from './border-panel';
|
|
|
21
21
|
import { useHasColorPanel } from './color-utils';
|
|
22
22
|
import { useHasDimensionsPanel } from './dimensions-panel';
|
|
23
23
|
import { useHasTypographyPanel } from './typography-panel';
|
|
24
|
+
import { useHasVariationsPanel } from './variations-panel';
|
|
24
25
|
import ScreenHeader from './header';
|
|
25
26
|
import { NavigationButtonAsItem } from './navigation-button';
|
|
26
27
|
|
|
@@ -53,8 +54,12 @@ function BlockMenuItem( { block } ) {
|
|
|
53
54
|
const hasBorderPanel = useHasBorderPanel( block.name );
|
|
54
55
|
const hasDimensionsPanel = useHasDimensionsPanel( block.name );
|
|
55
56
|
const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
|
|
57
|
+
const hasVariationsPanel = useHasVariationsPanel( block.name );
|
|
56
58
|
const hasBlockMenuItem =
|
|
57
|
-
hasTypographyPanel ||
|
|
59
|
+
hasTypographyPanel ||
|
|
60
|
+
hasColorPanel ||
|
|
61
|
+
hasLayoutPanel ||
|
|
62
|
+
hasVariationsPanel;
|
|
58
63
|
|
|
59
64
|
if ( ! hasBlockMenuItem ) {
|
|
60
65
|
return null;
|
|
@@ -9,15 +9,18 @@ import { __ } from '@wordpress/i18n';
|
|
|
9
9
|
import ScreenHeader from './header';
|
|
10
10
|
import BorderPanel, { useHasBorderPanel } from './border-panel';
|
|
11
11
|
import BlockPreviewPanel from './block-preview-panel';
|
|
12
|
+
import { getVariationClassNameFromPath } from './utils';
|
|
12
13
|
|
|
13
|
-
function ScreenBorder( { name } ) {
|
|
14
|
+
function ScreenBorder( { name, variationPath = '' } ) {
|
|
14
15
|
const hasBorderPanel = useHasBorderPanel( name );
|
|
15
|
-
|
|
16
|
+
const variationClassName = getVariationClassNameFromPath( variationPath );
|
|
16
17
|
return (
|
|
17
18
|
<>
|
|
18
19
|
<ScreenHeader title={ __( 'Border' ) } />
|
|
19
|
-
<BlockPreviewPanel name={ name } />
|
|
20
|
-
{ hasBorderPanel &&
|
|
20
|
+
<BlockPreviewPanel name={ name } variation={ variationClassName } />
|
|
21
|
+
{ hasBorderPanel && (
|
|
22
|
+
<BorderPanel name={ name } variationPath={ variationPath } />
|
|
23
|
+
) }
|
|
21
24
|
</>
|
|
22
25
|
);
|
|
23
26
|
}
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
useColorsPerOrigin,
|
|
16
16
|
} from './hooks';
|
|
17
17
|
|
|
18
|
-
function ScreenButtonColor( { name } ) {
|
|
18
|
+
function ScreenButtonColor( { name, variationPath = '' } ) {
|
|
19
19
|
const supports = getSupportedGlobalStylesPanels( name );
|
|
20
20
|
const [ solids ] = useSetting( 'color.palette', name );
|
|
21
21
|
const [ areCustomSolidsEnabled ] = useSetting( 'color.custom', name );
|
|
@@ -30,7 +30,7 @@ function ScreenButtonColor( { name } ) {
|
|
|
30
30
|
( solids.length > 0 || areCustomSolidsEnabled );
|
|
31
31
|
|
|
32
32
|
const [ buttonTextColor, setButtonTextColor ] = useStyle(
|
|
33
|
-
'elements.button.color.text',
|
|
33
|
+
variationPath + 'elements.button.color.text',
|
|
34
34
|
name
|
|
35
35
|
);
|
|
36
36
|
const [ userButtonTextColor ] = useStyle(
|