mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 21:34:24 +00:00
27 lines
1.1 KiB
JavaScript
27 lines
1.1 KiB
JavaScript
let theme = localStorage.getItem( 'theme' ) ?? '';
|
|
if ( window.matchMedia( '(prefers-color-scheme: dark)' ).matches || theme === '☼' ) {
|
|
document.documentElement.classList.add( 'dark' );
|
|
document.getElementById( 'themeSelector' ).innerHTML = '☼';
|
|
theme = '☼';
|
|
} else {
|
|
document.documentElement.classList.add( 'light' );
|
|
document.getElementById( 'themeSelector' ).innerHTML = '☽';
|
|
theme = '☽';
|
|
}
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
function changeTheme () {
|
|
if ( theme === '☼' ) {
|
|
document.documentElement.classList.remove( 'dark' );
|
|
document.documentElement.classList.add( 'light' );
|
|
localStorage.setItem( 'theme', '☽' );
|
|
document.getElementById( 'themeSelector' ).innerHTML = '☽';
|
|
theme = '☽';
|
|
} else if ( theme === '☽' ) {
|
|
document.documentElement.classList.remove( 'light' );
|
|
document.documentElement.classList.add( 'dark' );
|
|
localStorage.setItem( 'theme', '☼' );
|
|
document.getElementById( 'themeSelector' ).innerHTML = '☼';
|
|
theme = '☼';
|
|
}
|
|
} |