feat(web): set Safari window colors (#1543)

* feat(web): update meta-theme color

- used by Safari for its colored compact tab bar

* fix: hardcode the colors
This commit is contained in:
soup 2024-05-08 14:10:26 +02:00 committed by GitHub
parent 8120c33f6b
commit 190994c70b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View file

@ -9,7 +9,7 @@
<meta charset="utf-8" /> <meta charset="utf-8" />
<link rel="icon" href="/favicon.ico" /> <link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#141415" /> <meta name="theme-color" content="#18181B">
<meta name="description" content="autobrr" /> <meta name="description" content="autobrr" />
<link rel="preload" href="/Inter-Variable.woff2" as="font" type="font/woff2" crossorigin="use-credentials"> <link rel="preload" href="/Inter-Variable.woff2" as="font" type="font/woff2" crossorigin="use-credentials">
<link rel="apple-touch-icon" href="/logo192.png" /> <link rel="apple-touch-icon" href="/logo192.png" />

View file

@ -115,10 +115,27 @@ export const SettingsContext = newRidgeState<SettingsType>(
onSet: (newState, prevState) => { onSet: (newState, prevState) => {
document.documentElement.classList.toggle("dark", newState.darkTheme); document.documentElement.classList.toggle("dark", newState.darkTheme);
DefaultSetter(SettingsKey, newState, prevState); DefaultSetter(SettingsKey, newState, prevState);
updateMetaThemeColor(newState.darkTheme);
} }
} }
); );
/**
* Updates the meta theme color based on the current theme state.
* Used by Safari to color the compact tab bar on both iOS and MacOS.
*/
const updateMetaThemeColor = (darkTheme: boolean) => {
const color = darkTheme ? '#121315' : '#f4f4f5';
let metaThemeColor: HTMLMetaElement | null = document.querySelector('meta[name="theme-color"]');
if (!metaThemeColor) {
metaThemeColor = document.createElement('meta') as HTMLMetaElement;
metaThemeColor.name = "theme-color";
document.head.appendChild(metaThemeColor);
}
metaThemeColor.content = color;
};
export const FilterListContext = newRidgeState<FilterListState>( export const FilterListContext = newRidgeState<FilterListState>(
FilterListContextDefaults, FilterListContextDefaults,
{ {