2023-05-17 13:07:17 -04:00
|
|
|
<script lang="ts">
|
2023-07-01 00:50:47 -04:00
|
|
|
import { PersonResponseDto, api } from '@api';
|
|
|
|
import { createEventDispatcher } from 'svelte';
|
|
|
|
import ImageThumbnail from '../assets/thumbnail/image-thumbnail.svelte';
|
|
|
|
import Button from '../elements/buttons/button.svelte';
|
|
|
|
import { clickOutside } from '$lib/utils/click-outside';
|
2023-05-17 13:07:17 -04:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
export let person: PersonResponseDto;
|
|
|
|
let name = person.name;
|
2023-05-17 13:07:17 -04:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
const dispatch = createEventDispatcher<{
|
|
|
|
change: string;
|
|
|
|
cancel: void;
|
|
|
|
}>();
|
2023-05-17 13:07:17 -04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<div
|
2023-07-18 13:19:39 -05:00
|
|
|
class="flex max-w-lg place-items-center rounded-lg border bg-gray-100 p-2 dark:border-transparent dark:bg-gray-700"
|
2023-07-01 00:50:47 -04:00
|
|
|
use:clickOutside
|
|
|
|
on:outclick={() => dispatch('cancel')}
|
2023-05-17 13:07:17 -04:00
|
|
|
>
|
2023-07-01 00:50:47 -04:00
|
|
|
<ImageThumbnail
|
|
|
|
circle
|
|
|
|
shadow
|
|
|
|
url={api.getPeopleThumbnailUrl(person.id)}
|
|
|
|
altText={person.name}
|
|
|
|
widthStyle="2rem"
|
|
|
|
heightStyle="2rem"
|
|
|
|
/>
|
|
|
|
<form
|
2023-07-18 13:19:39 -05:00
|
|
|
class="ml-4 flex w-full justify-between gap-16"
|
2023-07-01 00:50:47 -04:00
|
|
|
autocomplete="off"
|
|
|
|
on:submit|preventDefault={() => dispatch('change', name)}
|
|
|
|
>
|
|
|
|
<!-- svelte-ignore a11y-autofocus -->
|
|
|
|
<input
|
|
|
|
autofocus
|
2023-07-18 13:19:39 -05:00
|
|
|
class="w-full gap-2 bg-gray-100 dark:bg-gray-700 dark:text-white"
|
2023-07-01 00:50:47 -04:00
|
|
|
type="text"
|
|
|
|
placeholder="New name or nickname"
|
|
|
|
bind:value={name}
|
|
|
|
/>
|
|
|
|
<Button size="sm" type="submit">Done</Button>
|
|
|
|
</form>
|
2023-05-17 13:07:17 -04:00
|
|
|
</div>
|