Skip to content

Commit

Permalink
Styling adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Sep 7, 2021
1 parent cb65b92 commit b386aba
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
19 changes: 11 additions & 8 deletions packages/edit-navigation/src/components/block-placeholder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ function convertPagesToBlocks( pages ) {
);
}

const TOGGLE_PROPS = { variant: 'tertiary' };
const POPOVER_PROPS = { position: 'bottom center' };

function BlockPlaceholder( { onCreate }, ref ) {
const [ selectedMenu, setSelectedMenu ] = useState();
const [ isCreatingFromMenu, setIsCreatingFromMenu ] = useState( false );
Expand Down Expand Up @@ -108,10 +111,6 @@ function BlockPlaceholder( { onCreate }, ref ) {
}
}, [ isCreatingFromMenu, hasResolvedMenuItems ] );

const toggleProps = {
variant: 'tertiary',
};

const selectableMenus = menus?.filter(
( menu ) => menu.id !== selectedMenuId
);
Expand All @@ -120,21 +119,24 @@ function BlockPlaceholder( { onCreate }, ref ) {

return (
<Placeholder
className="wp-block-placeholder"
className="edit-navigation-block-placeholder"
label={ menuName }
instructions={ __(
'This menu is empty. You can start blank and choose what to add,' +
' add your existing pages, or add the content of another menu.'
) }
>
<div className="wp-block-placeholder__controls">
<div className="edit-navigation-block-placeholder__controls">
{ isLoading && (
<div ref={ ref }>
<Spinner />
</div>
) }
{ ! isLoading && (
<div ref={ ref } className="wp-block-placeholder__actions">
<div
ref={ ref }
className="edit-navigation-block-placeholder__actions"
>
<Button
variant="tertiary"
onClick={ onCreateEmptyMenu }
Expand All @@ -153,7 +155,8 @@ function BlockPlaceholder( { onCreate }, ref ) {
<DropdownMenu
text={ __( 'Copy existing menu' ) }
icon={ chevronDown }
toggleProps={ toggleProps }
toggleProps={ TOGGLE_PROPS }
popoverProps={ POPOVER_PROPS }
>
{ ( { onClose } ) => (
<MenuGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
.wp-block-placeholder {
.edit-navigation-block-placeholder {
// The navigation editor already has a border around content.
// Hide the placeholder's border. Requires extra specificity.
&.wp-block-placeholder {
&.edit-navigation-block-placeholder {
box-shadow: none;
background: transparent;

@include break-medium() {
margin: -$grid-unit-20 0;
}
}

// Show placeholder instructions when it's a medium size.
Expand All @@ -11,29 +16,36 @@
}

// Display buttons in a column when placeholder is small.
.wp-block-placeholder__actions {
.edit-navigation-block-placeholder__actions {
display: flex;
flex-direction: column;
align-items: flex-start;

.components-button {
margin-bottom: $grid-unit-15;
margin-bottom: $grid-unit-05;
margin-right: 0;

// Avoid bottom margin on the dropdown since it makes the
// menu anchor itself too far away from the button.
&.components-dropdown-menu__toggle {
margin-bottom: 0;

svg {
// Make the spacing inside the left of the button match the
// spacing inside the right of the button.
margin-left: -6px;
}
}
}
}

@include break-medium() {
.wp-block-placeholder__actions {
.edit-navigation-block-placeholder__actions {
flex-direction: row;
}

// Change the default button margin. Again use extra specificity.
&.wp-block-placeholder.is-medium .components-button {
&.edit-navigation-block-placeholder.is-medium .components-button {
margin-bottom: 0;
margin-right: $grid-unit-15;
}
Expand Down

0 comments on commit b386aba

Please sign in to comment.