Discover dark mode automatically
All checks were successful
Build and Deploy / build-and-push (push) Successful in 1m14s

This commit is contained in:
2026-04-20 23:54:04 +02:00
parent 08a275093c
commit 8702830f68
2 changed files with 13 additions and 44 deletions

View File

@@ -547,7 +547,7 @@
width: min(calc(100% - 2.4rem), 24.5rem);
height: 3.34rem;
display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr));
grid-template-columns: repeat(4, minmax(0, 1fr));
align-items: stretch;
gap: 0.06rem;
padding: 0.22rem;
@@ -665,14 +665,18 @@
</head>
<body class="m-0 min-h-dvh bg-white text-gray-800 antialiased">
<script>
const savedTheme = localStorage.getItem('theme');
const useDarkTheme = savedTheme ? savedTheme === 'dark' : true;
if (useDarkTheme) document.documentElement.classList.add('dark');
const themeMeta = document.querySelector('meta[name="theme-color"]');
if (themeMeta) {
const appBgRgb = getComputedStyle(document.documentElement).getPropertyValue('--app-bg-rgb').trim();
if (appBgRgb) themeMeta.setAttribute('content', `rgb(${appBgRgb})`);
}
const darkModeQuery = window.matchMedia('(prefers-color-scheme: dark)');
const applySystemTheme = (isDark) => {
document.documentElement.classList.toggle('dark', isDark);
const themeMeta = document.querySelector('meta[name="theme-color"]');
if (themeMeta) {
const varName = isDark ? '--sunken-deep-rgb' : '--app-bg-rgb';
const rgb = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
if (rgb) themeMeta.setAttribute('content', `rgb(${rgb})`);
}
};
applySystemTheme(darkModeQuery.matches);
darkModeQuery.addEventListener('change', (e) => applySystemTheme(e.matches));
</script>
<div id="app-container" class="relative flex h-dvh min-h-0 w-full flex-col overflow-hidden bg-white">