Skip to content

Commit 5a6a6f6

Browse files
Update button styles
1 parent 286e270 commit 5a6a6f6

File tree

3 files changed

+45
-87
lines changed

3 files changed

+45
-87
lines changed

lib/theme.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,31 @@
370370
"bottom": "0px",
371371
"left": "0px"
372372
}
373+
},
374+
"blocks": {
375+
"core/button": {
376+
"variations": {
377+
"outline": {
378+
"border": {
379+
"width": "2px",
380+
"style": "solid",
381+
"color": "currentColor"
382+
},
383+
"color": {
384+
"text": "currentColor",
385+
"gradient": "transparent none"
386+
},
387+
"spacing": {
388+
"padding": {
389+
"top": "0.667em",
390+
"right": "1.33em",
391+
"bottom": "0.667em",
392+
"left": "1.33em"
393+
}
394+
}
395+
}
396+
}
397+
}
373398
}
374399
}
375400
}

packages/block-library/src/button/editor.scss

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -37,38 +37,3 @@ div[data-type="core/button"] {
3737
text-decoration: inherit;
3838
}
3939

40-
.editor-styles-wrapper .wp-block-button .wp-block-button__link {
41-
// The following styles ensure a default border is applied when the user selects only a border color or style in the editor,
42-
// but no width. They override the `border-width: 0;` applied by core's theme.json via the Elements API button.
43-
&:where(.has-border-color) {
44-
border-width: initial;
45-
}
46-
&:where([style*="border-top-color"]) {
47-
border-top-width: initial;
48-
}
49-
&:where([style*="border-right-color"]) {
50-
border-right-width: initial;
51-
}
52-
&:where([style*="border-bottom-color"]) {
53-
border-bottom-width: initial;
54-
}
55-
&:where([style*="border-left-color"]) {
56-
border-left-width: initial;
57-
}
58-
59-
&:where([style*="border-style"]) {
60-
border-width: initial;
61-
}
62-
&:where([style*="border-top-style"]) {
63-
border-top-width: initial;
64-
}
65-
&:where([style*="border-right-style"]) {
66-
border-right-width: initial;
67-
}
68-
&:where([style*="border-bottom-style"]) {
69-
border-bottom-width: initial;
70-
}
71-
&:where([style*="border-left-style"]) {
72-
border-left-width: initial;
73-
}
74-
}

packages/block-library/src/button/style.scss

Lines changed: 20 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -86,69 +86,37 @@ $blocks-block__margin: 0.5em;
8686
}
8787
}
8888

89-
// the first selector is required for old buttons markup
89+
// The follow block style selectors are required for old buttons markup
90+
// and do not use the `:root :where()` format to match specificity at
91+
// the time they were deprecated.
9092
.wp-block-button.is-style-squared,
9193
.wp-block-button__link.wp-block-button.is-style-squared {
9294
border-radius: 0;
9395
}
94-
95-
// the first selector is required for old buttons markup
9696
.wp-block-button.no-border-radius,
9797
.wp-block-button__link.no-border-radius {
9898
border-radius: 0 !important;
9999
}
100100

101-
.wp-block-button:where(.is-style-outline) > .wp-block-button__link,
102-
.wp-block-button .wp-block-button__link:where(.is-style-outline) {
103-
border: 2px solid currentColor;
104-
padding: 0.667em 1.333em;
105-
}
106-
107-
.wp-block-button:where(.is-style-outline) > .wp-block-button__link:not(.has-text-color),
108-
.wp-block-button .wp-block-button__link:where(.is-style-outline):not(.has-text-color) {
109-
color: currentColor;
110-
}
111-
112-
.wp-block-button:where(.is-style-outline) > .wp-block-button__link:not(.has-background),
113-
.wp-block-button .wp-block-button__link:where(.is-style-outline):not(.has-background) {
114-
background-color: transparent;
115-
// background-image is required to overwrite a gradient background
116-
background-image: none;
117-
}
118-
119-
.wp-block-button .wp-block-button__link {
120-
// The following styles ensure a default border is applied when the user
121-
// selects only a border color or style. This overcomes the zero border
122-
// width applied by core's theme.json via the elements API.
123-
&:where(.has-border-color) {
124-
border-width: initial;
125-
}
126-
&:where([style*="border-top-color"]) {
127-
border-top-width: initial;
128-
}
129-
&:where([style*="border-right-color"]) {
130-
border-right-width: initial;
131-
}
132-
&:where([style*="border-bottom-color"]) {
133-
border-bottom-width: initial;
134-
}
135-
&:where([style*="border-left-color"]) {
136-
border-left-width: initial;
101+
// Selectors here use the `:root :where()` format for maintaining compatibility
102+
// with global styles and nested block style variations.
103+
:root {
104+
// Outline Block Style Variation.
105+
:where(.wp-block-button.is-style-outline > .wp-block-button__link),
106+
:where(.wp-block-button .wp-block-button__link.is-style-outline) {
107+
border: 2px solid currentColor;
108+
padding: 0.667em 1.333em;
137109
}
138110

139-
&:where([style*="border-style"]) {
140-
border-width: initial;
141-
}
142-
&:where([style*="border-top-style"]) {
143-
border-top-width: initial;
111+
:where(.wp-block-button.is-style-outline > .wp-block-button__link:not(.has-text-color)),
112+
:where(.wp-block-button .wp-block-button__link.is-style-outline:not(.has-text-color)) {
113+
color: currentColor;
144114
}
145-
&:where([style*="border-right-style"]) {
146-
border-right-width: initial;
147-
}
148-
&:where([style*="border-bottom-style"]) {
149-
border-bottom-width: initial;
150-
}
151-
&:where([style*="border-left-style"]) {
152-
border-left-width: initial;
115+
116+
:where(.wp-block-button.is-style-outline > .wp-block-button__link:not(.has-background)),
117+
:where(.wp-block-button .wp-block-button__link.is-style-outline:not(.has-background)) {
118+
background-color: transparent;
119+
// background-image is required to overwrite a gradient background
120+
background-image: none;
153121
}
154122
}

0 commit comments

Comments
 (0)