Skip to content

Commit

Permalink
perf(material/checkbox): Optimize css selectors (#30386)
Browse files Browse the repository at this point in the history
(cherry picked from commit e4388c6)
  • Loading branch information
kseamon authored and andrewseguin committed Jan 27, 2025
1 parent 4a96a25 commit 5d6d25f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/material/checkbox/_checkbox-common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -457,15 +457,15 @@ $_fallback-size: 40px;
// MDC expects `.mdc-checkbox__ripple::before` to be the state layer, but we use
// `.mdc-checkbox__ripple` instead, so we emit the state layer slots ourselves.
&:hover {
.mdc-checkbox__ripple {
> .mdc-checkbox__ripple {
@include token-utils.create-token-slot(opacity, unselected-hover-state-layer-opacity);
@include token-utils.create-token-slot(
background-color,
unselected-hover-state-layer-color
);
}

.mat-mdc-checkbox-ripple .mat-ripple-element {
> .mat-mdc-checkbox-ripple .mat-ripple-element {
@include token-utils.create-token-slot(
background-color,
unselected-hover-state-layer-color
Expand All @@ -474,7 +474,7 @@ $_fallback-size: 40px;
}

.mdc-checkbox__native-control:focus {
& ~ .mdc-checkbox__ripple {
& + .mdc-checkbox__ripple {
@include token-utils.create-token-slot(opacity, unselected-focus-state-layer-opacity);
@include token-utils.create-token-slot(
background-color,
Expand All @@ -490,8 +490,8 @@ $_fallback-size: 40px;
}
}

&:active .mdc-checkbox__native-control {
& ~ .mdc-checkbox__ripple {
&:active > .mdc-checkbox__native-control {
& + .mdc-checkbox__ripple {
@include token-utils.create-token-slot(opacity, unselected-pressed-state-layer-opacity);
@include token-utils.create-token-slot(
background-color,
Expand All @@ -508,7 +508,7 @@ $_fallback-size: 40px;
}

&:hover .mdc-checkbox__native-control:checked {
& ~ .mdc-checkbox__ripple {
& + .mdc-checkbox__ripple {
@include token-utils.create-token-slot(opacity, selected-hover-state-layer-opacity);
@include token-utils.create-token-slot(
background-color,
Expand All @@ -525,7 +525,7 @@ $_fallback-size: 40px;
}

.mdc-checkbox__native-control:focus:checked {
& ~ .mdc-checkbox__ripple {
& + .mdc-checkbox__ripple {
@include token-utils.create-token-slot(opacity, selected-focus-state-layer-opacity);
@include token-utils.create-token-slot(
background-color,
Expand All @@ -541,8 +541,8 @@ $_fallback-size: 40px;
}
}

&:active .mdc-checkbox__native-control:checked {
& ~ .mdc-checkbox__ripple {
&:active > .mdc-checkbox__native-control:checked {
& + .mdc-checkbox__ripple {
@include token-utils.create-token-slot(opacity, selected-pressed-state-layer-opacity);
@include token-utils.create-token-slot(
background-color,
Expand All @@ -561,7 +561,7 @@ $_fallback-size: 40px;
// Needs extra specificity to override the focus, hover, active states.
.mdc-checkbox--disabled.mat-mdc-checkbox-disabled-interactive & {
.mdc-checkbox__native-control ~ .mat-mdc-checkbox-ripple .mat-ripple-element,
.mdc-checkbox__native-control ~ .mdc-checkbox__ripple {
.mdc-checkbox__native-control + .mdc-checkbox__ripple {
@include token-utils.create-token-slot(
background-color,
unselected-hover-state-layer-color
Expand Down

0 comments on commit 5d6d25f

Please sign in to comment.