Add toast for errors and success messages

This commit is contained in:
Thilo Hohlt
2024-08-02 16:36:21 +02:00
parent c86bc68e5c
commit ae128dea6c
10 changed files with 113 additions and 57 deletions

View File

@@ -0,0 +1,46 @@
<script lang="ts">
const { success, message } = $props<{
success: boolean | undefined;
message: string;
}>();
</script>
{#if success}
<p class="toast success">{message}</p>
{/if}
{#if success === false}
<p class="toast error">{message}</p>
{/if}
<style>
.toast {
position: fixed;
inset-block-end: 1rem;
inset-inline-end: 1rem;
padding-inline: 1rem;
padding-block: 0.5rem;
border-radius: var(--border-radius);
color: var(--color-text-invert);
z-index: 30;
animation: toast 3s forwards;
}
.success {
background-color: var(--color-success);
}
.error {
background-color: var(--color-error);
}
@keyframes toast {
0%,
90% {
opacity: 1;
}
100% {
opacity: 0;
}
}
</style>

View File

@@ -33,10 +33,10 @@
}
.operations {
inline-size: 50%;
border-inline-end: var(--border-primary);
resize: horizontal;
overflow-y: auto;
inline-size: 50%;
}
.operations__nav {
@@ -51,6 +51,6 @@
}
.preview {
flex-grow: 1;
flex: 1;
}
</style>