2023-07-18 12:36:20 -05:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { PersonResponseDto, api } from '@api';
|
|
|
|
|
import ImageThumbnail from '../assets/thumbnail/image-thumbnail.svelte';
|
|
|
|
|
import IconButton from '../elements/buttons/icon-button.svelte';
|
|
|
|
|
import DotsVertical from 'svelte-material-icons/DotsVertical.svelte';
|
|
|
|
|
import ContextMenu from '../shared-components/context-menu/context-menu.svelte';
|
|
|
|
|
import MenuOption from '../shared-components/context-menu/menu-option.svelte';
|
|
|
|
|
import Portal from '../shared-components/portal/portal.svelte';
|
|
|
|
|
import { createEventDispatcher } from 'svelte';
|
|
|
|
|
|
|
|
|
|
export let person: PersonResponseDto;
|
|
|
|
|
|
|
|
|
|
let showContextMenu = false;
|
2023-08-18 22:10:29 +02:00
|
|
|
let dispatch = createEventDispatcher<{
|
|
|
|
|
'change-name': void;
|
|
|
|
|
'set-birth-date': void;
|
|
|
|
|
'merge-faces': void;
|
|
|
|
|
'hide-face': void;
|
|
|
|
|
}>();
|
2023-07-18 12:36:20 -05:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div id="people-card" class="relative">
|
|
|
|
|
<a href="/people/{person.id}" draggable="false">
|
2023-07-23 05:00:43 +02:00
|
|
|
<div class="h-48 w-48 rounded-xl brightness-95 filter">
|
2023-07-18 12:36:20 -05:00
|
|
|
<ImageThumbnail shadow url={api.getPeopleThumbnailUrl(person.id)} altText={person.name} widthStyle="100%" />
|
|
|
|
|
</div>
|
|
|
|
|
{#if person.name}
|
2023-08-21 01:36:31 +02:00
|
|
|
<span
|
|
|
|
|
class="text-white-shadow absolute bottom-2 left-0 w-full select-text px-1 text-center font-medium text-white"
|
|
|
|
|
>
|
2023-07-18 12:36:20 -05:00
|
|
|
{person.name}
|
|
|
|
|
</span>
|
|
|
|
|
{/if}
|
|
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
<button
|
2023-07-18 20:09:43 +02:00
|
|
|
class="absolute right-2 top-2 z-20"
|
2023-07-18 12:36:20 -05:00
|
|
|
on:click|stopPropagation|preventDefault={() => {
|
|
|
|
|
showContextMenu = !showContextMenu;
|
|
|
|
|
}}
|
|
|
|
|
data-testid="context-button-parent"
|
|
|
|
|
id={`icon-${person.id}`}
|
|
|
|
|
>
|
|
|
|
|
<IconButton color="transparent-primary">
|
2023-08-21 01:36:31 +02:00
|
|
|
<DotsVertical size="20" class="icon-white-drop-shadow" color="white" />
|
2023-07-18 12:36:20 -05:00
|
|
|
</IconButton>
|
|
|
|
|
|
|
|
|
|
{#if showContextMenu}
|
|
|
|
|
<ContextMenu on:outclick={() => (showContextMenu = false)}>
|
2023-08-18 22:10:29 +02:00
|
|
|
<MenuOption on:click={() => dispatch('hide-face')} text="Hide face" />
|
|
|
|
|
<MenuOption on:click={() => dispatch('change-name')} text="Change name" />
|
|
|
|
|
<MenuOption on:click={() => dispatch('set-birth-date')} text="Set date of birth" />
|
|
|
|
|
<MenuOption on:click={() => dispatch('merge-faces')} text="Merge faces" />
|
2023-07-18 12:36:20 -05:00
|
|
|
</ContextMenu>
|
|
|
|
|
{/if}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{#if showContextMenu}
|
|
|
|
|
<Portal target="body">
|
2023-07-18 20:09:43 +02:00
|
|
|
<div class="heyo absolute left-0 top-0 z-10 h-screen w-screen bg-transparent" />
|
2023-07-18 12:36:20 -05:00
|
|
|
</Portal>
|
|
|
|
|
{/if}
|