feat(light-dark): normalize light/dark/like-os mode
permits user to define light, dark or like the desktop
This commit is contained in:
@@ -1,3 +1,21 @@
|
||||
// Apply saved theme immediately (render-blocking) to prevent FOUC.
|
||||
// This file MUST be loaded without "defer" or "async".
|
||||
if (localStorage.getItem('oxicloud_theme') === 'dark') document.documentElement.setAttribute('data-theme', 'dark');
|
||||
// Apply saved colour-scheme choice immediately (render-blocking) to prevent FOUC.
|
||||
// This file MUST be loaded WITHOUT "defer" or "async" so it runs before any paint.
|
||||
//
|
||||
// localStorage values:
|
||||
// 'light' / 'dark' → force that mode (stamp html[data-color-scheme]).
|
||||
// 'auto' / absent → follow the OS preference (no attribute → CSS default
|
||||
// `color-scheme: light dark` resolves via prefers-color-scheme).
|
||||
//
|
||||
// Backward compat: existing users have 'light' / 'dark' stored from the old
|
||||
// binary toggle; both still apply correctly. New 'auto' value is introduced
|
||||
// by the segmented control in user-menu.
|
||||
|
||||
(() => {
|
||||
var saved = localStorage.getItem('oxicloud_theme');
|
||||
var html = document.documentElement;
|
||||
if (saved === 'light' || saved === 'dark') {
|
||||
html.setAttribute('data-color-scheme', saved);
|
||||
} else {
|
||||
html.removeAttribute('data-color-scheme');
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user