/
page2.go
51 lines (47 loc) · 1.18 KB
/
page2.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
41
42
43
44
45
46
47
48
49
50
51
package main
type Page2 struct {
}
func (p *Page2) UI() string {
return `<col grow="1" justify="start" margin="24px">
<text font="NotoSans 24" color="#ffffff" margin="4px" padding="12px">
How does it work?
</text>
<p
grow="1"
border="frame.png 10"
font="RobotoMono 16"
color="#ffffff"
margin="4px"
padding="16px 24px">
<![CDATA[
// Define a struct to hold the UI state
type MyUI struct {
Clicks int
}
// Add some event handlers
func (u *MyUI) Click(event *bento.Event) {
u.Clicks++
}
// Layout the UI with XML
// Event handlers get attached with attributes
// text/template can be used to modify the content based on the state
func (u *MyUI) UI() string {
return ` + "`" + `
<col grow="1" justify="start" margin="24px">
<text font="NotoSans 24" color="#ffffff" margin="4px" padding="12px">
Your text goes here
</text>
<row justify="start center">
<button onClick="Click" color="#ffffff" margin="12px" padding="12px" btn="button.png 6">
Clickable Button
</button>
<text font="NotoSans 18" color="#ffffff" margin="4px" padding="12px">
{{ "{{ .Clicks }}" }} times
</text>
</row>
</col>` + "`" + `
}
]]>
</p>
</col>`
}