mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-06 02:33:48 +00:00
99 lines
2.1 KiB
Vue
99 lines
2.1 KiB
Vue
<template>
|
|
<div class="input-wrapper">
|
|
<div class="switch-content">
|
|
<label class="input-label" v-if="label">{{ label }}:</label>
|
|
<small class="input-info" v-if="info">{{ info }}</small>
|
|
</div>
|
|
|
|
<div class="switch-content text-right">
|
|
<div
|
|
class="switch"
|
|
:class="{ active: isSwitched }"
|
|
@click="changeState"
|
|
>
|
|
<div class="switch-button"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name:'SwitchInput',
|
|
props: ['label', 'name', 'state', 'info'],
|
|
data() {
|
|
return {
|
|
isSwitched: undefined
|
|
}
|
|
},
|
|
methods: {
|
|
changeState() {
|
|
this.isSwitched = ! this.isSwitched
|
|
this.$emit('input', this.isSwitched)
|
|
}
|
|
},
|
|
mounted() {
|
|
this.isSwitched = this.state
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
@import "@assets/app.scss";
|
|
|
|
.input-wrapper {
|
|
display: flex;
|
|
width: 100%;
|
|
|
|
.input-label {
|
|
color: $text;
|
|
}
|
|
|
|
.switch-content {
|
|
width: 100%;
|
|
|
|
&:last-child {
|
|
width: 80px;
|
|
}
|
|
}
|
|
}
|
|
|
|
.switch {
|
|
width: 50px;
|
|
height: 28px;
|
|
border-radius: 50px;
|
|
display: block;
|
|
background: #f1f1f5;
|
|
position: relative;
|
|
@include transition;
|
|
|
|
.switch-button {
|
|
@include transition;
|
|
width: 22px;
|
|
height: 22px;
|
|
border-radius: 50px;
|
|
display: block;
|
|
background: white;
|
|
position: absolute;
|
|
top: 3px;
|
|
left: 3px;
|
|
box-shadow: 0 2px 4px rgba(37, 38, 94, 0.1);
|
|
cursor: pointer;
|
|
}
|
|
|
|
&.active {
|
|
background: $theme;
|
|
|
|
.switch-button {
|
|
left: 25px;
|
|
}
|
|
}
|
|
}
|
|
|
|
@media (prefers-color-scheme: dark) {
|
|
.switch {
|
|
background: $dark_mode_foreground;
|
|
}
|
|
}
|
|
</style>
|