-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.go
75 lines (66 loc) · 3.01 KB
/
root.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package main
// DO NOT EDIT: This file was generated by vugu. Please regenerate instead of editing or add additional code in a separate file.
import "fmt"
import "reflect"
import "github.com/vugu/vugu"
type RootData struct{ Show bool }
func (data *RootData) Toggle() { data.Show = !data.Show }
var _ vugu.ComponentType = (*Root)(nil)
func (comp *Root) BuildVDOM(dataI interface{}) (vdom *vugu.VGNode, css *vugu.VGNode, reterr error) {
data := dataI.(*RootData)
_ = data
_ = fmt.Sprint
_ = reflect.Value{}
event := vugu.DOMEventStub
_ = event
css = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "style", DataAtom: vugu.VGAtom(458501), Namespace: "", Attr: []vugu.VGAttribute(nil)}
css.AppendChild(&vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n.my-first-vugu-comp { background: #eee; }\n", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)})
var n *vugu.VGNode
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "my-first-vugu-comp"}}}
vdom = n
{
parent := n
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n ", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "button", DataAtom: vugu.VGAtom(102662), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
// @click = { data.Toggle() }
{
var i_ interface{} = data
idat_ := reflect.ValueOf(&i_).Elem().InterfaceData()
var i2_ interface{} = data.Toggle
i2dat_ := reflect.ValueOf(&i2_).Elem().InterfaceData()
n.SetDOMEventHandler("click", vugu.DOMEventHandler{
ReceiverAndMethodHash: uint64(idat_[0]) ^ uint64(idat_[1]) ^ uint64(i2dat_[0]) ^ uint64(i2dat_[1]),
Method: reflect.ValueOf(data).MethodByName("Toggle"),
Args: []interface{}{},
})
}
if false {
// force compiler to check arguments for type safety
data.Toggle()
}
{
parent := n
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "Test", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n ", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
if data.Show {
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
{
parent := n
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "I am here!", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
}
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
}
return
}
type Root struct {}
func (ct *Root) NewData(props vugu.Props) (interface{}, error) { return &RootData{}, nil }
func init() { vugu.RegisterComponentType("root", &Root{}) }