-
Notifications
You must be signed in to change notification settings - Fork 0
/
helperline.go
36 lines (28 loc) · 884 Bytes
/
helperline.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package helperline
import (
"github.com/mlctrez/goapp-mdc/pkg/helperline/counter"
"github.com/mlctrez/goapp-mdc/pkg/helperline/text"
"github.com/maxence-charriere/go-app/v9/pkg/app"
)
type HelperLine struct {
app.Compo
id string
helpText string
counterText string
}
func New(id, helpText, counterText string) *HelperLine {
return &HelperLine{id: id, helpText: helpText, counterText: counterText}
}
func (t *HelperLine) Render() app.UI {
var elements []app.UI
if t.helpText != "" {
elements = append(elements, text.New(t.id+"-help", t.helpText))
}
if t.counterText != "" {
elements = append(elements, counter.New(t.id+"-counter", t.helpText))
}
if len(elements) == 0 {
elements = append(elements, text.New(t.id+"-help", "HelperLine used without help or counter set"))
}
return app.Div().Class("mdc-text-field-helper-line").Body(elements...)
}