-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathToast.svelte
56 lines (48 loc) · 1.62 KB
/
Toast.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
<script>
import { createEventDispatcher, onDestroy, onMount } from 'svelte'
import { fly, fade } from 'svelte/transition'
import Notice, { filterProps } from '../Notice.svelte'
/** Text or html message for toast
* @svelte-prop {String} message
* */
export let message
/** Duration toast will remain on screen
* @name duration
* @kind member
* @svelte-prop {Number} [duration=2000]
* */
/** Where the toast will show on the screen
* @name position
* @kind member
* @svelte-prop {String} [position=is-top]
* @values <code>is-top</code>, <code>is-bottom</code>, <code>is-top-left</code>, <code>is-top-right</code>, <code>is-bottom-left</code>, <code>is-bottom-right</code>
* */
/** Type (color)
* @svelte-prop {String} [type=is-dark]
* @values $$colors$$
* */
export let type = 'is-dark'
/** Background type (any of the Bulma <code>has-background-</code> classes will work)
* @svelte-prop {String} [background]
* @values <code>has-background-*</code>
* */
export let background = ''
$: newBackground = background || type.replace(/^is-(.*)/, 'has-background-$1')
</script>
<style lang="scss">
.toast {
text-align: center;
padding: 0.75em 1.5em;
border-radius: 2em;
margin: 0.5em 0;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04); /* super subtle... */
pointer-events: auto;
}
</style>
<Notice {...filterProps($$props)}>
<div class="toast {type} {newBackground}" role="alert">
<div class="text"> <!-- NOTE: this extra div is for dynamic text styling with background-clip -->
{@html message}
</div>
</div>
</Notice>