forked from mainmatter/svelte-promise-modals
-
Notifications
You must be signed in to change notification settings - Fork 0
/
+page.svelte
85 lines (72 loc) · 2.05 KB
/
+page.svelte
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<script lang="ts">
import '$lib/style.css';
import './app.css';
import { browser } from '$app/environment';
import ModalContainer from '$lib/ModalContainer.svelte';
import { destroyModals, openModal } from '$lib/service';
import FooComponent from './FooComponent.svelte';
import logo from './svelte-promise-modals-logo.svg';
type PlaywrightWindow = Window & {
modalOptions?: object;
modalResult?: unknown;
modals?: unknown;
destroyModals?: unknown;
};
if (browser) {
(window as PlaywrightWindow).destroyModals = destroyModals;
}
let modalOptions = (browser && (window as PlaywrightWindow).modalOptions) || {};
async function openFooModal() {
let result = await openModal(FooComponent);
(window as PlaywrightWindow).modalResult = result;
}
</script>
<svelte:head>
<script
defer
data-domain="svelte-promise-modals.com"
src="https://plausible.io/js/script.js"
></script>
</svelte:head>
<header>
<h1>
<a href="https://github.com/mainmatter/svelte-promise-modals">
<img
src={logo}
alt="svelte-promise-modals logo"
role="presentation"
width="600"
height="400"
/>
<span class="visually-hidden">svelte-promise-modals</span>
</a>
</h1>
</header>
<main>
<div class="box box-blue">
<p>
<button type="button" on:click={() => openFooModal()} data-testid="open-foo">
A simple modal with a button to close it
</button>
</p>
</div>
<p>
See the <a
href="https://github.com/mainmatter/svelte-promise-modals#readme"
target="_blank"
rel="noopener noreferrer">README on GitHub</a
> for setup & further instructions.
</p>
<div class="box box-placeholder">
<p>
<small>
Left blank to see <br />how scrolling is handled.
</small>
</p>
</div>
<p>
svelte-promise-modals is <br />made & sponsored with ❤️ by
<a href="https://mainmatter.com" target="_blank" rel="noopener noreferrer">Mainmatter</a>
</p>
</main>
<ModalContainer options={modalOptions} />