2023-02-22 18:53:08 +01:00
|
|
|
import { browser } from '$app/environment';
|
2023-05-21 08:26:06 +02:00
|
|
|
import { MapSettings } from '$lib/components/map-page/map-settings-modal.svelte';
|
2023-02-22 18:53:08 +01:00
|
|
|
import { persisted } from 'svelte-local-storage-store';
|
|
|
|
|
|
|
|
const initialTheme =
|
|
|
|
browser && !window.matchMedia('(prefers-color-scheme: dark)').matches ? 'light' : 'dark';
|
|
|
|
|
|
|
|
// The 'color-theme' key is also used by app.html to prevent FOUC on page load.
|
|
|
|
export const colorTheme = persisted<'dark' | 'light'>('color-theme', initialTheme, {
|
|
|
|
serializer: {
|
|
|
|
parse: (text) => (text === 'light' ? text : 'dark'),
|
|
|
|
stringify: (obj) => obj
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Locale to use for formatting dates, numbers, etc.
|
|
|
|
export const locale = persisted<string | undefined>('locale', undefined, {
|
|
|
|
serializer: {
|
|
|
|
parse: (text) => text,
|
|
|
|
stringify: (obj) => obj ?? ''
|
|
|
|
}
|
|
|
|
});
|
2023-05-21 08:26:06 +02:00
|
|
|
|
|
|
|
export const mapSettings = persisted<MapSettings>('map-settings', {
|
|
|
|
allowDarkMode: true,
|
2023-05-25 18:47:52 +02:00
|
|
|
onlyFavorites: false,
|
|
|
|
relativeDate: '',
|
|
|
|
dateAfter: '',
|
|
|
|
dateBefore: ''
|
2023-05-21 08:26:06 +02:00
|
|
|
});
|