Skip to content

Commit 488e749

Browse files
committed
bump vue-toggle + switch
1 parent 6561cf1 commit 488e749

File tree

6 files changed

+47
-54
lines changed

6 files changed

+47
-54
lines changed

README.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -510,20 +510,7 @@ components:
510510
<span slot="on">SomeOnLabel</span> <!-- defaults to On -->
511511
</switch>
512512
```
513-
[demo](https://paulpflug.github.io/vue-materialize/#!/forms/switch) - [source for demo](dev/forms/switch.vue)
514-
#### Props <sup>[top^](#table-of-contents)</sup>
515-
| Name | type | default | description |
516-
| ---:| --- | ---| --- |
517-
| is-on | Boolean | false | (two-way) toggle state |
518-
| disabled | Boolean | false | is disabled |
519-
520-
#### Events <sup>[top^](#table-of-contents)</sup>
521-
| Name | description |
522-
| ---:| --- | ---| --- |
523-
| off | will be emitted on click when state was on |
524-
| on | will be emitted on click when state was off |
525-
| toggle | will be emitted on click |
526-
513+
[demo](https://paulpflug.github.io/vue-materialize/#!/forms/switch) - [source for demo](dev/forms/switch.vue) - [doc: vue-toggle](https://github.com/vue-comps/vue-toggle)
527514

528515
### input-field <sup>[top^](#table-of-contents)</sup>
529516
```coffee
@@ -556,6 +543,7 @@ dataError | String | - | message to display on invalid input. Used with validate
556543
dataSuccess | String | - | message to display on valid input. Used with validate
557544
label | String | - | description of the input
558545
value | String | - | preset the value
546+
placeholder | String | - | sets a placeholder
559547
length | Number | 0 | maximum length of input
560548

561549
#### Events <sup>[top^](#table-of-contents)</sup>

dev/forms/switch.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
<template lang="jade">
22
.container
3-
p
4-
a(href="https://github.com/paulpflug/vue-materialize/blob/master/dev/forms/switch.vue") source
5-
p
6-
switch(@on="onOn" @off="onOff" @toggle="onToggle")
7-
p
8-
switch(disabled)
3+
br
4+
switch(@on="onOn" @off="onOff" @toggle="onToggle")
5+
p disabled:
6+
switch(disabled)
97
p Open console for events
8+
br
9+
a(href="https://github.com/paulpflug/vue-materialize/blob/master/dev/forms/switch.vue") source
10+
1011

1112
</template>
1213

1314
<script lang="coffee">
1415
require("../materialize.config.scss")
1516
module.exports =
1617
components:
17-
"switch" : require "../../src/switch.vue"
18+
"switch" : require "../../src/switch.coffee"
1819
methods:
1920
onOn: ->
2021
console.log "isOn"

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"vue-toaster": "^0.1.3",
3737
"vue-drag-handle": "^0.2.0",
3838
"vue-zoombox": "^0.1.0",
39-
"vue-textarea": "^0.2.0"
39+
"vue-textarea": "^0.2.0",
40+
"vue-toggle": "^1.0.1"
4041
},
4142
"devDependencies": {
4243
"callback-loader": "^0.2.4",

src/dropdown.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# out: ../dropdown.js
22
Velocity = require("velocity-animate")
33
ci = require "vue-comps-dropdown"
4+
ci.computed ?= {}
5+
ci.computed.mergeClass = ->
6+
return ["dropdown-content"]
47
ci.props.transitionIn.default = ({el,cb}) ->
58
Velocity el, "stop"
69
Velocity el, "slideDown",{

src/switch.coffee

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# out: ../switch.js
2+
3+
toggle = require "vue-toggle"
4+
t =
5+
template: """
6+
<div :class='computedClass'>
7+
<label>
8+
<slot name='off'>Off</slot>
9+
<input type='checkbox' v-model='isOn' v-bind:disabled='disabled'>
10+
<span class='lever'></span>
11+
<slot name='on'>On</slot>
12+
</label>
13+
</div>
14+
"""
15+
mixins: toggle.mixins
16+
props:
17+
onClass: toggle.props.onClass
18+
offClass: toggle.props.offClass
19+
isOn: toggle.props.isOn
20+
disabled:toggle.props.disabled
21+
class:
22+
default: "switch"
23+
computed: toggle.computed
24+
watch:
25+
isOn: (val) ->
26+
if val
27+
@$emit("on")
28+
else
29+
@$emit("off")
30+
@$emit("toggle")
31+
32+
module.exports = t

src/switch.vue

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)