-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswitch-html-css.js
63 lines (52 loc) · 1.57 KB
/
switch-html-css.js
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
const template = document.createElement('template');
template.id = "theme-switch"
template.innerHTML =`
<style>
/* ==== ThemeSwitch Component Styles ==== */
/* Define default styles for theme-switch */
:host {
--switch-color: black;
--switch-width: 60px;
--switch-height: 34px;
--switch-radius: 34px;
--slider-width: 25px;
--slider-height: 25px;
--slider-margin: 4px 2px 0px 5px;
--slider-transition: .4s;
--slider-radius: 50%;
--slider-cursor: pointer;
--slider-color: white;
--slider-translatex-unswitched: translateX(0px);
--slider-translatex-switched: translateX(26px);
}
/* The switch - the box around the slider */
.switch {
display: inline-block;
width: var(--switch-width);
height: var(--switch-height);
border-radius: var(--switch-radius);
background-color: var(--switch-color);
}
/* Rounded slider */
.slider {
cursor: var(--slider-cursor);
transition: var(--slider-transition);
border-radius: var(--slider-radius);
width: var(--slider-width);
height: var(--slider-height);
margin: var(--slider-margin);
background-color: var(--slider-color);
transform: var(--slider-translatex-unswitched);
}
/* Default State unswitched */
/* Slider is switched to the right */
.switch[data-state="1"] .slider{
transform: var(--slider-translatex-switched);
}
</style>
<!--HTML-->
<div class="switch">
<div class="slider round"></div>
</div>
`
export {template}