-
Notifications
You must be signed in to change notification settings - Fork 7
/
Alert.svelte
37 lines (33 loc) · 836 Bytes
/
Alert.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
<script>
/**
* Simple box with constrast styling to notify users.
*
* @component
*
* @example
* <Alert closable={true} on:close={() => ...}>
* User-defined content
* </Alert>
*/
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
const EVENT = {
CLOSE: "close"
}
export let closable = false;
</script>
<div>
<div>
<!-- The internal content of the alert block. -->
<slot></slot>
</div>
{#if closable}
<div>
<!--
The `close` event fired when user click to X button in the panel.
@event CloseEvent#close
-->
<button on:click={() => dispatch(EVENT.CLOSE)}>×</button>
</div>
{/if}
</div>