fix: migrate toasts from daisyui to tailwind
All checks were successful
Build Docker Image / Build-Docker-Image (push) Successful in 4m16s
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 4m51s

This commit was merged in pull request #54.
This commit is contained in:
2025-05-06 15:35:16 +02:00
parent ac0c918da7
commit 81380f184e
4 changed files with 22 additions and 30 deletions

View File

@@ -10,31 +10,21 @@ input:focus {
@apply outline-none ring-0; @apply outline-none ring-0;
} }
@theme {
--font-pirata: "Pirata One", sans-serif;
--font-shippori: "Shippori Mincho", sans-serif;
--animate-fade: fadeOut 0.25s ease-in;
@keyframes fadeOut {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
}
@font-face { @font-face {
font-family: "Pirata One"; font-family: "Pirata One";
src: url("/static/font/pirata_one/PirataOne-Regular.ttf") format("truetype"); src: url("/static/font/pirata_one/PirataOne-Regular.ttf") format("truetype");
} }
@font-face { @font-face {
font-family: "Shippori Mincho"; font-family: "Shippori Mincho";
src: url("/static/font/shippori_mincho/ShipporiMincho-Medium.ttf") format("truetype"); src: url("/static/font/shippori_mincho/ShipporiMincho-Medium.ttf") format("truetype");
} }
@theme {
--font-pirata: "Pirata One", sans-serif;
--font-shippori: "Shippori Mincho", sans-serif;
}
/* Button */ /* Button */
.button { .button {
transition: all 150ms linear; transition: all 150ms linear;

View File

@@ -19,7 +19,7 @@ import (
var ( var (
ErrInvalidCredentials = errors.New("invalid email or password") ErrInvalidCredentials = errors.New("invalid email or password")
ErrInvalidPassword = errors.New("password needs to be 8 characters long, contain at least one number, one special, one uppercase and one lowercase character") ErrInvalidPassword = errors.New("The password needs to be 8 characters long, contain at least one number, one special, one uppercase and one lowercase character")
ErrInvalidEmail = errors.New("invalid email") ErrInvalidEmail = errors.New("invalid email")
ErrAccountExists = errors.New("account already exists") ErrAccountExists = errors.New("account already exists")
ErrSessionIdInvalid = errors.New("session ID is invalid") ErrSessionIdInvalid = errors.New("session ID is invalid")

View File

@@ -3,14 +3,13 @@
function getClass(type) { function getClass(type) {
switch (type) { switch (type) {
case "error": case "error":
return "alert-error"; return ["bg-amber-900", "text-white"];
case "warning": case "warning":
return "alert-warning"; return ["bg-yellow-200", "text-gray-800"];
case "success": case "success":
return "alert-success"; return ["bg-green-900", "text-white"];
// case "info":
default: default:
return "alert-info"; return ["bg-gray-800", "text-white"];
} }
} }
@@ -21,20 +20,22 @@ htmx.on("toast", (e) => {
const template = document.getElementById("toast"); const template = document.getElementById("toast");
const toast = template.cloneNode(true); const toast = template.cloneNode(true);
const parent = document.getElementById("toasts"); const list = document.getElementById("toasts");
toast.id = "" toast.id = ""
toast.classList.remove("hidden"); toast.classList.remove("hidden");
toast.classList.add(getClass(type)); toast.classList.add(...getClass(type));
toast.innerText = message; toast.innerText = message;
parent.appendChild(toast); list.appendChild(toast);
setTimeout(() => {
toast.classList.remove("opacity-0");
}, 0);
setTimeout(() => { setTimeout(() => {
toast.classList.add("animate-fade");
toast.classList.add("opacity-0"); toast.classList.add("opacity-0");
setTimeout(() => { setTimeout(() => {
parent.removeChild(toast); list.removeChild(toast);
}, 250); }, 250);
}, 5000); }, 5000);
}); });

View File

@@ -40,9 +40,10 @@ templ Layout(slot templ.Component, user templ.Component) {
</div> </div>
// Footer // Footer
</div> </div>
<div class="" id="toasts"> <div id="toasts" class="fixed bottom-4 right-4 ml-4 max-w-96 flex flex-col gap-2 z-50">
<div class="hidden" id="toast"> <div id="toast"
New message arrived. class="transition-all duration-300 opacity-0 px-4 py-2 text-lg hidden text-bold rounded bg-amber-900 text-white">
M
</div> </div>
</div> </div>
</body> </body>