Discover dark mode automatically
All checks were successful
Build and Deploy / build-and-push (push) Successful in 1m14s
All checks were successful
Build and Deploy / build-and-push (push) Successful in 1m14s
This commit is contained in:
22
index.html
22
index.html
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user