Skip to content

Commit

Permalink
Storing controls as an object bu slug
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Apr 20, 2017
1 parent 17f8e73 commit 296bef3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
16 changes: 6 additions & 10 deletions blocks/controls/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,31 @@ function applyOrUnset( position ) {
};
}

const controls = [
{
slug: 'core/position-left',
const controls = {
'core/position-left': {
icon: 'align-left',
title: wp.i18n.__( 'Position left' ),
isActive: ( { position } ) => 'left' === position,
onClick: applyOrUnset( 'left' )
},
{
slug: 'core/position-center',
'core/position-center': {
icon: 'align-center',
title: wp.i18n.__( 'Position center' ),
isActive: ( { position } ) => 'center' === position,
onClick: applyOrUnset( 'center' )
},
{
slug: 'core/position-right',
'core/position-right': {
icon: 'align-right',
title: wp.i18n.__( 'Position right' ),
isActive: ( { position } ) => 'right' === position,
onClick: applyOrUnset( 'right' )
},
{
slug: 'core/position-none',
'core/position-none': {
icon: 'align-none',
title: wp.i18n.__( 'No positionning' ),
isActive: ( { position } ) => ! position || 'none' === position,
onClick: applyOrUnset( 'none' )
}
];
};

export default controls;
5 changes: 1 addition & 4 deletions editor/modes/visual-editor/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ function VisualEditorBlock( props ) {

const controls = settings.controls && compact(
settings.controls.map( ( control ) => {
if ( isString( control ) ) {
return wp.blocks.controls.find( ctrl => ctrl.slug === control );
}
return control;
return isString( control ) ? wp.blocks.controls[ control ] : control;
} )
);

Expand Down
8 changes: 4 additions & 4 deletions languages/gutenberg.pot
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"X-Generator: babel-plugin-wp-i18n\n"

#: blocks/controls/index.js:12
#: blocks/controls/index.js:11
msgid "Position left"
msgstr ""

#: blocks/controls/index.js:19
#: blocks/controls/index.js:17
msgid "Position center"
msgstr ""

#: blocks/controls/index.js:26
#: blocks/controls/index.js:23
msgid "Position right"
msgstr ""

#: blocks/controls/index.js:33
#: blocks/controls/index.js:29
msgid "No positionning"
msgstr ""

Expand Down

0 comments on commit 296bef3

Please sign in to comment.