mirror of
https://github.com/CNCKitchen/stlTexturizer.git
synced 2026-04-07 22:11:32 +00:00
feat: enhance theme selection logic to respect OS preferences
This commit is contained in:
+4
-1
@@ -9,7 +9,10 @@
|
||||
// Apply saved theme before first paint to avoid flash
|
||||
(function() {
|
||||
const t = localStorage.getItem('stlt-theme');
|
||||
if (t !== 'dark') document.documentElement.setAttribute('data-theme', 'light');
|
||||
// If user never picked a theme, respect their OS preference
|
||||
const prefersDark = t ? t === 'dark'
|
||||
: window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
if (!prefersDark) document.documentElement.setAttribute('data-theme', 'light');
|
||||
})();
|
||||
// Apply saved language before first paint to avoid flash
|
||||
(function() {
|
||||
|
||||
Reference in New Issue
Block a user