diff --git a/src/includes/site-header.ts b/src/includes/site-header.ts
index dd3a53b..7bf0d06 100644
--- a/src/includes/site-header.ts
+++ b/src/includes/site-header.ts
@@ -35,7 +35,7 @@ export const siteHeader = (config: PageConfig = {}) => html`
-
html`
aria-label="Enable dark mode"
aria-checked="false"
>
-
-
+
+
+
`;
diff --git a/src/static/assets/css/styles.css b/src/static/assets/css/styles.css
index 7a6e2a1..bee681f 100644
--- a/src/static/assets/css/styles.css
+++ b/src/static/assets/css/styles.css
@@ -562,91 +562,54 @@ h3 {
/* Theme switch */
.theme-switch {
- font-size: 0.8rem;
- box-sizing: content-box;
-
- --switch-width: 7.4em;
- --switch-height: 3.5em;
- --switch-border-size: 0.2em;
- --switch-handle-offset: 0.24em;
- --switch-handle-size: calc(
- var(--switch-height) - (var(--switch-handle-offset) * 4)
- );
- --switch-extra-click-area: 0.4em;
- --switch-transition-duration: 250ms;
+ --theme-switch-size: 2.8rem;
+ --theme-switch-extra-click-area: 0.3rem;
- display: block;
- width: var(--switch-width);
- height: var(--switch-height);
- padding: var(
- --switch-extra-click-area
- ); /* Visual spacing as well as increased click area for the switch */
+ all: unset;
+ display: none;
+ position: relative;
+ width: var(--theme-switch-size);
+ height: var(--theme-switch-size);
+ padding: var(--theme-switch-extra-click-area);
+ border-radius: 50%;
+ box-sizing: content-box;
+ cursor: pointer;
}
-.theme-switch:not(.loaded) .switch * {
- display: none !important;
+.theme-switch.loaded {
+ display: block;
}
.theme-switch:focus-visible {
- border-radius: calc(var(--switch-height) + var(--switch-extra-click-area));
outline: 0.2rem dashed var(--color-highlight);
}
-.theme-switch .switch {
- position: relative;
- display: block;
- width: 100%;
- height: 100%;
- margin: 0;
- padding: 0;
- border: var(--switch-border-size) solid var(--color-font);
- border-radius: calc(var(--switch-height) / 2);
-}
-
.theme-switch .icon {
position: absolute;
display: block;
- top: 0;
- width: calc(var(--switch-height) - (var(--switch-border-size) * 2));
- height: calc(var(--switch-height) - (var(--switch-border-size) * 2));
+ top: var(--theme-switch-extra-click-area);
+ width: var(--theme-switch-size);
+ height: var(--theme-switch-size);
background-color: transparent;
background-repeat: no-repeat;
background-size: 100%;
background-position: 50%;
transform: rotate(50deg);
transition:
- opacity var(--switch-transition-duration),
+ opacity 250ms,
transform 1s;
}
.theme-switch .icon.sun {
- top: 0.1em; /* The icon looks slightly better aligned this way */
- right: calc(var(--switch-border-size) + 0.1em);
background-image: url('data:image/svg+xml;utf8,');
opacity: 1;
}
.theme-switch .icon.moon {
- left: calc(var(--switch-border-size) + 0.1em);
background-image: url('data:image/svg+xml;utf8,');
opacity: 0;
}
-.theme-switch .handle {
- display: block;
- position: absolute;
- top: 0;
- bottom: 0;
- left: 0;
- width: var(--switch-handle-size);
- height: var(--switch-handle-size);
- margin: auto 0;
- background-color: var(--color-font);
- border-radius: 50%;
- transform: translateX(var(--switch-handle-offset));
- transition: transform var(--switch-transition-duration);
-}
-
.theme-switch[checked] .icon {
transform: rotate(10deg);
}
@@ -659,15 +622,6 @@ h3 {
opacity: 1;
}
-.theme-switch[checked] .handle {
- transform: translateX(
- calc(
- var(--switch-width) - var(--switch-handle-size) -
- (var(--switch-handle-offset) * 4) + var(--switch-border-size)
- )
- );
-}
-
/* Misc. styles */
.page h1 {