Skip to content

Commit c15befc

Browse files
committed
1.0.5 update image, add shadow effect
1 parent 9dce401 commit c15befc

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
A simple, lightweight on/off toggle component made with Vue.js. Provides multiple themes with default configurations. You can also customize size, color and borders.
44

55
<p align="center">
6-
<img src="https://i.imgur.com/Iram1NB.png">
6+
<img src="https://i.imgur.com/pVI4GIB.png">
77
</p>
88

99
## Installation
@@ -42,6 +42,7 @@ new Vue({
4242
<onoff-toggle
4343
v-model="checked"
4444
onColor="#008F13"
45+
:shadow="false"
4546
/>
4647

4748
<onoff-toggle
@@ -107,6 +108,10 @@ new Vue({
107108
<td>margin</td>
108109
<td>Space around the thumb</td>
109110
</tr>
111+
<tr>
112+
<td>shadow</td>
113+
<td>Only works on default theme. When set to true, a glow effect will be added around the toggle.</td>
114+
</tr>
110115
</tbody>
111116
</table>
112117

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-onoff-toggle",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "A smart, lightweight and easy-to-use on/off toggle component for Vue.js with multiple themes.",
55
"main": "src/onoff-toggle.vue",
66
"keywords": [

src/onoff-toggle.vue

100644100755
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ export default {
7777
borderColor: { type: String },
7878
width: { type: [Number, String] },
7979
height: { type: [Number, String] },
80-
margin: { type: [Number, String] }
80+
margin: { type: [Number, String] },
81+
shadow: { type: Boolean, default: true }
8182
},
8283
computed: {
8384
themeInfo() {
@@ -112,7 +113,7 @@ export default {
112113
113114
if (this.theme === THEME_IOS) {
114115
Object.assign(style, {
115-
backgroundColor: offColor,
116+
backgroundColor: this.value ? onColor : offColor,
116117
boxShadow: `inset 0 0 0 ${this.value ? height / 2 : 0}px ${onColor}, 0 0 0 ${margin}px ${this.value ? onColor : borderColor}`
117118
})
118119
} else if (this.theme === THEME_MATERIAL) {
@@ -124,6 +125,8 @@ export default {
124125
} else if (this.value && !this.onColor && this.thumbColor) {
125126
style.backgroundColor = semiOpaqueColor(this.thumbColor, 0.5)
126127
}
128+
} else if (this.theme === THEME_DEFAULT && this.shadow) {
129+
style.boxShadow = `0px 4px 10px 0px ${semiOpaqueColor(this.value ? onColor : offColor, 0.4)}`
127130
}
128131
129132
return style

0 commit comments

Comments
 (0)