-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add visible timer to individual alerts
- Loading branch information
1 parent
4ff03f6
commit 46a4a79
Showing
3 changed files
with
50 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<script> | ||
import { onMount, onDestroy, createEventDispatcher } from "svelte" | ||
export let text = "" | ||
export let type = "" | ||
export let key = "" | ||
const timer = 5000 | ||
const dispatch = createEventDispatcher() | ||
let timeout | ||
onMount(() => setTimeout(close, timer)) | ||
onDestroy(() => { if (timeout) clearTimeout(timeout) }) | ||
function close() { | ||
dispatch("close", key) | ||
} | ||
</script> | ||
|
||
<div class="alert {type} static"> | ||
<p class="m-0">{text}</p> | ||
|
||
<button class="button p-0 pl-1/16 pr-1/16 text-pure-white" on:click={close}>✕</button> | ||
|
||
<div class="alert__timer" style="--timer: {timer}ms" /> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters