mirror of
https://github.com/RoganDawes/P4wnP1_aloa.git
synced 2025-03-17 21:31:56 +01:00
53 lines
983 B
Go
53 lines
983 B
Go
// +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")
|
|
*/ |