Skip to content
This repository has been archived by the owner on Nov 30, 2020. It is now read-only.

Commit

Permalink
Finalized switch component.
Browse files Browse the repository at this point in the history
  • Loading branch information
matsp committed Oct 8, 2017
1 parent 6a42ffd commit 03cac4b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/Switch/Switch.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<template>
<div class="mdc-switch" :class="classes">
<input v-if="disabled" type="checkbox" class="mdc-switch__native-control" disabled/>
<input v-else type="checkbox" class="mdc-switch__native-control" />
<input :id="id" v-model="model" type="checkbox" class="mdc-switch__native-control" :disabled="disabled" />
<div class="mdc-switch__background">
<div class="mdc-switch__knob"></div>
</div>
Expand All @@ -15,16 +14,32 @@ export default {
type: String,
required: false
},
checked: {
type: Boolean,
required: true
},
disabled: {
type: Boolean,
required: false
}
},
model: {
prop: 'checked',
event: 'change'
},
computed: {
classes() {
return {
'mdc-switch--disabled': this.disabled
}
},
model: {
get() {
return this.checked
},
set(state) {
this.$emit('change', state)
}
}
}
}
Expand Down

0 comments on commit 03cac4b

Please sign in to comment.