Ejemplo n.º 1
7
func (m Model) View(rootUpdateFunc, wrapFunc interface{}) h.HTML {
	return h.Div(
		m.top.View(rootUpdateFunc, top(m)),
		m.bottom.View(rootUpdateFunc, bottom(m)),
		h.Button(h.Text("Reset")).OnClick(rootUpdateFunc, rootUpdateFunc, Reset),
	)
}
Ejemplo n.º 2
5
func (m Model) View(rootUpdateFunc, wrapFunc interface{}) h.HTML {
	remove := h.Button(h.Text("Remove")).OnClick(rootUpdateFunc, wrapper(m), Remove)
	insert := h.Button(h.Text("Add")).OnClick(rootUpdateFunc, wrapper(m), Insert)
	p := []h.HTML{remove, insert}
	for id, counter := range m.counters {
		p = append(p, counter.counter.View(rootUpdateFunc, cWrapper(m, id)))
	}
	return h.Div(p...)
}
Ejemplo n.º 3
3
func (m Model) View(rootUpdateFunc, wrapFunc interface{}) h.HTML {
	var wf WrapFunc
	if wrapFunc == nil {
		wf = identity
	}
	return h.Div(
		m.first.View(rootUpdateFunc, firstWrapper(m, wf)),
		m.last.View(rootUpdateFunc, lastWrapper(m, wf)),
		h.Button(h.Text("Reset All")).OnClick(rootUpdateFunc, wrapper(m, wf), ResetAll),
		h.Button(h.Text("Randomize All")).OnClick(rootUpdateFunc, wrapper(m, wf), RandomizeAll),
	)
}
Ejemplo n.º 4
3
func (m Model) View(rootUpdateFunc interface{}, wrapFunc WrapFunc) h.HTML {
	style := [][]string{
		{"font-size", "20px"},
		{"font-family", "monospace"},
		{"display", "inline-block"},
		{"width", "50px"},
		{"text-align", "center"},
	}
	return h.Div(
		h.Button(h.Text("-")).OnClick(rootUpdateFunc, wrapper(m, wrapFunc), Decrement),
		h.Div(h.Text(m.String())).Style(style),
		h.Button(h.Text("+")).OnClick(rootUpdateFunc, wrapper(m, wrapFunc), Increment),
	)
}
Ejemplo n.º 5
1
func (m Model) View(rootUpdateFunc interface{}, wrapFunc WrapFunc) h.HTML {
	return h.Div(
		m.top.View(rootUpdateFunc, topWrapper(m, wrapFunc)),
		m.bottom.View(rootUpdateFunc, bottomWrapper(m, wrapFunc)),
		h.Button(h.Text("Reset")).OnClick(rootUpdateFunc, wrapper(m, wrapFunc), Reset),
	)
}