2020-03-19 22:30:37 -07:00
|
|
|
<template>
|
|
|
|
<div class="timctyfi" :class="{ focused, disabled }">
|
|
|
|
<div class="icon"><slot name="icon"></slot></div>
|
2020-11-25 04:31:34 -08:00
|
|
|
<span class="label"><slot name="label"></slot></span>
|
2020-03-19 22:30:37 -07:00
|
|
|
<input
|
|
|
|
type="range"
|
|
|
|
ref="input"
|
|
|
|
v-model="v"
|
|
|
|
:disabled="disabled"
|
|
|
|
:min="min"
|
|
|
|
:max="max"
|
|
|
|
:step="step"
|
|
|
|
:autofocus="autofocus"
|
|
|
|
@focus="focused = true"
|
|
|
|
@blur="focused = false"
|
2020-10-17 04:12:00 -07:00
|
|
|
@input="$emit('update:value', $event.target.value)"
|
2020-03-19 22:30:37 -07:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-11-25 04:31:34 -08:00
|
|
|
import { defineComponent } from 'vue';
|
2020-10-17 04:12:00 -07:00
|
|
|
|
|
|
|
export default defineComponent({
|
2020-03-19 22:30:37 -07:00
|
|
|
props: {
|
|
|
|
value: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
|
|
|
default: 0
|
|
|
|
},
|
|
|
|
disabled: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
min: {
|
2020-03-20 07:08:45 -07:00
|
|
|
type: Number,
|
2020-03-19 22:30:37 -07:00
|
|
|
required: false,
|
2020-03-20 07:08:45 -07:00
|
|
|
default: 0
|
2020-03-19 22:30:37 -07:00
|
|
|
},
|
|
|
|
max: {
|
2020-03-20 07:08:45 -07:00
|
|
|
type: Number,
|
2020-03-19 22:30:37 -07:00
|
|
|
required: false,
|
2020-03-20 07:08:45 -07:00
|
|
|
default: 100
|
2020-03-19 22:30:37 -07:00
|
|
|
},
|
|
|
|
step: {
|
2020-03-20 07:08:45 -07:00
|
|
|
type: Number,
|
2020-03-19 22:30:37 -07:00
|
|
|
required: false,
|
2020-03-20 07:08:45 -07:00
|
|
|
default: 1
|
2020-03-19 22:30:37 -07:00
|
|
|
},
|
|
|
|
autofocus: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
v: this.value,
|
|
|
|
focused: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
value(v) {
|
|
|
|
this.v = parseFloat(v);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
if (this.autofocus) {
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.$refs.input.focus();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.timctyfi {
|
|
|
|
position: relative;
|
|
|
|
margin: 8px;
|
|
|
|
|
|
|
|
> .icon {
|
|
|
|
display: inline-block;
|
|
|
|
width: 24px;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .title {
|
|
|
|
pointer-events: none;
|
|
|
|
font-size: 16px;
|
|
|
|
color: var(--inputLabel);
|
2021-02-26 18:18:53 -08:00
|
|
|
overflow: hidden; // overflow: clip; をSafariが対応したら消す
|
|
|
|
overflow: clip;
|
2020-03-19 22:30:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
> input {
|
|
|
|
-webkit-appearance: none;
|
|
|
|
-moz-appearance: none;
|
|
|
|
appearance: none;
|
2020-07-04 11:49:58 -07:00
|
|
|
background: var(--X10);
|
2020-03-19 22:30:37 -07:00
|
|
|
height: 7px;
|
|
|
|
margin: 0 8px;
|
|
|
|
outline: 0;
|
|
|
|
border: 0;
|
|
|
|
border-radius: 7px;
|
|
|
|
|
|
|
|
&.disabled {
|
|
|
|
opacity: 0.6;
|
|
|
|
cursor: not-allowed;
|
|
|
|
}
|
|
|
|
|
|
|
|
&::-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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|