You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
168 lines
2.9 KiB
168 lines
2.9 KiB
<script>
|
|
import { createEventDispatcher } from 'svelte';
|
|
|
|
export let title = "";
|
|
export let wide = false;
|
|
export let error = null;
|
|
export let closable = false;
|
|
|
|
const dispatch = createEventDispatcher();
|
|
</script>
|
|
|
|
<div class="modal-background" on:click|self={() => closable ? dispatch("close") : null}>
|
|
<div class="modal" class:wide>
|
|
<div class="header">
|
|
<div class="title" class:noclose={!closable}>{title}</div>
|
|
{#if (closable)}
|
|
<div class="x">
|
|
<div class="button" on:click|self={() => dispatch("close")}>X</div>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
<hr />
|
|
{#if (error != null)}
|
|
<div class="error">{error}</div>
|
|
{/if}
|
|
<div class="body">
|
|
<slot></slot>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
div.modal-background {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
background: rgba(0,0,0,0.3);
|
|
}
|
|
|
|
div.modal {
|
|
position: absolute;
|
|
left: 50%;
|
|
top: 50%;
|
|
width: calc(100vw - 4em);
|
|
max-width: 40ch;
|
|
max-height: calc(100vh - 4em);
|
|
overflow: auto;
|
|
transform: translate(-50%,-50%);
|
|
padding: 1em;
|
|
border-radius: 0.2em;
|
|
|
|
background: #333;
|
|
}
|
|
div.modal.wide {
|
|
max-width: 60ch;
|
|
}
|
|
|
|
div.modal :global(hr) {
|
|
border: 0.5px solid gray;
|
|
margin: 0;
|
|
}
|
|
|
|
div.error {
|
|
margin: 0.5em;
|
|
padding: 0.5em;
|
|
|
|
border: 1px solid rgb(204, 65, 65);
|
|
border-radius: 0.2em;
|
|
background-color: rgb(133, 39, 39);
|
|
color: rgb(211, 141, 141);
|
|
|
|
animation: fadein 0.5s;
|
|
}
|
|
|
|
div.body {
|
|
margin: 1em 0.25ch;
|
|
}
|
|
|
|
div.title {
|
|
color: #CCC;
|
|
line-height: 1em;
|
|
}
|
|
|
|
div.title.noclose {
|
|
margin-bottom: 1.2em;
|
|
}
|
|
|
|
div.x {
|
|
position: relative;
|
|
line-height: 1em;
|
|
top: -1em;
|
|
text-align: right;
|
|
}
|
|
div.x div.button {
|
|
color: #CCC;
|
|
display: inline-block;
|
|
padding: 0em 0.5ch 0.1em 0.5ch;
|
|
line-height: 1em;
|
|
user-select: none;
|
|
cursor: pointer;
|
|
}
|
|
div.x div.button:hover {
|
|
background: #222;
|
|
color: #FFF;
|
|
}
|
|
|
|
div.modal :global(button) {
|
|
display: inline-block;
|
|
padding: 0.25em 0.75ch 0.26em 0.75ch;
|
|
margin: 0.75em 0.25ch 0.25em 0.25ch;
|
|
|
|
background: none;
|
|
border: none;
|
|
border-radius: 0.2em;
|
|
color: #CCC;
|
|
|
|
cursor: pointer;
|
|
}
|
|
|
|
div.modal :global(button:hover), div.modal :global(button:focus) {
|
|
background: #222;
|
|
color: #FFF;
|
|
}
|
|
|
|
div.modal :global(label) {
|
|
padding: 0 0 0.125em 0.25ch;
|
|
font-size: 0.75em;
|
|
}
|
|
|
|
div.modal :global(input), div.modal :global(select) {
|
|
width: 100%;
|
|
margin-bottom: 0.5em;
|
|
|
|
background: #222;
|
|
color: #777;
|
|
border: none;
|
|
outline: none;
|
|
}
|
|
div.modal :global(select) {
|
|
padding-left: 0.5ch;
|
|
}
|
|
|
|
div.modal :global(input:last-of-type) {
|
|
margin-bottom: 1em;
|
|
}
|
|
div.modal :global(input.nolast) {
|
|
margin-bottom: 0.5em;
|
|
}
|
|
|
|
div.modal :global(input:focus), div.modal :global(select:focus) {
|
|
background: #111;
|
|
color: #CCC;
|
|
border: none;
|
|
outline: none;
|
|
}
|
|
|
|
div.modal :global(p) {
|
|
margin: 0.25em 1ch 1em 1ch;
|
|
font-size: 0.9em;
|
|
}
|
|
|
|
@keyframes fadein {
|
|
from { opacity: 0; }
|
|
to { opacity: 1; }
|
|
}
|
|
</style>
|