-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Toast improvements: - Icon and color based on toast level (info, warn, error) - Animates out - Made it a component, removing logic from `app.svelte` - handles multiple toast messages better using a queue Sidebar styling logic: This was kinda gross so I revised it a bit. I'm considering doing an overhaul of the sidebar in the future.
- Loading branch information
Showing
8 changed files
with
87 additions
and
69 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
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,50 @@ | ||
<script> | ||
import { Toast } from "flowbite-svelte"; | ||
import { toastStore } from "$lib/stores/ToastStore"; | ||
import { fly } from "svelte/transition"; | ||
import IconCheck from "~icons/mdi/check"; | ||
import IconAlert from "~icons/mdi/stop-alert"; | ||
import IconAlertCircle from "~icons/mdi/alert-circle"; | ||
let open = false; | ||
let counter; | ||
let currentToast = null; | ||
$: if ($toastStore.length > 0 && !currentToast) { | ||
currentToast = $toastStore[0]; | ||
open = true; | ||
counter = 6; | ||
timeout(); | ||
} | ||
function timeout() { | ||
if (--counter > 0) return setTimeout(timeout, 1000); | ||
open = false; | ||
toastStore.removeToast(); | ||
currentToast = null; | ||
} | ||
</script> | ||
|
||
{#if currentToast} | ||
<Toast | ||
{open} | ||
dismissable={false} | ||
position="top-right" | ||
class="z-50 top-20" | ||
transition={fly} | ||
params={{ y: 200 }} | ||
> | ||
<svelte:fragment slot="icon"> | ||
{#if currentToast.level == "info"} | ||
<IconCheck class="text-green-500 text-5xl" /> | ||
{:else if currentToast.level == "warn"} | ||
<IconAlertCircle class="text-orange-500 text-5xl" /> | ||
{:else if currentToast.level == "error"} | ||
<IconAlert class="text-red-500 text-5xl" /> | ||
{/if} | ||
</svelte:fragment> | ||
<div class="ps-4 text-sm font-semibold"> | ||
{currentToast.msg} | ||
</div> | ||
</Toast> | ||
{/if} |
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
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