2022-05-21 02:23:55 -05:00
|
|
|
<script lang="ts">
|
2023-07-01 00:50:47 -04:00
|
|
|
import { clickOutside } from '../../utils/click-outside';
|
|
|
|
|
import { fade } from 'svelte/transition';
|
2024-03-27 20:55:27 +00:00
|
|
|
import FocusTrap from '$lib/components/shared-components/focus-trap.svelte';
|
2024-04-08 21:02:09 +00:00
|
|
|
import ModalHeader from '$lib/components/shared-components/modal-header.svelte';
|
2022-05-21 02:23:55 -05:00
|
|
|
|
2024-04-08 21:02:09 +00:00
|
|
|
export let onClose: () => void;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Unique identifier for the modal.
|
|
|
|
|
*/
|
|
|
|
|
export let id: string;
|
|
|
|
|
export let title: string;
|
|
|
|
|
/**
|
|
|
|
|
* If true, the logo will be displayed next to the modal title.
|
|
|
|
|
*/
|
|
|
|
|
export let showLogo = false;
|
|
|
|
|
/**
|
|
|
|
|
* Optional icon to display next to the modal title, if `showLogo` is false.
|
|
|
|
|
*/
|
|
|
|
|
export let icon: string | undefined = undefined;
|
|
|
|
|
/**
|
|
|
|
|
* Sets the width of the modal.
|
|
|
|
|
*
|
|
|
|
|
* - `wide`: 750px
|
|
|
|
|
* - `narrow`: 450px
|
|
|
|
|
* - `auto`: fits the width of the modal content, up to a maximum of 550px
|
|
|
|
|
*/
|
|
|
|
|
export let width: 'wide' | 'narrow' | 'auto' = 'narrow';
|
|
|
|
|
|
|
|
|
|
$: titleId = `${id}-title`;
|
|
|
|
|
|
|
|
|
|
let modalWidth: string;
|
|
|
|
|
$: {
|
|
|
|
|
if (width === 'wide') {
|
|
|
|
|
modalWidth = 'w-[750px]';
|
|
|
|
|
} else if (width === 'narrow') {
|
|
|
|
|
modalWidth = 'w-[450px]';
|
|
|
|
|
} else {
|
|
|
|
|
modalWidth = 'sm:max-w-[550px]';
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-21 02:23:55 -05:00
|
|
|
</script>
|
|
|
|
|
|
2024-03-27 20:55:27 +00:00
|
|
|
<FocusTrap>
|
|
|
|
|
<section
|
|
|
|
|
in:fade={{ duration: 100 }}
|
|
|
|
|
out:fade={{ duration: 100 }}
|
|
|
|
|
class="fixed left-0 top-0 z-[9990] flex h-screen w-screen place-content-center place-items-center bg-black/40"
|
|
|
|
|
>
|
2024-04-08 21:02:09 +00:00
|
|
|
<div
|
|
|
|
|
class="z-[9999] max-w-[95vw] max-h-[95vh] {modalWidth} overflow-y-auto rounded-3xl bg-immich-bg shadow-md dark:bg-immich-dark-gray dark:text-immich-dark-fg immich-scrollbar"
|
|
|
|
|
use:clickOutside={{ onOutclick: onClose, onEscape: onClose }}
|
|
|
|
|
tabindex="-1"
|
|
|
|
|
aria-modal="true"
|
|
|
|
|
aria-labelledby={titleId}
|
|
|
|
|
>
|
2024-04-11 09:01:16 +00:00
|
|
|
<ModalHeader id={titleId} {title} {showLogo} {icon} {onClose} />
|
2024-04-08 21:02:09 +00:00
|
|
|
<div class="p-5 pt-0">
|
|
|
|
|
<slot />
|
|
|
|
|
</div>
|
2024-03-27 20:55:27 +00:00
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
</FocusTrap>
|