-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOverlay.svelte
More file actions
67 lines (61 loc) · 1.24 KB
/
Copy pathOverlay.svelte
File metadata and controls
67 lines (61 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!--
Can be used like this
{#if showOverlay}
<Overlay
on:overlay={handleOverlay}>
some html
</Overlay>
{/if}
-->
<script>
import { createEventDispatcher } from 'svelte';
import { fly } from 'svelte/transition';
import svgClose from '../inline-svg/close.svg'; // I used 'rollup-plugin-svg' to inline my svg
const dispatch = createEventDispatcher();
const overlay = (ev) => {
if(!ev.target.classList.contains("js-close")) return;
dispatch("overlay", "close");
};
</script>
<div
class="shadow js-close"
on:click={overlay}>
<div
class="content"
transition:fly="{{ y: 200, duration: 600 }}">
<button class="js-close" title="close dialog">
{@html svgClose}
</button>
<slot></slot>
</div>
</div>
<style>
.shadow {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, .9);
}
.content {
position: relative;
background: #fff;
padding: 48px 56px 0;
max-width: 730px;
margin: 0 auto;
height: 100%;
overflow-y: auto;
z-index: 5;
}
.content:after {
content: '';
display: block;
padding-bottom: 56px;
}
button {
position: absolute;
top: 20px;
right: 20px;
}
</style>