mirror of
https://github.com/boostorg/website-v2.git
synced 2026-02-27 17:42:08 +00:00
Hooked up light and dark mode to the nav. In addition to changing the content colors the logo is swapped based on mode.
16 lines
551 B
JavaScript
16 lines
551 B
JavaScript
let explicitelyPreferScheme = false;
|
|
|
|
if (window.localStorage) {
|
|
if (localStorage.getItem('colorMode') === 'dark') {
|
|
document.documentElement.classList.add('dark');
|
|
explicitelyPreferScheme = 'dark';
|
|
} else if (localStorage.getItem('colorMode') === 'light') {
|
|
document.documentElement.classList.remove('dark');
|
|
explicitelyPreferScheme = 'light';
|
|
}
|
|
}
|
|
|
|
if (explicitelyPreferScheme !== 'light' && window.matchMedia('(prefers-color-scheme:dark)').matches) {
|
|
document.documentElement.classList.add('dark');
|
|
}
|