Skip to content

Commit 22b59c7

Browse files
committed
allow generic background css property
1 parent 2b1ae4c commit 22b59c7

File tree

4 files changed

+48
-48
lines changed

4 files changed

+48
-48
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Use:
4848
| color | [String, Object] | `#75C791` | If `String` - color of the button when checked <br>If `Object` - colors for the button when checked/uncheked <br>Example: `{checked: '#00FF00', unchecked: '#FF0000'}` |
4949
| cssColors | Boolean | false | If `true` - deactivates the setting of colors through inline styles in favor of using CSS styling |
5050
| labels | [Boolean, Object] | false | If `Boolean` - shows/hides default labels ("on" and "off") <br>If `Object` - sets custom labels for both states. <br>Example: `{checked: 'Foo', unchecked: 'Bar'}` |
51-
| buttonColor | [String, Object] | `#BFCBD9` | If `String` - color of the switch when checked <br>If `Object` - colors for the switch when checked/uncheked <br>Example: `{checked: '#25EF02', unchecked: '#EF1E02'}` |
51+
| buttonBackground | [String, Object] | `#BFCBD9` | If `String` - color or background property of the switch when checked <br>If `Object` - colors or background property for the switch when checked/uncheked <br>Example: `{checked: '#25EF02', unchecked: 'linear-gradient(red, yellow)'}` |
5252
| width | Number | 50 | Width of the button, default is 50 |
5353
| height | Number | 22 | Height of the button, default is 22 |
5454

dist/index.js

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ssr.index.js

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Button.vue

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const constants = {
3333
width: 50,
3434
height: 22,
3535
margin: 3,
36-
buttonColor: '#fff'
36+
buttonBackground: '#fff'
3737
}
3838
3939
const contains = (object, title) => {
@@ -69,7 +69,7 @@ export default {
6969
: typeof value === 'string'
7070
}
7171
},
72-
buttonColor: {
72+
buttonBackground: {
7373
type: [String, Object],
7474
validator (value) {
7575
return typeof value === 'object'
@@ -135,7 +135,7 @@ export default {
135135
transform: this.toggled
136136
? `translate3d(${this.distance}, 3px, 0px)`
137137
: null,
138-
backgroundColor: this.buttonColor ? this.buttonColorCurrent : undefined
138+
background: this.buttonBackground ? this.buttonBackgroundCurrent : undefined
139139
}
140140
},
141141
@@ -183,32 +183,32 @@ export default {
183183
: constants.labelUnchecked
184184
},
185185
186-
buttonColorChecked () {
187-
let { buttonColor } = this
186+
buttonBackgroundChecked () {
187+
let { buttonBackground } = this
188188
189-
return contains(buttonColor, 'checked')
190-
? buttonColor.checked
191-
: constants.buttonColor
189+
return contains(buttonBackground, 'checked')
190+
? buttonBackground.checked
191+
: constants.buttonBackground
192192
},
193193
194-
buttonColorUnchecked () {
195-
let { buttonColor } = this
194+
buttonBackgroundUnchecked () {
195+
let { buttonBackground } = this
196196
197-
return contains(buttonColor, 'unchecked')
198-
? buttonColor.unchecked
199-
: constants.buttonColor
197+
return contains(buttonBackground, 'unchecked')
198+
? buttonBackground.unchecked
199+
: constants.buttonBackground
200200
},
201201
202-
buttonColorCurrent () {
203-
let { buttonColor } = this
202+
buttonBackgroundCurrent () {
203+
let { buttonBackground } = this
204204
205-
if (typeof buttonColor !== 'object') {
206-
return buttonColor || constants.buttonColor
205+
if (typeof buttonBackground !== 'object') {
206+
return buttonBackground || constants.buttonBackground
207207
}
208208
209209
return this.toggled
210-
? this.buttonColorChecked
211-
: this.buttonColorUnchecked
210+
? this.buttonBackgroundChecked
211+
: this.buttonBackgroundUnchecked
212212
}
213213
214214
},

0 commit comments

Comments
 (0)