2024-08-02 15:33:18 +02:00
|
|
|
<script lang="ts">
|
|
|
|
|
import type { Snippet } from "svelte";
|
|
|
|
|
|
2024-09-13 17:04:04 +02:00
|
|
|
const {
|
|
|
|
|
children,
|
|
|
|
|
id,
|
|
|
|
|
text,
|
|
|
|
|
isWider = false
|
|
|
|
|
}: { children: Snippet; id: string; text: string; isWider?: boolean } = $props();
|
2024-08-24 21:53:05 +02:00
|
|
|
|
2024-08-24 21:57:41 +02:00
|
|
|
const modalId = `${id}-modal`;
|
2024-08-02 15:33:18 +02:00
|
|
|
</script>
|
|
|
|
|
|
2024-08-24 21:53:05 +02:00
|
|
|
<a href={`#${modalId}`} role="button">{text}</a>
|
2024-08-02 15:33:18 +02:00
|
|
|
|
2024-09-13 17:04:04 +02:00
|
|
|
<div id={modalId} class="modal" style="--modal-width: {isWider ? 600 : 300}px">
|
2024-08-02 15:33:18 +02:00
|
|
|
<div class="modal__content">
|
|
|
|
|
{@render children()}
|
|
|
|
|
<a href="#!" role="button">Close</a>
|
|
|
|
|
</div>
|
|
|
|
|
<a href="#!" class="modal__closeoverlay" aria-label="Close modal"></a>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.modal {
|
|
|
|
|
position: fixed;
|
|
|
|
|
inset: 0;
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.modal:target {
|
2024-08-03 18:07:27 +02:00
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
2024-08-15 16:26:32 +02:00
|
|
|
padding: var(--space-s);
|
2024-08-02 15:33:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.modal__closeoverlay {
|
|
|
|
|
position: fixed;
|
|
|
|
|
inset: 0;
|
|
|
|
|
z-index: 10;
|
2024-09-24 17:35:28 +02:00
|
|
|
background-color: var(--bg-blurred);
|
2024-08-02 15:33:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.modal__content {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
2024-08-15 16:26:32 +02:00
|
|
|
gap: var(--space-s);
|
|
|
|
|
padding-inline: var(--space-s);
|
|
|
|
|
padding-block: var(--space-m);
|
2024-08-02 15:33:18 +02:00
|
|
|
background-color: var(--bg-primary);
|
|
|
|
|
border-radius: var(--border-radius);
|
|
|
|
|
border: var(--border-primary);
|
2024-09-13 17:04:04 +02:00
|
|
|
inline-size: var(--modal-width);
|
2024-08-03 18:07:27 +02:00
|
|
|
max-inline-size: 100%;
|
2024-08-15 16:26:32 +02:00
|
|
|
max-block-size: calc(100vh - var(--space-m));
|
2024-08-03 18:07:27 +02:00
|
|
|
overflow-y: auto;
|
2024-08-02 15:33:18 +02:00
|
|
|
z-index: 20;
|
|
|
|
|
}
|
|
|
|
|
</style>
|