mirror of
https://github.com/imputnet/cobalt.git
synced 2024-12-29 11:06:10 +00:00
web/theme: add dynamic status bar color on mobile
This commit is contained in:
parent
d817888838
commit
f383f5d94e
|
@ -1,9 +1,11 @@
|
|||
import { readable, derived } from 'svelte/store';
|
||||
import { readable, derived, type Readable } from 'svelte/store';
|
||||
|
||||
import settings from '$lib/settings';
|
||||
import { themeOptions } from '$lib/types/settings';
|
||||
|
||||
let set: (_: typeof themeOptions[number]) => void;
|
||||
type Theme = typeof themeOptions[number];
|
||||
|
||||
let set: (_: Theme) => void;
|
||||
|
||||
const browserPreference = () =>
|
||||
window.matchMedia('(prefers-color-scheme: light)')
|
||||
|
@ -30,5 +32,9 @@ export default derived(
|
|||
return $browserPref;
|
||||
},
|
||||
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/500.css";
|
||||
|
||||
import currentTheme from "$lib/state/theme";
|
||||
import currentTheme, { statusBarColors } from "$lib/state/theme";
|
||||
|
||||
import Sidebar from "$components/sidebar/Sidebar.svelte";
|
||||
|
||||
import device from "$lib/device";
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
{#if device.isMobile}
|
||||
<meta name="theme-color" content={statusBarColors[$currentTheme]}>
|
||||
{/if}
|
||||
</svelte:head>
|
||||
|
||||
<div style="display: contents" data-theme={$currentTheme}>
|
||||
<div id="cobalt">
|
||||
<Sidebar />
|
||||
|
|
Loading…
Reference in a new issue