Skip to content

Commit

Permalink
Update button styles
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed May 23, 2024
1 parent 286e270 commit 5a6a6f6
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 87 deletions.
25 changes: 25 additions & 0 deletions lib/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,31 @@
"bottom": "0px",
"left": "0px"
}
},
"blocks": {
"core/button": {
"variations": {
"outline": {
"border": {
"width": "2px",
"style": "solid",
"color": "currentColor"
},
"color": {
"text": "currentColor",
"gradient": "transparent none"
},
"spacing": {
"padding": {
"top": "0.667em",
"right": "1.33em",
"bottom": "0.667em",
"left": "1.33em"
}
}
}
}
}
}
}
}
35 changes: 0 additions & 35 deletions packages/block-library/src/button/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,38 +37,3 @@ div[data-type="core/button"] {
text-decoration: inherit;
}

.editor-styles-wrapper .wp-block-button .wp-block-button__link {
// The following styles ensure a default border is applied when the user selects only a border color or style in the editor,
// but no width. They override the `border-width: 0;` applied by core's theme.json via the Elements API button.
&:where(.has-border-color) {
border-width: initial;
}
&:where([style*="border-top-color"]) {
border-top-width: initial;
}
&:where([style*="border-right-color"]) {
border-right-width: initial;
}
&:where([style*="border-bottom-color"]) {
border-bottom-width: initial;
}
&:where([style*="border-left-color"]) {
border-left-width: initial;
}

&:where([style*="border-style"]) {
border-width: initial;
}
&:where([style*="border-top-style"]) {
border-top-width: initial;
}
&:where([style*="border-right-style"]) {
border-right-width: initial;
}
&:where([style*="border-bottom-style"]) {
border-bottom-width: initial;
}
&:where([style*="border-left-style"]) {
border-left-width: initial;
}
}
72 changes: 20 additions & 52 deletions packages/block-library/src/button/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -86,69 +86,37 @@ $blocks-block__margin: 0.5em;
}
}

// the first selector is required for old buttons markup
// The follow block style selectors are required for old buttons markup
// and do not use the `:root :where()` format to match specificity at
// the time they were deprecated.
.wp-block-button.is-style-squared,
.wp-block-button__link.wp-block-button.is-style-squared {
border-radius: 0;
}

// the first selector is required for old buttons markup
.wp-block-button.no-border-radius,
.wp-block-button__link.no-border-radius {
border-radius: 0 !important;
}

.wp-block-button:where(.is-style-outline) > .wp-block-button__link,
.wp-block-button .wp-block-button__link:where(.is-style-outline) {
border: 2px solid currentColor;
padding: 0.667em 1.333em;
}

.wp-block-button:where(.is-style-outline) > .wp-block-button__link:not(.has-text-color),
.wp-block-button .wp-block-button__link:where(.is-style-outline):not(.has-text-color) {
color: currentColor;
}

.wp-block-button:where(.is-style-outline) > .wp-block-button__link:not(.has-background),
.wp-block-button .wp-block-button__link:where(.is-style-outline):not(.has-background) {
background-color: transparent;
// background-image is required to overwrite a gradient background
background-image: none;
}

.wp-block-button .wp-block-button__link {
// The following styles ensure a default border is applied when the user
// selects only a border color or style. This overcomes the zero border
// width applied by core's theme.json via the elements API.
&:where(.has-border-color) {
border-width: initial;
}
&:where([style*="border-top-color"]) {
border-top-width: initial;
}
&:where([style*="border-right-color"]) {
border-right-width: initial;
}
&:where([style*="border-bottom-color"]) {
border-bottom-width: initial;
}
&:where([style*="border-left-color"]) {
border-left-width: initial;
// Selectors here use the `:root :where()` format for maintaining compatibility
// with global styles and nested block style variations.
:root {
// Outline Block Style Variation.
:where(.wp-block-button.is-style-outline > .wp-block-button__link),
:where(.wp-block-button .wp-block-button__link.is-style-outline) {
border: 2px solid currentColor;
padding: 0.667em 1.333em;
}

&:where([style*="border-style"]) {
border-width: initial;
}
&:where([style*="border-top-style"]) {
border-top-width: initial;
:where(.wp-block-button.is-style-outline > .wp-block-button__link:not(.has-text-color)),
:where(.wp-block-button .wp-block-button__link.is-style-outline:not(.has-text-color)) {
color: currentColor;
}
&:where([style*="border-right-style"]) {
border-right-width: initial;
}
&:where([style*="border-bottom-style"]) {
border-bottom-width: initial;
}
&:where([style*="border-left-style"]) {
border-left-width: initial;

:where(.wp-block-button.is-style-outline > .wp-block-button__link:not(.has-background)),
:where(.wp-block-button .wp-block-button__link.is-style-outline:not(.has-background)) {
background-color: transparent;
// background-image is required to overwrite a gradient background
background-image: none;
}
}

0 comments on commit 5a6a6f6

Please sign in to comment.