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

Add advanced alignment to inspector #1454

Closed
wants to merge 1 commit into from
Closed
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
35 changes: 23 additions & 12 deletions blocks/library/heading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,29 @@ registerBlockType( 'core/heading', {

return [
focus && (
<BlockControls
key="controls"
controls={
'234'.split( '' ).map( ( level ) => ( {
icon: 'heading',
title: sprintf( __( 'Heading %s' ), level ),
isActive: 'H' + level === nodeName,
onClick: () => setAttributes( { nodeName: 'H' + level } ),
subscript: level,
} ) )
}
/>
<BlockControls key="controls">
<Toolbar
controls={ [ {
icon: 'editor-aligncenter',
title: __( 'Align center' ),
isActive: align === 'center',
onClick: () => setAttributes( {
align: align === 'center' ? null : 'center',
} ),
} ] }
/>
<Toolbar
controls={
'234'.split( '' ).map( ( level ) => ( {
icon: 'heading',
title: sprintf( __( 'Heading %s' ), level ),
isActive: 'H' + level === nodeName,
onClick: () => setAttributes( { nodeName: 'H' + level } ),
subscript: level,
} ) )
}
/>
</BlockControls>
),
focus && (
<InspectorControls key="inspector">
Expand Down
18 changes: 17 additions & 1 deletion blocks/library/quote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { registerBlockType, createBlock, query as hpq } from '../../api';
import AlignmentToolbar from '../../alignment-toolbar';
import BlockControls from '../../block-controls';
import Editable from '../../editable';
import InspectorControls from '../../inspector-controls';

const { children, query } = hpq;

Expand Down Expand Up @@ -90,6 +91,16 @@ registerBlockType( 'core/quote', {
return [
focus && (
<BlockControls key="controls">
<Toolbar
controls={ [ {
icon: 'editor-aligncenter',
title: __( 'Align center' ),
isActive: align === 'center',
onClick: () => setAttributes( {
align: align === 'center' ? null : 'center',
} ),
} ] }
/>
<Toolbar controls={ [ 1, 2 ].map( ( variation ) => ( {
icon: 'format-quote',
title: sprintf( __( 'Quote style %d' ), variation ),
Expand All @@ -99,13 +110,18 @@ registerBlockType( 'core/quote', {
},
subscript: variation,
} ) ) } />
</BlockControls>
),
focus && (
<InspectorControls key="inspector">
<h3>{ __( 'Text Alignment' ) }</h3>
<AlignmentToolbar
value={ align }
onChange={ ( nextAlign ) => {
setAttributes( { align: nextAlign } );
} }
/>
</BlockControls>
</InspectorControls>
),
<blockquote
key="quote"
Expand Down
22 changes: 17 additions & 5 deletions blocks/library/text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import { __ } from 'i18n';
import { concatChildren } from 'element';
import { Toolbar } from 'components';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note with #2172, these need to be updated to prefix the dependencies with @wordpress/. You will need to perform a rebase against the latest version of master and apply your changes:

git fetch origin
git rebase origin/master


/**
* Internal dependencies
Expand Down Expand Up @@ -41,11 +42,15 @@ registerBlockType( 'core/text', {
return [
focus && (
<BlockControls key="controls">
<AlignmentToolbar
value={ align }
onChange={ ( nextAlign ) => {
setAttributes( { align: nextAlign } );
} }
<Toolbar
controls={ [ {
icon: 'editor-aligncenter',
title: __( 'Align center' ),
isActive: align === 'center',
onClick: () => setAttributes( {
align: align === 'center' ? null : 'center',
} ),
} ] }
/>
</BlockControls>
),
Expand All @@ -56,6 +61,13 @@ registerBlockType( 'core/text', {
checked={ !! dropCap }
onChange={ toggleDropCap }
/>
<h3>{ __( 'Text Alignment' ) }</h3>
<AlignmentToolbar
value={ align }
onChange={ ( nextAlign ) => {
setAttributes( { align: nextAlign } );
} }
/>
</InspectorControls>
),
<Editable
Expand Down