Example #1
0
File: editor.go Project: kego/ke
func (v *IconEditorView) Render() *vecty.HTML {
	v.editor = editors.NewStringEditorView(v.Ctx, v.model.Node.Map["url"], editable.Inline)
	url := ""
	if v.icon.Url != nil {
		url = v.icon.Url.Value()
	}
	return elem.Div(
		prop.Class("container-fluid"),
		elem.Div(
			prop.Class("row"),
			elem.Div(
				prop.Class("col-sm-10"),
				vecty.Style("padding-left", "0"),
				vecty.Style("padding-right", "0"),
				v.editor,
			),
			elem.Div(
				prop.Class("col-sm-2"),
				elem.Image(
					prop.Class("img-responsive"),
					style.MaxHeight("200px"),
					prop.Src(url),
				),
			),
		),
	)
}
Example #2
0
func TestBranchControlView_Render(t *testing.T) {

	cb := ctests.New(t).SetApp(true, false, false)
	defer cb.Finish()

	b := NewBranchControlView(cb.Ctx(), models.NewBranchModel(cb.Ctx(), &models.RootContents{Name: "a"}))

	expected := elem.Div(
		elem.Anchor(
			vecty.ClassMap{
				"toggle": true,
				"empty":  true,
			},
			event.Click(nil),
		),
		elem.Div(
			vecty.ClassMap{
				"node-content": true,
			},
			elem.Span(
				prop.Class("node-label"),
				event.Click(nil),
				vecty.Text("a"),
			),
			elem.Span(
				prop.Class("badge"),
				vecty.Style("display", "none"),
			),
		),
	)
	equal(t, expected, b.Render())

	cb.AssertAppSuccess()

}
Example #3
0
func (v *BranchControlView) Render() *vecty.HTML {
	if v.model == nil {
		v.holder = elem.Div()
		return v.holder
	}

	selected := v.App.Branches.Selected() == v.model

	icon := v.model.Icon()

	v.holder = elem.Div(
		elem.Anchor(
			vecty.ClassMap{
				"toggle":   true,
				"selected": selected,
				"plus":     icon == "plus",
				"minus":    icon == "minus",
				"unknown":  icon == "unknown",
				"empty":    icon == "empty",
			},
			event.Click(v.toggleClick),
		),
		elem.Div(
			vecty.ClassMap{
				"node-content": true,
				"selected":     selected,
			},
			elem.Span(
				prop.Class("node-label"),
				event.Click(v.labelClick),
				vecty.Text(v.model.Contents.Label(v.Ctx)),
			),
			elem.Span(
				prop.Class("badge"),
				vecty.Style("display", "none"),
			),
		),
	)
	return v.holder

}