_form-adv-switch.scss
2.32 KB
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
70
71
72
73
74
75
76
.switch {
position: relative;
&.checkbox,
&.radio {
label {
padding-left: ($font-size-h4 + ($font-size * 5 - $font-size-h4) / 4 + $grid-gutter / 2);
}
}
}
.switch-toggle {
background-color: $black-hint;
border-radius: ($font-size-h6 / 2);
cursor: pointer;
display: inline-block;
height: $font-size-h6;
margin-right: ($grid-gutter / 2);
position: relative;
vertical-align: middle;
width: ($font-size-h4 + ($font-size * 5 - $font-size-h4) / 4);
@include transition(background-color 0.3s $timing);
&:after {
background-color: $white;
border-radius: 50%;
content: "";
display: block;
height: $font-size-h4;
position: absolute;
top:(($font-size-h4 - $font-size-h6) / -2);
left: 0;
width: $font-size-h4;
@include box-shadow(0 1px 3px 1px rgba(0, 0, 0, 0.25));
@include transition(background-color 0.3s $timing, box-shadow 0.15s $timing, left 0.3s $timing);
}
input[type="checkbox"]:checked + &,
input[type="radio"]:checked + & {
background-color: $brand-color-light-m;
&:after {
background-color: $brand-color;
// position
left: (($font-size * 5 - $font-size-h4) / 4);
}
}
.checkbox.switch &,
.radio.switch & {
position: absolute;
top: (($line-height - $font-size-h6) / 2);
left: 0;
}
.no-touch & {
&:active:after {
@include box-shadow(0 1px 3px 1px rgba(0, 0, 0, 0.25), 0 0 0 (($font-size * 5 - $font-size-h4) / 4) rgba(0, 0, 0, 0.1));
}
}
.no-touch input[type="checkbox"]:checked + &,
.no-touch input[type="radio"]:checked + & {
&:active:after {
@include box-shadow(0 1px 3px 1px rgba(0, 0, 0, 0.25), 0 0 0 (($font-size * 5 - $font-size-h4) / 4) rgba(red($brand-color), green($brand-color), blue($brand-color), 0.25));
}
}
.touch & {
@include transition(background-color 0.3s $timing 0.15s);
&:after {
@include transition(background-color 0.3s $timing 0.15s, box-shadow 0.15s $timing, left 0.3s $timing 0.15s);
}
&.switch-toggle-on:after {
@include box-shadow(0 1px 3px 1px rgba(0, 0, 0, 0.25), 0 0 0 (($font-size * 5 - $font-size-h4) / 4) rgba(red($brand-color), green($brand-color), blue($brand-color), 0.25));
}
}
.touch input[type="checkbox"]:checked + &,
.touch input[type="radio"]:checked + & {
&.switch-toggle-on:after {
@include box-shadow(0 1px 3px 1px rgba(0, 0, 0, 0.25), 0 0 0 (($font-size * 5 - $font-size-h4) / 4) rgba(0, 0, 0, 0.1));
}
}
}