Skip to content

Commit

Permalink
Refactor nav block paddings/margins to inherit global styles. (#31878)
Browse files Browse the repository at this point in the history
* Refactor nav block paddings/margins to inherit global styles.

* Fix color inheritance. Fix last-child margin.

* Use :where to minimize specificity.

* Move chevron inside link.

* Provide default paddings for submenus.

* Fix page list bug.
  • Loading branch information
jasmussen authored Jun 1, 2021
1 parent 77c7192 commit 0522521
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 188 deletions.
10 changes: 5 additions & 5 deletions packages/block-library/src/navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,12 +605,12 @@ export default function NavigationLinkEdit( {
/>
</Popover>
) }
{ hasDescendants && showSubmenuIcon && (
<span className="wp-block-navigation-link__submenu-icon">
<ItemSubmenuIcon />
</span>
) }
</a>
{ hasDescendants && showSubmenuIcon && (
<span className="wp-block-navigation-link__submenu-icon">
<ItemSubmenuIcon />
</span>
) }
<ul { ...innerBlocksProps } />
</li>
</Fragment>
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/navigation-link/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,14 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {

$html .= '</span>';

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

if ( $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-link__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
5 changes: 5 additions & 0 deletions packages/block-library/src/navigation/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
}
}

// This element is inline on the frontend but needs to be editable, therefore inline-block, in the editor.
.wp-block-navigation-link__label {
display: inline-block;
}


/**
* Submenus.
Expand Down
Loading

0 comments on commit 0522521

Please sign in to comment.