Added controls to player
This commit is contained in:
1 parent
967f84ca40
commit
53e584b528
2 files changed
+28
-8
No files matched your search
@@ -1,11 +1,11 @@
|
|||||||
<script setup lang="tsx">
|
<script setup lang="tsx">
|
||||||
const widthFixerRef = useTemplateRef("width-fixer")
|
const widthFixerRef = useTemplateRef("width-fixer-ref")
|
||||||
const playerRef = useTemplateRef("player")
|
const playerRef = useTemplateRef("player-ref")
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
const resizePlayer = () => {
|
const resizePlayer = () => {
|
||||||
if (playerRef.value && widthFixerRef.value)
|
if (playerRef.value && widthFixerRef.value)
|
||||||
playerRef.value.style.width = `calc(${widthFixerRef.value.clientWidth}px + 2rem)`
|
playerRef.value.style.width = `calc(${widthFixerRef.value.clientWidth}px)`
|
||||||
}
|
}
|
||||||
|
|
||||||
const resizeObserver = new ResizeObserver(() => {
|
const resizeObserver = new ResizeObserver(() => {
|
||||||
@@ -17,11 +17,12 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const song = useSong()
|
const song = useSong()
|
||||||
|
const { isPlaying, play, pause, next, prev } = usePlayer()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div id="width-fixer" ref="width-fixer"></div>
|
<div id="width-fixer" ref="width-fixer-ref"></div>
|
||||||
<article class="player" ref="player" :class="{ active: song }">
|
<article class="player" ref="player-ref" :class="{ active: song }">
|
||||||
<template v-if="song">
|
<template v-if="song">
|
||||||
<div class="track">
|
<div class="track">
|
||||||
<NuxtImg
|
<NuxtImg
|
||||||
@@ -36,7 +37,14 @@ const song = useSong()
|
|||||||
<ArtistName :artists="song.artists" class="artists" />
|
<ArtistName :artists="song.artists" class="artists" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="controls"></div>
|
<div class="controls">
|
||||||
|
<Icon name="lucide:shuffle" />
|
||||||
|
<Icon name="lucide:skip-back" @click="prev()" />
|
||||||
|
<Icon name="lucide:pause" v-if="isPlaying" @click="pause()" />
|
||||||
|
<Icon name="lucide:play" v-else @click="play()" />
|
||||||
|
<Icon name="lucide:skip-forward" @click="next()" />
|
||||||
|
<Icon name="lucide:repeat" />
|
||||||
|
</div>
|
||||||
<div class="misc-btns"></div>
|
<div class="misc-btns"></div>
|
||||||
</template>
|
</template>
|
||||||
</article>
|
</article>
|
||||||
@@ -52,11 +60,10 @@ const song = useSong()
|
|||||||
.player {
|
.player {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 1rem;
|
bottom: 1rem;
|
||||||
margin: 0 -1rem;
|
|
||||||
|
|
||||||
height: 72px;
|
height: 72px;
|
||||||
|
|
||||||
border-radius: $border-radius-standard;
|
border-radius: $border-radius-lg;
|
||||||
border: 1px solid $color-border;
|
border: 1px solid $color-border;
|
||||||
|
|
||||||
display: grid;
|
display: grid;
|
||||||
@@ -82,6 +89,7 @@ const song = useSong()
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.track {
|
||||||
.details {
|
.details {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -96,4 +104,15 @@ img {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
border-radius: $border-radius-standard;
|
border-radius: $border-radius-standard;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.controls {
|
||||||
|
justify-content: center;
|
||||||
|
gap: 1rem;
|
||||||
|
|
||||||
|
span {
|
||||||
|
font-size: 24px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -9,3 +9,4 @@ $color-button-hover: rgba(255, 255, 255, 0.16);
|
|||||||
$color-attention: #fc8181;
|
$color-attention: #fc8181;
|
||||||
|
|
||||||
$border-radius-standard: 0.3rem;
|
$border-radius-standard: 0.3rem;
|
||||||
|
$border-radius-lg: 0.6rem;
|
||||||
Reference in new issue
Block a user