package input import "github.com/vugu/vugu" type Button struct { AttrMap vugu.AttrMap IconSlot vugu.Builder `vugu:"data"` // Slot for the symbol. DefaultSlot vugu.Builder `vugu:"data"` Bind *bool `vugu:"data"` // A data binding with some bool variable. If this contains a reference, the button can be toggled. Click ClickHandler // External handler that is called upon an event. classes string // Additional computed classes that are added to the component. } func (c *Button) Compute(ctx vugu.ComputeCtx) { if c.Bind != nil && *c.Bind { c.classes = "d3c-color-accent" } else { c.classes = "" } } func (c *Button) HandleClick(event vugu.DOMEvent) { if c.Bind != nil { *c.Bind = !*c.Bind } if c.Click != nil { c.Click.ClickHandle(ClickEvent{DOMEvent: event}) } }