Skip to content

Commit

Permalink
feat(web): set Safari window colors (#1543)
Browse files Browse the repository at this point in the history
* feat(web): update meta-theme color

- used by Safari for its colored compact tab bar

* fix: hardcode the colors
  • Loading branch information
s0up4200 committed May 8, 2024
1 parent 8120c33 commit 190994c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<meta charset="utf-8" />
<link rel="icon" href="/favicon.ico" />
<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" />
<link rel="preload" href="/Inter-Variable.woff2" as="font" type="font/woff2" crossorigin="use-credentials">
<link rel="apple-touch-icon" href="/logo192.png" />
Expand Down
17 changes: 17 additions & 0 deletions web/src/utils/Context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,27 @@ export const SettingsContext = newRidgeState<SettingsType>(
onSet: (newState, prevState) => {
document.documentElement.classList.toggle("dark", newState.darkTheme);
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>(
FilterListContextDefaults,
{
Expand Down

0 comments on commit 190994c

Please sign in to comment.