blob: ae8c2765fa07250bc94de9d4c7dab451b2b536e5 [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;
Yoshie Muranaka6f7ec802019-06-24 14:35:41 -050042 background-color: $border-color-02;
Michael Davis5a752b22017-03-09 09:41:08 -060043 @include borderRadius;
44 @include marginTransition;
45}
Michael Davis9e00ce92017-03-09 18:31:02 -060046
47input.toggle-switch__round-flat:focus + label {
Yoshie Muranaka6f7ec802019-06-24 14:35:41 -050048 box-shadow: 0 0 4px 4px $primary-accent;
Michael Davis9e00ce92017-03-09 18:31:02 -060049}
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;
Yoshie Muranaka6f7ec802019-06-24 14:35:41 -050060 background-color: $primary-light;
Michael Davis5a752b22017-03-09 09:41:08 -060061 @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;
Yoshie Muranaka6f7ec802019-06-24 14:35:41 -050069 background-color: $border-color-02;
Michael Davis5a752b22017-03-09 09:41:08 -060070 -webkit-border-radius: 52px;
71 -moz-border-radius: 52px;
Michael Davis5a752b22017-03-09 09:41:08 -060072 border-radius: 52px;
73 @include marginTransition;
74}
75input.toggle-switch__round-flat:checked + label {
Yoshie Muranaka6f7ec802019-06-24 14:35:41 -050076 background-color: $primary-accent;
Michael Davis5a752b22017-03-09 09:41:08 -060077}
78input.toggle-switch__round-flat:checked + label:before {
Yoshie Muranaka6f7ec802019-06-24 14:35:41 -050079 background-color: $background-02;
Michael Davis5a752b22017-03-09 09:41:08 -060080}
81input.toggle-switch__round-flat:checked + label:after {
82 margin-left: 20px;
Yoshie Muranaka6f7ec802019-06-24 14:35:41 -050083 background-color: $primary-accent;
Michael Davis5a752b22017-03-09 09:41:08 -060084}