Skip to content

Commit

Permalink
feat(switch): add disabled track tokens
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 530932722
  • Loading branch information
asyncLiz authored and copybara-github committed May 10, 2023
1 parent 61550d2 commit a2045f5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 43 deletions.
13 changes: 0 additions & 13 deletions switch/lib/_switch.scss
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,6 @@ $_forced-colors-theme: (
(
color-key: disabled-unselected-handle-color,
opacity-key: disabled-unselected-handle-opacity
),
// Disabled Track
(
color-key: disabled-selected-track-color,
opacity-key: disabled-track-opacity
),
(
color-key: disabled-unselected-track-color,
opacity-key: disabled-track-opacity
),
(
color-key: disabled-unselected-track-outline-color,
opacity-key: disabled-track-opacity
)
)
);
Expand Down
58 changes: 28 additions & 30 deletions switch/lib/_track.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,55 +20,53 @@
display: flex;
justify-content: center;
align-items: center;
}

transition: background-color 67ms linear;
background-color: var(--_selected-track-color);
// Separate node for background/outline colors to support opacity changes.
.track::before {
content: '';
display: flex;
position: absolute;
height: 100%;
width: 100%;
border-radius: inherit;
box-sizing: border-box;
transition-property: opacity, background-color;
transition-timing-function: linear;
transition-duration: 67ms;
}
.switch:disabled .track {

.switch:disabled .track::before,
.switch:disabled .track::after {
transition: none;
opacity: var(--_disabled-track-opacity);
}

.switch--selected .track::before {
background-color: var(--_selected-track-color);
}

.switch--selected:hover .track {
.switch--selected:hover .track::before {
background-color: var(--_selected-hover-track-color);
}

.switch--selected:focus-visible .track {
.switch--selected:focus-visible .track::before {
background-color: var(--_selected-focus-track-color);
}

.switch--selected:active .track {
.switch--selected:active .track::before {
background-color: var(--_selected-pressed-track-color);
}

.switch--selected:disabled .track {
.switch--selected:disabled .track::before {
background-color: var(--_disabled-selected-track-color);
}

.track::before {
content: '';
display: flex;
position: absolute;
height: 100%;
width: 100%;
border-radius: inherit;
box-sizing: border-box;
border-style: solid;

transition-property: opacity, background-color;
transition-timing-function: linear;
transition-duration: 67ms;

border-width: var(--_track-outline-width);
.switch--unselected .track::before {
background-color: var(--_unselected-track-color);
border-color: var(--_unselected-track-outline-color);
}
.switch:disabled .track::before {
transition: none;
}

.switch--selected .track::before {
// When selected, turn off ::before
opacity: 0;
border-style: solid;
border-width: var(--_track-outline-width);
}

.switch--unselected:hover .track::before {
Expand Down

0 comments on commit a2045f5

Please sign in to comment.