Theme-aware SVG favicon; SW cache v13
- Add sim-analyser-light.svg (#2563eb, light-theme accent); dark keeps the existing #3b82f6 variant. - applyTheme() now swaps the favicon href alongside data-theme and theme-color, so the icon follows toggle click, saved theme on load, and OS-preference fallback (all route through applyTheme). - Precache the new asset in the service worker.
This commit is contained in:
1 parent
d9133ffa57
commit
0f4f5e4e95
3 files changed
+51
-2
No files matched your search
+4
-1
@@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>SIMtrace Analyser</title>
|
||||
<link rel="manifest" href="manifest.json">
|
||||
<link rel="icon" type="image/svg+xml" href="sim-analyser.svg">
|
||||
<link rel="icon" type="image/svg+xml" href="sim-analyser.svg" id="favicon-svg">
|
||||
<link rel="icon" type="image/png" href="favicon.png">
|
||||
<meta name="theme-color" content="#0f172a">
|
||||
<style>
|
||||
@@ -2009,6 +2009,9 @@ function applyTheme(theme) {
|
||||
document.getElementById('theme-btn').textContent = theme === 'dark' ? '☀️' : '🌙';
|
||||
document.querySelector('meta[name="theme-color"]').setAttribute(
|
||||
'content', theme === 'dark' ? '#0f172a' : '#fafafa');
|
||||
const fav = document.getElementById('favicon-svg');
|
||||
if (fav) fav.setAttribute('href',
|
||||
theme === 'dark' ? 'sim-analyser.svg' : 'sim-analyser-light.svg');
|
||||
}
|
||||
|
||||
function toggleTheme() {
|
||||
|
||||
Reference in new issue
Block a user