Skip to content

Commit 6e0ebd0

Browse files
committed
feat: 优化暗黑模式
1 parent 5a4e8f5 commit 6e0ebd0

File tree

3 files changed

+90
-10
lines changed

3 files changed

+90
-10
lines changed

components/hana/RangeInput.vue

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<script lang="ts" setup>
2+
defineProps<{
3+
id: string
4+
min: number
5+
max: number
6+
step: number
7+
value: number
8+
ariaValuemin: number
9+
ariaValuemax: number
10+
ariaValuenow: number
11+
ariaLabel: string
12+
}>()
13+
14+
const emits = defineEmits<{
15+
(e: 'input', event: Event): void
16+
(e: 'change', event: Event): void
17+
(e: 'pointerdown'): void
18+
}>()
19+
</script>
20+
21+
<template>
22+
<input
23+
:id="id"
24+
class="h-2 appearance-none rounded outline-none transition-[box-shadow] duration-200 accent-hana-blue dark:bg-hana-black-700 focus-visible:ring-2 focus-visible:ring-hana-blue-300 dark:accent-hana-blue-300"
25+
type="range"
26+
:min="min"
27+
:max="max"
28+
:step="step"
29+
:value="value"
30+
:aria-valuemin="ariaValuemin"
31+
:aria-valuemax="ariaValuemax"
32+
:aria-valuenow="ariaValuenow"
33+
:aria-label="ariaLabel"
34+
:style="`--progress: ${value}`"
35+
@input="emits('input', $event)"
36+
@change="emits('change', $event)"
37+
@pointerdown="emits('pointerdown')"
38+
>
39+
</template>
40+
41+
<style scoped>
42+
input[type="range"] {
43+
background: linear-gradient(to right,
44+
oklch(0.5 0.1102 250.04) calc(var(--progress) * 100%),
45+
oklch(0.93 0.0358 205.23) calc(var(--progress) * 100%)
46+
);
47+
}
48+
49+
.dark {
50+
input[type="range"] {
51+
background: linear-gradient(to right,
52+
oklch(0.75 0.0883 226.04) calc(var(--progress) * 100%),
53+
oklch(0.93 0.0358 205.23) calc(var(--progress) * 100%)
54+
);
55+
}
56+
}
57+
</style>

components/hana/VolumeController.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function handleInput(e: Event) {
5858
@mouseleave="toggleShowVolumePanel"
5959
>
6060
<div class="absolute bottom-2 flex flex-col items-center gap-4">
61-
<p class="text-xs text-text">
61+
<p class="text-xs text-text dark:text-hana-white-700">
6262
{{ Math.round(volume * 100) }}%
6363
</p>
6464
<input
@@ -92,7 +92,7 @@ function handleInput(e: Event) {
9292
oklch(0.5 0.1102 250.04) calc(var(--progress) * 100%),
9393
oklch(0.93 0.0358 205.23) calc(var(--progress) * 100%)
9494
);
95-
appearance: slider-vertical;
96-
writing-mode: bt-lr;
95+
writing-mode: vertical-lr;
96+
direction: rtl;
9797
}
9898
</style>

components/recently/MusicCard.vue

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,18 @@ function stepMusic(type: 'prev' | 'next') {
6161
</script>
6262

6363
<template>
64-
<div class="w-full flex flex-col gap-3 overflow-hidden border border-hana-blue-200 rounded-lg bg-hana-blue-200/10 p-4 sm:flex-row sm:items-center">
64+
<div class="w-full flex flex-col gap-3 overflow-hidden border border-hana-blue-200 rounded-lg bg-hana-blue-200/10 p-4 sm:flex-row sm:items-center dark:bg-hana-black">
6565
<nuxt-img
6666
:src="curMusic.album.cover"
6767
:alt="curMusic.album.title"
6868
class="aspect-video w-full rounded-lg object-cover sm:aspect-square sm:size-42"
6969
/>
7070
<div class="min-w-0 flex flex-1 flex-col gap-3">
7171
<div class="min-w-0 flex flex-col gap-1">
72-
<h3 class="truncate text-base font-bold leading-snug md:text-lg">
72+
<h3 class="truncate text-base font-bold leading-snug md:text-lg dark:text-hana-white">
7373
{{ curMusic.title }}
7474
</h3>
75-
<p class="truncate text-sm text-text-3">
75+
<p class="truncate text-sm text-text dark:text-hana-white-700">
7676
{{ curMusic.album.title }}
7777
</p>
7878
</div>
@@ -98,9 +98,9 @@ function stepMusic(type: 'prev' | 'next') {
9898
@click="stepMusic('next')"
9999
/>
100100
</div>
101-
<input
101+
<!-- <input
102102
id="music-progress"
103-
class="h-2 appearance-none rounded outline-none transition-[box-shadow] duration-200 accent-hana-blue dark:bg-hana-black-700 focus-visible:ring-2 focus-visible:ring-hana-blue-300"
103+
class="h-2 appearance-none rounded outline-none transition-[box-shadow] duration-200 accent-hana-blue dark:bg-hana-black-700 focus-visible:ring-2 focus-visible:ring-hana-blue-300 dark:accent-hana-blue-300"
104104
type="range"
105105
min="0"
106106
max="1"
@@ -114,8 +114,22 @@ function stepMusic(type: 'prev' | 'next') {
114114
@input="handleInput"
115115
@change="handleChange"
116116
@pointerdown="isSeeking = true"
117-
>
118-
<div class="w-full flex items-center justify-between text-xs text-text tabular-nums">
117+
> -->
118+
<hana-range-input
119+
id="music-progress"
120+
:min="0"
121+
:max="1"
122+
:step="0.001"
123+
:value="currentProgress"
124+
:aria-valuemin="0"
125+
:aria-valuemax="1"
126+
:aria-valuenow="progressPercent"
127+
aria-label="播放进度"
128+
@input="handleInput"
129+
@change="handleChange"
130+
@pointerdown="isSeeking = true"
131+
/>
132+
<div class="w-full flex items-center justify-between text-xs text-text tabular-nums dark:text-hana-white-700">
119133
<p>{{ formatTime(currentTime) }}</p>
120134
<p>{{ formatTime(curMusic.seconds) }}</p>
121135
</div>
@@ -130,4 +144,13 @@ function stepMusic(type: 'prev' | 'next') {
130144
oklch(0.93 0.0358 205.23) calc(var(--progress) * 100%)
131145
);
132146
}
147+
148+
.dark {
149+
#music-progress {
150+
background: linear-gradient(to right,
151+
oklch(0.75 0.0883 226.04) calc(var(--progress) * 100%),
152+
oklch(0.93 0.0358 205.23) calc(var(--progress) * 100%)
153+
);
154+
}
155+
}
133156
</style>

0 commit comments

Comments
 (0)