diff --git a/assets/js/set-theme.js b/assets/js/set-theme.js
index 5ee4ac4..0f8165d 100644
--- a/assets/js/set-theme.js
+++ b/assets/js/set-theme.js
@@ -37,4 +37,6 @@ window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e)
const newTheme = e.matches ? 'dark' : 'light';
setTheme(newTheme);
}
-});
\ No newline at end of file
+});
+
+setTheme(getPreferredTheme());
\ No newline at end of file
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 4691e45..2ea6652 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -33,7 +33,7 @@
})();
-
+
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
index c3435de..edcbad4 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -8,7 +8,15 @@
\ No newline at end of file
diff --git a/static/css/custom.css b/static/css/custom.css
index 41d797f..1941c41 100644
--- a/static/css/custom.css
+++ b/static/css/custom.css
@@ -70,12 +70,39 @@ body {
border: none;
cursor: pointer;
padding: 0;
- width: 2rem;
- height: 2rem;
+ width: 1.5rem;
+ height: 1.5rem;
z-index: 1000;
transition: opacity 0.3s ease;
}
+.theme-toggle__icon {
+ width: 100%;
+ height: 100%;
+ transition: opacity 0.3s ease;
+}
+
+.theme-toggle__icon svg {
+ width: 100%;
+ height: 100%;
+ fill: var(--off-fg);
+ transition: fill 0.3s ease;
+}
+
+.theme-toggle:hover .theme-toggle__icon svg {
+ fill: var(--hover);
+}
+
+.theme-toggle__icon--sun,
+[data-theme="dark"] .theme-toggle__icon--moon {
+ display: none;
+}
+
+[data-theme="dark"] .theme-toggle__icon--sun,
+.theme-toggle__icon--moon {
+ display: block;
+}
+
.theme-toggle:hover {
opacity: 0.7;
}
@@ -89,21 +116,10 @@ body {
outline-offset: 2px;
}
-.theme-toggle__icon {
- width: 100%;
- height: 100%;
- transition: transform 0.3s ease, fill 0.3s ease;
- fill: var(--off-fg);
-}
-
.theme-toggle:hover .theme-toggle__icon {
fill: var(--hover);
}
-[data-theme="dark"] .theme-toggle__icon {
- transform: rotate(180deg);
-}
-
.page__nav ul {
padding-right: 3rem;
}