Skip to content

Commit

Permalink
Inserter: Move "Saved" blocks to the bottom and show icon (#7021)
Browse files Browse the repository at this point in the history
* Add support for rendering an icon in component-panel title.
* Inserter: move "saved" blocks to the bottom and display icon.
* Update snapshots.
  • Loading branch information
mtias committed May 31, 2018
1 parent c591184 commit 02c9edb
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
7 changes: 4 additions & 3 deletions components/panel/body.js
Expand Up @@ -37,9 +37,9 @@ class PanelBody extends Component {
}

render() {
const { title, children, opened, className } = this.props;
const { title, children, opened, className, icon } = this.props;
const isOpened = opened === undefined ? this.state.opened : opened;
const icon = `arrow-${ isOpened ? 'up' : 'down' }`;
const arrow = `arrow-${ isOpened ? 'up' : 'down' }`;
const classes = classnames( 'components-panel__body', className, { 'is-opened': isOpened } );

return (
Expand All @@ -51,7 +51,8 @@ class PanelBody extends Component {
onClick={ this.toggle }
aria-expanded={ isOpened }
>
<Dashicon icon={ icon } />
<Dashicon icon={ arrow } className="components-panel__arrow" />
{ icon && <Dashicon icon={ icon } className="components-panel__icon" /> }
{ title }
</Button>
</h2>
Expand Down
9 changes: 8 additions & 1 deletion components/panel/style.scss
Expand Up @@ -80,7 +80,7 @@
@include menu-style__focus;
}

.dashicon {
.components-panel__arrow {
position: absolute;
right: $item-spacing;
top: 50%;
Expand All @@ -98,6 +98,13 @@
/* rtl:end:ignore */
}

.components-panel__icon {
color: $dark-gray-400;
margin-right: 5px;
position: relative;
top: -2px;
}

.components-panel__body-toggle-icon {
margin-right: -5px;
}
Expand Down
Expand Up @@ -26,11 +26,12 @@ exports[`PluginPostPublishPanel renders fill properly 1`] = `
type="button"
>
<Dashicon
className="components-panel__arrow"
icon="arrow-up"
>
<svg
aria-hidden={true}
className="dashicon dashicons-arrow-up"
className="dashicon dashicons-arrow-up components-panel__arrow"
focusable="false"
height={20}
role="img"
Expand Down
Expand Up @@ -26,11 +26,12 @@ exports[`PluginPrePublishPanel renders fill properly 1`] = `
type="button"
>
<Dashicon
className="components-panel__arrow"
icon="arrow-up"
>
<svg
aria-hidden={true}
className="dashicon dashicons-arrow-up"
className="dashicon dashicons-arrow-up components-panel__arrow"
focusable="false"
height={20}
role="img"
Expand Down
22 changes: 10 additions & 12 deletions editor/components/inserter/menu.js
Expand Up @@ -185,17 +185,6 @@ export class InserterMenu extends Component {
<ItemList items={ suggestedItems } onSelect={ onSelect } onHover={ this.onHover } />
</PanelBody>
}

{ !! sharedItems.length && (
<PanelBody
title={ __( 'Shared' ) }
opened={ isPanelOpen( 'shared' ) }
onToggle={ this.onTogglePanel( 'shared' ) }
>
<ItemList items={ sharedItems } onSelect={ onSelect } onHover={ this.onHover } />
</PanelBody>
) }

{ map( getCategories(), ( category ) => {
const categoryItems = itemsPerCategory[ category.slug ];
if ( ! categoryItems || ! categoryItems.length ) {
Expand All @@ -212,7 +201,16 @@ export class InserterMenu extends Component {
</PanelBody>
);
} ) }

{ !! sharedItems.length && (
<PanelBody
title={ __( 'Shared' ) }
opened={ isPanelOpen( 'shared' ) }
onToggle={ this.onTogglePanel( 'shared' ) }
icon="controls-repeat"
>
<ItemList items={ sharedItems } onSelect={ onSelect } onHover={ this.onHover } />
</PanelBody>
) }
{ isEmpty( suggestedItems ) && isEmpty( sharedItems ) && isEmpty( itemsPerCategory ) && (
<p className="editor-inserter__no-results">{ __( 'No blocks found.' ) }</p>
) }
Expand Down

0 comments on commit 02c9edb

Please sign in to comment.