28 lines
427 B
Go
28 lines
427 B
Go
|
package input
|
||
|
|
||
|
import (
|
||
|
"github.com/vugu/vugu"
|
||
|
)
|
||
|
|
||
|
// CheckBox is a boolean type input component.
|
||
|
// Similar to a button that can be toggled.
|
||
|
type CheckBox struct {
|
||
|
AttrMap vugu.AttrMap
|
||
|
|
||
|
Bind *bool
|
||
|
}
|
||
|
|
||
|
func (c *CheckBox) isChecked() bool {
|
||
|
if c.Bind != nil {
|
||
|
return *c.Bind
|
||
|
}
|
||
|
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
func (c *CheckBox) handleChange(event vugu.DOMEvent) {
|
||
|
if c.Bind != nil {
|
||
|
*c.Bind = event.PropBool("target", "checked")
|
||
|
}
|
||
|
}
|