Skip to content

Commit

Permalink
Remove max width from buttons with custom width set
Browse files Browse the repository at this point in the history
PR WordPress#23168 overhauls alignment controls on the Buttons container and
allows for full width. For a Button inside a very large container,
in order to be set correctly to 100% it must be able to exceed any
configured max-width.

This commit does not remove the max-width for any button that does
NOT have a custom width percentage selected. This is so that
default buttons continue to be sized as they normally would.
  • Loading branch information
Staci Cooper authored and Staci Cooper committed Oct 28, 2020
1 parent 99e243c commit 3780aa5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/block-library/src/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ function ButtonEdit( props ) {
<div
{ ...blockProps }
className={ classnames( blockProps.className, {
[ `wp-block-button__width-${ width }` ]: width,
[ `has-custom-width wp-block-button__width-${ width }` ]: width,
} ) }
>
<RichText
Expand Down
17 changes: 6 additions & 11 deletions packages/block-library/src/button/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,27 @@ $blocks-button__height: 3.1em;
}

.wp-block-button {
&.wp-block-button__width-25 {
width: 25%;
&.has-custom-width {
max-width: none;
.wp-block-button__link {
width: 100%;
}
}

&.wp-block-button__width-25 {
width: 25%;
}

&.wp-block-button__width-50 {
width: 50%;
.wp-block-button__link {
width: 100%;
}
}

&.wp-block-button__width-75 {
width: 75%;
.wp-block-button__link {
width: 100%;
}
}

&.wp-block-button__width-100 {
width: 100%;
.wp-block-button__link {
width: 100%;
}
}
}

Expand Down

0 comments on commit 3780aa5

Please sign in to comment.