mirror of
https://github.com/wukko/cobalt.git
synced 2025-01-26 04:36:25 +01:00
web/theme: add dynamic status bar color on mobile
This commit is contained in:
parent
980dd67344
commit
192351681b
2 changed files with 18 additions and 4 deletions
|
@ -1,9 +1,11 @@
|
||||||
import { readable, derived } from 'svelte/store';
|
import { readable, derived, type Readable } from 'svelte/store';
|
||||||
|
|
||||||
import settings from '$lib/settings';
|
import settings from '$lib/settings';
|
||||||
import { themeOptions } from '$lib/types/settings';
|
import { themeOptions } from '$lib/types/settings';
|
||||||
|
|
||||||
let set: (_: typeof themeOptions[number]) => void;
|
type Theme = typeof themeOptions[number];
|
||||||
|
|
||||||
|
let set: (_: Theme) => void;
|
||||||
|
|
||||||
const browserPreference = () =>
|
const browserPreference = () =>
|
||||||
window.matchMedia('(prefers-color-scheme: light)')
|
window.matchMedia('(prefers-color-scheme: light)')
|
||||||
|
@ -30,5 +32,9 @@ export default derived(
|
||||||
return $browserPref;
|
return $browserPref;
|
||||||
},
|
},
|
||||||
browserPreference()
|
browserPreference()
|
||||||
);
|
) as Readable<Exclude<Theme, "auto">>
|
||||||
|
|
||||||
|
export const statusBarColors = {
|
||||||
|
"dark": "#000000",
|
||||||
|
"light": "#ffffff"
|
||||||
|
}
|
||||||
|
|
|
@ -2,11 +2,19 @@
|
||||||
import "@fontsource/ibm-plex-mono/400.css";
|
import "@fontsource/ibm-plex-mono/400.css";
|
||||||
import "@fontsource/ibm-plex-mono/500.css";
|
import "@fontsource/ibm-plex-mono/500.css";
|
||||||
|
|
||||||
import currentTheme from "$lib/state/theme";
|
import currentTheme, { statusBarColors } from "$lib/state/theme";
|
||||||
|
|
||||||
import Sidebar from "$components/sidebar/Sidebar.svelte";
|
import Sidebar from "$components/sidebar/Sidebar.svelte";
|
||||||
|
|
||||||
|
import device from "$lib/device";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<svelte:head>
|
||||||
|
{#if device.isMobile}
|
||||||
|
<meta name="theme-color" content={statusBarColors[$currentTheme]}>
|
||||||
|
{/if}
|
||||||
|
</svelte:head>
|
||||||
|
|
||||||
<div style="display: contents" data-theme={$currentTheme}>
|
<div style="display: contents" data-theme={$currentTheme}>
|
||||||
<div id="cobalt">
|
<div id="cobalt">
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
|
|
Loading…
Reference in a new issue