Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated classnames from Navigation Link block #35358

Merged
merged 4 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-litem__label"
carolinan marked this conversation as resolved.
Show resolved Hide resolved
carolinan marked this conversation as resolved.
Show resolved Hide resolved
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what these docs about Nav block classnames are doing in the components package 🤔 they should be in the block folder instead. No need to fix that here though, I've created #35445 to address it separately.

- `.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