-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11deabd
commit 5259eb0
Showing
5 changed files
with
139 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
/** | ||
* Walker_Pages_Block class. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* Class that adds submenu dropdown indicators to Pages block. | ||
*/ | ||
class Walker_Pages_Block extends Walker_Page { | ||
/** | ||
* Outputs the beginning of the current level in the tree before elements are output. | ||
* | ||
* @since 2.1.0 | ||
* | ||
* @see Walker::start_lvl() | ||
* | ||
* @param string $output Used to append additional content (passed by reference). | ||
* @param int $depth Optional. Depth of page. Used for padding. Default 0. | ||
* @param array $args Optional. Arguments for outputting the next level. | ||
* Default empty array. | ||
*/ | ||
public function start_lvl( &$output, $depth = 0, $args = array() ) { | ||
if ( isset( $args['item_spacing'] ) && 'preserve' === $args['item_spacing'] ) { | ||
$t = "\t"; | ||
$n = "\n"; | ||
} else { | ||
$t = ''; | ||
$n = ''; | ||
} | ||
$indent = str_repeat( $t, $depth ); | ||
$output .= "<span class='wp-block-pages__submenu-icon'><svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' transform='rotate(90)'><path d='M8 5v14l11-7z'/><path d='M0 0h24v24H0z' fill='none'/></svg></span>{$n}{$indent}<ul class='children'>{$n}"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
.wp-block-navigation-link__submenu-icon { | ||
display: none; | ||
} | ||
|
||
.show-submenu-icons { | ||
.wp-block-navigation-link__submenu-icon { | ||
display: block; | ||
} | ||
} | ||
|
||
// The Pages block should inherit navigation styles when nested within it | ||
.wp-block-navigation { | ||
.wp-block-page-list { | ||
display: flex; | ||
flex-wrap: wrap; | ||
} | ||
.page_item a { | ||
display: block; | ||
color: inherit; | ||
padding: 0.5em 1em; | ||
} | ||
|
||
.page_item_has_children { | ||
display: flex; | ||
position: relative; | ||
|
||
> a { | ||
padding-right: 0.5em; | ||
} | ||
> .children { | ||
border: $border-width solid rgba(0, 0, 0, 0.15); | ||
background-color: inherit; | ||
color: inherit; | ||
position: absolute; | ||
left: 0; | ||
top: 100%; | ||
width: fit-content; | ||
z-index: 2; | ||
opacity: 0; | ||
transition: opacity 0.1s linear; | ||
visibility: hidden; | ||
|
||
@include break-medium { | ||
left: 1.5em; | ||
|
||
// Nested submenus sit to the left on large breakpoints | ||
.children { | ||
left: 100%; | ||
top: -1px; | ||
|
||
// Prevent the menu from disappearing when the mouse is over the gap | ||
&::before { | ||
content: ""; | ||
position: absolute; | ||
right: 100%; | ||
height: 100%; | ||
display: block; | ||
width: 0.5em; | ||
background: transparent; | ||
} | ||
} | ||
|
||
.wp-block-navigation-link__submenu-icon svg { | ||
transform: rotate(0); | ||
} | ||
} | ||
} | ||
|
||
&:hover { | ||
cursor: pointer; | ||
|
||
> .children { | ||
visibility: visible; | ||
opacity: 1; | ||
} | ||
} | ||
|
||
&:focus-within { | ||
cursor: pointer; | ||
|
||
> .children { | ||
visibility: visible; | ||
opacity: 1; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters