Skip to content

Commit

Permalink
Remove deprecated classnames from Navigation Link block (#35358)
Browse files Browse the repository at this point in the history
* Remove deprecated classnames from Navigation Link block
* Update class names in navigation block and navigation editor
  • Loading branch information
carolinan authored Oct 8, 2021
1 parent 724da47 commit d721110
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 20 deletions.
12 changes: 4 additions & 8 deletions packages/block-library/src/navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,13 +516,9 @@ export default function NavigationLinkEdit( {
blockProps.onClick = () => setIsLinkOpen( true );
}

const classes = classnames(
'wp-block-navigation-link__content',
'wp-block-navigation-item__content',
{
'wp-block-navigation-link__placeholder': ! url,
}
);
const classes = classnames( 'wp-block-navigation-item__content', {
'wp-block-navigation-link__placeholder': ! url,
} );

let missingText = '';
switch ( type ) {
Expand Down Expand Up @@ -615,7 +611,7 @@ export default function NavigationLinkEdit( {
<RichText
ref={ ref }
identifier="label"
className="wp-block-navigation-link__label"
className="wp-block-navigation-item__label"
value={ label }
onChange={ ( labelValue ) =>
setAttributes( { label: labelValue } )
Expand Down
8 changes: 4 additions & 4 deletions packages/block-library/src/navigation-link/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
)
);
$html = '<li ' . $wrapper_attributes . '>' .
'<a class="wp-block-navigation-link__content wp-block-navigation-item__content" ';
'<a class="wp-block-navigation-item__content" ';

// Start appending HTML attributes to anchor tag.
if ( isset( $attributes['url'] ) ) {
Expand All @@ -192,7 +192,7 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
// Start anchor tag content.
$html .= '>' .
// Wrap title with span to isolate it from submenu icon.
'<span class="wp-block-navigation-link__label">';
'<span class="wp-block-navigation-item__label">';

if ( isset( $attributes['label'] ) ) {
$html .= wp_kses(
Expand Down Expand Up @@ -220,7 +220,7 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {

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-link__submenu-icon wp-block-navigation__submenu-icon">' . block_core_navigation_link_render_submenu_icon() . '</span>';
$html .= '<span class="wp-block-navigation__submenu-icon">' . block_core_navigation_link_render_submenu_icon() . '</span>';
}

$html .= '</a>';
Expand All @@ -233,7 +233,7 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
}

$html .= sprintf(
'<ul class="wp-block-navigation-link__container wp-block-navigation__submenu-container">%s</ul>',
'<ul class="wp-block-navigation__submenu-container">%s</ul>',
$inner_blocks_html
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/navigation-link/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// those from the Page List block.
.wp-block-navigation {
// This wraps just the innermost text for custom menu items.
.wp-block-navigation-link__label {
.wp-block-navigation-item__label {
word-break: normal;
overflow-wrap: break-word;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/navigation-submenu/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ export default function NavigationSubmenuEdit( {
<RichText
ref={ ref }
identifier="label"
className="wp-block-navigation-link__label"
className="wp-block-navigation-item__label"
value={ label }
onChange={ ( labelValue ) =>
setAttributes( { label: labelValue } )
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/navigation-submenu/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
$html .= '<button class="wp-block-navigation-item__content wp-block-navigation-submenu__toggle" aria-expanded="false">';

// Wrap title with span to isolate it from submenu icon.
$html .= '<span class="wp-block-navigation-link__label">';
$html .= '<span class="wp-block-navigation-item__label">';

if ( isset( $attributes['label'] ) ) {
$html .= wp_kses(
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/navigation/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}

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

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/navigation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The structural CSS for the navigation block targets generic classnames across me
- `.wp-block-navigation__submenu-container` is applied to submenus to main menu items.
- `.wp-block-navigation-item` is applied to every menu item.
- `.wp-block-navigation-item__content` is applied to the link inside a menu item.
- `.wp-block-navigation-link__label` is applied to the innermost container around the menu item text label.
- `.wp-block-navigation-item__label` is applied to the innermost container around the menu item text label.
- `.wp-block-navigation__submenu-icon` is applied to the submenu indicator (chevron).

## Navigation Props
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ describe( 'Navigation', () => {
await createPageButton.click();

const draftLink = await page.waitForSelector(
'.wp-block-navigation-link__content'
'.wp-block-navigation-item__content'
);
await draftLink.click();

Expand Down
4 changes: 2 additions & 2 deletions packages/edit-navigation/src/components/editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@
}
}

.wp-block-navigation-link__label,
.wp-block-navigation-item__label,
.wp-block-navigation-link__placeholder-text {
padding: $grid-unit-05;
padding-left: $grid-unit-10;
line-height: 1;
}

.wp-block-navigation-link__label {
.wp-block-navigation-item__label {
// Without this Links with submenus display a pointer.
cursor: text;
}
Expand Down

0 comments on commit d721110

Please sign in to comment.