2021-11-24 12:19:07 +00:00
|
|
|
|
|
|
|
let obj = !localStorage ? {id: 'theme-light', type: 'light'} : JSON.parse(localStorage.getItem("ui-theme"));
|
|
|
|
if ( !obj ) {
|
2022-01-28 08:32:57 +00:00
|
|
|
obj = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ?
|
|
|
|
{id: 'theme-dark', type: 'dark'} : {id: 'theme-light', type: 'light'};
|
|
|
|
localStorage && localStorage.setItem("ui-theme", JSON.stringify(obj));
|
2021-11-24 12:19:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
document.body.classList.add(`theme-type-${obj.type}`);
|