Mostly completed dark mode support
This commit is contained in:
@@ -49,7 +49,7 @@ nav a {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
background-color: var( --color-background-accent );
|
background-color: var( --color-background-accent );
|
||||||
transition: all 0.5s;
|
transition: left 0.5s, top 0.5s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-top-bar {
|
.nav-top-bar {
|
||||||
|
|||||||
@@ -57,6 +57,10 @@ body {
|
|||||||
color: var( --color-text-primary );
|
color: var( --color-text-primary );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body.loaded {
|
||||||
|
transition: color 0.5s, background-color 0.5s;
|
||||||
|
}
|
||||||
|
|
||||||
.material-symbols-outlined {
|
.material-symbols-outlined {
|
||||||
font-variation-settings:
|
font-variation-settings:
|
||||||
'FILL' 0,
|
'FILL' 0,
|
||||||
|
|||||||
@@ -68,34 +68,7 @@
|
|||||||
document.getElementById( 'analytics' ).classList.add( 'show' );
|
document.getElementById( 'analytics' ).classList.add( 'show' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Themeing
|
// Show which theme is loaded
|
||||||
let loadedTheme = localStorage.getItem( 'theme' ) ?? 'auto';
|
|
||||||
var theme = loadedTheme;
|
|
||||||
let loadTheme = () => {
|
|
||||||
loadedTheme = localStorage.getItem( 'theme' ) ?? 'auto';
|
|
||||||
if ( loadedTheme === 'auto' ) {
|
|
||||||
if ( window.matchMedia( '(prefers-color-scheme: dark)' ).matches ) {
|
|
||||||
theme = 'dark_mode';
|
|
||||||
} else {
|
|
||||||
theme = 'light_mode';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( theme === 'dark_mode' ) {
|
|
||||||
document.documentElement.classList.remove( 'light' );
|
|
||||||
document.documentElement.classList.add( 'dark' );
|
|
||||||
} else {
|
|
||||||
document.documentElement.classList.add( 'light' );
|
|
||||||
document.documentElement.classList.remove( 'dark' );
|
|
||||||
theme === 'light_mode';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
loadTheme();
|
|
||||||
document.getElementById( 'theme-select' ).value = loadedTheme;
|
document.getElementById( 'theme-select' ).value = loadedTheme;
|
||||||
|
|
||||||
function changeTheme () {
|
|
||||||
theme = document.getElementById( 'theme-select' ).value;
|
|
||||||
localStorage.setItem( 'theme', theme );
|
|
||||||
loadTheme();
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,38 @@
|
|||||||
|
<script>
|
||||||
|
// Themeing
|
||||||
|
let loadedTheme = localStorage.getItem( 'theme' ) ?? 'auto';
|
||||||
|
var theme = loadedTheme;
|
||||||
|
let loadTheme = () => {
|
||||||
|
loadedTheme = localStorage.getItem( 'theme' ) ?? 'auto';
|
||||||
|
if ( loadedTheme === 'auto' ) {
|
||||||
|
if ( window.matchMedia( '(prefers-color-scheme: dark)' ).matches ) {
|
||||||
|
theme = 'dark_mode';
|
||||||
|
} else {
|
||||||
|
theme = 'light_mode';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( theme === 'dark_mode' ) {
|
||||||
|
document.documentElement.classList.remove( 'light' );
|
||||||
|
document.documentElement.classList.add( 'dark' );
|
||||||
|
} else {
|
||||||
|
document.documentElement.classList.add( 'light' );
|
||||||
|
document.documentElement.classList.remove( 'dark' );
|
||||||
|
theme === 'light_mode';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
loadTheme();
|
||||||
|
|
||||||
|
setTimeout( () => {
|
||||||
|
document.querySelector( 'body' ).classList.add( 'loaded' );
|
||||||
|
}, 500 );
|
||||||
|
|
||||||
|
function changeTheme () {
|
||||||
|
theme = document.getElementById( 'theme-select' ).value;
|
||||||
|
localStorage.setItem( 'theme', theme );
|
||||||
|
loadTheme();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<div class="nav-placeholder"></div>
|
<div class="nav-placeholder"></div>
|
||||||
|
|
||||||
<div class="nav-top-bar">
|
<div class="nav-top-bar">
|
||||||
|
|||||||
Reference in New Issue
Block a user