-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client): add modal components (#33)
- Loading branch information
Showing
2 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<script lang="ts"> | ||
import Button from './Button.svelte'; | ||
import Close from '../icons/Close.svelte'; | ||
export let showModal = false; | ||
let dialog: HTMLDialogElement | null; | ||
$: showModal ? dialog?.show() : dialog?.close(); | ||
</script> | ||
|
||
<dialog bind:this={dialog} on:close> | ||
<div class="column"> | ||
<div> | ||
<div id="headerIcon"> | ||
<div> | ||
<slot name="header" /> | ||
</div> | ||
<div> | ||
<Close on:click={() => showModal = false} /> | ||
</div> | ||
</div> | ||
<div class="column"> | ||
<hr /> | ||
<slot /> | ||
<hr /> | ||
<div id="buttons"> | ||
<slot name="buttons"> | ||
<Button on:click={() => showModal = false}>Close Modal</Button> | ||
</slot> | ||
</div> | ||
</div> | ||
</div> | ||
</dialog> | ||
|
||
<style> | ||
/* https://svelte.dev/examples/modal */ | ||
@import url('../../pages/global.css'); | ||
dialog { | ||
border-radius: var(--border-radius); | ||
border: none; | ||
padding: 0; | ||
} | ||
dialog::backdrop { | ||
background: rgba(0, 0, 0, 0.3); | ||
} | ||
dialog > div { | ||
padding: var(--spacing-large); | ||
} | ||
dialog[open] { | ||
animation: zoom var(--animation-length) cubic-bezier(0.34, 1.56, 0.64, 1); | ||
} | ||
dialog[open]::backdrop { | ||
animation: fade var(--animation-length) ease-out; | ||
} | ||
.column { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
#headerIcon { | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
#buttons { | ||
display: flex; | ||
justify-content: space-evenly; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters