Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
euvl committed Feb 24, 2019
1 parent a63cd2b commit d86802b
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ yarn-error.log
demo/dist
*.map
package-lock.json
.vscode
105 changes: 93 additions & 12 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 21 additions & 3 deletions dist/ssr.index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 34 additions & 19 deletions src/Button.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
<template>
<label :class="className">
<input type="checkbox"
class="v-switch-input"
:name="name"
:checked="value"
:disabled="disabled"
@change.stop="toggle">
<div class="v-switch-core"
:style="coreStyle">
<div class="v-switch-button"
:style="buttonStyle"/>
<input
type="checkbox"
class="v-switch-input"
:name="name"
:checked="value"
:disabled="disabled"
@change.stop="toggle"
>
<div
class="v-switch-core"
:style="coreStyle"
>
<div
class="v-switch-button"
:style="buttonStyle"
/>
</div>
<template v-if="labels">
<span class="v-switch-label v-left"
:style="labelStyle"
v-if="toggled">
<span
class="v-switch-label v-left"
:style="labelStyle"
v-if="toggled"
>
<slot name="checked">
<template>{{labelChecked}}</template>
</slot>
</span>
<span class="v-switch-label v-right"
:style="labelStyle"
v-else>
<span
class="v-switch-label v-right"
:style="labelStyle"
v-else
>
<slot name="unchecked">
<template>{{labelUnchecked}}</template>
</slot>
Expand All @@ -42,6 +52,10 @@ const contains = (object, title) =>
const px = v => v + 'px'
const translate3d = (x, y, z = '0px') => {
return `translate3d(${x}, ${y}, ${z})`
}
export default {
name: 'ToggleButton',
props: {
Expand Down Expand Up @@ -112,7 +126,7 @@ export default {
computed: {
className () {
let { toggled, disabled } = this
return ['vue-js-switch', { toggled, disabled }]
},
Expand All @@ -137,10 +151,11 @@ export default {
buttonStyle () {
const transition = `transform ${this.speed}ms`
const margin = px(this.margin)
const transform = this.toggled
? `translate3d(${this.distance}, ${px(this.margin)}, 0px)`
: `translate3d(${px(this.margin)}, ${px(this.margin)}, 0px)`
? translate3d(this.distance, margin)
: translate3d(margin, margin)
const background = this.switchColor
? this.switchColorCurrent
Expand Down

0 comments on commit d86802b

Please sign in to comment.