@wordpress/block-library 7.3.10 → 7.3.11

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.
@@ -549,6 +549,144 @@ function Navigation( {
549
549
  } );
550
550
  }, [ clientId, ref ] );
551
551
 
552
+ const isResponsive = 'never' !== overlayMenu;
553
+
554
+ const overlayMenuPreviewClasses = classnames(
555
+ 'wp-block-navigation__overlay-menu-preview',
556
+ { open: overlayMenuPreview }
557
+ );
558
+
559
+ const stylingInspectorControls = (
560
+ <InspectorControls>
561
+ { hasSubmenuIndicatorSetting && (
562
+ <PanelBody title={ __( 'Display' ) }>
563
+ { isResponsive && (
564
+ <Button
565
+ className={ overlayMenuPreviewClasses }
566
+ onClick={ () => {
567
+ setOverlayMenuPreview( ! overlayMenuPreview );
568
+ } }
569
+ >
570
+ { hasIcon && <OverlayMenuIcon /> }
571
+ { ! hasIcon && <span>{ __( 'Menu' ) }</span> }
572
+ </Button>
573
+ ) }
574
+ { overlayMenuPreview && (
575
+ <ToggleControl
576
+ label={ __( 'Show icon button' ) }
577
+ help={ __(
578
+ 'Configure the visual appearance of the button opening the overlay menu.'
579
+ ) }
580
+ onChange={ ( value ) =>
581
+ setAttributes( { hasIcon: value } )
582
+ }
583
+ checked={ hasIcon }
584
+ />
585
+ ) }
586
+ <h3>{ __( 'Overlay Menu' ) }</h3>
587
+ <ToggleGroupControl
588
+ label={ __( 'Configure overlay menu' ) }
589
+ value={ overlayMenu }
590
+ help={ __(
591
+ 'Collapses the navigation options in a menu icon opening an overlay.'
592
+ ) }
593
+ onChange={ ( value ) =>
594
+ setAttributes( { overlayMenu: value } )
595
+ }
596
+ isBlock
597
+ hideLabelFromVision
598
+ >
599
+ <ToggleGroupControlOption
600
+ value="never"
601
+ label={ __( 'Off' ) }
602
+ />
603
+ <ToggleGroupControlOption
604
+ value="mobile"
605
+ label={ __( 'Mobile' ) }
606
+ />
607
+ <ToggleGroupControlOption
608
+ value="always"
609
+ label={ __( 'Always' ) }
610
+ />
611
+ </ToggleGroupControl>
612
+ { hasSubmenus && (
613
+ <>
614
+ <h3>{ __( 'Submenus' ) }</h3>
615
+ <ToggleControl
616
+ checked={ openSubmenusOnClick }
617
+ onChange={ ( value ) => {
618
+ setAttributes( {
619
+ openSubmenusOnClick: value,
620
+ ...( value && {
621
+ showSubmenuIcon: true,
622
+ } ), // Make sure arrows are shown when we toggle this on.
623
+ } );
624
+ } }
625
+ label={ __( 'Open on click' ) }
626
+ />
627
+
628
+ <ToggleControl
629
+ checked={ showSubmenuIcon }
630
+ onChange={ ( value ) => {
631
+ setAttributes( {
632
+ showSubmenuIcon: value,
633
+ } );
634
+ } }
635
+ disabled={ attributes.openSubmenusOnClick }
636
+ label={ __( 'Show arrow' ) }
637
+ />
638
+ </>
639
+ ) }
640
+ </PanelBody>
641
+ ) }
642
+ { hasColorSettings && (
643
+ <PanelColorSettings
644
+ __experimentalHasMultipleOrigins
645
+ __experimentalIsRenderedInSidebar
646
+ title={ __( 'Color' ) }
647
+ initialOpen={ false }
648
+ colorSettings={ [
649
+ {
650
+ value: textColor.color,
651
+ onChange: setTextColor,
652
+ label: __( 'Text' ),
653
+ },
654
+ {
655
+ value: backgroundColor.color,
656
+ onChange: setBackgroundColor,
657
+ label: __( 'Background' ),
658
+ },
659
+ {
660
+ value: overlayTextColor.color,
661
+ onChange: setOverlayTextColor,
662
+ label: __( 'Submenu & overlay text' ),
663
+ },
664
+ {
665
+ value: overlayBackgroundColor.color,
666
+ onChange: setOverlayBackgroundColor,
667
+ label: __( 'Submenu & overlay background' ),
668
+ },
669
+ ] }
670
+ >
671
+ { enableContrastChecking && (
672
+ <>
673
+ <ContrastChecker
674
+ backgroundColor={ detectedBackgroundColor }
675
+ textColor={ detectedColor }
676
+ />
677
+ <ContrastChecker
678
+ backgroundColor={
679
+ detectedOverlayBackgroundColor
680
+ }
681
+ textColor={ detectedOverlayColor }
682
+ />
683
+ </>
684
+ ) }
685
+ </PanelColorSettings>
686
+ ) }
687
+ </InspectorControls>
688
+ );
689
+
552
690
  // If the block has inner blocks, but no menu id, then these blocks are either:
553
691
  // - inserted via a pattern.
554
692
  // - inserted directly via Code View (or otherwise).
@@ -559,6 +697,7 @@ function Navigation( {
559
697
  if ( hasUnsavedBlocks ) {
560
698
  return (
561
699
  <TagName { ...blockProps }>
700
+ { stylingInspectorControls }
562
701
  <ResponsiveWrapper
563
702
  id={ clientId }
564
703
  onToggle={ setResponsiveMenuVisibility }
@@ -624,13 +763,6 @@ function Navigation( {
624
763
  ? CustomPlaceholder
625
764
  : Placeholder;
626
765
 
627
- const isResponsive = 'never' !== overlayMenu;
628
-
629
- const overlayMenuPreviewClasses = classnames(
630
- 'wp-block-navigation__overlay-menu-preview',
631
- { open: overlayMenuPreview }
632
- );
633
-
634
766
  if ( isPlaceholder ) {
635
767
  return (
636
768
  <TagName { ...blockProps }>
@@ -668,142 +800,7 @@ function Navigation( {
668
800
  </ToolbarGroup>
669
801
  ) }
670
802
  </BlockControls>
671
- <InspectorControls>
672
- { hasSubmenuIndicatorSetting && (
673
- <PanelBody title={ __( 'Display' ) }>
674
- { isResponsive && (
675
- <Button
676
- className={ overlayMenuPreviewClasses }
677
- onClick={ () => {
678
- setOverlayMenuPreview(
679
- ! overlayMenuPreview
680
- );
681
- } }
682
- >
683
- { hasIcon && <OverlayMenuIcon /> }
684
- { ! hasIcon && (
685
- <span>{ __( 'Menu' ) }</span>
686
- ) }
687
- </Button>
688
- ) }
689
- { overlayMenuPreview && (
690
- <ToggleControl
691
- label={ __( 'Show icon button' ) }
692
- help={ __(
693
- 'Configure the visual appearance of the button opening the overlay menu.'
694
- ) }
695
- onChange={ ( value ) =>
696
- setAttributes( { hasIcon: value } )
697
- }
698
- checked={ hasIcon }
699
- />
700
- ) }
701
- <h3>{ __( 'Overlay Menu' ) }</h3>
702
- <ToggleGroupControl
703
- label={ __( 'Configure overlay menu' ) }
704
- value={ overlayMenu }
705
- help={ __(
706
- 'Collapses the navigation options in a menu icon opening an overlay.'
707
- ) }
708
- onChange={ ( value ) =>
709
- setAttributes( { overlayMenu: value } )
710
- }
711
- isBlock
712
- hideLabelFromVision
713
- >
714
- <ToggleGroupControlOption
715
- value="never"
716
- label={ __( 'Off' ) }
717
- />
718
- <ToggleGroupControlOption
719
- value="mobile"
720
- label={ __( 'Mobile' ) }
721
- />
722
- <ToggleGroupControlOption
723
- value="always"
724
- label={ __( 'Always' ) }
725
- />
726
- </ToggleGroupControl>
727
- { hasSubmenus && (
728
- <>
729
- <h3>{ __( 'Submenus' ) }</h3>
730
- <ToggleControl
731
- checked={ openSubmenusOnClick }
732
- onChange={ ( value ) => {
733
- setAttributes( {
734
- openSubmenusOnClick: value,
735
- ...( value && {
736
- showSubmenuIcon: true,
737
- } ), // Make sure arrows are shown when we toggle this on.
738
- } );
739
- } }
740
- label={ __( 'Open on click' ) }
741
- />
742
-
743
- <ToggleControl
744
- checked={ showSubmenuIcon }
745
- onChange={ ( value ) => {
746
- setAttributes( {
747
- showSubmenuIcon: value,
748
- } );
749
- } }
750
- disabled={
751
- attributes.openSubmenusOnClick
752
- }
753
- label={ __( 'Show arrow' ) }
754
- />
755
- </>
756
- ) }
757
- </PanelBody>
758
- ) }
759
- { hasColorSettings && (
760
- <PanelColorSettings
761
- __experimentalHasMultipleOrigins
762
- __experimentalIsRenderedInSidebar
763
- title={ __( 'Color' ) }
764
- initialOpen={ false }
765
- colorSettings={ [
766
- {
767
- value: textColor.color,
768
- onChange: setTextColor,
769
- label: __( 'Text' ),
770
- },
771
- {
772
- value: backgroundColor.color,
773
- onChange: setBackgroundColor,
774
- label: __( 'Background' ),
775
- },
776
- {
777
- value: overlayTextColor.color,
778
- onChange: setOverlayTextColor,
779
- label: __( 'Submenu & overlay text' ),
780
- },
781
- {
782
- value: overlayBackgroundColor.color,
783
- onChange: setOverlayBackgroundColor,
784
- label: __( 'Submenu & overlay background' ),
785
- },
786
- ] }
787
- >
788
- { enableContrastChecking && (
789
- <>
790
- <ContrastChecker
791
- backgroundColor={
792
- detectedBackgroundColor
793
- }
794
- textColor={ detectedColor }
795
- />
796
- <ContrastChecker
797
- backgroundColor={
798
- detectedOverlayBackgroundColor
799
- }
800
- textColor={ detectedOverlayColor }
801
- />
802
- </>
803
- ) }
804
- </PanelColorSettings>
805
- ) }
806
- </InspectorControls>
803
+ { stylingInspectorControls }
807
804
  { isEntityAvailable && (
808
805
  <InspectorControls __experimentalGroup="advanced">
809
806
  { hasResolvedCanUserUpdateNavigationMenu &&