coolify/apps/ui/src/lib/components/Toast.svelte

60 lines
1.5 KiB
Svelte
Raw Normal View History

2022-08-09 15:28:26 +00:00
<script>
2022-08-12 14:09:52 +00:00
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
2022-08-09 15:28:26 +00:00
export let type = 'info';
</script>
<div
2022-08-16 11:58:37 +00:00
on:click={() => dispatch('click')}
2022-08-12 14:09:52 +00:00
on:mouseover={() => dispatch('pause')}
on:focus={() => dispatch('pause')}
on:mouseout={() => dispatch('resume')}
on:blur={() => dispatch('resume')}
2022-08-16 11:58:37 +00:00
class="alert shadow-lg text-white rounded hover:scale-105 transition-all duration-100 cursor-pointer"
2022-08-12 14:09:52 +00:00
class:bg-coollabs={type === 'success'}
2022-08-09 15:28:26 +00:00
class:alert-error={type === 'error'}
class:alert-info={type === 'info'}
>
2022-08-16 11:58:37 +00:00
{#if type === 'success'}
2022-08-09 15:28:26 +00:00
<svg
xmlns="http://www.w3.org/2000/svg"
class="stroke-current flex-shrink-0 h-6 w-6"
fill="none"
viewBox="0 0 24 24"
><path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
/></svg
>
{:else if type === 'error'}
<svg
xmlns="http://www.w3.org/2000/svg"
class="stroke-current flex-shrink-0 h-6 w-6"
fill="none"
viewBox="0 0 24 24"
><path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"
/></svg
>
{:else if type === 'info'}
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
class="stroke-current flex-shrink-0 w-6 h-6"
><path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
/></svg
>
2022-08-16 11:58:37 +00:00
{/if}
2022-08-09 15:28:26 +00:00
<slot />
</div>