Skip to content

Commit

Permalink
Revert did not include PHP render file, cause was moved
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravobernal committed Feb 19, 2024
1 parent cd4e8da commit 2a95460
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,25 +390,16 @@ private static function get_classes( $attributes ) {
$text_decoration = $attributes['style']['typography']['textDecoration'] ?? null;
$text_decoration_class = sprintf( 'has-text-decoration-%s', $text_decoration );

// Sets the is-collapsed class when the navigation is set to always use the overlay.
// This saves us from needing to do this check in the view.js file (see the collapseNav function).
$is_collapsed_class = static::is_always_overlay( $attributes ) ? array( 'is-collapsed' ) : array();

$classes = array_merge(
$colors['css_classes'],
$font_sizes['css_classes'],
$is_responsive_menu ? array( 'is-responsive' ) : array(),
$layout_class ? array( $layout_class ) : array(),
$text_decoration ? array( $text_decoration_class ) : array(),
$is_collapsed_class
$text_decoration ? array( $text_decoration_class ) : array()
);
return implode( ' ', $classes );
}

private static function is_always_overlay( $attributes ) {
return isset( $attributes['overlayMenu'] ) && 'always' === $attributes['overlayMenu'];
}

/**
* Get styles for the navigation block.
*
Expand All @@ -435,12 +426,16 @@ private static function get_responsive_container_markup( $attributes, $inner_blo
$colors = block_core_navigation_build_css_colors( $attributes );
$modal_unique_id = wp_unique_id( 'modal-' );

$is_hidden_by_default = isset( $attributes['overlayMenu'] ) && 'always' === $attributes['overlayMenu'];

$responsive_container_classes = array(
'wp-block-navigation__responsive-container',
$is_hidden_by_default ? 'hidden-by-default' : '',
implode( ' ', $colors['overlay_css_classes'] ),
);
$open_button_classes = array(
'wp-block-navigation__responsive-container-open',
$is_hidden_by_default ? 'always-shown' : '',
);

$should_display_icon_label = isset( $attributes['hasIcon'] ) && true === $attributes['hasIcon'];
Expand Down Expand Up @@ -538,7 +533,7 @@ private static function get_nav_wrapper_attributes( $attributes, $inner_blocks )
);

if ( $is_responsive_menu ) {
$nav_element_directives = static::get_nav_element_directives( $is_interactive, $attributes );
$nav_element_directives = static::get_nav_element_directives( $is_interactive );
$wrapper_attributes .= ' ' . $nav_element_directives;
}

Expand All @@ -552,7 +547,7 @@ private static function get_nav_wrapper_attributes( $attributes, $inner_blocks )
* @param array $attributes The block attributes.
* @return string the directives for the navigation element.
*/
private static function get_nav_element_directives( $is_interactive, $attributes ) {
private static function get_nav_element_directives( $is_interactive ) {
if ( ! $is_interactive ) {
return '';
}
Expand All @@ -569,16 +564,6 @@ private static function get_nav_element_directives( $is_interactive, $attributes
data-wp-interactive="core/navigation"'
. $nav_element_context;

/*
* When the navigation's 'overlayMenu' attribute is set to 'always', JavaScript
* is not needed for collapsing the menu because the class is set manually.
*/
if ( ! static::is_always_overlay( $attributes ) ) {
$nav_element_directives .= 'data-wp-init="callbacks.initNav"';
$nav_element_directives .= ' '; // space separator
$nav_element_directives .= 'data-wp-class--is-collapsed="context.isCollapsed"';
}

return $nav_element_directives;
}

Expand Down

0 comments on commit 2a95460

Please sign in to comment.