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

Show the block styles in the block inspector #10543

Merged
merged 4 commits into from
Oct 15, 2018
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
54 changes: 35 additions & 19 deletions packages/editor/src/components/block-inspector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { __ } from '@wordpress/i18n';
import { getBlockType } from '@wordpress/blocks';
import { PanelBody } from '@wordpress/components';
import { withSelect } from '@wordpress/data';
import { Fragment } from '@wordpress/element';

/**
* Internal Dependencies
Expand All @@ -18,6 +19,7 @@ import SkipToSelectedBlock from '../skip-to-selected-block';
import BlockIcon from '../block-icon';
import InspectorControls from '../inspector-controls';
import InspectorAdvancedControls from '../inspector-advanced-controls';
import BlockStyles from '../block-styles';

const BlockInspector = ( { selectedBlock, blockType, count } ) => {
if ( count > 1 ) {
Expand All @@ -28,30 +30,44 @@ const BlockInspector = ( { selectedBlock, blockType, count } ) => {
return <span className="editor-block-inspector__no-blocks">{ __( 'No block selected.' ) }</span>;
}

return [
<div className="editor-block-inspector__card" key="card">
<BlockIcon icon={ blockType.icon } showColors />
<div className="editor-block-inspector__card-content">
<div className="editor-block-inspector__card-title">{ blockType.title }</div>
<div className="editor-block-inspector__card-description">{ blockType.description }</div>
return (
<Fragment>
<div className="editor-block-inspector__card">
<BlockIcon icon={ blockType.icon } showColors />
<div className="editor-block-inspector__card-content">
<div className="editor-block-inspector__card-title">{ blockType.title }</div>
<div className="editor-block-inspector__card-description">{ blockType.description }</div>
</div>
</div>
</div>,
<div key="inspector-controls"><InspectorControls.Slot /></div>,
<div key="inspector-advanced-controls">
<InspectorAdvancedControls.Slot>
{ ( fills ) => ! isEmpty( fills ) && (
{ !! blockType.styles && (
<div>
<PanelBody
className="editor-block-inspector__advanced"
title={ __( 'Advanced' ) }
title={ __( 'Styles' ) }
initialOpen={ false }
>
{ fills }
<BlockStyles
clientId={ selectedBlock.clientId }
/>
</PanelBody>
) }
</InspectorAdvancedControls.Slot>
</div>,
<SkipToSelectedBlock key="back" />,
];
</div>
) }
<div><InspectorControls.Slot /></div>
<div>
youknowriad marked this conversation as resolved.
Show resolved Hide resolved
<InspectorAdvancedControls.Slot>
{ ( fills ) => ! isEmpty( fills ) && (
<PanelBody
className="editor-block-inspector__advanced"
title={ __( 'Advanced' ) }
initialOpen={ false }
>
{ fills }
</PanelBody>
) }
</InspectorAdvancedControls.Slot>
</div>
<SkipToSelectedBlock key="back" />
</Fragment>
);
};

export default withSelect(
Expand Down
1 change: 1 addition & 0 deletions packages/editor/src/components/block-inspector/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@
width: $icon-button-size;
height: $icon-button-size-small;
}

6 changes: 3 additions & 3 deletions packages/editor/src/components/block-styles/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { find, get } from 'lodash';
import { find, get, noop } from 'lodash';
import classnames from 'classnames';

/**
Expand Down Expand Up @@ -69,8 +69,8 @@ function BlockStyles( {
onChangeClassName,
name,
attributes,
onSwitch,
onHoverClassName,
onSwitch = noop,
onHoverClassName = noop,
} ) {
if ( ! styles ) {
return null;
Expand Down