Refactor to TypeScript ES modules and add metadata sidebar

This commit is contained in:
Alan Grainger
2026-06-04 07:40:52 +12:00
parent d86c8721cc
commit e43b57d644
49 changed files with 5909 additions and 2409 deletions
+25
View File
@@ -0,0 +1,25 @@
// Mirrors Immich's FOUC-prevention pattern: read color-theme from localStorage
// (or fall back to OS preference), then add/remove .dark on <html> before paint.
// Source: immich-app/immich v2.7.5 web/src/app.html (2026-05-23).
const themeScript = `
const key = 'color-theme';
let theme = localStorage.getItem(key);
if (!theme) {
theme = { value: 'light', system: true };
} else if (theme === 'dark' || theme === 'light') {
theme = { value: theme, system: false };
localStorage.setItem(key, JSON.stringify(theme));
} else {
theme = JSON.parse(theme);
}
let v = theme.value;
if (theme.system) {
v = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}
if (v === 'dark') document.documentElement.classList.add('dark');
else document.documentElement.classList.remove('dark');
`
export function ThemeScript () {
return <script dangerouslySetInnerHTML={{ __html: themeScript }}/>
}