not-overlay 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -5
- package/src/standalone/overlay.svelte +80 -84
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "not-overlay",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "not-* family overlay plugin",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "git@github.com:interrupter/not-overlay.git",
|
|
@@ -27,9 +27,6 @@
|
|
|
27
27
|
"@babel/plugin-transform-runtime": "^7.9.6",
|
|
28
28
|
"@babel/preset-env": "^7.9.6",
|
|
29
29
|
"@cypress/code-coverage": "^3.7.0",
|
|
30
|
-
"@material/theme": "^3.1.0",
|
|
31
|
-
"@material/typography": "^3.1.0",
|
|
32
|
-
"@smui/icon-button": "^1.0.0-beta.21",
|
|
33
30
|
"babel-plugin-istanbul": "^6.0.0",
|
|
34
31
|
"babel-preset-env": "^1.7.0",
|
|
35
32
|
"chai": "^4.2.0",
|
|
@@ -97,4 +94,4 @@
|
|
|
97
94
|
]
|
|
98
95
|
}
|
|
99
96
|
}
|
|
100
|
-
}
|
|
97
|
+
}
|
|
@@ -1,90 +1,86 @@
|
|
|
1
|
-
{#if show}
|
|
2
|
-
<div class="not-overlay" transition:fade on:click={overlayClick}>
|
|
3
|
-
{#if closeButton}
|
|
4
|
-
<IconButton on:click={closeButtonClick} class="close-btn">
|
|
5
|
-
<Icon class="material-icons">close</Icon>
|
|
6
|
-
</IconButton>
|
|
7
|
-
{/if}
|
|
8
|
-
<slot></slot>
|
|
9
|
-
</div>
|
|
10
|
-
{/if}
|
|
11
|
-
|
|
12
1
|
<script>
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
document.body.style.overflow = overflowSave;
|
|
71
|
-
});
|
|
72
|
-
|
|
2
|
+
let overflowSave = "";
|
|
3
|
+
|
|
4
|
+
import { fade } from "svelte/transition";
|
|
5
|
+
|
|
6
|
+
import { onMount, onDestroy } from "svelte";
|
|
7
|
+
|
|
8
|
+
import IconButton, { Icon } from "@smui/icon-button";
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
closeButton = false,
|
|
12
|
+
show = true,
|
|
13
|
+
closeOnClick = true,
|
|
14
|
+
onchange = () => {},
|
|
15
|
+
onreject = () => {},
|
|
16
|
+
onresolve = () => {},
|
|
17
|
+
} = $props();
|
|
18
|
+
|
|
19
|
+
$: if (show) {
|
|
20
|
+
document.body.style.overflow = "hidden";
|
|
21
|
+
} else {
|
|
22
|
+
document.body.style.overflow = overflowSave;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function overlayClick(e) {
|
|
26
|
+
if (closeOnClick) {
|
|
27
|
+
closeOverlay(e);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function closeButtonClick() {
|
|
32
|
+
rejectOverlay();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function closeOverlay(e) {
|
|
36
|
+
if (
|
|
37
|
+
e.originalTarget &&
|
|
38
|
+
e.originalTarget.classList.contains("not-overlay")
|
|
39
|
+
) {
|
|
40
|
+
rejectOverlay();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function rejectOverlay(data = {}) {
|
|
45
|
+
onreject(data);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function resolveOverlay(data = {}) {
|
|
49
|
+
onresolve(data);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
onMount(() => {
|
|
53
|
+
overflowSave = document.body.style.overflow;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
onDestroy(() => {
|
|
57
|
+
document.body.style.overflow = overflowSave;
|
|
58
|
+
});
|
|
73
59
|
</script>
|
|
74
60
|
|
|
61
|
+
{#if show}
|
|
62
|
+
<div class="not-overlay" transition:fade onclick={overlayClick}>
|
|
63
|
+
{#if closeButton}
|
|
64
|
+
<IconButton onclick={closeButtonClick} class="close-btn">
|
|
65
|
+
<Icon class="material-icons">close</Icon>
|
|
66
|
+
</IconButton>
|
|
67
|
+
{/if}
|
|
68
|
+
<slot></slot>
|
|
69
|
+
</div>
|
|
70
|
+
{/if}
|
|
75
71
|
|
|
76
72
|
<style>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
73
|
+
.not-overlay {
|
|
74
|
+
position: fixed;
|
|
75
|
+
top: 0px;
|
|
76
|
+
left: 0px;
|
|
77
|
+
width: 100vw;
|
|
78
|
+
height: 100vh;
|
|
79
|
+
margin: 0px;
|
|
80
|
+
background-color: #ccc;
|
|
81
|
+
z-index: 2000;
|
|
82
|
+
display: block;
|
|
83
|
+
opacity: 1;
|
|
84
|
+
overflow: hidden;
|
|
85
|
+
}
|
|
90
86
|
</style>
|