Skip to content

Commit

Permalink
Navigation: Try unifying submenu arrow positioning.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmussen committed Jan 26, 2022
1 parent 60bff62 commit bbeabf1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
5 changes: 2 additions & 3 deletions packages/block-library/src/navigation-link/index.php
Expand Up @@ -215,15 +215,14 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
}

$html .= '</span>';
$html .= '</a>';
// End anchor tag content.

if ( isset( $block->context['showSubmenuIcon'] ) && $block->context['showSubmenuIcon'] && $has_submenu ) {
// The submenu icon can be hidden by a CSS rule on the Navigation Block.
$html .= '<span class="wp-block-navigation__submenu-icon">' . block_core_navigation_link_render_submenu_icon() . '</span>';
}

$html .= '</a>';
// End anchor tag content.

if ( $has_submenu ) {
$inner_blocks_html = '';
foreach ( $block->inner_blocks as $inner_block ) {
Expand Down
10 changes: 5 additions & 5 deletions packages/block-library/src/navigation-submenu/edit.js
Expand Up @@ -657,12 +657,12 @@ export default function NavigationSubmenuEdit( {
/>
</Popover>
) }
{ ( showSubmenuIcon || openSubmenusOnClick ) && (
<span className="wp-block-navigation__submenu-icon">
<ItemSubmenuIcon />
</span>
) }
</ParentElement>
{ ( showSubmenuIcon || openSubmenusOnClick ) && (
<span className="wp-block-navigation__submenu-icon">
<ItemSubmenuIcon />
</span>
) }
<div { ...innerBlocksProps } />
</div>
</Fragment>
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/navigation-submenu/index.php
Expand Up @@ -245,10 +245,10 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {

$html .= '</span>';

$html .= '<span class="wp-block-navigation__submenu-icon">' . block_core_navigation_submenu_render_submenu_icon() . '</span>';

$html .= '</button>';

$html .= '<span class="wp-block-navigation__submenu-icon">' . block_core_navigation_submenu_render_submenu_icon() . '</span>';

}

if ( $has_submenu ) {
Expand Down
9 changes: 8 additions & 1 deletion packages/block-library/src/navigation/style.scss
Expand Up @@ -85,7 +85,6 @@ $navigation-icon-size: 24px;
align-self: center; // This one affects nested submenu indicators.
line-height: 0;
display: inline-block;
vertical-align: middle;
font-size: inherit;

// Affect the button as well.
Expand All @@ -104,6 +103,9 @@ $navigation-icon-size: 24px;
stroke: currentColor;
width: inherit;
height: inherit;

// Position the arrow to balance with the the text.
margin-top: 0.075em;
}
}

Expand Down Expand Up @@ -216,6 +218,11 @@ $navigation-icon-size: 24px;
}
}

// Push inwards from right edge of submenu.
.wp-block-navigation__submenu-icon {
margin-right: 0.25em;
}

// Reset the submenu indicator for horizontal flyouts.
.wp-block-navigation__submenu-icon svg {
transform: rotate(-90deg);
Expand Down
14 changes: 8 additions & 6 deletions packages/block-library/src/page-list/edit.js
Expand Up @@ -235,14 +235,16 @@ const PageItems = memo( function PageItems( {

function ItemSubmenuToggle( { title } ) {
return (
<button
className="wp-block-navigation-item__content wp-block-navigation-submenu__toggle"
aria-expanded="false"
>
{ title }
<>
<button
className="wp-block-navigation-item__content wp-block-navigation-submenu__toggle"
aria-expanded="false"
>
{ title }
</button>
<span className="wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon">
<ItemSubmenuIcon />
</span>
</button>
</>
);
}

0 comments on commit bbeabf1

Please sign in to comment.