workding memory of dark on the toggle
This commit is contained in:
parent
5bb6ac9d5f
commit
9e5ef69aeb
|
@ -5,54 +5,57 @@
|
|||
|
||||
|
||||
|
||||
$diameter: 50px;
|
||||
$diameter: 1em;
|
||||
|
||||
.toggle-switch {
|
||||
.toggle-dark {
|
||||
position: relative;
|
||||
width: $diameter * 2;
|
||||
}
|
||||
width: 2em;
|
||||
display: inline-block;
|
||||
top: -0.8em;
|
||||
|
||||
label {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: $diameter;
|
||||
background-color: var(--primary-text-color);
|
||||
border-radius: $diameter / 2;
|
||||
cursor: pointer;
|
||||
}
|
||||
label {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: $diameter * 1.0;
|
||||
background-color: var(--primary-text-color);
|
||||
border-radius: $diameter / 2 * 1.2;
|
||||
cursor: pointer;
|
||||
|
||||
input {
|
||||
position: absolute;
|
||||
display: none;
|
||||
}
|
||||
input {
|
||||
position: absolute;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.slider {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: $diameter / 2;
|
||||
transition: 0.3s;
|
||||
}
|
||||
input:checked~.slider {
|
||||
/* background-color: var(--primary-color); */
|
||||
}
|
||||
|
||||
input:checked~.slider {
|
||||
background-color: var(--primary-color);
|
||||
}
|
||||
input:checked~.slider::before {
|
||||
transform: translateX($diameter * 0.95);
|
||||
background-color: var(--primary-color);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.slider::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: $diameter * 0.13;
|
||||
left: $diameter * 0.16;
|
||||
width: $diameter * 0.75;
|
||||
height: $diameter * 0.75;
|
||||
border-radius: 50%;
|
||||
box-shadow: inset $diameter * .28 $diameter * -.04 0px 0px var(--primary-color);
|
||||
background-color: var(--primary-text-color);
|
||||
transition: 0.3s;
|
||||
}
|
||||
.slider {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: $diameter / 2.5;
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
input:checked~.slider::before {
|
||||
transform: translateX($diameter * 0.95);
|
||||
background-color: var(--primary-text-color);
|
||||
box-shadow: none;
|
||||
.slider::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: $diameter * 0.13;
|
||||
left: $diameter * 0.16;
|
||||
width: $diameter * 0.75;
|
||||
height: $diameter * 0.75;
|
||||
border-radius: 50%;
|
||||
box-shadow: inset $diameter * .28 $diameter * -.04 0px 0px var(--primary-color);
|
||||
background-color: var(--primary--color);
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -41,13 +41,22 @@
|
|||
{% endif %}
|
||||
|
||||
|
||||
<div class='toggle-switch'>
|
||||
<div class='toggle-dark'>
|
||||
<label>
|
||||
<input type='checkbox' _="on click or load if me.checked
|
||||
<input type='checkbox' _="on click
|
||||
log(the first <body/>) then
|
||||
if me.checked
|
||||
log('checked')
|
||||
add .dark to the closest <body/>
|
||||
else
|
||||
remove .dark from the closest <body/>
|
||||
end
|
||||
end
|
||||
on load
|
||||
if (the first <body/> match .dark)
|
||||
log('loaded as dark') then
|
||||
set me.checked to true then
|
||||
log(me)
|
||||
">
|
||||
<span class='slider'></span>
|
||||
</label>
|
||||
|
|
Loading…
Reference in a new issue