1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
<!--
SPDX-FileCopyrightText: syuilo and misskey-project
SPDX-License-Identifier: AGPL-3.0-only
-->
<!-- Media系専用のinput range -->
<template>
<div :style="sliderBgWhite ? '--sliderBg: rgba(255,255,255,.25);' : '--sliderBg: var(--MI_THEME-scrollbarHandle);'">
<div :class="$style.controlsSeekbar">
<progress v-if="buffer !== undefined" :class="$style.buffer" :value="isNaN(buffer) ? 0 : buffer" min="0" max="1">{{ Math.round(buffer * 100) }}% buffered</progress>
<input v-model="model" :class="$style.seek" :style="`--value: ${modelValue * 100}%;`" type="range" min="0" max="1" step="any" @change="emit('dragEnded', modelValue)"/>
</div>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue';
withDefaults(defineProps<{
buffer?: number;
sliderBgWhite?: boolean;
}>(), {
buffer: undefined,
sliderBgWhite: false,
});
const emit = defineEmits<{
(ev: 'dragEnded', value: number): void;
}>();
const model = defineModel<string | number>({ required: true });
const modelValue = computed({
get: () => typeof model.value === 'number' ? model.value : parseFloat(model.value),
set: v => { model.value = v; },
});
</script>
<style lang="scss" module>
.controlsSeekbar {
position: relative;
}
.seek {
position: relative;
-webkit-appearance: none;
appearance: none;
background: transparent;
border: 0;
border-radius: 26px;
color: var(--MI_THEME-accent);
display: block;
height: 19px;
margin: 0;
min-width: 0;
padding: 0;
transition: box-shadow .3s ease;
width: 100%;
&::-webkit-slider-runnable-track {
background-color: var(--sliderBg);
background-image: linear-gradient(to right,currentColor var(--value,0),transparent var(--value,0));
border: 0;
border-radius: 99rem;
height: 5px;
transition: box-shadow .3s ease;
user-select: none;
}
&::-moz-range-track {
background: transparent;
border: 0;
border-radius: 99rem;
height: 5px;
transition: box-shadow .3s ease;
user-select: none;
background-color: var(--sliderBg);
}
&::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
background: #fff;
border: 0;
border-radius: 100%;
box-shadow: 0 1px 1px rgba(35, 40, 47, .15),0 0 0 1px rgba(35, 40, 47, .2);
height: 13px;
margin-top: -4px;
position: relative;
transition: all .2s ease;
width: 13px;
&:active {
box-shadow: 0 1px 1px rgba(35, 40, 47, .15), 0 0 0 1px rgba(35, 40, 47, .15), 0 0 0 3px rgba(255, 255, 255, .5);
}
}
&::-moz-range-thumb {
background: #fff;
border: 0;
border-radius: 100%;
box-shadow: 0 1px 1px rgba(35, 40, 47, .15),0 0 0 1px rgba(35, 40, 47, .2);
height: 13px;
position: relative;
transition: all .2s ease;
width: 13px;
&:active {
box-shadow: 0 1px 1px rgba(35, 40, 47, .15), 0 0 0 1px rgba(35, 40, 47, .15), 0 0 0 3px rgba(255, 255, 255, .5);
}
}
&::-moz-range-progress {
background: currentColor;
border-radius: 99rem;
height: 5px;
}
}
.buffer {
appearance: none;
background: transparent;
color: var(--sliderBg);
border: 0;
border-radius: 99rem;
height: 5px;
left: 0;
margin-top: -2.5px;
padding: 0;
position: absolute;
top: 50%;
width: 100%;
&::-webkit-progress-bar {
background: transparent;
}
&::-webkit-progress-value {
background: currentColor;
border-radius: 100px;
min-width: 5px;
transition: width .2s ease;
}
&::-moz-progress-bar {
background: currentColor;
border-radius: 100px;
min-width: 5px;
transition: width .2s ease;
}
}
</style>
|