Skip to content

Commit

Permalink
Add icon to menu item.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZebulanStanphill committed Oct 13, 2020
1 parent 2ab5913 commit e324a60
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { getBlockType, serialize } from '@wordpress/blocks';
* Internal dependencies
*/
import BlockActions from '../block-actions';
import BlockIcon from '../block-icon';
import BlockModeToggle from './block-mode-toggle';
import BlockHTMLConvertButton from './block-html-convert-button';
import __experimentalBlockSettingsMenuFirstItem from './block-settings-menu-first-item';
Expand Down Expand Up @@ -125,6 +126,11 @@ export function BlockSettingsDropdown( {
/>
{ firstParentClientId !== undefined && (
<MenuItem
icon={
<BlockIcon
icon={ parentBlockType.icon }
/>
}
onClick={ () =>
selectBlock( firstParentClientId )
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@
}
}

// Override standard MenuItem icon spacing, since the block transform icons are
// shown on the left, rather than the right.
.block-editor-block-switcher__transforms__menugroup .block-editor-block-icon {
margin-left: -2px; // This optically balances the icon.
margin-right: $grid-unit-10;
}

.block-editor-block-switcher__popover__preview__parent {
.block-editor-block-switcher__popover__preview__container {
position: absolute;
Expand Down
6 changes: 0 additions & 6 deletions packages/components/src/menu-item/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
.components-menu-item__shortcut + .components-menu-items__item-icon {
margin-left: $grid-unit-10;
}

// If a block item is shown inline (such as transforms), space it correctly.
.block-editor-block-icon {
margin-left: -2px; // This optically balances the icon.
margin-right: $grid-unit-10;
}
}

.components-menu-item__info-wrapper {
Expand Down

0 comments on commit e324a60

Please sign in to comment.