From 91f2bd4033873a9d929b4ab0a5406b53914ede9a Mon Sep 17 00:00:00 2001 From: Domantas Petrauskas Date: Sun, 24 Feb 2019 15:32:18 +0200 Subject: [PATCH] Add margin prop (#99) --- README.md | 1 + demo/src/App.vue | 7 ++++++- dist/index.js | 12 ++++++++---- dist/ssr.index.js | 12 ++++++++---- src/Button.vue | 16 ++++++++-------- 5 files changed, 31 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index c8e7a12..5182037 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ Vue.component('ToggleButton', ToggleButton) | switch-color | [String, Object] | `#BFCBD9` | If `String` - color or background property of the switch when checked
If `Object` - colors or background property for the switch when checked/uncheked
Example: `{checked: '#25EF02', unchecked: 'linear-gradient(red, yellow)'}` | | width | Number | 50 | Width of the button | | height | Number | 22 | Height of the button | +| margin | Number | 3 | Space between the switch and background border | | name | String | undefined | Name to attach to the generated input field | | font-size | Number | undefined | Font size | diff --git a/demo/src/App.vue b/demo/src/App.vue index 6e4ff6b..414f58d 100644 --- a/demo/src/App.vue +++ b/demo/src/App.vue @@ -43,7 +43,7 @@ :disabled="true"/> @@ -63,6 +63,11 @@ +
typeof object === 'object' && object.hasOwnProperty(title) @@ -102,6 +101,10 @@ export default { type: Number, default: 50 }, + margin: { + type: Number, + default: 3 + }, fontSize: { type: Number } @@ -125,19 +128,19 @@ export default { }, buttonRadius () { - return this.height - MARGIN * 2; + return this.height - this.margin * 2; }, distance () { - return px(this.width - this.height + MARGIN) + return px(this.width - this.height + this.margin) }, buttonStyle () { const transition = `transform ${this.speed}ms` const transform = this.toggled - ? `translate3d(${this.distance}, 3px, 0px)` - : null + ? `translate3d(${this.distance}, ${px(this.margin)}, 0px)` + : `translate3d(${px(this.margin)}, ${px(this.margin)}, 0px)` const background = this.switchColor ? this.switchColorCurrent @@ -264,12 +267,10 @@ export default {