2024-01-07 01:15:25 +01:00
< script lang = "ts" >
2024-02-22 15:36:14 +01:00
import type { ComboBoxOption } from '$lib/components/shared-components/combobox.svelte';
import SettingCombobox from '$lib/components/shared-components/settings/setting-combobox.svelte';
import SettingSwitch from '$lib/components/shared-components/settings/setting-switch.svelte';
import { fallbackLocale , locales } from '$lib/constants';
2024-02-22 10:14:11 -05:00
import { sidebarSettings } from '$lib/stores/preferences.store';
2024-03-11 12:45:01 -04:00
import { alwaysLoadOriginalFile , playVideoThumbnailOnHover , showDeleteModal } from '$lib/stores/preferences.store';
2024-02-22 15:36:14 +01:00
import { colorTheme , locale } from '$lib/stores/preferences.store';
import { findLocale } from '$lib/utils';
import { onMount } from 'svelte';
2024-01-07 01:15:25 +01:00
import { fade } from 'svelte/transition';
2024-02-22 15:36:14 +01:00
let time = new Date();
$: formattedDate = time.toLocaleString(editedLocale, {
year: 'numeric',
month: '2-digit',
day: '2-digit',
});
$: timePortion = time.toLocaleString(editedLocale, {
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
});
$: selectedDate = `${ formattedDate } ${ timePortion } `;
$: editedLocale = findLocale($locale).code;
$: selectedOption = {
value: findLocale(editedLocale).code || fallbackLocale.code,
label: findLocale(editedLocale).name || fallbackLocale.name,
};
onMount(() => {
const interval = setInterval(() => {
time = new Date();
}, 1000);
return () => {
clearInterval(interval);
};
});
const getAllLanguages = (): ComboBoxOption[] => {
return locales
.filter(({ code } ) => Intl.NumberFormat.supportedLocalesOf(code).length > 0)
.map((locale) => ({
label: locale.name,
value: locale.code,
}));
};
const handleToggleColorTheme = () => {
2024-01-07 01:15:25 +01:00
$colorTheme.system = !$colorTheme.system;
};
2024-02-22 15:36:14 +01:00
const handleToggleLocaleBrowser = () => {
$locale = $locale ? undefined : fallbackLocale.code;
};
const handleLocaleChange = (newLocale: string | undefined) => {
$locale = newLocale;
};
2024-01-07 01:15:25 +01:00
< / script >
< section class = "my-4" >
< div in:fade = {{ duration : 500 }} >
< div class = "ml-4 mt-4 flex flex-col gap-4" >
< div class = "ml-4" >
< SettingSwitch
2024-04-06 14:18:49 +00:00
id="theme-selection"
2024-01-07 01:15:25 +01:00
title="Theme selection"
subtitle="Automatically set the theme to light or dark based on your browser's system preference"
bind:checked={ $colorTheme . system }
2024-02-22 15:36:14 +01:00
on:toggle={ handleToggleColorTheme }
2024-01-07 01:15:25 +01:00
/>
< / div >
2024-02-22 10:14:11 -05:00
2024-02-22 15:36:14 +01:00
< div class = "ml-4" >
< SettingSwitch
2024-04-06 14:18:49 +00:00
id="default-locale"
2024-02-22 15:36:14 +01:00
title="Default Locale"
subtitle="Format dates and numbers based on your browser locale"
checked={ $locale == undefined }
on:toggle={ handleToggleLocaleBrowser }
>
2024-02-22 19:08:55 +01:00
< p class = "mt-2 dark:text-gray-400" > { selectedDate } </ p >
2024-02-22 15:36:14 +01:00
< / SettingSwitch >
< / div >
{ #if $locale !== undefined }
< div class = "ml-4" >
< SettingCombobox
2024-03-19 12:56:41 +00:00
id="custom-locale"
2024-02-22 15:36:14 +01:00
comboboxPlaceholder="Searching locales..."
{ selectedOption }
options={ getAllLanguages ()}
title="Custom Locale"
subtitle="Format dates and numbers based on the language and the region"
onSelect={( combobox ) => handleLocaleChange ( combobox ? . value )}
/>
< / div >
{ /if }
2024-02-22 10:14:11 -05:00
< div class = "ml-4" >
< SettingSwitch
2024-04-06 14:18:49 +00:00
id="always-load-original-file"
2024-02-22 10:14:11 -05:00
title="Display original photos"
subtitle="Prefer to display the original photo when viewing an asset rather than thumbnails when the original asset is web-compatible. This may result in slower photo display speeds."
bind:checked={ $alwaysLoadOriginalFile }
on:toggle={() => ( $alwaysLoadOriginalFile = ! $alwaysLoadOriginalFile )}
/>
< / div >
2024-03-11 12:45:01 -04:00
< div class = "ml-4" >
< SettingSwitch
2024-04-06 14:18:49 +00:00
id="play-video-thumbnail-on-hover"
2024-03-11 12:45:01 -04:00
title="Play video thumbnail on hover"
subtitle="Play video thumbnail when mouse is hovering over item. Even when disabled, playback can be started by hovering over the play icon."
bind:checked={ $playVideoThumbnailOnHover }
on:toggle={() => ( $playVideoThumbnailOnHover = ! $playVideoThumbnailOnHover )}
/>
< / div >
< div class = "ml-4" >
< SettingSwitch
2024-04-06 14:18:49 +00:00
id="show-delete-warning"
2024-03-11 12:45:01 -04:00
title="Permanent deletion warning"
subtitle="Show a warning when permanently deleting assets"
bind:checked={ $showDeleteModal }
/>
< / div >
2024-02-22 10:14:11 -05:00
< div class = "ml-4" >
< SettingSwitch
2024-04-06 14:18:49 +00:00
id="people-sidebar-link"
2024-02-22 10:14:11 -05:00
title="People"
subtitle="Display a link to People in the sidebar"
bind:checked={ $sidebarSettings . people }
/>
< / div >
< div class = "ml-4" >
< SettingSwitch
2024-04-06 14:18:49 +00:00
id="sharing-sidebar-link"
2024-02-22 10:14:11 -05:00
title="Sharing"
subtitle="Display a link to Sharing in the sidebar"
bind:checked={ $sidebarSettings . sharing }
/>
< / div >
2024-01-07 01:15:25 +01:00
< / div >
< / div >
< / section >