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

Buttons: Add space-between justification controls #29160

Merged
merged 3 commits into from Feb 22, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/block-library/src/buttons/edit.js
Expand Up @@ -42,11 +42,16 @@ function ButtonsEdit( {
templateInsertUpdatesSelection: true,
} );

const justifyControls =
orientation === 'vertical'
? [ 'left', 'center', 'right' ]
: [ 'left', 'center', 'right', 'space-between' ];

return (
<>
<BlockControls>
<JustifyToolbar
allowedControls={ [ 'left', 'center', 'right' ] }
allowedControls={ justifyControls }
value={ contentJustification }
onChange={ ( value ) =>
setAttributes( { contentJustification: value } )
Expand Down
9 changes: 7 additions & 2 deletions packages/block-library/src/buttons/edit.native.js
Expand Up @@ -31,7 +31,7 @@ const BUTTONS_TEMPLATE = [ [ 'core/button' ] ];
const layoutProp = { type: 'default', alignments: [] };

export default function ButtonsEdit( {
attributes: { contentJustification, align },
attributes: { contentJustification, align, orientation },
clientId,
isSelected,
setAttributes,
Expand Down Expand Up @@ -114,14 +114,19 @@ export default function ButtonsEdit( {
</View>
) );

const justifyControls =
orientation === 'vertical'
? [ 'left', 'center', 'right' ]
: [ 'left', 'center', 'right', 'space-between' ];

const remove = useCallback( () => removeBlock( clientId ), [ clientId ] );
const shouldRenderFooterAppender = isSelected || isInnerButtonSelected;
return (
<>
{ isSelected && (
<BlockControls>
<JustifyToolbar
allowedControls={ [ 'left', 'center', 'right' ] }
allowedControls={ justifyControls }
value={ contentJustification }
onChange={ ( value ) =>
setAttributes( { contentJustification: value } )
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/buttons/style.scss
Expand Up @@ -92,4 +92,8 @@ $blocks-block__margin: 0.5em;
margin-left: 0;
}
}

&.is-content-justification-space-between {
justify-content: space-between;
}
}