Skip to content

Commit 81edcde

Browse files
authored
refactor(button): remove spectrum-ButtonWithFocusRing extend (#2725)
The styles had previously diverged from what this placeholder class was providing, which was causing an issue with needing to override styles with unnecessary CSS. This cleans that up by integrating the small number of styles from spectrum-ButtonWithFocusRing that were not already present, and removing that "extend".
1 parent e73a897 commit 81edcde

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

.changeset/fresh-seahorses-join.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@spectrum-css/button": patch
3+
---
4+
5+
#### refactor: remove spectrum-ButtonWithFocusRing placeholder class extend
6+
7+
Removes the need for the extend from this placeholder class, as the styles it provides have diverged slightly from what is in button and it was causing some unnecessary CSS to override.
8+
This should not result in any changed visuals or behavior, as the same CSS has been integrated.

components/button/index.css

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ governing permissions and limitations under the License.
331331

332332
.spectrum-Button {
333333
@extend %spectrum-BaseButton;
334-
@extend %spectrum-ButtonWithFocusRing;
335334

336335
border-radius: var(--mod-button-border-radius, var(--spectrum-button-border-radius));
337336
border-width: var(--mod-button-border-width, var(--spectrum-button-border-width));
@@ -384,6 +383,8 @@ governing permissions and limitations under the License.
384383

385384
/* Focus indicator */
386385
&::after {
386+
content: "";
387+
display: block;
387388
position: absolute;
388389
inset: 0;
389390
margin: calc((
@@ -397,7 +398,6 @@ governing permissions and limitations under the License.
397398
));
398399
transition: box-shadow var(--mod-button-animation-duration, var(--spectrum-button-animation-duration)) ease-in-out;
399400
pointer-events: none;
400-
content: '';
401401
}
402402

403403
&:focus-visible,
@@ -409,13 +409,6 @@ governing permissions and limitations under the License.
409409
box-shadow: 0 0 0
410410
var(--mod-button-focus-ring-thickness, var(--spectrum-button-focus-ring-thickness))
411411
var(--highcontrast-button-focus-ring-color, var(--mod-button-focus-ring-color, var(--spectrum-button-focus-indicator-color)));
412-
413-
/* Margin is repeated to override declaration coming from the imported BaseButton. */
414-
margin: calc((
415-
var(--mod-button-focus-ring-gap, var(--spectrum-button-focus-ring-gap)) +
416-
var(--mod-button-border-width, var(--spectrum-button-border-width))
417-
) * -1
418-
);
419412
}
420413
}
421414

components/button/metadata/mods.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
| `--mod-button-edge-to-text` |
2323
| `--mod-button-edge-to-visual` |
2424
| `--mod-button-edge-to-visual-only` |
25-
| `--mod-button-focus-indicator-gap` |
2625
| `--mod-button-focus-ring-border-radius` |
2726
| `--mod-button-focus-ring-color` |
2827
| `--mod-button-focus-ring-gap` |

0 commit comments

Comments
 (0)