forked from Andrey-1988-dev/snowfall-js
/
snowAnimationSwitchStyles-template.css
77 lines (67 loc) · 2.08 KB
/
snowAnimationSwitchStyles-template.css
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
77
/* The toggle has various components:
- The guiding text next to it either left or right of the toggle with flexbox.
- The checkbox element itself is made invisible, only use the form functionality.
- The label element is what is visible to the user.
- The toggle is able to scale with the font-size of the guiding text.
- You may have to adjust the line-height to get the desired alignment
- Based on https://codepen.io/jorishr/pen/xxxPPLP
*/
:root {
--snow-animation-switch-bgClrOff: rgba(189, 195, 199, 1);
--snow-animation-switch-bgClrOn: rgba(149, 165, 166, 1);
--snow-animation-switch-toggleClr: #fff;
--snow-animation-switch-txtClr: rgba(33, 37, 41, 1);
--snow-animation-switch-txtPosition: 2;
--snow-animation-switch-txtMargin: 0 0 0 0.75em;
}
.snow-animation-switch {
display: none;
}
.snow-animation-switch--show {
display: flex;
justify-content: center;
}
.snow-animation-switch__input {
height: 0;
width: 0;
visibility: hidden;
}
.snow-animation-switch__label {
position: relative;
display: block;
text-indent: -9999px;
cursor: pointer;
width: 2.5em; /* 40px */
height: 1.25em; /* 20px */
background: var(--snow-animation-switch-bgClrOff);
border-radius: 1.25em; /* 20px, equal to height */
order: 2;
}
.snow-animation-switch__label::after {
content: "";
position: absolute;
top: 0.125em; /* 2px */
left: 0.125em; /* 2px */
width: 1em; /* 16px */
height: 1em; /* 16px */
background: var(--snow-animation-switch-toggleClr);
border-radius: 1em; /* 16px */
transition: 0.3s;
}
/* extend the toggle when active */
.snow-animation-switch__label:active::after {
width: 1.375em; /* 22px */
}
.snow-animation-switch__input:checked + label {
background: var(--snow-animation-switch-bgClrOn);
}
.snow-animation-switch__input:checked + label::after {
left: calc(100% - 0.125em); /* 100% - 2px */
transform: translateX(-100%);
}
.snow-animation-switch__text {
line-height: 1.25;
order: var(--snow-animation-switch-txtPosition);
color: var(--snow-animation-switch-txtClr);
margin: var(--snow-animation-switch-txtMargin);
}