@wordpress/block-library 6.0.15 → 6.0.16
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/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 +1 -2
- 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-template/edit.js +54 -13
- package/build/post-template/edit.js.map +1 -1
- package/build/site-logo/edit.js +9 -6
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-logo/index.js +0 -3
- 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-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 +1 -2
- 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-template/edit.js +54 -15
- package/build-module/post-template/edit.js.map +1 -1
- package/build-module/site-logo/edit.js +9 -6
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-logo/index.js +0 -3
- 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-style/common-rtl.css +10 -0
- package/build-style/common.css +10 -0
- package/build-style/editor-rtl.css +13 -11
- package/build-style/editor.css +13 -11
- package/build-style/navigation/editor-rtl.css +2 -0
- package/build-style/navigation/editor.css +2 -0
- package/build-style/navigation/style-rtl.css +55 -24
- package/build-style/navigation/style.css +55 -24
- 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 -25
- package/build-style/style.css +68 -25
- package/package.json +14 -14
- package/src/common.scss +12 -0
- package/src/editor.scss +12 -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 +1 -2
- 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 +2 -0
- 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-template/edit.js +54 -17
- package/src/site-logo/block.json +0 -3
- package/src/site-logo/edit.js +6 -5
- package/src/site-logo/editor.scss +1 -15
- package/src/site-logo/index.php +0 -4
- package/src/site-logo/style.scss +3 -1
- package/src/template-part/edit/index.js +6 -1
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;
|
|
@@ -6,12 +6,12 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { memo, useMemo, useState } from '@wordpress/element';
|
|
10
10
|
import { useSelect } from '@wordpress/data';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
12
|
import {
|
|
13
13
|
BlockContextProvider,
|
|
14
|
-
|
|
14
|
+
__experimentalUseBlockPreview as useBlockPreview,
|
|
15
15
|
useBlockProps,
|
|
16
16
|
useInnerBlocksProps,
|
|
17
17
|
store as blockEditorStore,
|
|
@@ -30,6 +30,39 @@ function PostTemplateInnerBlocks() {
|
|
|
30
30
|
return <li { ...innerBlocksProps } />;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
function PostTemplateBlockPreview( {
|
|
34
|
+
blocks,
|
|
35
|
+
blockContextId,
|
|
36
|
+
isHidden,
|
|
37
|
+
setActiveBlockContextId,
|
|
38
|
+
} ) {
|
|
39
|
+
const blockPreviewProps = useBlockPreview( {
|
|
40
|
+
blocks,
|
|
41
|
+
} );
|
|
42
|
+
|
|
43
|
+
const handleOnClick = () => {
|
|
44
|
+
setActiveBlockContextId( blockContextId );
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const style = {
|
|
48
|
+
display: isHidden ? 'none' : undefined,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<li
|
|
53
|
+
{ ...blockPreviewProps }
|
|
54
|
+
tabIndex={ 0 }
|
|
55
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
|
|
56
|
+
role="button"
|
|
57
|
+
onClick={ handleOnClick }
|
|
58
|
+
onKeyPress={ handleOnClick }
|
|
59
|
+
style={ style }
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const MemoizedPostTemplateBlockPreview = memo( PostTemplateBlockPreview );
|
|
65
|
+
|
|
33
66
|
export default function PostTemplateEdit( {
|
|
34
67
|
clientId,
|
|
35
68
|
context: {
|
|
@@ -53,7 +86,7 @@ export default function PostTemplateEdit( {
|
|
|
53
86
|
},
|
|
54
87
|
} ) {
|
|
55
88
|
const [ { page } ] = queryContext;
|
|
56
|
-
const [
|
|
89
|
+
const [ activeBlockContextId, setActiveBlockContextId ] = useState();
|
|
57
90
|
|
|
58
91
|
const { posts, blocks } = useSelect(
|
|
59
92
|
( select ) => {
|
|
@@ -115,7 +148,6 @@ export default function PostTemplateEdit( {
|
|
|
115
148
|
templateSlug,
|
|
116
149
|
]
|
|
117
150
|
);
|
|
118
|
-
|
|
119
151
|
const blockContexts = useMemo(
|
|
120
152
|
() =>
|
|
121
153
|
posts?.map( ( post ) => ( {
|
|
@@ -144,6 +176,10 @@ export default function PostTemplateEdit( {
|
|
|
144
176
|
return <p { ...blockProps }> { __( 'No results found.' ) }</p>;
|
|
145
177
|
}
|
|
146
178
|
|
|
179
|
+
// To avoid flicker when switching active block contexts, a preview is rendered
|
|
180
|
+
// for each block context, but the preview for the active block context is hidden.
|
|
181
|
+
// This ensures that when it is displayed again, the cached rendering of the
|
|
182
|
+
// block preview is used, instead of having to re-render the preview from scratch.
|
|
147
183
|
return (
|
|
148
184
|
<ul { ...blockProps }>
|
|
149
185
|
{ blockContexts &&
|
|
@@ -152,20 +188,21 @@ export default function PostTemplateEdit( {
|
|
|
152
188
|
key={ blockContext.postId }
|
|
153
189
|
value={ blockContext }
|
|
154
190
|
>
|
|
155
|
-
{ blockContext ===
|
|
156
|
-
(
|
|
191
|
+
{ blockContext.postId ===
|
|
192
|
+
( activeBlockContextId ||
|
|
193
|
+
blockContexts[ 0 ]?.postId ) ? (
|
|
157
194
|
<PostTemplateInnerBlocks />
|
|
158
|
-
) :
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
195
|
+
) : null }
|
|
196
|
+
<MemoizedPostTemplateBlockPreview
|
|
197
|
+
blocks={ blocks }
|
|
198
|
+
blockContextId={ blockContext.postId }
|
|
199
|
+
setActiveBlockContextId={ setActiveBlockContextId }
|
|
200
|
+
isHidden={
|
|
201
|
+
blockContext.postId ===
|
|
202
|
+
( activeBlockContextId ||
|
|
203
|
+
blockContexts[ 0 ]?.postId )
|
|
204
|
+
}
|
|
205
|
+
/>
|
|
169
206
|
</BlockContextProvider>
|
|
170
207
|
) ) }
|
|
171
208
|
</ul>
|
package/src/site-logo/block.json
CHANGED
|
@@ -6,9 +6,6 @@
|
|
|
6
6
|
"description": "Display a graphic to represent this site. Update the block, and the changes apply everywhere it’s used. This is different than the site icon, which is the smaller image visible in your dashboard, browser tabs, etc used to help others recognize this site.",
|
|
7
7
|
"textdomain": "default",
|
|
8
8
|
"attributes": {
|
|
9
|
-
"align": {
|
|
10
|
-
"type": "string"
|
|
11
|
-
},
|
|
12
9
|
"width": {
|
|
13
10
|
"type": "number"
|
|
14
11
|
},
|
package/src/site-logo/edit.js
CHANGED
|
@@ -142,7 +142,11 @@ const SiteLogo = ( {
|
|
|
142
142
|
return <div style={ { width, height } }>{ imgWrapper }</div>;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
// Set the default width to a responsible size.
|
|
146
|
+
// Note that this width is also set in the attached frontend CSS file.
|
|
147
|
+
const defaultWidth = 120;
|
|
148
|
+
|
|
149
|
+
const currentWidth = width || defaultWidth;
|
|
146
150
|
const ratio = naturalWidth / naturalHeight;
|
|
147
151
|
const currentHeight = currentWidth / ratio;
|
|
148
152
|
const minWidth = naturalWidth < naturalHeight ? MIN_SIZE : MIN_SIZE * ratio;
|
|
@@ -160,10 +164,6 @@ const SiteLogo = ( {
|
|
|
160
164
|
// becomes available.
|
|
161
165
|
const maxWidthBuffer = maxWidth * 2.5;
|
|
162
166
|
|
|
163
|
-
// Set the default width to a responsible size.
|
|
164
|
-
// Note that this width is also set in the attached CSS file.
|
|
165
|
-
const defaultWidth = 120;
|
|
166
|
-
|
|
167
167
|
let showRightHandle = false;
|
|
168
168
|
let showLeftHandle = false;
|
|
169
169
|
|
|
@@ -383,6 +383,7 @@ export default function LogoEdit( {
|
|
|
383
383
|
const onRemoveLogo = () => {
|
|
384
384
|
setLogo( null );
|
|
385
385
|
setLogoUrl( undefined );
|
|
386
|
+
setAttributes( { width: undefined } );
|
|
386
387
|
};
|
|
387
388
|
|
|
388
389
|
const { createErrorNotice } = useDispatch( noticesStore );
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.wp-block[data-align="center"] > .wp-block-site-logo {
|
|
2
|
+
display: table;
|
|
2
3
|
margin-left: auto;
|
|
3
4
|
margin-right: auto;
|
|
4
|
-
text-align: center;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
.wp-block-site-logo {
|
|
@@ -10,20 +10,6 @@
|
|
|
10
10
|
pointer-events: none;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
&:not(.is-default-size) {
|
|
14
|
-
display: table;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Provide a sane starting point for the size.
|
|
18
|
-
&.is-default-size {
|
|
19
|
-
width: 120px;
|
|
20
|
-
|
|
21
|
-
img {
|
|
22
|
-
height: auto;
|
|
23
|
-
width: 100%;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
13
|
.custom-logo-link {
|
|
28
14
|
cursor: inherit;
|
|
29
15
|
|
package/src/site-logo/index.php
CHANGED
|
@@ -48,10 +48,6 @@ function render_block_core_site_logo( $attributes ) {
|
|
|
48
48
|
$classnames[] = $attributes['className'];
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
if ( ! empty( $attributes['align'] ) && in_array( $attributes['align'], array( 'center', 'left', 'right' ), true ) ) {
|
|
52
|
-
$classnames[] = "align{$attributes['align']}";
|
|
53
|
-
}
|
|
54
|
-
|
|
55
51
|
if ( empty( $attributes['width'] ) ) {
|
|
56
52
|
$classnames[] = 'is-default-size';
|
|
57
53
|
}
|
package/src/site-logo/style.scss
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { isEmpty } from 'lodash';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -99,7 +104,7 @@ export default function TemplatePartEdit( {
|
|
|
99
104
|
return {
|
|
100
105
|
innerBlocks: getBlocks( clientId ),
|
|
101
106
|
isResolved: hasResolvedEntity,
|
|
102
|
-
isMissing: hasResolvedEntity &&
|
|
107
|
+
isMissing: hasResolvedEntity && isEmpty( entityRecord ),
|
|
103
108
|
defaultWrapper: defaultWrapperElement || 'div',
|
|
104
109
|
area: _area,
|
|
105
110
|
enableSelection: _enableSelection,
|