forked from andreasbm/weightless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
switch.scss
69 lines (57 loc) · 1.34 KB
/
switch.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
@import "../style/base";
@import "switch-vars";
:host {
--_switch-bg: #{$switch-bg};
--_switch-color: #{$switch-color};
background: var(--_switch-bg);
color: var(--_switch-color);
width: $switch-width;
height: $switch-height;
border-radius: $switch-border-radius;
transition: $switch-transition;
display: inline-flex;
align-items: center;
position: relative;
outline: none;
user-select: none;
}
:host(:not([disabled])) {
cursor: pointer;
}
:host([checked]) {
--_switch-bg: #{$switch-bg-checked};
--_switch-color: #{$switch-color-checked};
#knob {
transform: translateX(calc(#{$switch-width} - 100%));
}
}
/* Switch the color of the ripple to be the background color */
:host(:not([checked])) {
#ripple {
color: var(--_switch-bg);
}
}
:host(:hover), :host(:focus) {
will-change: background-color;
}
:host([disabled]) {
--_switch-bg: #{$switch-bg-disabled};
--_switch-color: #{$switch-color-disabled};
pointer-events: none;
}
:host([disabled][checked]) {
--_switch-bg: #{$switch-bg-disabled-checked};
--_switch-color: #{$switch-color-disabled-checked};
}
#knob {
width: $switch-knob-size;
height: $switch-knob-size;
border-radius: $switch-knob-border-radius;
box-shadow: $switch-knob-elevation;
transition: $switch-knob-transition;
background: currentColor;
position: absolute;
}
#ripple {
transform: $switch-ripple-transform;
}