blob: 88b1def9f10be6f7e1a58092da3e8168abcedb36 [file] [log] [blame]
Michael Davis5a752b22017-03-09 09:41:08 -06001@mixin marginTransition {
2 -webkit-transition: margin 0.4s, background 0.4s;
3 -moz-transition: margin 0.4s, background 0.4s;
4 -o-transition: margin 0.4s, background 0.4s;
5 transition: margin 0.4s, background 0.4s;
6}
7
8@mixin borderRadius {
9 -webkit-border-radius: 60px;
10 -moz-border-radius: 60px;
Michael Davis5a752b22017-03-09 09:41:08 -060011 border-radius: 60px;
12}
13
14.toggle-switch {
15 position: absolute;
Michael Davis9e00ce92017-03-09 18:31:02 -060016 left: 20px;
17 height: 1px;
18 width: 1px;
19 opacity: 0;
Michael Davis5a752b22017-03-09 09:41:08 -060020}
Michael Davisc5626182017-03-10 15:48:05 -060021
Michael Davis5a752b22017-03-09 09:41:08 -060022.toggle-switch + label {
23 display: block;
24 position: relative;
25 cursor: pointer;
26 outline: none;
27 -webkit-user-select: none;
28 -moz-user-select: none;
29 -ms-user-select: none;
30 user-select: none;
31}
32
Michael Davisc5626182017-03-10 15:48:05 -060033.toggle label {
34 text-indent: -9999px;
35 transform: translateY(-50%); // keeps switch centered
36}
37
Michael Davis5a752b22017-03-09 09:41:08 -060038input.toggle-switch__round-flat + label {
39 padding: 2px;
40 width: 50px;
41 height: 30px;
42 background-color: $lightgrey;
43 @include borderRadius;
44 @include marginTransition;
45}
Michael Davis9e00ce92017-03-09 18:31:02 -060046
47input.toggle-switch__round-flat:focus + label {
48 box-shadow: 0 0 4px 4px $darkbg__accent;
49}
Michael Davis5a752b22017-03-09 09:41:08 -060050input.toggle-switch__round-flat + label:before, input.toggle-switch__round-flat + label:after {
51 display: block;
52 position: absolute;
53 content: "";
54}
55input.toggle-switch__round-flat + label:before {
56 top: 2px;
57 left: 2px;
58 bottom: 2px;
59 right: 2px;
60 background-color: $white;
61 @include borderRadius;
62 @include marginTransition;
63}
64input.toggle-switch__round-flat + label:after {
65 top: 4px;
66 left: 4px;
67 bottom: 4px;
68 width: 20px;
69 background-color: $lightgrey;
70 -webkit-border-radius: 52px;
71 -moz-border-radius: 52px;
72 -ms-border-radius: 52px;
73 border-radius: 52px;
74 @include marginTransition;
75}
76input.toggle-switch__round-flat:checked + label {
77 background-color: $primebtn__bg;
78}
79input.toggle-switch__round-flat:checked + label:before {
80 background-color: $lightbg__accent;
81}
82input.toggle-switch__round-flat:checked + label:after {
83 margin-left: 20px;
84 background-color: $primebtn__bg;
85}