Skip to content

Commit

Permalink
fix(web): slider (#6485)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasm91 authored Jan 19, 2024
1 parent b4d1470 commit dacca4c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
35 changes: 19 additions & 16 deletions web/src/lib/components/admin-page/settings/setting-switch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@
const dispatch = createEventDispatcher<{ toggle: boolean }>();
</script>

<Slider bind:checked {disabled} on:toggle={() => dispatch('toggle', checked)}>
<div class="flex h-[26px] place-items-center gap-1">
<label class="font-medium text-immich-primary dark:text-immich-dark-primary text-sm" for={title}>
{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>
<div class="flex place-items-center justify-between">
<div>
<div class="flex h-[26px] place-items-center gap-1">
<label class="font-medium text-immich-primary dark:text-immich-dark-primary text-sm" for={title}>
{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>

<p class="text-sm dark:text-immich-dark-fg">{subtitle}</p>
</Slider>
<p class="text-sm dark:text-immich-dark-fg">{subtitle}</p>
</div>
<Slider bind:checked {disabled} on:toggle={() => dispatch('toggle', checked)} />
</div>
31 changes: 14 additions & 17 deletions web/src/lib/components/elements/slider.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,21 @@
const onToggle = (event: Event) => dispatch('toggle', (event.target as HTMLInputElement).checked);
</script>

<div class="flex place-items-center justify-between">
<slot name="leading" />
<label class="relative inline-block h-[10px] w-[36px] flex-none">
<input
class="disabled::cursor-not-allowed h-0 w-0 opacity-0"
type="checkbox"
bind:checked
on:click={onToggle}
{disabled}
/>
<label class="relative inline-block h-[10px] w-[36px] flex-none">
<input
class="disabled::cursor-not-allowed h-0 w-0 opacity-0"
type="checkbox"
bind:checked
on:click={onToggle}
{disabled}
/>

{#if disabled}
<span class="slider slider-disabled cursor-not-allowed" />
{:else}
<span class="slider slider-enabled cursor-pointer" />
{/if}
</label>
</div>
{#if disabled}
<span class="slider slider-disabled cursor-not-allowed" />
{:else}
<span class="slider slider-enabled cursor-pointer" />
{/if}
</label>

<style>
.slider {
Expand Down

0 comments on commit dacca4c

Please sign in to comment.