Add manual theme switcher (fixes #5)

This commit is contained in:
daudix
2024-08-18 02:19:34 +03:00
parent 656a6f2328
commit 67c698b949
10 changed files with 285 additions and 108 deletions

View File

@ -56,7 +56,7 @@
list-style: none;
@media only screen and (max-width: 480px) {
&:not(#search, #language-switcher, #feed) {
&:not(#search, #language-switcher, #theme-switcher, #feed) {
width: 100%;
}
}
@ -84,15 +84,7 @@
}
@media only screen and (max-width: 480px) {
position: absolute;
top: unset;
right: unset;
bottom: -0.125rem;
left: -0.125rem;
background-color: var(--fg-muted-2);
width: calc(100% + 0.25rem);
height: max(1px, 0.0625em);
content: "";
display: none;
}
}
@ -150,7 +142,9 @@
a,
&#search button,
&#language-switcher summary {
&#language-switcher summary,
&#theme-switcher summary,
&#theme-switcher button {
&:hover {
box-shadow: var(--edge-highlight);
background-color: var(--fg-muted-1);
@ -240,7 +234,9 @@
&#search button,
&#language-switcher summary,
&#feed a {
&#feed a,
&#theme-switcher summary,
&#theme-switcher button {
padding: 0.5rem 0.625rem;
&:hover .icon {
@ -256,7 +252,7 @@
}
}
&#search button {
button {
-webkit-appearance: none;
appearance: none;
transition: var(--transition);
@ -266,15 +262,15 @@
background-color: transparent;
font-weight: bold;
font-size: 1rem;
}
.icon {
$icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M6.57.063c-3.578 0-6.5 2.921-6.5 6.5 0 3.578 2.922 6.5 6.5 6.5a6.46 6.46 0 0 0 3.83-1.256l2.975 2.974c.957.938 2.363-.5 1.406-1.437l-2.96-2.961a6.46 6.46 0 0 0 1.25-3.82c0-3.579-2.923-6.5-6.5-6.5m0 2c2.5 0 4.5 2.003 4.5 4.5 0 2.5-2 4.5-4.5 4.5-2.496 0-4.5-2-4.5-4.5 0-2.497 2.004-4.5 4.5-4.5'/%3E%3C/svg%3E");
-webkit-mask-image: $icon;
mask-image: $icon;
&#search button .icon {
$icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M6.57.063c-3.578 0-6.5 2.921-6.5 6.5 0 3.578 2.922 6.5 6.5 6.5a6.46 6.46 0 0 0 3.83-1.256l2.975 2.974c.957.938 2.363-.5 1.406-1.437l-2.96-2.961a6.46 6.46 0 0 0 1.25-3.82c0-3.579-2.923-6.5-6.5-6.5m0 2c2.5 0 4.5 2.003 4.5 4.5 0 2.5-2 4.5-4.5 4.5-2.496 0-4.5-2-4.5-4.5 0-2.497 2.004-4.5 4.5-4.5'/%3E%3C/svg%3E");
-webkit-mask-image: $icon;
mask-image: $icon;
:root[dir*="rtl"] & {
transform: scaleX(-100%);
}
:root[dir*="rtl"] & {
transform: scaleX(-100%);
}
}
@ -288,26 +284,63 @@
}
}
details {
position: relative;
box-shadow: none;
border-radius: 0;
background-color: transparent;
padding: 0;
summary {
transition: var(--transition);
border-radius: 999px;
background-color: transparent;
color: var(--fg-muted-4);
list-style: none;
&::marker,
&::-webkit-details-marker {
display: none;
}
}
&[open] ul {
animation: dropdown-open var(--transition);
@keyframes dropdown-open {
from {
transform: translate(-50%, 0);
opacity: 0;
}
}
}
ul {
-webkit-backdrop-filter: var(--blur);
text-wrap: nowrap;
position: absolute;
left: 50%;
transform: translate(-50%, 1rem);
z-index: 1;
backdrop-filter: var(--blur);
box-shadow: var(--edge-highlight), 0 0.75rem 1.5rem -1rem rgba(0, 0, 0, 0.5);
background-color: var(--nav-bg);
padding: 0.25rem;
li {
width: 100%;
a {
border-radius: var(--rounded-corner);
width: 100%;
}
}
}
}
&#language-switcher {
details {
position: relative;
box-shadow: none;
border-radius: 0;
background-color: transparent;
padding: 0;
summary {
transition: var(--transition);
border-radius: 999px;
background-color: transparent;
color: var(--fg-muted-4);
list-style: none;
&::marker,
&::-webkit-details-marker {
display: none;
}
.icon {
$icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M3.98 1v3H1v2h2.947a4.8 4.8 0 0 1-.592 1.871c-.425.758-1.101 1.488-2.062 2.45l1.414 1.413c.92-.92 1.703-1.728 2.283-2.697.38.632.844 1.196 1.377 1.768l.668-2.309a6 6 0 0 1-.41-.625A4.75 4.75 0 0 1 6.033 6h1.53l.511-2H6V1zm5.24 1L6 15h2l.781-3h4.438L14 15h2L12.781 2zm1.562 2h.438l1.5 6H9.28z'/%3E%3C/svg%3E");
-webkit-mask-image: $icon;
@ -315,37 +348,58 @@
}
}
&[open] ul {
animation: dropdown-open var(--transition);
ul {
border-radius: calc(var(--rounded-corner) + 0.25rem);
}
}
}
@keyframes dropdown-open {
from {
transform: translate(-50%, 0);
opacity: 0;
&#theme-switcher {
details {
summary {
.icon {
$icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M8 0C3.594 0 0 3.594 0 8s3.594 8 8 8 8-3.594 8-8-3.594-8-8-8m0 1.941c3.36 0 6.059 2.7 6.059 6.059s-2.7 6.059-6.059 6.059zm0 0'/%3E%3C/svg%3E");
-webkit-mask-image: $icon;
mask-image: $icon;
:root[dir*="rtl"] & {
transform: scaleX(-100%);
}
}
}
}
ul {
-webkit-backdrop-filter: var(--blur);
text-wrap: nowrap;
position: absolute;
left: 50%;
transform: translate(-50%, 1rem);
z-index: 1;
backdrop-filter: var(--blur);
box-shadow: var(--edge-highlight), 0 0.75rem 1.5rem -1rem rgba(0, 0, 0, 0.5);
border-radius: calc(var(--rounded-corner) + 0.25rem);
background-color: var(--nav-bg);
padding: 0.25rem;
ul {
flex-wrap: nowrap;
border-radius: 999px;
li {
display: flex;
width: 100%;
li {
display: flex;
width: 100%;
a {
border-radius: var(--rounded-corner);
width: 100%;
#theme-light .icon {
$icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M8.004-.008a1 1 0 0 0-1 1v1a1 1 0 1 0 2 0v-1c0-.554-.445-1-1-1M3.053 2.035a1 1 0 0 0-.26.035.994.994 0 0 0-.45 1.672l.708.707a1 1 0 1 0 1.414-1.414l-.707-.707a1 1 0 0 0-.705-.293m9.9.012a1 1 0 0 0-.707.293l-.707.707a1 1 0 1 0 1.414 1.414l.707-.707a1 1 0 0 0-.707-1.707M8 4C5.785 4 4 5.785 4 8s1.785 4 4 4 4-1.785 4-4-1.785-4-4-4m0 2c1.098 0 2 .902 2 2s-.902 2-2 2-2-.902-2-2 .902-2 2-2m-7.004.984a1 1 0 1 0 0 2h1a1 1 0 1 0 0-2zM14 7c-.55 0-1 .45-1 1s.45 1 1 1h1c.55 0 1-.45 1-1s-.45-1-1-1zM3.748 11.234a1 1 0 0 0-.705.293l-.711.707a1.007 1.007 0 0 0 0 1.414c.39.391 1.027.391 1.418 0l.707-.707a1 1 0 0 0-.709-1.707m8.49.006q-.131 0-.261.033a1.01 1.01 0 0 0-.707.711 1 1 0 0 0 .261.965l.707.707a.995.995 0 0 0 1.672-.445 1 1 0 0 0-.258-.969l-.707-.707a1 1 0 0 0-.707-.295m-4.246 1.756c-.554 0-1 .445-1 1v1a1 1 0 1 0 2 0v-1a1 1 0 0 0-1-1'/%3E%3C/svg%3E");
-webkit-mask-image: $icon;
mask-image: $icon;
}
#theme-dark .icon {
$icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M.918 8.004a7.072 7.072 0 0 0 14.102.793 1.01 1.01 0 0 0-.457-.957 1 1 0 0 0-1.063-.004 3.9 3.9 0 0 1-2.031.578 3.89 3.89 0 0 1-3.883-3.883c0-.715.203-1.422.578-2.031a1 1 0 0 0-.004-1.062c-.207-.32-.578-.5-.957-.458A7.07 7.07 0 0 0 .918 8.004M5.586 4.53a5.877 5.877 0 0 0 8.965 5.004l-1.52-.96a5.09 5.09 0 0 1-5.035 4.507 5.09 5.09 0 0 1-5.078-5.078 5.09 5.09 0 0 1 4.508-5.035l-.961-1.52a5.9 5.9 0 0 0-.88 3.082m0 0'/%3E%3C/svg%3E");
-webkit-mask-image: $icon;
mask-image: $icon;
:root[dir*="rtl"] & {
transform: scaleX(-100%);
}
}
#theme-system .icon {
$icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M8 0C3.594 0 0 3.594 0 8s3.594 8 8 8 8-3.594 8-8-3.594-8-8-8m0 1.941c3.36 0 6.059 2.7 6.059 6.059s-2.7 6.059-6.059 6.059zm0 0'/%3E%3C/svg%3E");
-webkit-mask-image: $icon;
mask-image: $icon;
:root[dir*="rtl"] & {
transform: scaleX(-100%);
}
}
}