2022-12-09 15:51:42 -05:00
|
|
|
<script lang="ts">
|
2023-07-01 00:50:47 -04:00
|
|
|
import { quintOut } from 'svelte/easing';
|
|
|
|
import { fly } from 'svelte/transition';
|
2023-09-03 02:21:51 -04:00
|
|
|
import { createEventDispatcher } from 'svelte';
|
2024-02-23 06:01:19 +01:00
|
|
|
import Slider from '$lib/components/elements/slider.svelte';
|
2023-01-22 02:09:02 +00:00
|
|
|
|
2024-04-06 14:18:49 +00:00
|
|
|
export let id: string;
|
2023-07-01 00:50:47 -04:00
|
|
|
export let title: string;
|
|
|
|
export let subtitle = '';
|
|
|
|
export let checked = false;
|
|
|
|
export let disabled = false;
|
|
|
|
export let isEdited = false;
|
2023-09-03 02:21:51 -04:00
|
|
|
|
2024-04-06 14:18:49 +00:00
|
|
|
$: sliderId = `${id}-slider`;
|
|
|
|
$: subtitleId = subtitle ? `${id}-subtitle` : undefined;
|
|
|
|
|
2023-09-03 02:21:51 -04:00
|
|
|
const dispatch = createEventDispatcher<{ toggle: boolean }>();
|
2024-04-06 14:18:49 +00:00
|
|
|
const onToggle = (isChecked: boolean) => dispatch('toggle', isChecked);
|
2022-12-09 15:51:42 -05:00
|
|
|
</script>
|
|
|
|
|
2024-01-19 09:57:15 -05:00
|
|
|
<div class="flex place-items-center justify-between">
|
2024-04-06 14:18:49 +00:00
|
|
|
<div class="mr-2">
|
2024-01-19 09:57:15 -05:00
|
|
|
<div class="flex h-[26px] place-items-center gap-1">
|
2024-04-06 14:18:49 +00:00
|
|
|
<label class="font-medium text-immich-primary dark:text-immich-dark-primary text-sm" for={sliderId}>
|
2024-01-19 09:57:15 -05:00
|
|
|
{title}
|
|
|
|
</label>
|
|
|
|
{#if isEdited}
|
|
|
|
<div
|
|
|
|
transition:fly={{ x: 10, duration: 200, easing: quintOut }}
|
|
|
|
class="rounded-full bg-orange-100 px-2 text-[10px] text-orange-900"
|
|
|
|
>
|
|
|
|
Unsaved change
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
</div>
|
2023-12-17 00:17:38 +01:00
|
|
|
|
2024-04-06 14:18:49 +00:00
|
|
|
{#if subtitle}
|
|
|
|
<p id={subtitleId} class="text-sm dark:text-immich-dark-fg">{subtitle}</p>
|
|
|
|
{/if}
|
2024-02-22 15:36:14 +01:00
|
|
|
<slot />
|
2024-01-19 09:57:15 -05:00
|
|
|
</div>
|
2024-01-19 11:34:20 -06:00
|
|
|
|
2024-04-06 14:18:49 +00:00
|
|
|
<Slider
|
|
|
|
id={sliderId}
|
|
|
|
bind:checked
|
|
|
|
{disabled}
|
|
|
|
on:toggle={({ detail }) => onToggle(detail)}
|
|
|
|
ariaDescribedBy={subtitleId}
|
|
|
|
/>
|
2024-01-19 09:57:15 -05:00
|
|
|
</div>
|