Skip to content

Commit 361e013

Browse files
authored
fix(switch): style component using sass themes (#1991)
1 parent 69ae895 commit 361e013

File tree

5 files changed

+29
-36
lines changed

5 files changed

+29
-36
lines changed

src/components/checkbox/themes/shared/switch/switch.bootstrap.scss

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,6 @@ $theme: $bootstrap;
5656

5757
:host(:not([disabled]):hover),
5858
:host(:not(:disabled):hover) {
59-
[part~='control'] {
60-
border-color: var-get($theme, 'border-hover-color');
61-
}
62-
63-
[part~='control'][part~='checked'] {
64-
background: var-get($theme, 'track-on-hover-color');
65-
border-color: var-get($theme, 'border-on-hover-color');
66-
}
67-
6859
[part~='thumb'][part~='checked'] {
6960
background: var-get($theme, 'thumb-on-color');
7061
}

src/components/checkbox/themes/shared/switch/switch.common.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ $theme: $material;
2020
}
2121
}
2222

23+
:host(:not([disabled]):hover),
24+
:host(:not(:disabled):hover) {
25+
[part~='control'] {
26+
border-color: var-get($theme, 'border-hover-color');
27+
}
28+
29+
[part~='control'][part~='checked'] {
30+
background: var-get($theme, 'track-on-hover-color');
31+
border-color: var-get($theme, 'border-on-hover-color');
32+
}
33+
}
34+
2335
:host([disabled]),
2436
:host(:disabled) {
2537
[part~='label'] {

src/components/checkbox/themes/shared/switch/switch.fluent.scss

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,14 @@ $theme: $fluent;
6161

6262
:host(:not([disabled]):hover),
6363
:host(:not(:disabled):hover) {
64-
[part~='control'] {
65-
border-color: var-get($theme, 'border-hover-color');
64+
[part~='thumb'][part~='checked'] {
65+
background: var-get($theme, 'thumb-on-color');
6666
}
67+
}
6768

69+
:host([disabled]),
70+
:host(:disabled) {
6871
[part~='control'][part~='checked'] {
69-
background: var-get($theme, 'track-on-hover-color');
70-
border-color: var-get($theme, 'border-on-hover-color');
71-
}
72-
73-
[part~='thumb'][part~='checked'] {
74-
background: var-get($theme, 'thumb-on-color');
72+
border-color: var-get($theme, 'track-on-disabled-color');
7573
}
7674
}

src/components/checkbox/themes/shared/switch/switch.indigo.scss

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,6 @@ $border-width: rem(1px);
1919
@include type-style('body-2');
2020
}
2121

22-
:host(:hover) {
23-
[part~='control'] {
24-
border-color: var-get($theme, 'border-hover-color');
25-
}
26-
27-
[part~='control'][part~='checked'] {
28-
background: var-get($theme, 'track-on-hover-color');
29-
border-color: var-get($theme, 'border-on-hover-color');
30-
}
31-
}
32-
3322
[part~='control'][part~='focused'] {
3423
box-shadow: 0 0 0 rem(3px) var-get($theme, 'focus-outline-color');
3524
}

src/components/checkbox/themes/shared/switch/switch.material.scss

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ $ripple-radius: calc(#{$ripple-size} / 2);
3232
background: var-get($theme, 'thumb-on-color');
3333
}
3434
}
35-
36-
[part~='control'] {
37-
border-color: var-get($theme, 'border-hover-color');
38-
}
39-
40-
[part~='control'][part~='checked'] {
41-
border-color: var-get($theme, 'border-on-hover-color');
42-
}
4335
}
4436

4537
&:focus-visible,
@@ -98,6 +90,10 @@ $ripple-radius: calc(#{$ripple-size} / 2);
9890
overflow: hidden;
9991
z-index: -1;
10092
}
93+
94+
&:hover {
95+
box-shadow: var-get($theme, 'hover-elevation');
96+
}
10197
}
10298

10399
[part~='thumb'][part~='checked'] {
@@ -107,3 +103,10 @@ $ripple-radius: calc(#{$ripple-size} / 2);
107103
animation-duration: .2s;
108104
animation-fill-mode: forwards;
109105
}
106+
107+
:host([disabled]),
108+
:host(:disabled) {
109+
[part~='thumb'] {
110+
box-shadow: var-get($theme, 'disabled-elevation');
111+
}
112+
}

0 commit comments

Comments
 (0)