-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Surface alignment toolbar as block control
- Loading branch information
Showing
9 changed files
with
109 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from 'i18n'; | ||
import { Toolbar } from 'components'; | ||
|
||
const ALIGNMENT_CONTROLS = [ | ||
{ | ||
icon: 'editor-alignleft', | ||
title: __( 'Align left' ), | ||
align: 'left', | ||
}, | ||
{ | ||
icon: 'editor-aligncenter', | ||
title: __( 'Align center' ), | ||
align: 'center', | ||
}, | ||
{ | ||
icon: 'editor-alignright', | ||
title: __( 'Align right' ), | ||
align: 'right', | ||
}, | ||
]; | ||
|
||
export default function AlignmentToolbar( { value, onChange } ) { | ||
return ( | ||
<Toolbar | ||
controls={ ALIGNMENT_CONTROLS.map( ( control ) => { | ||
const { align } = control; | ||
const isActive = ( value === align ); | ||
|
||
return { | ||
...control, | ||
isActive, | ||
onClick: () => onChange( isActive ? null : align ), | ||
}; | ||
} ) } | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<!-- wp:core/text --> | ||
<!-- wp:core/text align="right" --> | ||
<p style="text-align:right;">... like this one, which is separate from the above and right aligned.</p> | ||
<!-- /wp:core/text --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
"uid": "_uid_0", | ||
"name": "core/text", | ||
"attributes": { | ||
"align": "right", | ||
"content": [ | ||
{ | ||
"type": "p", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<!-- wp:core/text --> | ||
<!-- wp:core/text align="right" --> | ||
<p style="text-align:right;">... like this one, which is separate from the above and right aligned.</p> | ||
<!-- /wp:core/text --> | ||
|