|
@@ -0,0 +1,68 @@
|
|
|
+<template>
|
|
|
+ <div class="track aria-theme-independent" :class="value ? 'on' : 'off'"
|
|
|
+ @click.passive="onClick"
|
|
|
+ @keydown.enter.passive="onEnter"
|
|
|
+ >
|
|
|
+ <div class="slider"></div>
|
|
|
+ <input v-show="false" type="checkbox" :id="id">
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ props: {
|
|
|
+ value: {
|
|
|
+ type: Boolean,
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ id: {
|
|
|
+ type: String,
|
|
|
+ default: '',
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ onClick() {
|
|
|
+ this.$emit('input', !this.value)
|
|
|
+ },
|
|
|
+ onEnter() {
|
|
|
+ this.$emit('input', !this.value)
|
|
|
+ },
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+.track {
|
|
|
+ width: 40px;
|
|
|
+ height: 20px;
|
|
|
+ border-radius: 10px;
|
|
|
+ position: relative;
|
|
|
+ transition: all 0.3s;
|
|
|
+ cursor: pointer;
|
|
|
+ display: inline-block;
|
|
|
+ vertical-align: middle;
|
|
|
+ .slider {
|
|
|
+ width: 16px;
|
|
|
+ height: 16px;
|
|
|
+ border-radius: 50%;
|
|
|
+ background: white;
|
|
|
+ position: absolute;
|
|
|
+ top: 2px;
|
|
|
+ }
|
|
|
+}
|
|
|
+.off {
|
|
|
+ background: #DCDFE6;
|
|
|
+ .slider {
|
|
|
+ left: 2px;
|
|
|
+ right: auto;
|
|
|
+ }
|
|
|
+}
|
|
|
+.on {
|
|
|
+ background: #AB3434;
|
|
|
+ .slider {
|
|
|
+ left: auto;
|
|
|
+ right: 2px;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|