Loading files
a37771a92This file is pinned to the selected release. Download the original to open it in your design tool.
<template>
<label :for="id + '_button'" :class="{'active': currentState}" class="toggle__button">
<span v-if="currentState" class="toggle__label">{{ labelEnableText }}</span>
<span v-if="! currentState" class="toggle__label">{{ labelDisableText }}</span>
<input type="checkbox" :id="id + '_button'" v-model="checkedValue">
<span class="toggle__switch"></span>
</label>
</template>
<script>
export default {
props: {
labelEnableText: {
type: String,
required: true
},
labelDisableText: {
type: String,
required: true
},
id: {
type: String,
default: 'primary'
},
currentState: {
type: Boolean,
required: true
}
},
computed: {
checkedValue: {
get() {
return this.currentState;
},
set(newValue) {
this.$emit('change', newValue);
}
}
}
}
</script>
<style scoped>
.toggle__button {
vertical-align: middle;
user-select: none;
cursor: pointer;
}
.toggle__button input[type="checkbox"] {
opacity: 0;
position: absolute;
width: 1px;
height: 1px;
}
.toggle__button .toggle__switch {
display:inline-block;
height:12px;
border-radius:6px;
width:40px;
background: #BFCBD9;
box-shadow: inset 0 0 1px #BFCBD9;
position:relative;
margin-left: 10px;
transition: all .25s;
}
.toggle__button .toggle__switch::after,
.toggle__button .toggle__switch::before {
content: "";
position: absolute;
display: block;
height: 18px;
width: 18px;
border-radius: 50%;
left: 0;
top: -3px;
transform: translateX(0);
transition: all .25s cubic-bezier(.5, -.6, .5, 1.6);
}
.toggle__button .toggle__switch::after {
background: #4D4D4D;
box-shadow: 0 0 1px #666;
}
.toggle__button .toggle__switch::before {
background: #4D4D4D;
box-shadow: 0 0 0 3px rgba(0,0,0,0.1);
opacity:0;
}
.active .toggle__switch {
background: #FFEA9B;
box-shadow: inset 0 0 1px #FFEA9B;
}
.active .toggle__switch::after,
.active .toggle__switch::before{
transform:translateX(40px - 18px);
}
.active .toggle__switch::after {
left: 23px;
background: #FFCB05;
box-shadow: 0 0 1px #FFCB05;
}
</style>