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()), ), ) }