summaryrefslogtreecommitdiff
path: root/ping/frontend/src/lib/components/ToastList.svelte
blob: 5351ef727cce9846b54e8de1b2f62402bc15f4a8 (plain)
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
57
58
59
60
61
62
63
64
65
66
67
<script lang="ts">
	import { toastList } from '$lib/stores/toast';
</script>

<div class="toast">
	{#each $toastList as toast}
		<div class="toast-item" style="border-top: 4px {toast.color} solid">
			<h3 style="color: {toast.color}">{toast.title}</h3>
			<p>{toast.message}</p>
		</div>
	{/each}
</div>

<style>
	.toast {
		position: fixed;
		bottom: 20px;
		right: 20px;
		z-index: 1000;
		display: flex;
		flex-direction: column;
		gap: 10px;
	}

	.toast-item {
		background-color: var(--bg-secondary);
		padding: 10px;
		color: white;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
		transition:
			transform 0.3s,
			opacity 0.3s;
		transform: translateY(30px);
		opacity: 0;
		animation-delay: 0s, 4.7s;
		animation-name: toast-in, toast-out;
		animation-duration: 0.3s, 0.3s;
		animation-fill-mode: forwards, forwards;
	}

	@keyframes toast-in {
		from {
			transform: translateY(30px);
			opacity: 0;
		}
		to {
			transform: translateY(0);
			opacity: 1;
		}
	}

	@keyframes toast-out {
		from {
			transform: translateY(0);
			opacity: 1;
		}
		to {
			transform: translateY(30px);
			opacity: 0;
		}
	}

	.toast-item h3 {
		margin: 0;
		font-weight: bold;
	}
</style>