Skip to content

Commit

Permalink
Try: Always collapse block alignments.
Browse files Browse the repository at this point in the history
This PR makes the block alignments always be collapsed. This group would already collapse at mobile responsive breakpoints. In addition, this PR also adds a dropdown arrow.

This comes with a couple of benefit:

- It ensures that the block toolbar always fits even when the item is deeply nested inside columns.
- It affords a scalable method to show additional alignment options, such as those suggested in #16385.
- It scales to future ideas of allowing a theme to create CSS grid-based layouts, which could allow theme authors to create their own custom alignments such as "pull right" or others.
- It has labels, to be descriptive of such new alignments.

Noting that 3 is just an idea at this point, but the other items on the list can potentially benefit us today.
  • Loading branch information
Joen Asmussen committed Jul 12, 2019
1 parent 86c1562 commit 8f12cf0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,12 @@ export default compose(
};
} ),
withViewportMatch( { isLargeViewport: 'medium' } ),
withSelect( ( select, { clientId, isLargeViewport, isCollapsed } ) => {
const { getBlockRootClientId, getSettings } = select( 'core/block-editor' );
withSelect( ( select ) => {
const { getSettings } = select( 'core/block-editor' );
const settings = getSettings();
return {
wideControlsEnabled: settings.alignWide,
isCollapsed: isCollapsed || ! isLargeViewport || (
! settings.hasFixedToolbar &&
getBlockRootClientId( clientId )
),
isCollapsed: true,
};
} ),
)( BlockAlignmentToolbar );
6 changes: 6 additions & 0 deletions packages/components/src/dropdown-menu/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
@include dropdown-arrow();
}
}

// Add a dropdown arrow indicator.
&.components-toolbar .components-dropdown-menu__toggle::after {
@include dropdown-arrow();
}

}

.components-dropdown-menu__popover .components-popover__content {
Expand Down

0 comments on commit 8f12cf0

Please sign in to comment.