-
-
Notifications
You must be signed in to change notification settings - Fork 353
/
text.go
40 lines (32 loc) · 745 Bytes
/
text.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
37
38
39
40
package app
import (
"fmt"
)
// Text returns a UI element representing plain text, converting the provided
// value to its string representation.
func Text(v any) UI {
return &text{value: toString(v)}
}
// Textf returns a UI element representing formatted text. The format and values
// follow the conventions of fmt.Sprintf.
func Textf(format string, v ...any) UI {
return &text{value: fmt.Sprintf(format, v...)}
}
type text struct {
jsvalue Value
parentElement UI
value string
}
func (t *text) JSValue() Value {
return t.jsvalue
}
func (t *text) Mounted() bool {
return t.jsvalue != nil
}
func (t *text) parent() UI {
return t.parentElement
}
func (t *text) setParent(p UI) UI {
t.parentElement = p
return t
}