owncast-webhook/internal/web/controller/chat/utils.go
Simon Vieille 68c05816dd
Some checks are pending
ci/woodpecker/push/build Pipeline is pending approval
feat(chat): add effect and improve faker
2025-09-07 20:14:05 +02:00

50 lines
1.1 KiB
Go

package chat
import (
"fmt"
"gitnet.fr/deblan/owncast-webhook/assets"
"gitnet.fr/deblan/owncast-webhook/internal/store"
. "maragu.dev/gomponents"
. "maragu.dev/gomponents/html"
)
func CreateMessageView(message store.MessageInterface) Node {
var containerStyle Node
var userStyle Node
var originIcon Node
switch message.Origin() {
case store.MessageOriginOwncast:
msg := message.(store.OwncastMessage)
containerStyle = StyleAttr(fmt.Sprintf(
"border-color: var(--theme-color-users-%d)",
msg.WebhookMessage.User.DisplayColor,
))
userStyle = StyleAttr(fmt.Sprintf(
"color: var(--theme-color-users-%d)",
msg.WebhookMessage.User.DisplayColor,
))
originIcon = Img(Src(assets.Asset("dist/img/owncast.png")), Class("message-origin"))
case store.MessageOriginTwitch:
originIcon = Img(Src(assets.Asset("dist/img/twitch.png")), Class("message-origin"))
}
return Div(
Class("message animate__animated animate__fadeInUp"),
ID(message.ID()),
containerStyle,
Div(
Class("message-user"),
userStyle,
Group([]Node{originIcon, Text(message.Author())}),
),
Div(
Class("message-body"),
Raw(message.Content()),
),
)
}