feat(pwa): loading screen in the colours of the last used theme
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
57a97a3750
commit
4a923eaf01
5 files changed
+52
-7
No files matched your search
@@ -0,0 +1,17 @@
|
||||
// Runs before the first paint: the loading screen takes the colours of the theme used last on this
|
||||
// device (stored by the app in lib/theme.ts), so a light or orange theme does not start in blue.
|
||||
// A file instead of an inline script so the CSP can stay at script-src 'self'.
|
||||
(function () {
|
||||
try {
|
||||
var colors = JSON.parse(localStorage.getItem('mindsift_boot_colors') || 'null');
|
||||
if (!colors || typeof colors.bg !== 'string' || typeof colors.accent !== 'string') return;
|
||||
var root = document.documentElement;
|
||||
root.style.setProperty('--boot-bg', colors.bg);
|
||||
root.style.setProperty('--boot-accent', colors.accent);
|
||||
if (typeof colors.onAccent === 'string') root.style.setProperty('--boot-on-accent', colors.onAccent);
|
||||
var meta = document.querySelector('meta[name="theme-color"]');
|
||||
if (meta) meta.setAttribute('content', colors.bg);
|
||||
} catch (e) {
|
||||
// no storage: the loading screen stays blue
|
||||
}
|
||||
})();
|
||||
Reference in new issue
Block a user