2021-03-31 11:59:07 +02:00
|
|
|
<script>
|
|
|
|
import { slide } from "svelte/transition"
|
|
|
|
import Portal from "svelte-portal"
|
2021-04-19 15:40:51 +02:00
|
|
|
import ActionButton from "../ActionButton/ActionButton.svelte"
|
2021-03-31 11:59:07 +02:00
|
|
|
|
|
|
|
export let title
|
|
|
|
|
|
|
|
let visible = false
|
|
|
|
|
|
|
|
export function show() {
|
|
|
|
if (visible) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
visible = true
|
|
|
|
}
|
|
|
|
|
|
|
|
export function hide() {
|
|
|
|
if (!visible) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
visible = false
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleKey(e) {
|
|
|
|
if (visible && e.key === "Escape") {
|
|
|
|
hide()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<svelte:window on:keydown={handleKey} />
|
|
|
|
|
|
|
|
{#if visible}
|
|
|
|
<Portal>
|
|
|
|
<section class="drawer" transition:slide>
|
|
|
|
<header>
|
|
|
|
<div class="text">
|
|
|
|
<div class="title">{title}</div>
|
|
|
|
<slot name="description" />
|
|
|
|
</div>
|
|
|
|
<div class="controls">
|
|
|
|
<slot name="buttons" />
|
2021-04-09 13:38:48 +02:00
|
|
|
<ActionButton quiet icon="Close" on:click={hide} />
|
2021-03-31 11:59:07 +02:00
|
|
|
</div>
|
|
|
|
</header>
|
|
|
|
<slot name="body" />
|
|
|
|
</section>
|
|
|
|
</Portal>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.drawer {
|
|
|
|
position: absolute;
|
|
|
|
bottom: 0;
|
|
|
|
left: 260px;
|
|
|
|
width: calc(100% - 520px);
|
|
|
|
background: var(--background);
|
|
|
|
border: var(--border-light);
|
|
|
|
z-index: 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
header {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
border-bottom: var(--border-light);
|
|
|
|
padding: var(--spacing-m);
|
|
|
|
}
|
|
|
|
|
|
|
|
.controls {
|
|
|
|
display: grid;
|
|
|
|
grid-auto-flow: column;
|
|
|
|
grid-gap: var(--spacing-m);
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.close {
|
|
|
|
font-size: var(--font-size-xl);
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
.title {
|
|
|
|
font-weight: bold;
|
|
|
|
margin-right: var(--spacing-m);
|
|
|
|
}
|
|
|
|
.text {
|
|
|
|
display: flex;
|
2021-04-19 15:40:51 +02:00
|
|
|
flex-direction: row;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: center;
|
2021-03-31 11:59:07 +02:00
|
|
|
}
|
|
|
|
</style>
|