2020-11-25 14:31:34 +02:00
|
|
|
<template>
|
2021-09-29 18:50:45 +03:00
|
|
|
<div class="timctyfi" :class="{ focused, disabled }">
|
|
|
|
<div class="icon"><slot name="icon"></slot></div>
|
|
|
|
<span class="label"><slot name="label"></slot></span>
|
|
|
|
<input
|
|
|
|
ref="input"
|
|
|
|
v-model="v"
|
2021-11-19 12:36:12 +02:00
|
|
|
type="range"
|
2021-09-29 18:50:45 +03:00
|
|
|
:disabled="disabled"
|
|
|
|
:min="min"
|
|
|
|
:max="max"
|
|
|
|
:step="step"
|
|
|
|
:autofocus="autofocus"
|
|
|
|
@focus="focused = true"
|
|
|
|
@blur="focused = false"
|
|
|
|
@input="$emit('update:value', $event.target.value)"
|
|
|
|
/>
|
2020-11-25 14:31:34 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
props: {
|
|
|
|
value: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
|
|
|
default: 0
|
|
|
|
},
|
|
|
|
disabled: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
min: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
|
|
|
default: 0
|
|
|
|
},
|
|
|
|
max: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
|
|
|
default: 100
|
|
|
|
},
|
|
|
|
step: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
|
|
|
default: 1
|
|
|
|
},
|
2021-09-29 18:50:45 +03:00
|
|
|
autofocus: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false
|
|
|
|
}
|
2020-11-25 14:31:34 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
v: this.value,
|
|
|
|
focused: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
value(v) {
|
|
|
|
this.v = parseFloat(v);
|
|
|
|
}
|
|
|
|
},
|
2021-09-29 18:50:45 +03:00
|
|
|
mounted() {
|
|
|
|
if (this.autofocus) {
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.$refs.input.focus();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2020-11-25 14:31:34 +02:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-09-29 18:50:45 +03:00
|
|
|
.timctyfi {
|
2020-11-25 14:31:34 +02:00
|
|
|
position: relative;
|
2021-09-29 18:50:45 +03:00
|
|
|
margin: 8px;
|
2020-11-25 14:31:34 +02:00
|
|
|
|
2021-09-29 18:50:45 +03:00
|
|
|
> .icon {
|
|
|
|
display: inline-block;
|
|
|
|
width: 24px;
|
|
|
|
text-align: center;
|
|
|
|
}
|
2020-11-25 14:31:34 +02:00
|
|
|
|
2021-09-29 18:50:45 +03:00
|
|
|
> .title {
|
|
|
|
pointer-events: none;
|
|
|
|
font-size: 16px;
|
|
|
|
color: var(--inputLabel);
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
2020-11-25 14:31:34 +02:00
|
|
|
|
2021-09-29 18:50:45 +03:00
|
|
|
> input {
|
|
|
|
-webkit-appearance: none;
|
|
|
|
-moz-appearance: none;
|
|
|
|
appearance: none;
|
|
|
|
background: var(--X10);
|
|
|
|
height: 7px;
|
|
|
|
margin: 0 8px;
|
|
|
|
outline: 0;
|
|
|
|
border: 0;
|
|
|
|
border-radius: 7px;
|
2020-11-25 14:31:34 +02:00
|
|
|
|
2021-09-29 18:50:45 +03:00
|
|
|
&.disabled {
|
|
|
|
opacity: 0.6;
|
|
|
|
cursor: not-allowed;
|
|
|
|
}
|
2020-11-25 14:31:34 +02:00
|
|
|
|
2021-09-29 18:50:45 +03:00
|
|
|
&::-webkit-slider-thumb {
|
|
|
|
-webkit-appearance: none;
|
|
|
|
appearance: none;
|
|
|
|
cursor: pointer;
|
|
|
|
width: 20px;
|
|
|
|
height: 20px;
|
|
|
|
display: block;
|
|
|
|
border-radius: 50%;
|
|
|
|
border: none;
|
|
|
|
background: var(--accent);
|
|
|
|
box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
|
|
|
|
box-sizing: content-box;
|
|
|
|
}
|
|
|
|
|
|
|
|
&::-moz-range-thumb {
|
|
|
|
-moz-appearance: none;
|
|
|
|
appearance: none;
|
|
|
|
cursor: pointer;
|
|
|
|
width: 20px;
|
|
|
|
height: 20px;
|
|
|
|
display: block;
|
|
|
|
border-radius: 50%;
|
|
|
|
border: none;
|
|
|
|
background: var(--accent);
|
|
|
|
box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
|
2020-11-25 14:31:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|