@wordpress/block-library 6.0.15 → 6.0.18
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/build/columns/index.js +1 -2
- package/build/columns/index.js.map +1 -1
- package/build/group/edit.native.js +1 -1
- package/build/group/edit.native.js.map +1 -1
- package/build/group/index.js +3 -1
- package/build/group/index.js.map +1 -1
- package/build/navigation/deprecated.js +1 -3
- package/build/navigation/deprecated.js.map +1 -1
- package/build/navigation/edit/index.js +100 -44
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +3 -2
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +15 -7
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/edit/responsive-wrapper.js +9 -7
- package/build/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +3 -11
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/edit/use-navigation-notice.js +54 -0
- package/build/navigation/edit/use-navigation-notice.js.map +1 -0
- package/build/navigation/index.js +2 -7
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +9 -2
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation/view.js +12 -7
- package/build/navigation/view.js.map +1 -1
- package/build/post-author/edit.js +1 -1
- package/build/post-author/edit.js.map +1 -1
- package/build/post-content/edit.js +1 -1
- package/build/post-content/edit.js.map +1 -1
- package/build/post-date/edit.js +1 -1
- package/build/post-date/edit.js.map +1 -1
- package/build/post-excerpt/edit.js +1 -1
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +1 -1
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-template/edit.js +54 -13
- package/build/post-template/edit.js.map +1 -1
- package/build/post-title/edit.js +1 -1
- package/build/post-title/edit.js.map +1 -1
- package/build/site-logo/edit.js +117 -16
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-logo/index.js +5 -4
- package/build/site-logo/index.js.map +1 -1
- package/build/template-part/edit/index.js +7 -1
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/index.js +25 -1
- package/build/template-part/index.js.map +1 -1
- package/build-module/columns/index.js +1 -2
- package/build-module/columns/index.js.map +1 -1
- package/build-module/group/edit.native.js +1 -1
- package/build-module/group/edit.native.js.map +1 -1
- package/build-module/group/index.js +3 -1
- package/build-module/group/index.js.map +1 -1
- package/build-module/navigation/deprecated.js +1 -3
- package/build-module/navigation/deprecated.js.map +1 -1
- package/build-module/navigation/edit/index.js +98 -44
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +3 -2
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +15 -7
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/edit/responsive-wrapper.js +9 -7
- package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +4 -13
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/use-navigation-notice.js +44 -0
- package/build-module/navigation/edit/use-navigation-notice.js.map +1 -0
- package/build-module/navigation/index.js +2 -7
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +9 -2
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation/view.js +12 -7
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/post-author/edit.js +1 -1
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-content/edit.js +1 -1
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-date/edit.js +1 -1
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-excerpt/edit.js +1 -1
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +1 -1
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-template/edit.js +54 -15
- package/build-module/post-template/edit.js.map +1 -1
- package/build-module/post-title/edit.js +1 -1
- package/build-module/post-title/edit.js.map +1 -1
- package/build-module/site-logo/edit.js +118 -17
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-logo/index.js +5 -4
- package/build-module/site-logo/index.js.map +1 -1
- package/build-module/template-part/edit/index.js +6 -1
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/index.js +25 -1
- package/build-module/template-part/index.js.map +1 -1
- package/build-style/common-rtl.css +10 -0
- package/build-style/common.css +10 -0
- package/build-style/editor-rtl.css +29 -17
- package/build-style/editor.css +29 -17
- package/build-style/navigation/editor-rtl.css +15 -6
- package/build-style/navigation/editor.css +15 -6
- package/build-style/navigation/style-rtl.css +55 -24
- package/build-style/navigation/style.css +55 -24
- package/build-style/post-comments/style-rtl.css +0 -1
- package/build-style/post-comments/style.css +0 -1
- package/build-style/site-logo/editor-rtl.css +1 -11
- package/build-style/site-logo/editor.css +1 -11
- package/build-style/site-logo/style-rtl.css +3 -1
- package/build-style/site-logo/style.css +3 -1
- package/build-style/style-rtl.css +68 -26
- package/build-style/style.css +68 -26
- package/package.json +14 -14
- package/src/columns/block.json +1 -2
- package/src/common.scss +12 -0
- package/src/editor.scss +15 -0
- package/src/gallery/index.php +1 -1
- package/src/group/block.json +3 -1
- package/src/group/edit.native.js +1 -1
- package/src/home-link/index.php +1 -1
- package/src/navigation/block.json +2 -13
- package/src/navigation/deprecated.js +0 -2
- package/src/navigation/edit/index.js +153 -55
- package/src/navigation/edit/navigation-menu-selector.js +19 -13
- package/src/navigation/edit/placeholder/index.js +40 -24
- package/src/navigation/edit/responsive-wrapper.js +10 -7
- package/src/navigation/edit/unsaved-inner-blocks.js +13 -25
- package/src/navigation/edit/use-navigation-notice.js +37 -0
- package/src/navigation/editor.scss +20 -8
- package/src/navigation/index.php +19 -8
- package/src/navigation/style.scss +81 -32
- package/src/navigation/use-navigation-menu.js +20 -0
- package/src/navigation/view.js +13 -7
- package/src/navigation-link/index.php +1 -1
- package/src/navigation-submenu/index.php +1 -1
- package/src/page-list/index.php +1 -1
- package/src/post-author/edit.js +1 -1
- package/src/post-comments/style.scss +0 -1
- package/src/post-content/edit.js +1 -1
- package/src/post-content/index.php +6 -1
- package/src/post-date/edit.js +1 -1
- package/src/post-excerpt/edit.js +1 -1
- package/src/post-excerpt/index.php +1 -1
- package/src/post-featured-image/edit.js +1 -1
- package/src/post-template/edit.js +54 -17
- package/src/post-title/edit.js +1 -1
- package/src/post-title/index.php +1 -1
- package/src/site-logo/block.json +5 -4
- package/src/site-logo/edit.js +130 -12
- package/src/site-logo/editor.scss +1 -15
- package/src/site-logo/index.php +17 -4
- package/src/site-logo/style.scss +3 -1
- package/src/template-part/edit/index.js +6 -1
- package/src/template-part/index.js +28 -0
|
@@ -31,6 +31,7 @@ const ExistingMenusDropdown = ( {
|
|
|
31
31
|
onFinish,
|
|
32
32
|
menus,
|
|
33
33
|
onCreateFromMenu,
|
|
34
|
+
showClassicMenus = false,
|
|
34
35
|
} ) => {
|
|
35
36
|
const toggleProps = {
|
|
36
37
|
variant: 'tertiary',
|
|
@@ -65,22 +66,24 @@ const ExistingMenusDropdown = ( {
|
|
|
65
66
|
);
|
|
66
67
|
} ) }
|
|
67
68
|
</MenuGroup>
|
|
68
|
-
|
|
69
|
-
{
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
69
|
+
{ showClassicMenus && (
|
|
70
|
+
<MenuGroup label={ __( 'Classic Menus' ) }>
|
|
71
|
+
{ menus?.map( ( menu ) => {
|
|
72
|
+
return (
|
|
73
|
+
<MenuItem
|
|
74
|
+
onClick={ () => {
|
|
75
|
+
setSelectedMenu( menu.id );
|
|
76
|
+
onCreateFromMenu( menu.name );
|
|
77
|
+
} }
|
|
78
|
+
onClose={ onClose }
|
|
79
|
+
key={ menu.id }
|
|
80
|
+
>
|
|
81
|
+
{ decodeEntities( menu.name ) }
|
|
82
|
+
</MenuItem>
|
|
83
|
+
);
|
|
84
|
+
} ) }
|
|
85
|
+
</MenuGroup>
|
|
86
|
+
) }
|
|
84
87
|
</>
|
|
85
88
|
) }
|
|
86
89
|
</DropdownMenu>
|
|
@@ -92,6 +95,7 @@ export default function NavigationPlaceholder( {
|
|
|
92
95
|
onFinish,
|
|
93
96
|
canSwitchNavigationMenu,
|
|
94
97
|
hasResolvedNavigationMenus,
|
|
98
|
+
canUserCreateNavigation = false,
|
|
95
99
|
} ) {
|
|
96
100
|
const [ selectedMenu, setSelectedMenu ] = useState();
|
|
97
101
|
const [ isCreatingFromMenu, setIsCreatingFromMenu ] = useState( false );
|
|
@@ -102,6 +106,10 @@ export default function NavigationPlaceholder( {
|
|
|
102
106
|
blocks,
|
|
103
107
|
navigationMenuTitle = null
|
|
104
108
|
) => {
|
|
109
|
+
if ( ! canUserCreateNavigation ) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
105
113
|
const navigationMenu = await createNavigationMenu(
|
|
106
114
|
navigationMenuTitle,
|
|
107
115
|
blocks
|
|
@@ -176,8 +184,10 @@ export default function NavigationPlaceholder( {
|
|
|
176
184
|
<Icon icon={ navigation } />{ ' ' }
|
|
177
185
|
{ __( 'Navigation' ) }
|
|
178
186
|
</div>
|
|
187
|
+
|
|
179
188
|
<hr />
|
|
180
|
-
|
|
189
|
+
|
|
190
|
+
{ hasMenus || navigationMenus?.length ? (
|
|
181
191
|
<>
|
|
182
192
|
<ExistingMenusDropdown
|
|
183
193
|
canSwitchNavigationMenu={
|
|
@@ -188,11 +198,14 @@ export default function NavigationPlaceholder( {
|
|
|
188
198
|
onFinish={ onFinish }
|
|
189
199
|
menus={ menus }
|
|
190
200
|
onCreateFromMenu={ onCreateFromMenu }
|
|
201
|
+
showClassicMenus={
|
|
202
|
+
canUserCreateNavigation
|
|
203
|
+
}
|
|
191
204
|
/>
|
|
192
205
|
<hr />
|
|
193
206
|
</>
|
|
194
207
|
) : undefined }
|
|
195
|
-
{ hasPages ? (
|
|
208
|
+
{ canUserCreateNavigation && hasPages ? (
|
|
196
209
|
<>
|
|
197
210
|
<Button
|
|
198
211
|
variant="tertiary"
|
|
@@ -203,12 +216,15 @@ export default function NavigationPlaceholder( {
|
|
|
203
216
|
<hr />
|
|
204
217
|
</>
|
|
205
218
|
) : undefined }
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
219
|
+
|
|
220
|
+
{ canUserCreateNavigation && (
|
|
221
|
+
<Button
|
|
222
|
+
variant="tertiary"
|
|
223
|
+
onClick={ onCreateEmptyMenu }
|
|
224
|
+
>
|
|
225
|
+
{ __( 'Start empty' ) }
|
|
226
|
+
</Button>
|
|
227
|
+
) }
|
|
212
228
|
</div>
|
|
213
229
|
</div>
|
|
214
230
|
</Placeholder>
|
|
@@ -39,12 +39,20 @@ export default function ResponsiveWrapper( {
|
|
|
39
39
|
|
|
40
40
|
const modalId = `${ id }-modal`;
|
|
41
41
|
|
|
42
|
+
const dialogProps = {
|
|
43
|
+
className: 'wp-block-navigation__responsive-dialog',
|
|
44
|
+
...( isOpen && {
|
|
45
|
+
role: 'dialog',
|
|
46
|
+
'aria-modal': true,
|
|
47
|
+
'aria-label': __( 'Menu' ),
|
|
48
|
+
} ),
|
|
49
|
+
};
|
|
50
|
+
|
|
42
51
|
return (
|
|
43
52
|
<>
|
|
44
53
|
{ ! isOpen && (
|
|
45
54
|
<Button
|
|
46
55
|
aria-haspopup="true"
|
|
47
|
-
aria-expanded={ isOpen }
|
|
48
56
|
aria-label={ __( 'Open menu' ) }
|
|
49
57
|
className={ openButtonClasses }
|
|
50
58
|
onClick={ () => onToggle( true ) }
|
|
@@ -73,12 +81,7 @@ export default function ResponsiveWrapper( {
|
|
|
73
81
|
className="wp-block-navigation__responsive-close"
|
|
74
82
|
tabIndex="-1"
|
|
75
83
|
>
|
|
76
|
-
<div
|
|
77
|
-
className="wp-block-navigation__responsive-dialog"
|
|
78
|
-
role="dialog"
|
|
79
|
-
aria-modal="true"
|
|
80
|
-
aria-labelledby={ `${ modalId }-title` }
|
|
81
|
-
>
|
|
84
|
+
<div { ...dialogProps }>
|
|
82
85
|
<Button
|
|
83
86
|
className="wp-block-navigation__responsive-container-close"
|
|
84
87
|
aria-label={ __( 'Close menu' ) }
|
|
@@ -18,7 +18,6 @@ import { useContext, useEffect, useRef } from '@wordpress/element';
|
|
|
18
18
|
import useNavigationMenu from '../use-navigation-menu';
|
|
19
19
|
import useCreateNavigationMenu from './use-create-navigation-menu';
|
|
20
20
|
|
|
21
|
-
const NOOP = () => {};
|
|
22
21
|
const EMPTY_OBJECT = {};
|
|
23
22
|
const DRAFT_MENU_PARAMS = [
|
|
24
23
|
'postType',
|
|
@@ -41,13 +40,6 @@ export default function UnsavedInnerBlocks( {
|
|
|
41
40
|
|
|
42
41
|
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
43
42
|
renderAppender: hasSelection ? undefined : false,
|
|
44
|
-
|
|
45
|
-
// Make the inner blocks 'controlled'. This allows the block to always
|
|
46
|
-
// work with controlled inner blocks, smoothing out the switch to using
|
|
47
|
-
// an entity.
|
|
48
|
-
value: blocks,
|
|
49
|
-
onChange: NOOP,
|
|
50
|
-
onInput: NOOP,
|
|
51
43
|
} );
|
|
52
44
|
|
|
53
45
|
const {
|
|
@@ -125,22 +117,18 @@ export default function UnsavedInnerBlocks( {
|
|
|
125
117
|
] );
|
|
126
118
|
|
|
127
119
|
return (
|
|
128
|
-
|
|
129
|
-
<
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
{ hasSelection && <Spinner /> }
|
|
142
|
-
</div>
|
|
143
|
-
</nav>
|
|
144
|
-
</>
|
|
120
|
+
<div className="wp-block-navigation__unsaved-changes">
|
|
121
|
+
<Disabled
|
|
122
|
+
className={ classnames(
|
|
123
|
+
'wp-block-navigation__unsaved-changes-overlay',
|
|
124
|
+
{
|
|
125
|
+
'is-saving': hasSelection,
|
|
126
|
+
}
|
|
127
|
+
) }
|
|
128
|
+
>
|
|
129
|
+
<div { ...innerBlocksProps } />
|
|
130
|
+
</Disabled>
|
|
131
|
+
{ hasSelection && <Spinner /> }
|
|
132
|
+
</div>
|
|
145
133
|
);
|
|
146
134
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useRef } from '@wordpress/element';
|
|
5
|
+
import { useDispatch } from '@wordpress/data';
|
|
6
|
+
import { store as noticeStore } from '@wordpress/notices';
|
|
7
|
+
|
|
8
|
+
function useNavigationNotice( { name, message } = {} ) {
|
|
9
|
+
const noticeRef = useRef();
|
|
10
|
+
|
|
11
|
+
const { createWarningNotice, removeNotice } = useDispatch( noticeStore );
|
|
12
|
+
|
|
13
|
+
const showNotice = () => {
|
|
14
|
+
if ( noticeRef.current ) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
noticeRef.current = name;
|
|
19
|
+
|
|
20
|
+
createWarningNotice( message, {
|
|
21
|
+
id: noticeRef.current,
|
|
22
|
+
type: 'snackbar',
|
|
23
|
+
} );
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const hideNotice = () => {
|
|
27
|
+
if ( ! noticeRef.current ) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
removeNotice( noticeRef.current );
|
|
31
|
+
noticeRef.current = null;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return [ showNotice, hideNotice ];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default useNavigationNotice;
|
|
@@ -100,6 +100,7 @@
|
|
|
100
100
|
.is-editing > .wp-block-navigation__submenu-container > .block-list-appender {
|
|
101
101
|
display: block;
|
|
102
102
|
position: static;
|
|
103
|
+
width: 100%;
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
// Hide when hovering.
|
|
@@ -304,7 +305,6 @@ $color-control-label-height: 20px;
|
|
|
304
305
|
|
|
305
306
|
// Selected state.
|
|
306
307
|
.wp-block-navigation-placeholder__controls {
|
|
307
|
-
padding: $grid-unit-10;
|
|
308
308
|
border-radius: $radius-block-ui;
|
|
309
309
|
background-color: $white;
|
|
310
310
|
box-shadow: inset 0 0 0 $border-width $gray-900;
|
|
@@ -313,11 +313,7 @@ $color-control-label-height: 20px;
|
|
|
313
313
|
display: none;
|
|
314
314
|
position: relative;
|
|
315
315
|
z-index: 1;
|
|
316
|
-
|
|
317
|
-
// Adjust padding for when shown horizontally.
|
|
318
|
-
.is-large & {
|
|
319
|
-
padding: $grid-unit-05 $grid-unit-10;
|
|
320
|
-
}
|
|
316
|
+
padding: $grid-unit-05 $grid-unit-10;
|
|
321
317
|
|
|
322
318
|
// If an ancestor has a text-decoration property applied, it is inherited regardless of
|
|
323
319
|
// the specificity of a child element. Only pulling the child out of the flow fixes it.
|
|
@@ -330,9 +326,19 @@ $color-control-label-height: 20px;
|
|
|
330
326
|
display: flex;
|
|
331
327
|
}
|
|
332
328
|
|
|
333
|
-
//
|
|
334
|
-
.
|
|
329
|
+
// Hide a few elements in medium size placeholders.
|
|
330
|
+
// @todo: part of the code here will be irrelevant if https://github.com/WordPress/gutenberg/pull/36775 lands.
|
|
335
331
|
.is-medium & {
|
|
332
|
+
.wp-block-navigation-placeholder__actions__indicator,
|
|
333
|
+
.wp-block-navigation-placeholder__actions__indicator + hr,
|
|
334
|
+
.wp-block-navigation-placeholder__actions > :nth-last-child(3), // Add all pages.
|
|
335
|
+
.wp-block-navigation-placeholder__actions > :nth-last-child(2) { // hr separator after it.
|
|
336
|
+
display: none;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Show stacked for the vertical navigation, or small placeholders.
|
|
341
|
+
.is-small & {
|
|
336
342
|
.wp-block-navigation-placeholder__actions {
|
|
337
343
|
flex-direction: column;
|
|
338
344
|
}
|
|
@@ -366,11 +372,17 @@ $color-control-label-height: 20px;
|
|
|
366
372
|
}
|
|
367
373
|
}
|
|
368
374
|
|
|
375
|
+
// Keep as row for medium.
|
|
376
|
+
.wp-block-navigation .components-placeholder.is-medium .components-placeholder__fieldset {
|
|
377
|
+
flex-direction: row !important;
|
|
378
|
+
}
|
|
379
|
+
|
|
369
380
|
.wp-block-navigation-placeholder__actions {
|
|
370
381
|
display: flex;
|
|
371
382
|
font-size: $default-font-size;
|
|
372
383
|
font-family: $default-font;
|
|
373
384
|
gap: $grid-unit-15 * 0.5;
|
|
385
|
+
align-items: center;
|
|
374
386
|
|
|
375
387
|
// Margins.
|
|
376
388
|
.components-dropdown,
|
package/src/navigation/index.php
CHANGED
|
@@ -452,14 +452,24 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
|
|
452
452
|
|
|
453
453
|
}
|
|
454
454
|
|
|
455
|
+
$layout_justification = array(
|
|
456
|
+
'left' => 'items-justified-left',
|
|
457
|
+
'right' => 'items-justified-right',
|
|
458
|
+
'center' => 'items-justified-center',
|
|
459
|
+
'space-between' => 'items-justified-space-between',
|
|
460
|
+
);
|
|
461
|
+
|
|
455
462
|
// Restore legacy classnames for submenu positioning.
|
|
456
463
|
$layout_class = '';
|
|
457
464
|
if ( isset( $attributes['layout']['justifyContent'] ) ) {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
465
|
+
$layout_class .= $layout_justification[ $attributes['layout']['justifyContent'] ];
|
|
466
|
+
}
|
|
467
|
+
if ( isset( $attributes['layout']['orientation'] ) && 'vertical' === $attributes['layout']['orientation'] ) {
|
|
468
|
+
$layout_class .= ' is-vertical';
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
if ( isset( $attributes['layout']['flexWrap'] ) && 'nowrap' === $attributes['layout']['flexWrap'] ) {
|
|
472
|
+
$layout_class .= ' no-wrap';
|
|
463
473
|
}
|
|
464
474
|
|
|
465
475
|
$colors = block_core_navigation_build_css_colors( $attributes );
|
|
@@ -528,10 +538,10 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
|
|
528
538
|
);
|
|
529
539
|
|
|
530
540
|
$responsive_container_markup = sprintf(
|
|
531
|
-
'<button aria-
|
|
541
|
+
'<button aria-haspopup="true" aria-label="%3$s" class="%6$s" data-micromodal-trigger="modal-%1$s"><svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-hidden="true" focusable="false"><rect x="4" y="7.5" width="16" height="1.5" /><rect x="4" y="15" width="16" height="1.5" /></svg></button>
|
|
532
542
|
<div class="%5$s" style="%7$s" id="modal-%1$s">
|
|
533
543
|
<div class="wp-block-navigation__responsive-close" tabindex="-1" data-micromodal-close>
|
|
534
|
-
<div class="wp-block-navigation__responsive-dialog"
|
|
544
|
+
<div class="wp-block-navigation__responsive-dialog" aria-label="%8$s">
|
|
535
545
|
<button aria-label="%4$s" data-micromodal-close class="wp-block-navigation__responsive-container-close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" role="img" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg></button>
|
|
536
546
|
<div class="wp-block-navigation__responsive-container-content" id="modal-%1$s-content">
|
|
537
547
|
%2$s
|
|
@@ -545,7 +555,8 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
|
|
545
555
|
__( 'Close menu' ), // Close button label.
|
|
546
556
|
implode( ' ', $responsive_container_classes ),
|
|
547
557
|
implode( ' ', $open_button_classes ),
|
|
548
|
-
$colors['overlay_inline_styles']
|
|
558
|
+
$colors['overlay_inline_styles'],
|
|
559
|
+
__( 'Menu' )
|
|
549
560
|
);
|
|
550
561
|
|
|
551
562
|
return sprintf(
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
// - .wp-block-navigation-item targets the menu item itself.
|
|
7
7
|
// - .wp-block-navigation-item__content targets the link inside a menu item.
|
|
8
8
|
// - .wp-block-navigation__submenu-icon targets the chevron icon indicating submenus.
|
|
9
|
+
|
|
10
|
+
// Size of burger and close icons.
|
|
11
|
+
$navigation-icon-size: 24px;
|
|
12
|
+
|
|
9
13
|
.wp-block-navigation {
|
|
10
14
|
position: relative;
|
|
11
15
|
|
|
@@ -102,6 +106,45 @@
|
|
|
102
106
|
height: inherit;
|
|
103
107
|
}
|
|
104
108
|
}
|
|
109
|
+
|
|
110
|
+
// Custom properties for layout style cascade: default values.
|
|
111
|
+
--navigation-layout-justification-setting: flex-start;
|
|
112
|
+
--navigation-layout-direction: row;
|
|
113
|
+
--navigation-layout-wrap: wrap;
|
|
114
|
+
--navigation-layout-justify: flex-start;
|
|
115
|
+
--navigation-layout-align: center;
|
|
116
|
+
|
|
117
|
+
&.is-vertical {
|
|
118
|
+
--navigation-layout-direction: column;
|
|
119
|
+
--navigation-layout-justify: initial;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&.no-wrap {
|
|
123
|
+
--navigation-layout-wrap: nowrap;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
&.items-justified-center {
|
|
127
|
+
--navigation-layout-justification-setting: center;
|
|
128
|
+
--navigation-layout-justify: center;
|
|
129
|
+
|
|
130
|
+
&.is-vertical {
|
|
131
|
+
--navigation-layout-align: center;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
&.items-justified-right {
|
|
136
|
+
--navigation-layout-justification-setting: flex-end;
|
|
137
|
+
--navigation-layout-justify: flex-end;
|
|
138
|
+
|
|
139
|
+
&.is-vertical {
|
|
140
|
+
--navigation-layout-align: flex-end;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
&.items-justified-space-between {
|
|
145
|
+
--navigation-layout-justification-setting: space-between;
|
|
146
|
+
--navigation-layout-justify: space-between;
|
|
147
|
+
}
|
|
105
148
|
}
|
|
106
149
|
|
|
107
150
|
// Styles for submenu flyout.
|
|
@@ -347,10 +390,10 @@ button.wp-block-navigation-item__content {
|
|
|
347
390
|
// Navigation block inner container.
|
|
348
391
|
.wp-block-navigation__container {
|
|
349
392
|
display: flex;
|
|
350
|
-
flex-wrap: var(--layout-wrap, wrap);
|
|
351
|
-
flex-direction: var(--layout-direction, initial);
|
|
352
|
-
justify-content: var(--layout-justify, initial);
|
|
353
|
-
align-items: var(--layout-align, initial);
|
|
393
|
+
flex-wrap: var(--navigation-layout-wrap, wrap);
|
|
394
|
+
flex-direction: var(--navigation-layout-direction, initial);
|
|
395
|
+
justify-content: var(--navigation-layout-justify, initial);
|
|
396
|
+
align-items: var(--navigation-layout-align, initial);
|
|
354
397
|
|
|
355
398
|
// Reset the default list styles
|
|
356
399
|
list-style: none;
|
|
@@ -384,10 +427,10 @@ button.wp-block-navigation-item__content {
|
|
|
384
427
|
|
|
385
428
|
.wp-block-navigation__responsive-container-content {
|
|
386
429
|
display: flex;
|
|
387
|
-
flex-wrap: var(--layout-wrap, wrap);
|
|
388
|
-
flex-direction: var(--layout-direction, initial);
|
|
389
|
-
justify-content: var(--layout-justify, initial);
|
|
390
|
-
align-items: var(--layout-align, initial);
|
|
430
|
+
flex-wrap: var(--navigation-layout-wrap, wrap);
|
|
431
|
+
flex-direction: var(--navigation-layout-direction, initial);
|
|
432
|
+
justify-content: var(--navigation-layout-justify, initial);
|
|
433
|
+
align-items: var(--navigation-layout-align, initial);
|
|
391
434
|
}
|
|
392
435
|
|
|
393
436
|
// If the responsive wrapper is present but overlay is not open,
|
|
@@ -405,6 +448,10 @@ button.wp-block-navigation-item__content {
|
|
|
405
448
|
&.is-menu-open {
|
|
406
449
|
display: flex; // Needs to be set to override "none".
|
|
407
450
|
flex-direction: column;
|
|
451
|
+
background-color: inherit;
|
|
452
|
+
|
|
453
|
+
// Use em units to apply padding, so themes can more easily style this in various ways.
|
|
454
|
+
padding: 2em;
|
|
408
455
|
|
|
409
456
|
// Allow modal to scroll.
|
|
410
457
|
overflow: auto;
|
|
@@ -412,18 +459,22 @@ button.wp-block-navigation-item__content {
|
|
|
412
459
|
// Give it a z-index just higher than the adminbar.
|
|
413
460
|
z-index: 100000;
|
|
414
461
|
|
|
415
|
-
// Add extra top padding so items don't conflict with close button.
|
|
416
|
-
padding: 72px 24px 24px 24px;
|
|
417
|
-
background-color: inherit;
|
|
418
|
-
|
|
419
462
|
.wp-block-navigation__responsive-container-content {
|
|
463
|
+
// Add padding above to accommodate close button.
|
|
464
|
+
padding-top: calc(2em + #{ $navigation-icon-size });
|
|
465
|
+
|
|
466
|
+
// Don't crop the focus style.
|
|
467
|
+
overflow: visible;
|
|
468
|
+
|
|
420
469
|
// Override the container flex layout settings
|
|
421
470
|
// because we want overlay menu to always display
|
|
422
471
|
// as a column.
|
|
423
472
|
display: flex;
|
|
424
473
|
flex-direction: column;
|
|
474
|
+
flex-wrap: nowrap;
|
|
475
|
+
|
|
425
476
|
// Inherit alignment settings from container.
|
|
426
|
-
align-items: var(--layout-justification-setting, inherit);
|
|
477
|
+
align-items: var(--navigation-layout-justification-setting, inherit);
|
|
427
478
|
|
|
428
479
|
// Always align the contents of the menu to the top.
|
|
429
480
|
&,
|
|
@@ -432,10 +483,6 @@ button.wp-block-navigation-item__content {
|
|
|
432
483
|
justify-content: flex-start;
|
|
433
484
|
}
|
|
434
485
|
|
|
435
|
-
// Allow menu to scroll.
|
|
436
|
-
overflow: auto;
|
|
437
|
-
padding: 0;
|
|
438
|
-
|
|
439
486
|
.wp-block-navigation__submenu-icon {
|
|
440
487
|
display: none;
|
|
441
488
|
}
|
|
@@ -454,20 +501,19 @@ button.wp-block-navigation-item__content {
|
|
|
454
501
|
// Position and style.
|
|
455
502
|
position: static;
|
|
456
503
|
border: none;
|
|
457
|
-
padding-left:
|
|
458
|
-
padding-right:
|
|
504
|
+
padding-left: 2em;
|
|
505
|
+
padding-right: 2em;
|
|
459
506
|
}
|
|
460
507
|
|
|
461
508
|
// Space unfolded items using gap and padding for submenus.
|
|
462
509
|
.wp-block-navigation__submenu-container,
|
|
463
510
|
.wp-block-navigation__container {
|
|
464
511
|
gap: var(--wp--style--block-gap, 2em);
|
|
512
|
+
}
|
|
465
513
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
padding-top: var(--wp--style--block-gap, 2em);
|
|
470
|
-
}
|
|
514
|
+
// Apply top padding to nested submenus.
|
|
515
|
+
.wp-block-navigation__submenu-container {
|
|
516
|
+
padding-top: var(--wp--style--block-gap, 2em);
|
|
471
517
|
}
|
|
472
518
|
|
|
473
519
|
// A default padding is added to submenu items. It's not appropriate inside the modal.
|
|
@@ -482,7 +528,7 @@ button.wp-block-navigation-item__content {
|
|
|
482
528
|
display: flex;
|
|
483
529
|
flex-direction: column;
|
|
484
530
|
// Inherit alignment settings from container.
|
|
485
|
-
align-items: var(--layout-justification-setting, initial);
|
|
531
|
+
align-items: var(--navigation-layout-justification-setting, initial);
|
|
486
532
|
}
|
|
487
533
|
}
|
|
488
534
|
|
|
@@ -548,8 +594,8 @@ button.wp-block-navigation-item__content {
|
|
|
548
594
|
fill: currentColor;
|
|
549
595
|
pointer-events: none;
|
|
550
596
|
display: block;
|
|
551
|
-
width:
|
|
552
|
-
height:
|
|
597
|
+
width: $navigation-icon-size;
|
|
598
|
+
height: $navigation-icon-size;
|
|
553
599
|
}
|
|
554
600
|
}
|
|
555
601
|
|
|
@@ -567,8 +613,8 @@ button.wp-block-navigation-item__content {
|
|
|
567
613
|
// Button to close the menus.
|
|
568
614
|
.wp-block-navigation__responsive-container-close {
|
|
569
615
|
position: absolute;
|
|
570
|
-
top:
|
|
571
|
-
right:
|
|
616
|
+
top: 0;
|
|
617
|
+
right: 0;
|
|
572
618
|
z-index: 2; // Needs to be above the modal z index itself.
|
|
573
619
|
}
|
|
574
620
|
|
|
@@ -580,11 +626,14 @@ button.wp-block-navigation-item__content {
|
|
|
580
626
|
.is-menu-open .wp-block-navigation__responsive-close,
|
|
581
627
|
.is-menu-open .wp-block-navigation__responsive-dialog,
|
|
582
628
|
.is-menu-open .wp-block-navigation__responsive-container-content {
|
|
583
|
-
|
|
584
|
-
height: 100%;
|
|
629
|
+
box-sizing: border-box;
|
|
585
630
|
}
|
|
586
631
|
|
|
632
|
+
.wp-block-navigation__responsive-dialog {
|
|
633
|
+
position: relative;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// Prevent scrolling of the parent content when the modal is open.
|
|
587
637
|
html.has-modal-open {
|
|
588
638
|
overflow: hidden;
|
|
589
639
|
}
|
|
590
|
-
|
|
@@ -12,6 +12,7 @@ export default function useNavigationMenu( ref ) {
|
|
|
12
12
|
getEditedEntityRecord,
|
|
13
13
|
getEntityRecords,
|
|
14
14
|
hasFinishedResolution,
|
|
15
|
+
canUser,
|
|
15
16
|
} = select( coreStore );
|
|
16
17
|
|
|
17
18
|
const navigationMenuSingleArgs = [
|
|
@@ -64,6 +65,25 @@ export default function useNavigationMenu( ref ) {
|
|
|
64
65
|
),
|
|
65
66
|
navigationMenu,
|
|
66
67
|
navigationMenus,
|
|
68
|
+
canUserUpdateNavigationEntity: ref
|
|
69
|
+
? canUser( 'update', 'navigation', ref )
|
|
70
|
+
: undefined,
|
|
71
|
+
hasResolvedCanUserUpdateNavigationEntity: hasFinishedResolution(
|
|
72
|
+
'canUser',
|
|
73
|
+
[ 'update', 'navigation', ref ]
|
|
74
|
+
),
|
|
75
|
+
canUserDeleteNavigationEntity: ref
|
|
76
|
+
? canUser( 'delete', 'navigation', ref )
|
|
77
|
+
: undefined,
|
|
78
|
+
hasResolvedCanUserDeleteNavigationEntity: hasFinishedResolution(
|
|
79
|
+
'canUser',
|
|
80
|
+
[ 'delete', 'navigation', ref ]
|
|
81
|
+
),
|
|
82
|
+
canUserCreateNavigation: canUser( 'create', 'navigation' ),
|
|
83
|
+
hasResolvedCanUserCreateNavigation: hasFinishedResolution(
|
|
84
|
+
'canUser',
|
|
85
|
+
[ 'create', 'navigation' ]
|
|
86
|
+
),
|
|
67
87
|
};
|
|
68
88
|
},
|
|
69
89
|
[ ref ]
|
package/src/navigation/view.js
CHANGED
|
@@ -5,16 +5,22 @@ import MicroModal from 'micromodal';
|
|
|
5
5
|
|
|
6
6
|
// Responsive navigation toggle.
|
|
7
7
|
function navigationToggleModal( modal ) {
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const dialogContainer = document.querySelector(
|
|
9
|
+
`.wp-block-navigation__responsive-dialog`
|
|
10
10
|
);
|
|
11
|
-
|
|
12
|
-
// Use aria-hidden to determine the status of the modal, as this attribute is
|
|
13
|
-
// managed by micromodal.
|
|
11
|
+
|
|
14
12
|
const isHidden = 'true' === modal.getAttribute( 'aria-hidden' );
|
|
15
|
-
|
|
16
|
-
closeButton.setAttribute( 'aria-expanded', ! isHidden );
|
|
13
|
+
|
|
17
14
|
modal.classList.toggle( 'has-modal-open', ! isHidden );
|
|
15
|
+
dialogContainer.toggleAttribute( 'aria-modal', ! isHidden );
|
|
16
|
+
|
|
17
|
+
if ( isHidden ) {
|
|
18
|
+
dialogContainer.removeAttribute( 'role' );
|
|
19
|
+
dialogContainer.removeAttribute( 'aria-modal' );
|
|
20
|
+
} else {
|
|
21
|
+
dialogContainer.setAttribute( 'role', 'dialog' );
|
|
22
|
+
dialogContainer.setAttribute( 'aria-modal', 'true' );
|
|
23
|
+
}
|
|
18
24
|
|
|
19
25
|
// Add a class to indicate the modal is open.
|
|
20
26
|
const htmlElement = document.documentElement;
|
|
@@ -98,7 +98,7 @@ function block_core_navigation_link_build_css_font_sizes( $context ) {
|
|
|
98
98
|
$font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
|
|
99
99
|
} elseif ( $has_custom_font_size ) {
|
|
100
100
|
// Add the custom font size inline style.
|
|
101
|
-
$font_sizes['inline_styles'] = sprintf( 'font-size: %
|
|
101
|
+
$font_sizes['inline_styles'] = sprintf( 'font-size: %s;', $context['style']['typography']['fontSize'] );
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
return $font_sizes;
|
|
@@ -98,7 +98,7 @@ function block_core_navigation_submenu_build_css_font_sizes( $context ) {
|
|
|
98
98
|
$font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
|
|
99
99
|
} elseif ( $has_custom_font_size ) {
|
|
100
100
|
// Add the custom font size inline style.
|
|
101
|
-
$font_sizes['inline_styles'] = sprintf( 'font-size: %
|
|
101
|
+
$font_sizes['inline_styles'] = sprintf( 'font-size: %s;', $context['style']['typography']['fontSize'] );
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
return $font_sizes;
|
package/src/page-list/index.php
CHANGED
|
@@ -119,7 +119,7 @@ function block_core_page_list_build_css_font_sizes( $context ) {
|
|
|
119
119
|
$font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
|
|
120
120
|
} elseif ( $has_custom_font_size ) {
|
|
121
121
|
// Add the custom font size inline style.
|
|
122
|
-
$font_sizes['inline_styles'] = sprintf( 'font-size: %
|
|
122
|
+
$font_sizes['inline_styles'] = sprintf( 'font-size: %s;', $context['style']['typography']['fontSize'] );
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
return $font_sizes;
|