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

Navigation: Refactor and simplify setup state. #36375

Merged
merged 2 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
58 changes: 31 additions & 27 deletions packages/block-library/src/navigation/edit/placeholder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { store as coreStore } from '@wordpress/core-data';
import { useDispatch } from '@wordpress/data';
import { useCallback, useState, useEffect } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { navigation, chevronDown, Icon } from '@wordpress/icons';
import { navigation, Icon } from '@wordpress/icons';

/**
* Internal dependencies
Expand All @@ -34,13 +34,14 @@ const ExistingMenusDropdown = ( {
onCreateFromMenu,
} ) => {
const toggleProps = {
variant: 'primary',
variant: 'tertiary',
iconPosition: 'right',
className: 'wp-block-navigation-placeholder__actions__dropdown',
};
return (
<DropdownMenu
text={ __( 'Select existing menu' ) }
icon={ chevronDown }
text={ __( 'Select menu' ) }
icon={ null }
toggleProps={ toggleProps }
popoverProps={ { isAlternate: true } }
>
Expand Down Expand Up @@ -201,32 +202,35 @@ export default function NavigationPlaceholder( {
<Icon icon={ navigation } />{ ' ' }
{ __( 'Navigation' ) }
</div>
<hr />
{ hasMenus || navigationMenus.length ? (
<ExistingMenusDropdown
canSwitchNavigationMenu={
canSwitchNavigationMenu
}
navigationMenus={ navigationMenus }
setSelectedMenu={ setSelectedMenu }
onFinish={ onFinish }
menus={ menus }
onCreateFromMenu={ onCreateFromMenu }
/>
<>
<ExistingMenusDropdown
canSwitchNavigationMenu={
canSwitchNavigationMenu
}
navigationMenus={ navigationMenus }
setSelectedMenu={ setSelectedMenu }
onFinish={ onFinish }
menus={ menus }
onCreateFromMenu={ onCreateFromMenu }
/>
<hr />
</>
) : undefined }
{ hasPages ? (
<Button
variant={
hasMenus || canSwitchNavigationMenu
? 'tertiary'
: 'primary'
}
onClick={ () => {
setIsNewMenuModalVisible( true );
setCreateEmpty( false );
} }
>
{ __( 'Add all pages' ) }
</Button>
<>
<Button
variant="tertiary"
onClick={ () => {
setIsNewMenuModalVisible( true );
setCreateEmpty( false );
} }
>
{ __( 'Add all pages' ) }
</Button>
<hr />
</>
) : undefined }
<Button
variant="tertiary"
Expand Down
44 changes: 26 additions & 18 deletions packages/block-library/src/navigation/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ $color-control-label-height: 20px;
.wp-block-navigation-placeholder__actions {
flex-direction: column;
}

// Hide the separators in the vertical version.
.wp-block-navigation-placeholder__actions hr {
display: none;
}
}

.wp-block-navigation-placeholder__icon {
Expand All @@ -333,47 +338,50 @@ $color-control-label-height: 20px;

// Block title
.wp-block-navigation-placeholder__actions__indicator {
margin-right: $grid-unit-15;
padding: 0;
display: flex;
padding: 0 ($grid-unit-15 * 0.5) 0 0;
align-items: center;
justify-content: flex-start;
line-height: 0;
min-height: $button-size;

// Line up with the icon in the toolbar.
margin-left: $grid-unit-05 + $border-width;
margin-left: $grid-unit-05;

svg {
margin-right: $grid-unit-05;
}

// Show only in big placeholders.
display: none;
.is-large & {
display: inline-flex;
}
}
}

.wp-block-navigation-placeholder__actions {
display: flex;
font-size: $default-font-size;
font-family: $default-font;

.components-button.components-dropdown-menu__toggle.has-icon {
padding:
( $grid-unit-15 * 0.5 ) $grid-unit-05 ( $grid-unit-15 * 0.5 )
$grid-unit-15;
display: flex;
flex-direction: row-reverse; // This puts the chevron, which is hidden from screen readers, on the right.
}
gap: $grid-unit-15 * 0.5;

// Margins.
.components-dropdown,
> .components-button {
margin-right: $grid-unit-15;
margin-right: 0;
}

// Separator.
height: 100%; // This allows the separator to scale vertically.

// Separator.
&.wp-block-navigation-placeholder__actions hr {
border: 0;
min-height: $border-width;
min-width: $border-width;
background-color: $gray-900;
margin: auto 0;
height: 100%;
max-height: $grid-unit-20;
}
}


/**
* Mobile menu.
*/
Expand Down