Redmage/views/components/toasts.templ

33 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

2024-04-09 16:09:08 +07:00
package components
import "fmt"
import "strings"
templ SuccessToast(message string, args ...any) {
<div
onclick="this.remove();"
role="alert"
class="alert alert-success hover:bg-accent cursor-pointer transition-all"
>
<svg xmlns="http://www.w3.org/2000/svg" class="stroke-current 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"></path></svg>
<div class="text-base-100 flex flex-col gap-1">
for _, line := range strings.Split(fmt.Sprintf(message, args...), "\n") {
<p class="my-0">{ line }</p>
}
</div>
</div>
}
templ ErrorToast(message string, args ...any) {
<div
onclick="this.remove();"
class="alert alert-error hover:bg-accent cursor-pointer"
>
<svg xmlns="http://www.w3.org/2000/svg" class="stroke-current 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"></path></svg>
<div class="text-base-100 flex flex-col gap-1">
for _, line := range strings.Split(fmt.Sprintf(message, args...), "\n") {
<p class="my-0">{ line }</p>
}
</div>
</div>
}