mirror of
https://github.com/boostorg/website-v2.git
synced 2026-02-27 05:32:08 +00:00
This problem only seemed to be an issue in Firefox so adding an explicity setting if matchMedia finds dark. Issue: #729
17 lines
710 B
JavaScript
17 lines
710 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) {
|
|
localStorage.colorMode = 'dark'; // explicitly set `colorMode` to system if there is no preference. this fixes charts and search default mode in Firefox.
|
|
document.documentElement.classList.add('dark');
|
|
}
|