diff --git a/public/index.html b/public/index.html
index 5f2aa1e..759c9a4 100644
--- a/public/index.html
+++ b/public/index.html
@@ -44,11 +44,25 @@
-
-
-
+
-
-
-
-
-
+
@@ -331,7 +345,13 @@
-
+
+
+
+
+
+
+
diff --git a/public_included_ws_fallback/scripts/theme.js b/public_included_ws_fallback/scripts/theme.js
index f839411..81cf0b2 100644
--- a/public_included_ws_fallback/scripts/theme.js
+++ b/public_included_ws_fallback/scripts/theme.js
@@ -1,39 +1,78 @@
(function(){
- // Select the button
- const btnTheme = document.getElementById('theme');
- // Check for dark mode preference at the OS level
- const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)');
-
- // Get the user's theme preference from local storage, if it's available
- const currentTheme = localStorage.getItem('theme');
- // If the user's preference in localStorage is dark...
+ const prefersDarkTheme = window.matchMedia('(prefers-color-scheme: dark)').matches;
+ const prefersLightTheme = window.matchMedia('(prefers-color-scheme: light)').matches;
+
+ const $themeAuto = document.getElementById('theme-auto');
+ const $themeLight = document.getElementById('theme-light');
+ const $themeDark = document.getElementById('theme-dark');
+
+ let currentTheme = localStorage.getItem('theme');
+
if (currentTheme === 'dark') {
- // ...let's toggle the .dark-theme class on the body
- document.body.classList.toggle('dark-theme');
- // Otherwise, if the user's preference in localStorage is light...
+ setModeToDark();
} else if (currentTheme === 'light') {
- // ...let's toggle the .light-theme class on the body
- document.body.classList.toggle('light-theme');
+ setModeToLight();
}
-
- // Listen for a click on the button
- btnTheme.addEventListener('click', function(e) {
- e.preventDefault();
- // If the user's OS setting is dark and matches our .dark-theme class...
- let theme;
- if (prefersDarkScheme.matches) {
- // ...then toggle the light mode class
- document.body.classList.toggle('light-theme');
- // ...but use .dark-theme if the .light-theme class is already on the body,
- theme = document.body.classList.contains('light-theme') ? 'light' : 'dark';
+
+ $themeAuto.addEventListener('click', _ => {
+ if (currentTheme) {
+ setModeToAuto();
} else {
- // Otherwise, let's do the same thing, but for .dark-theme
- document.body.classList.toggle('dark-theme');
- theme = document.body.classList.contains('dark-theme') ? 'dark' : 'light';
+ setModeToDark();
+ }
+ });
+ $themeLight.addEventListener('click', _ => {
+ if (currentTheme !== 'light') {
+ setModeToLight();
+ } else {
+ setModeToAuto();
+ }
+ });
+ $themeDark.addEventListener('click', _ => {
+ if (currentTheme !== 'dark') {
+ setModeToDark();
+ } else {
+ setModeToLight();
}
- // Finally, let's save the current preference to localStorage to keep using it
- localStorage.setItem('theme', theme);
});
+ function setModeToDark() {
+ document.body.classList.remove('light-theme');
+ document.body.classList.add('dark-theme');
+ localStorage.setItem('theme', 'dark');
+ currentTheme = 'dark';
+
+ $themeAuto.classList.remove("selected");
+ $themeLight.classList.remove("selected");
+ $themeDark.classList.add("selected");
+ }
+
+ function setModeToLight() {
+ document.body.classList.remove('dark-theme');
+ document.body.classList.add('light-theme');
+ localStorage.setItem('theme', 'light');
+ currentTheme = 'light';
+
+ $themeAuto.classList.remove("selected");
+ $themeLight.classList.add("selected");
+ $themeDark.classList.remove("selected");
+ }
+
+ function setModeToAuto() {
+ document.body.classList.remove('dark-theme');
+ document.body.classList.remove('light-theme');
+ if (prefersDarkTheme) {
+ document.body.classList.add('dark-theme');
+ } else if (prefersLightTheme) {
+ document.body.classList.add('light-theme');
+ }
+ localStorage.removeItem('theme');
+ currentTheme = undefined;
+
+ $themeAuto.classList.add("selected");
+ $themeLight.classList.remove("selected");
+ $themeDark.classList.remove("selected");
+ }
+
})();
diff --git a/public_included_ws_fallback/styles.css b/public_included_ws_fallback/styles.css
index 6193cf2..e68e226 100644
--- a/public_included_ws_fallback/styles.css
+++ b/public_included_ws_fallback/styles.css
@@ -76,11 +76,74 @@ html {
}
header {
- position: relative;
- height: 56px;
- align-items: center;
- padding: 16px;
+ position: absolute;
+ align-items: baseline;
+ padding: 8px 16px;
box-sizing: border-box;
+ width: 100vw;
+ z-index: 2;
+ top: 0;
+ right: 0;
+}
+
+header > a,
+header > div {
+ margin-left: 8px;
+}
+
+header > div {
+ display: flex;
+ flex-direction: column;
+ align-self: flex-start;
+ touch-action: manipulation;
+}
+header > div a {
+ height: 40px;
+ transition: all 300ms;
+}
+
+header > div > div {
+ display: flex;
+ flex-direction: column;
+}
+
+header > div:not(:hover) a:not(.selected) {
+ height: 0;
+ opacity: 0;
+}
+
+header > div:hover::before {
+ border-radius: 20px;
+ background: currentColor;
+ opacity: 0.1;
+ transition: opacity 300ms;
+ content: '';
+ position: absolute;
+ width: 40px;
+ top: 0;
+ bottom: 0;
+ margin-top: 8px;
+ margin-bottom: 8px;
+}
+
+header > div:hover a.selected::before {
+ opacity: 0.1;
+}
+
+@media (pointer: coarse) {
+ header > div:hover a.selected:hover::before {
+ opacity: 0.2;
+ }
+
+ header > div a:not(.selected) {
+ height: 0;
+ opacity: 0;
+ pointer-events: none;
+ }
+
+ header > div > div {
+ flex-direction: column-reverse;
+ }
}
[hidden] {
@@ -193,15 +256,10 @@ x-noscript {
}
}
-/* Main Header */
-
-body>header a {
- margin-left: 8px;
-}
-
#center {
position: relative;
display: flex;
+ margin-top: 56px;
flex-direction: column-reverse;
flex-grow: 1;
--footer-height: 146px;