mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
feat(web): allow hiding all unnamed faces and reset hidden faces (#9378)
* feat: hide all unnamed * feat: remove dispatch event * pr feedback
This commit is contained in:
parent
2ae44022c2
commit
aa1dc68867
2 changed files with 55 additions and 26 deletions
|
|
@ -1,24 +1,46 @@
|
|||
<script lang="ts" context="module">
|
||||
export enum ToggleVisibilty {
|
||||
HIDE_ALL = 'hide-all',
|
||||
HIDE_UNNANEMD = 'hide-unnamed',
|
||||
VIEW_ALL = 'view-all',
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { fly } from 'svelte/transition';
|
||||
import CircleIconButton from '../elements/buttons/circle-icon-button.svelte';
|
||||
import { quintOut } from 'svelte/easing';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import LoadingSpinner from '$lib/components/shared-components/loading-spinner.svelte';
|
||||
import { mdiClose, mdiEye, mdiEyeOff, mdiRestart } from '@mdi/js';
|
||||
import { mdiClose, mdiEye, mdiEyeOff, mdiEyeSettings, mdiRestart } from '@mdi/js';
|
||||
import { locale } from '$lib/stores/preferences.store';
|
||||
import Button from '$lib/components/elements/buttons/button.svelte';
|
||||
|
||||
const dispatch = createEventDispatcher<{
|
||||
close: void;
|
||||
reset: void;
|
||||
change: void;
|
||||
done: void;
|
||||
}>();
|
||||
|
||||
export let showLoadingSpinner: boolean;
|
||||
export let toggleVisibility: boolean;
|
||||
export let toggleVisibility: ToggleVisibilty = ToggleVisibilty.VIEW_ALL;
|
||||
export let screenHeight: number;
|
||||
export let countTotalPeople: number;
|
||||
export let onClose: () => void;
|
||||
export let onReset: () => void;
|
||||
export let onChange: (toggleVisibility: ToggleVisibilty) => void;
|
||||
export let onDone: () => void;
|
||||
|
||||
const getNextVisibility = (toggleVisibility: ToggleVisibilty) => {
|
||||
if (toggleVisibility === ToggleVisibilty.VIEW_ALL) {
|
||||
return ToggleVisibilty.HIDE_UNNANEMD;
|
||||
} else if (toggleVisibility === ToggleVisibilty.HIDE_UNNANEMD) {
|
||||
return ToggleVisibilty.HIDE_ALL;
|
||||
} else {
|
||||
return ToggleVisibilty.VIEW_ALL;
|
||||
}
|
||||
};
|
||||
|
||||
const toggleIconOptions: Record<ToggleVisibilty, string> = {
|
||||
[ToggleVisibilty.HIDE_ALL]: mdiEyeOff,
|
||||
[ToggleVisibilty.HIDE_UNNANEMD]: mdiEyeSettings,
|
||||
[ToggleVisibilty.VIEW_ALL]: mdiEye,
|
||||
};
|
||||
|
||||
$: toggleIcon = toggleIconOptions[toggleVisibility];
|
||||
</script>
|
||||
|
||||
<section
|
||||
|
|
@ -29,7 +51,7 @@
|
|||
class="fixed top-0 z-10 flex h-16 w-full items-center justify-between border-b bg-white p-1 dark:border-immich-dark-gray dark:bg-black dark:text-immich-dark-fg md:p-8"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<CircleIconButton title="Close" icon={mdiClose} on:click={() => dispatch('close')} />
|
||||
<CircleIconButton title="Close" icon={mdiClose} on:click={onClose} />
|
||||
<div class="flex gap-2 items-center">
|
||||
<p class="ml-2">Show & hide people</p>
|
||||
<p class="text-sm text-gray-400 dark:text-gray-600">({countTotalPeople.toLocaleString($locale)})</p>
|
||||
|
|
@ -37,15 +59,15 @@
|
|||
</div>
|
||||
<div class="flex items-center justify-end">
|
||||
<div class="flex items-center md:mr-8">
|
||||
<CircleIconButton title="Reset people visibility" icon={mdiRestart} on:click={() => dispatch('reset')} />
|
||||
<CircleIconButton title="Reset people visibility" icon={mdiRestart} on:click={onReset} />
|
||||
<CircleIconButton
|
||||
title="Toggle visibility"
|
||||
icon={toggleVisibility ? mdiEye : mdiEyeOff}
|
||||
on:click={() => dispatch('change')}
|
||||
icon={toggleIcon}
|
||||
on:click={() => onChange(getNextVisibility(toggleVisibility))}
|
||||
/>
|
||||
</div>
|
||||
{#if !showLoadingSpinner}
|
||||
<Button on:click={() => dispatch('done')} size="sm" rounded="lg">Done</Button>
|
||||
<Button on:click={onDone} size="sm" rounded="lg">Done</Button>
|
||||
{:else}
|
||||
<LoadingSpinner />
|
||||
{/if}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue