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

81 lines
2 KiB
Vue
Raw Normal View History

2022-10-13 15:18:47 +00:00
<template>
<div class="playback-controls" data-testid="footer-middle-pane">
<div class="buttons">
2022-12-02 16:17:37 +00:00
<LikeButton v-if="song" :song="song" class="like-btn" />
<button v-else type="button" /> <!-- a placeholder to maintain the flex layout -->
2022-10-13 15:18:47 +00:00
<button type="button" title="Play previous song" @click.prevent="playPrev">
2023-11-10 13:16:06 +00:00
<Icon :icon="faStepBackward" />
2022-10-13 15:18:47 +00:00
</button>
2022-12-02 16:17:37 +00:00
<PlayButton />
2022-10-13 15:18:47 +00:00
<button type="button" title="Play next song" @click.prevent="playNext">
2023-11-10 13:16:06 +00:00
<Icon :icon="faStepForward" />
2022-10-13 15:18:47 +00:00
</button>
2022-12-02 16:17:37 +00:00
<RepeatModeSwitch class="repeat-mode-btn" />
2022-10-13 15:18:47 +00:00
</div>
</div>
</template>
<script lang="ts" setup>
import { faStepBackward, faStepForward } from '@fortawesome/free-solid-svg-icons'
2022-12-23 15:44:34 +00:00
import { ref } from 'vue'
2022-10-13 15:18:47 +00:00
import { playbackService } from '@/services'
2022-12-23 15:44:34 +00:00
import { requireInjection } from '@/utils'
2022-10-13 15:18:47 +00:00
import { CurrentSongKey } from '@/symbols'
import RepeatModeSwitch from '@/components/ui/RepeatModeSwitch.vue'
import LikeButton from '@/components/song/SongLikeButton.vue'
import PlayButton from '@/components/ui/FooterPlayButton.vue'
2022-12-23 15:44:34 +00:00
const song = requireInjection(CurrentSongKey, ref())
2022-10-13 15:18:47 +00:00
const playPrev = async () => await playbackService.playPrev()
const playNext = async () => await playbackService.playNext()
</script>
<style lang="scss" scoped>
.playback-controls {
flex: 1;
display: flex;
flex-direction: column;
place-content: center;
place-items: center;
2022-12-23 15:44:34 +00:00
:fullscreen & {
transform: scale(1.2);
}
2022-10-13 15:18:47 +00:00
}
.buttons {
color: var(--color-text-secondary);
display: flex;
place-content: center;
place-items: center;
gap: 2rem;
@media screen and (max-width: 768px) {
gap: .75rem;
}
button {
color: currentColor;
font-size: 1.5rem;
width: 2.5rem;
aspect-ratio: 1/1;
transition: all .2s ease-in-out;
transition-property: color, border, transform;
&:hover {
color: var(--color-text-primary);
}
&.like-btn, &.repeat-mode-btn {
font-size: 1rem;
}
}
}
</style>