2023-02-22 18:53:08 +01:00
|
|
|
import { browser } from '$app/environment';
|
|
|
|
import { persisted } from 'svelte-local-storage-store';
|
|
|
|
|
2023-07-01 06:50:47 +02:00
|
|
|
const initialTheme = browser && !window.matchMedia('(prefers-color-scheme: dark)').matches ? 'light' : 'dark';
|
2023-02-22 18:53:08 +01:00
|
|
|
|
|
|
|
// 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, {
|
2023-07-01 06:50:47 +02:00
|
|
|
serializer: {
|
|
|
|
parse: (text) => (text === 'light' ? text : 'dark'),
|
|
|
|
stringify: (obj) => obj,
|
|
|
|
},
|
2023-02-22 18:53:08 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// Locale to use for formatting dates, numbers, etc.
|
|
|
|
export const locale = persisted<string | undefined>('locale', undefined, {
|
2023-07-01 06:50:47 +02:00
|
|
|
serializer: {
|
|
|
|
parse: (text) => text,
|
|
|
|
stringify: (obj) => obj ?? '',
|
|
|
|
},
|
2023-02-22 18:53:08 +01:00
|
|
|
});
|
2023-05-21 08:26:06 +02:00
|
|
|
|
2023-06-02 15:55:08 +02:00
|
|
|
export interface MapSettings {
|
2023-07-01 06:50:47 +02:00
|
|
|
allowDarkMode: boolean;
|
|
|
|
onlyFavorites: boolean;
|
|
|
|
relativeDate: string;
|
|
|
|
dateAfter: string;
|
|
|
|
dateBefore: string;
|
2023-06-02 15:55:08 +02:00
|
|
|
}
|
|
|
|
|
2023-05-21 08:26:06 +02:00
|
|
|
export const mapSettings = persisted<MapSettings>('map-settings', {
|
2023-07-01 06:50:47 +02:00
|
|
|
allowDarkMode: true,
|
|
|
|
onlyFavorites: false,
|
|
|
|
relativeDate: '',
|
|
|
|
dateAfter: '',
|
|
|
|
dateBefore: '',
|
2023-05-21 08:26:06 +02:00
|
|
|
});
|
2023-06-21 16:59:13 +02:00
|
|
|
|
|
|
|
export const videoViewerVolume = persisted<number>('video-viewer-volume', 1, {});
|
2023-06-26 18:54:20 +02:00
|
|
|
|
2023-06-29 04:14:16 +02:00
|
|
|
export const isShowDetail = persisted<boolean>('info-opened', false, {});
|
|
|
|
|
2023-06-26 18:54:20 +02:00
|
|
|
export interface AlbumViewSettings {
|
2023-07-01 06:50:47 +02:00
|
|
|
sortBy: string;
|
2023-06-26 18:54:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export const albumViewSettings = persisted<AlbumViewSettings>('album-view-settings', {
|
2023-07-01 06:50:47 +02:00
|
|
|
sortBy: 'Most recent photo',
|
2023-06-26 18:54:20 +02:00
|
|
|
});
|