generate elem with go
This commit is contained in:
@@ -3,24 +3,33 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
elem "github.com/chasefleming/elem-go"
|
||||
"github.com/chasefleming/elem-go/attrs"
|
||||
)
|
||||
|
||||
// TODO: switch to https://github.com/chasefleming/elem-go
|
||||
|
||||
func chatDiv(content string, color string) string {
|
||||
return fmt.Sprintf(`<div class="p-2 my-2 rounded bg-%s-600">%s</div>`, color, htmlIfy(content))
|
||||
div := elem.Div(attrs.Props{
|
||||
// attrs.ID: "container",
|
||||
attrs.Class: fmt.Sprintf("p-2 my-2 rounded bg-%s-600", color),
|
||||
},
|
||||
elem.Raw(htmlIfy(content)),
|
||||
)
|
||||
return div.Render()
|
||||
}
|
||||
|
||||
func loader() string {
|
||||
return `<div class="loader"></div>`
|
||||
return elem.Div(attrs.Props{
|
||||
attrs.Class: "loader",
|
||||
}).Render()
|
||||
}
|
||||
|
||||
func disabledElement(id string, disabled bool) string {
|
||||
if disabled {
|
||||
return `<script> document.getElementById('` + id + `').disabled = true;</script>`
|
||||
}
|
||||
|
||||
return `<script> document.getElementById('` + id + `').disabled = false;</script>`
|
||||
return elem.Script(nil,
|
||||
elem.If(disabled,
|
||||
elem.Raw(`document.getElementById('`+id+`').disabled = true`),
|
||||
elem.Raw(`document.getElementById('`+id+`').disabled = false`),
|
||||
)).Render()
|
||||
}
|
||||
|
||||
func htmlIfy(s string) string {
|
||||
|
||||
Reference in New Issue
Block a user