fix: toast fixes

toasts aren't as "jumpy" anymore, toasts can be different sizes (not affected by sizes of other toasts), derive icon/color
This commit is contained in:
JovannMC 2025-02-16 19:52:31 +03:00
parent 775eebbc28
commit e6d862deb5
No known key found for this signature in database
4 changed files with 15 additions and 11 deletions

View File

@ -33,8 +33,6 @@
let color = $derived(colors[type]); let color = $derived(colors[type]);
let Icon = $derived(Icons[type]); let Icon = $derived(Icons[type]);
console.log(`ID: ${id}, type: ${type}`);
</script> </script>
<div <div

View File

@ -8,8 +8,12 @@
}); });
</script> </script>
<div class="fixed bottom-28 md:bottom-0 right-0 p-4 space-y-4 z-50"> <div
class="fixed bottom-28 md:bottom-0 right-0 p-4 flex flex-col-reverse gap-4 z-50"
>
{#each toastList as { id, type, message, durations }} {#each toastList as { id, type, message, durations }}
<Toast {id} {type} {message} {durations} /> <div class="flex justify-end">
<Toast {id} {type} {message} {durations} />
</div>
{/each} {/each}
</div> </div>

View File

@ -23,19 +23,22 @@
let { id, type, message, durations }: Props = $props(); let { id, type, message, durations }: Props = $props();
const color = { const colors = {
success: "purple", success: "purple",
error: "red", error: "red",
info: "blue", info: "blue",
warning: "pink", warning: "pink",
}[type]; };
const Icon = { const Icons = {
success: CheckIcon, success: CheckIcon,
error: BanIcon, error: BanIcon,
info: InfoIcon, info: InfoIcon,
warning: TriangleAlert, warning: TriangleAlert,
}[type]; };
let color = $derived(colors[type]);
let Icon = $derived(Icons[type]);
// intentionally unused. this is so tailwind can generate the css for these colours as it doesn't detect if it's dynamically loaded // intentionally unused. this is so tailwind can generate the css for these colours as it doesn't detect if it's dynamically loaded
// this would lead to the colours not being generated in the final css file by tailwind // this would lead to the colours not being generated in the final css file by tailwind
@ -48,7 +51,7 @@
</script> </script>
<div <div
class="flex items-center justify-between w-full max-w-sm p-4 gap-4 bg-accent-{color} border-accent-{color}-alt border-l-4 rounded-lg shadow-md" class="flex items-center justify-between max-w-sm p-4 gap-4 bg-accent-{color} border-accent-{color}-alt border-l-4 rounded-lg shadow-md"
in:fly={{ in:fly={{
duration: durations.enter, duration: durations.enter,
easing: quintOut, easing: quintOut,
@ -70,7 +73,7 @@
<p class="text-black font-normal">{message}</p> <p class="text-black font-normal">{message}</p>
</div> </div>
<button <button
class="text-gray-600 hover:text-black" class="text-gray-600 hover:text-black flex-shrink-0"
onclick={() => removeToast(id)} onclick={() => removeToast(id)}
> >
<XIcon size="16" /> <XIcon size="16" />

View File

@ -52,7 +52,6 @@
const cachedContribs = sessionStorage.getItem("ghContribs"); const cachedContribs = sessionStorage.getItem("ghContribs");
if (cachedContribs) { if (cachedContribs) {
ghContribs = JSON.parse(cachedContribs); ghContribs = JSON.parse(cachedContribs);
log(["about"], "loaded GitHub contributors from cache");
return; return;
} }