Spaces:
Running
Running
Update app.py
#2
by volivers - opened
app.py
CHANGED
|
@@ -2336,18 +2336,17 @@ SELECTION_JS = """
|
|
| 2336 |
document.body.classList.toggle('dark', dark);
|
| 2337 |
const container = document.querySelector('.gradio-container');
|
| 2338 |
if (container) container.classList.toggle('dark', dark);
|
| 2339 |
-
const el = document.getElementById('theme-emoji');
|
| 2340 |
-
if (el) el.textContent = dark ? '☀️' : '🌙';
|
| 2341 |
}
|
| 2342 |
function toggleDark() {
|
| 2343 |
const url = new URL(window.location);
|
| 2344 |
-
const
|
|
|
|
|
|
|
| 2345 |
url.searchParams.set('__theme', isDark ? 'light' : 'dark');
|
| 2346 |
window.location.href = url.href;
|
| 2347 |
}
|
| 2348 |
window._lolaby_applyTheme = applyTheme;
|
| 2349 |
window._lolaby_toggleDark = toggleDark;
|
| 2350 |
-
|
| 2351 |
window.addEventListener('load', function () {
|
| 2352 |
const url = new URL(window.location);
|
| 2353 |
const isDark = url.searchParams.get('__theme') === 'dark';
|
|
@@ -2358,7 +2357,7 @@ SELECTION_JS = """
|
|
| 2358 |
window.location.replace(url.href);
|
| 2359 |
return;
|
| 2360 |
}
|
| 2361 |
-
applyTheme(isDark);
|
| 2362 |
});
|
| 2363 |
})();
|
| 2364 |
|
|
|
|
| 2336 |
document.body.classList.toggle('dark', dark);
|
| 2337 |
const container = document.querySelector('.gradio-container');
|
| 2338 |
if (container) container.classList.toggle('dark', dark);
|
|
|
|
|
|
|
| 2339 |
}
|
| 2340 |
function toggleDark() {
|
| 2341 |
const url = new URL(window.location);
|
| 2342 |
+
const isBrowserDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
| 2343 |
+
const noTheme = !url.searchParams.has('__theme');
|
| 2344 |
+
const isDark = noTheme ? isBrowserDark : url.searchParams.get('__theme') === 'dark';
|
| 2345 |
url.searchParams.set('__theme', isDark ? 'light' : 'dark');
|
| 2346 |
window.location.href = url.href;
|
| 2347 |
}
|
| 2348 |
window._lolaby_applyTheme = applyTheme;
|
| 2349 |
window._lolaby_toggleDark = toggleDark;
|
|
|
|
| 2350 |
window.addEventListener('load', function () {
|
| 2351 |
const url = new URL(window.location);
|
| 2352 |
const isDark = url.searchParams.get('__theme') === 'dark';
|
|
|
|
| 2357 |
window.location.replace(url.href);
|
| 2358 |
return;
|
| 2359 |
}
|
| 2360 |
+
applyTheme(noTheme ? isBrowserDark : isDark);
|
| 2361 |
});
|
| 2362 |
})();
|
| 2363 |
|