Skip to content

Commit 9fe065c

Browse files
committed
Update Vanilla JS load pattern
1 parent c2d9f38 commit 9fe065c

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

README.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
[![npm (scoped)](https://img.shields.io/npm/v/@zerodevx/svelte-toast)](https://www.npmjs.com/package/@zerodevx/svelte-toast)
2+
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
3+
14
# svelte-toast
25

36
> Simple elegant toast notifications.
47
8+
A lightweight, unopinionated and performant toast notification component for modern web frontends in very little
9+
lines of code. Compiled, it's only **15kb** minified (**6kb** gzipped) and can be used in Vanilla JS, or as a
10+
Svelte component.
11+
512
Because a demo helps better than a thousand API docs: https://zerodevx.github.io/svelte-toast/
613

714
## Usage
@@ -78,18 +85,24 @@ Or if you prefer to go old-school javascript and a CDN:
7885
```html
7986
<head>
8087
...
88+
<!-- Load `toast` and `SvelteToast` into global scope -->
89+
<script src="https://cdn.jsdelivr.net/npm/@zerodevx/svelte-toast@0"></script>
90+
<!-- Register the app -->
8191
<script>
82-
function registerToast() {
83-
window.toastApp = new SvelteToastUMD.SvelteToast({
84-
target: document.body
85-
});
86-
window.toast = SvelteToastUMD.toast;
87-
88-
// Now you can `toast` anywhere!
89-
toast.push('Hello world!');
90-
}
92+
const toastApp = new SvelteToast({
93+
// Set where the toast container should be appended into
94+
target: document.body,
95+
props: {
96+
options: {
97+
// Optionally set default options here
98+
...
99+
}
100+
}
101+
})
102+
103+
// Now you can `toast` anywhere!
104+
toast.push('Hello world!');
91105
</script>
92-
<script defer src="https://cdn.jsdelivr.net/npm/@zerodevx/svelte-toast@0" onload="registerToast()"></script>
93106
</head>
94107
```
95108

0 commit comments

Comments
 (0)