2024-08-19 08:43:43 -04:00
|
|
|
<script lang="ts">
|
|
|
|
import { createEventDispatcher } from 'svelte';
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
import { onMount } from 'svelte';
|
|
|
|
let modal: HTMLDialogElement;
|
|
|
|
import type { Adventure } from '$lib/types';
|
|
|
|
|
|
|
|
export let image: string;
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
modal = document.getElementById('my_modal_1') as HTMLDialogElement;
|
|
|
|
if (modal) {
|
|
|
|
modal.showModal();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
function close() {
|
|
|
|
dispatch('close');
|
2024-08-19 18:48:05 +02:00
|
|
|
if (modal) {
|
|
|
|
modal.close();
|
|
|
|
}
|
2024-08-19 08:43:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function handleKeydown(event: KeyboardEvent) {
|
|
|
|
if (event.key === 'Escape') {
|
2024-08-19 18:48:05 +02:00
|
|
|
close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleClickOutside(event: MouseEvent) {
|
|
|
|
if (event.target === modal) {
|
|
|
|
close();
|
2024-08-19 08:43:43 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2024-08-19 13:58:14 -04:00
|
|
|
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
|
|
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
|
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
2024-08-19 18:48:05 +02:00
|
|
|
<dialog id="my_modal_1" class="modal" on:click={handleClickOutside}>
|
2024-08-19 08:43:43 -04:00
|
|
|
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
|
|
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
|
|
|
<div class="modal-box w-11/12 max-w-5xl" role="dialog" on:keydown={handleKeydown} tabindex="0">
|
2024-08-19 18:48:05 +02:00
|
|
|
<div class="modal-header flex justify-between items-center mb-4">
|
2024-10-13 23:23:32 -04:00
|
|
|
<h3 class="font-bold text-2xl">Image Preview</h3>
|
2024-08-19 13:58:14 -04:00
|
|
|
<button class="btn btn-circle btn-neutral" on:click={close}>
|
|
|
|
<svg
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
class="h-6 w-6"
|
|
|
|
fill="none"
|
|
|
|
viewBox="0 0 24 24"
|
|
|
|
stroke="currentColor"
|
|
|
|
>
|
|
|
|
<path
|
|
|
|
stroke-linecap="round"
|
|
|
|
stroke-linejoin="round"
|
|
|
|
stroke-width="2"
|
|
|
|
d="M6 18L18 6M6 6l12 12"
|
|
|
|
/>
|
|
|
|
</svg>
|
|
|
|
</button>
|
2024-08-19 18:48:05 +02:00
|
|
|
</div>
|
2024-08-19 13:58:14 -04:00
|
|
|
<div
|
|
|
|
class="flex justify-center items-center"
|
|
|
|
style="display: flex; justify-content: center; align-items: center;"
|
|
|
|
>
|
|
|
|
<img
|
|
|
|
src={image}
|
2024-10-13 23:23:32 -04:00
|
|
|
alt="My Adventure"
|
2024-08-19 13:58:14 -04:00
|
|
|
style="max-width: 100%; max-height: 75vh; object-fit: contain;"
|
|
|
|
/>
|
2024-08-19 08:43:43 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</dialog>
|