saasitone/templ/components/messages.templ

22 lines
565 B
Plaintext
Raw Permalink Normal View History

package components
import (
"git.grosinger.net/tgrosinger/saasitone/pkg/page"
"git.grosinger.net/tgrosinger/saasitone/pkg/msg"
)
templ Messages(p page.Page) {
for _, msgType := range []msg.Type{msg.TypeSuccess, msg.TypeInfo, msg.TypeWarning, msg.TypeDanger} {
for _, msg := range p.GetMessages(msgType) {
@message(msgType, msg)
}
}
}
templ message(msgType msg.Type, msg string) {
<div class={ "notification is-light", "is-" + msgType } x-data="{show: true}" x-show="show">
<button class="delete" @click="show = false"></button>
{ msg }
</div>
}