koel/resources/assets/js/components/layout/app-footer/FooterSongInfo.vue

82 lines
2 KiB
Vue
Raw Normal View History

2022-10-13 15:18:47 +00:00
<template>
<div
:class="{ playing: song?.playback_state === 'Playing' }"
:draggable="draggable"
2024-04-04 22:20:42 +00:00
class="song-info px-6 py-0 flex items-center content-start w-[84px] md:w-80 gap-5"
@dragstart="onDragStart"
>
2024-04-04 22:20:42 +00:00
<span class="album-thumb block h-[55%] md:h-3/4 aspect-square rounded-full bg-cover" />
<div v-if="song" class="meta overflow-hidden hidden md:block">
<h3 class="title text-ellipsis overflow-hidden whitespace-nowrap">{{ song.title }}</h3>
<a
class="artist text-ellipsis overflow-hidden whitespace-nowrap block text-[0.9rem] !text-k-text-secondary hover:!text-k-accent"
:href="`/#/artist/${song.artist_id}`"
>
{{ song.artist_name }}
</a>
2022-10-13 15:18:47 +00:00
</div>
</div>
</template>
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { defaultCover, requireInjection } from '@/utils'
import { CurrentSongKey } from '@/symbols'
import { useDraggable } from '@/composables'
const { startDragging } = useDraggable('songs')
2022-10-13 15:18:47 +00:00
2022-12-23 15:44:34 +00:00
const song = requireInjection(CurrentSongKey, ref())
2022-10-13 15:18:47 +00:00
const cover = computed(() => song.value?.album_cover || defaultCover)
2024-04-04 22:20:42 +00:00
const coverBackgroundImage = computed(() => `url(${ cover.value })`)
const draggable = computed(() => Boolean(song.value))
const onDragStart = (event: DragEvent) => {
if (song.value) {
startDragging(event, [song.value])
}
}
2022-10-13 15:18:47 +00:00
</script>
2024-04-04 20:13:35 +00:00
<style lang="postcss" scoped>
2022-10-13 15:18:47 +00:00
.song-info {
:fullscreen & {
2024-04-04 22:20:42 +00:00
@apply pl-0;
2022-10-13 15:18:47 +00:00
}
.album-thumb {
2024-04-04 22:20:42 +00:00
background-image: v-bind(coverBackgroundImage);
2022-12-23 15:44:34 +00:00
:fullscreen & {
2024-04-04 22:20:42 +00:00
@apply h-20;
2022-12-23 15:44:34 +00:00
}
2022-10-13 15:18:47 +00:00
}
.meta {
2022-12-23 15:44:34 +00:00
:fullscreen & {
2024-04-04 22:20:42 +00:00
@apply -mt-72 origin-bottom-left absolute overflow-hidden;
2022-12-23 15:44:34 +00:00
.title {
2024-04-04 22:20:42 +00:00
@apply text-5xl mb-[0.4rem] font-bold;
2022-12-23 15:44:34 +00:00
}
.artist {
2024-04-04 22:20:42 +00:00
@apply text-3xl w-fit;
2022-12-23 15:44:34 +00:00
}
}
2022-10-13 15:18:47 +00:00
}
&.playing .album-thumb {
2024-04-04 22:20:42 +00:00
@apply motion-reduce:animate-none;
2022-10-13 15:18:47 +00:00
animation: spin 30s linear infinite;
}
}
@keyframes spin {
100% {
transform: rotate(360deg);
}
}
</style>