refactor: slideshow modal (#24788)

This commit is contained in:
Jason Rasmussen
2025-12-22 13:44:53 -05:00
committed by GitHub
parent edc21ed746
commit 8ad27c7cea

View File

@@ -1,9 +1,6 @@
<script lang="ts"> <script lang="ts">
import SettingInputField from '$lib/components/shared-components/settings/setting-input-field.svelte';
import SettingSwitch from '$lib/components/shared-components/settings/setting-switch.svelte';
import { SettingInputFieldType } from '$lib/constants';
import type { RenderedOption } from '$lib/elements/Dropdown.svelte'; import type { RenderedOption } from '$lib/elements/Dropdown.svelte';
import { Button, HStack, Modal, ModalBody, ModalFooter } from '@immich/ui'; import { Field, FormModal, HelperText, NumberInput, Switch } from '@immich/ui';
import { import {
mdiArrowDownThin, mdiArrowDownThin,
mdiArrowUpThin, mdiArrowUpThin,
@@ -26,9 +23,9 @@
slideshowState, slideshowState,
} = slideshowStore; } = slideshowStore;
interface Props { type Props = {
onClose: () => void; onClose: () => void;
} };
let { onClose }: Props = $props(); let { onClose }: Props = $props();
@@ -63,7 +60,7 @@
} }
}; };
const applyChanges = () => { const onSubmit = () => {
$slideshowDelay = tempSlideshowDelay; $slideshowDelay = tempSlideshowDelay;
$showProgressBar = tempShowProgressBar; $showProgressBar = tempShowProgressBar;
$slideshowNavigation = tempSlideshowNavigation; $slideshowNavigation = tempSlideshowNavigation;
@@ -75,9 +72,8 @@
}; };
</script> </script>
<Modal size="small" title={$t('slideshow_settings')} onClose={() => onClose()}> <FormModal size="small" title={$t('slideshow_settings')} {onClose} {onSubmit}>
<ModalBody> <div class="flex flex-col gap-4">
<div class="flex flex-col gap-4 text-primary">
<SettingDropdown <SettingDropdown
title={$t('direction')} title={$t('direction')}
options={Object.values(navigationOptions)} options={Object.values(navigationOptions)}
@@ -86,6 +82,7 @@
tempSlideshowNavigation = handleToggle(option, navigationOptions) || tempSlideshowNavigation; tempSlideshowNavigation = handleToggle(option, navigationOptions) || tempSlideshowNavigation;
}} }}
/> />
<SettingDropdown <SettingDropdown
title={$t('look')} title={$t('look')}
options={Object.values(lookOptions)} options={Object.values(lookOptions)}
@@ -94,22 +91,22 @@
tempSlideshowLook = handleToggle(option, lookOptions) || tempSlideshowLook; tempSlideshowLook = handleToggle(option, lookOptions) || tempSlideshowLook;
}} }}
/> />
<SettingSwitch title={$t('autoplay_slideshow')} bind:checked={tempSlideshowAutoplay} />
<SettingSwitch title={$t('show_progress_bar')} bind:checked={tempShowProgressBar} /> <Field label={$t('autoplay_slideshow')}>
<SettingSwitch title={$t('show_slideshow_transition')} bind:checked={tempSlideshowTransition} /> <Switch bind:checked={tempSlideshowAutoplay} />
<SettingInputField </Field>
inputType={SettingInputFieldType.NUMBER}
label={$t('duration')} <Field label={$t('show_progress_bar')}>
description={$t('admin.slideshow_duration_description')} <Switch bind:checked={tempShowProgressBar} />
min={1} </Field>
bind:value={tempSlideshowDelay}
/> <Field label={$t('show_slideshow_transition')}>
<Switch bind:checked={tempSlideshowTransition} />
</Field>
<Field label={$t('duration')}>
<NumberInput min={1} bind:value={tempSlideshowDelay} />
<HelperText>{$t('admin.slideshow_duration_description')}</HelperText>
</Field>
</div> </div>
</ModalBody> </FormModal>
<ModalFooter>
<HStack fullWidth>
<Button color="secondary" shape="round" fullWidth onclick={() => onClose()}>{$t('cancel')}</Button>
<Button fullWidth color="primary" shape="round" onclick={applyChanges}>{$t('confirm')}</Button>
</HStack>
</ModalFooter>
</Modal>