forked from RoganDawes/P4wnP1_aloa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hvueCompToggleSwitch.go
53 lines (40 loc) · 983 Bytes
/
hvueCompToggleSwitch.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
// +build js
package main
import (
"github.com/gopherjs/gopherjs/js"
"github.com/mame82/hvue"
)
type CompToggleSwitchData struct {
*js.Object
}
func newCompToggleSwitchData(vm *hvue.VM) interface{} {
newVM := &CompToggleSwitchData{
Object: js.Global.Get("Object").New(),
}
return newVM
}
func InitCompToggleSwitch() {
hvue.NewComponent(
"toggle-switch",
hvue.Template(compToggleSwitchTemplate),
hvue.DataFunc(newCompToggleSwitchData),
hvue.PropObj("value", hvue.Types(hvue.PBoolean), hvue.Required),
)
}
const (
compToggleSwitchTemplate = `
<label class="toggle-switch">
<input type="checkbox" v-bind:checked="value" v-on:change="$emit('input', $event.target.checked)">
<div><span class="on">On</span><span class="off">Off</span></div>
<span class="toggle-switch-slider"></span>
</label>
`
)
/*
<script src="Vue.js"></script>
<script>Vue.Register()</script>
<div id="app">
<toggle-switch ledcolor="colorvar">
</div>
Vue.Register("#app")
*/