htmgo/examples/chat/chat/component.go

21 lines
420 B
Go
Raw Normal View History

2024-09-30 22:31:09 +00:00
package chat
2024-10-01 03:08:52 +00:00
import (
"github.com/maddalax/htmgo/framework/h"
"time"
)
2024-09-30 22:31:09 +00:00
2024-10-01 03:08:52 +00:00
func MessageRow(message *Message) *h.Element {
2024-09-30 22:31:09 +00:00
return h.Div(
h.Attribute("hx-swap-oob", "beforeend"),
h.Class("flex flex-col gap-2 w-full"),
h.Id("messages"),
2024-10-01 03:08:52 +00:00
h.Div(
h.Class("flex gap-2 items-center"),
h.Pf(message.UserName),
h.Pf(message.CreatedAt.In(time.Local).Format("01/02 03:04 PM")),
h.Pf(message.Message),
),
2024-09-30 22:31:09 +00:00
)
}