koel/resources/assets/js/components/site-footer/index.vue

479 lines
9.5 KiB
Vue
Raw Normal View History

2015-12-13 04:42:28 +00:00
<template>
2016-06-25 16:05:24 +00:00
<footer id="mainFooter">
<div class="side player-controls" id="playerControls">
2016-10-31 04:28:12 +00:00
<i class="prev fa fa-step-backward control" @click.prevent="playPrev"/>
2016-06-25 16:05:24 +00:00
2016-10-31 08:15:32 +00:00
<span class="play control" v-if="song.playbackState !== 'playing'" @click.prevent="resume">
2016-06-25 16:05:24 +00:00
<i class="fa fa-play"></i>
</span>
<span class="pause control" v-else @click.prevent="pause">
<i class="fa fa-pause"></i>
</span>
2016-10-31 04:28:12 +00:00
<i class="next fa fa-step-forward control" @click.prevent="playNext"/>
2016-06-25 16:05:24 +00:00
</div>
<div class="media-info-wrap">
<div class="middle-pane">
<span class="album-thumb" v-if="cover" :style="{ backgroundImage: 'url('+cover+')' }"/>
2016-06-25 16:05:24 +00:00
<div class="progress" id="progressPane">
<h3 class="title">{{ song.title }}</h3>
<p class="meta">
<a class="artist" :href="'/#!/artist/'+song.artist.id">{{ song.artist.name }}</a>
<a class="album" :href="'/#!/album/'+song.album.id">{{ song.album.name }}</a>
2016-06-25 16:05:24 +00:00
</p>
<div class="plyr">
<audio crossorigin="anonymous" controls></audio>
</div>
2015-12-13 04:42:28 +00:00
</div>
2016-06-25 16:05:24 +00:00
</div>
2016-07-08 01:03:18 +00:00
<div class="other-controls" :class="{ 'with-gradient': prefs.showExtraPanel }">
2016-09-18 04:33:52 +00:00
<div class="wrapper" v-koel-clickaway="closeEqualizer">
2016-10-31 04:28:12 +00:00
<equalizer v-if="useEqualizer" v-show="showEqualizer"/>
<sound-bar v-show="song.playbackState === 'playing'"/>
2016-11-28 10:12:48 +00:00
<i v-if="song.id"
class="like control fa fa-heart"
:class="{ liked: song.liked }"
@click.prevent="like"/>
<span class="control info"
2016-07-08 01:03:18 +00:00
@click.prevent="toggleExtraPanel"
:class="{ active: prefs.showExtraPanel }">Info</span>
<i class="fa fa-sliders control equalizer"
2016-07-08 01:03:18 +00:00
v-if="useEqualizer"
@click="showEqualizer = !showEqualizer"
2016-10-31 04:28:12 +00:00
:class="{ active: showEqualizer }"/>
2016-11-24 08:50:22 +00:00
<a v-else class="queue control" :class="{ active: viewingQueue }" href="/#!/queue">
2016-07-10 18:28:14 +00:00
<i class="fa fa-list-ol"></i>
</a>
2016-07-08 01:03:18 +00:00
<span class="repeat control" :class="prefs.repeatMode" @click.prevent="changeRepeatMode">
<i class="fa fa-repeat"></i>
</span>
2016-11-24 08:50:22 +00:00
<volume/>
2016-07-08 01:03:18 +00:00
</div>
</div>
2016-06-25 16:05:24 +00:00
</div>
</footer>
</template>
2016-06-25 16:05:24 +00:00
<script>
2016-11-26 03:25:35 +00:00
import { playback } from '../../services'
import { isAudioContextSupported, event } from '../../utils'
import { songStore, favoriteStore, preferenceStore } from '../../stores'
2016-06-25 16:05:24 +00:00
2016-11-26 03:25:35 +00:00
import soundBar from '../shared/sound-bar.vue'
import equalizer from './equalizer.vue'
import volume from './volume.vue'
2016-06-25 16:05:24 +00:00
export default {
2016-11-26 03:25:35 +00:00
data () {
2016-06-25 16:05:24 +00:00
return {
song: songStore.stub,
viewingQueue: false,
prefs: preferenceStore.state,
showEqualizer: false,
2016-09-23 09:37:57 +00:00
cover: null,
2016-06-25 16:05:24 +00:00
/**
* Indicate if we should build and use an equalizer.
*
* @type {Boolean}
*/
2016-11-26 03:25:35 +00:00
useEqualizer: isAudioContextSupported()
}
2016-06-25 16:05:24 +00:00
},
2016-11-24 08:50:22 +00:00
components: { soundBar, equalizer, volume },
2016-06-25 16:05:24 +00:00
computed: {
/**
* Get the previous song in queue.
*
* @return {?Object}
*/
2016-11-26 03:25:35 +00:00
prev () {
return playback.previous
2016-06-25 16:05:24 +00:00
},
/**
* Get the next song in queue.
*
* @return {?Object}
*/
2016-11-26 03:25:35 +00:00
next () {
return playback.next
}
2016-06-25 16:05:24 +00:00
},
methods: {
/**
* Play the previous song in queue.
*/
2016-11-26 03:25:35 +00:00
playPrev () {
return playback.playPrev()
2016-06-25 16:05:24 +00:00
},
/**
* Play the next song in queue.
*/
2016-11-26 03:25:35 +00:00
playNext () {
return playback.playNext()
2016-06-25 16:05:24 +00:00
},
/**
* Resume the current song.
* If the current song is the stub, just play the first song in the queue.
*/
2016-11-26 03:25:35 +00:00
resume () {
2016-06-25 16:05:24 +00:00
if (!this.song.id) {
2016-11-26 03:25:35 +00:00
return playback.playFirstInQueue()
2016-06-25 16:05:24 +00:00
}
2016-11-26 03:25:35 +00:00
playback.resume()
2016-06-25 16:05:24 +00:00
},
/**
* Pause the playback.
*/
2016-11-26 03:25:35 +00:00
pause () {
playback.pause()
2016-06-25 16:05:24 +00:00
},
/**
* Change the repeat mode.
*/
2016-11-26 03:25:35 +00:00
changeRepeatMode () {
return playback.changeRepeatMode()
2016-06-25 16:05:24 +00:00
},
/**
* Like the current song.
*/
2016-11-26 03:25:35 +00:00
like () {
2016-06-25 16:05:24 +00:00
if (!this.song.id) {
2016-11-26 03:25:35 +00:00
return
2016-06-25 16:05:24 +00:00
}
2016-11-26 03:25:35 +00:00
favoriteStore.toggleOne(this.song)
2016-06-25 16:05:24 +00:00
},
/**
* Toggle hide or show the extra panel.
*/
2016-11-26 03:25:35 +00:00
toggleExtraPanel () {
preferenceStore.set('showExtraPanel', !this.prefs.showExtraPanel)
2016-06-25 16:05:24 +00:00
},
2016-09-18 04:33:52 +00:00
2016-11-26 03:25:35 +00:00
closeEqualizer () {
this.showEqualizer = false
}
2016-06-25 16:05:24 +00:00
},
2016-11-26 03:25:35 +00:00
created () {
2016-06-25 16:05:24 +00:00
event.on({
/**
2016-09-23 09:37:57 +00:00
* Listen to song:played event to set the current playing song and the cover image.
2016-06-25 16:05:24 +00:00
*
* @param {Object} song
*
* @return {Boolean}
*/
2016-09-23 09:37:57 +00:00
'song:played': song => {
2016-11-26 03:25:35 +00:00
this.song = song
this.cover = this.song.album.cover
2016-09-23 09:37:57 +00:00
},
2016-06-25 16:05:24 +00:00
/**
* Listen to main-content-view:load event and highlight the Queue icon if
* the Queue screen is being loaded.
*/
2016-11-26 03:25:35 +00:00
'main-content-view:load': view => {
this.viewingQueue = view === 'queue'
},
2016-06-25 16:05:24 +00:00
2016-11-26 03:25:35 +00:00
'koel:teardown': () => {
this.song = songStore.stub
}
})
}
}
2016-06-25 16:05:24 +00:00
</script>
2016-06-25 16:05:24 +00:00
<style lang="sass">
@import "../../../sass/partials/_vars.scss";
@import "../../../sass/partials/_mixins.scss";
@mixin hasSoftGradientOnTop($startColor) {
position: relative;
// Add a reverse gradient here to elimate the "hard cut" feel when the
// song list is too long.
&::before {
$gradientHeight: 2*$footerHeight/3;
content: " ";
position: absolute;
width: 100%;
height: $gradientHeight;
top: -$gradientHeight;
left: 0;
// Safari 8 won't recognize rgba(255, 255, 255, 0) and treat it as black.
// rgba($startColor, 0) is a workaround.
background-image: linear-gradient(to bottom, rgba($startColor, 0) 0%, rgba($startColor, 1) 100%);
pointer-events: none; // click-through
}
}
#mainFooter {
background: $color2ndBgr;
position: fixed;
width: 100%;
height: $footerHeight;
bottom: 0;
left: 0;
border-top: 1px solid $colorMainBgr;
display: flex;
flex: 1;
z-index: 1000;
.media-info-wrap {
flex: 1;
display: flex;
}
.other-controls {
@include vertical-center();
@include hasSoftGradientOnTop($colorMainBgr);
&.with-gradient {
@include hasSoftGradientOnTop($colorExtraBgr);
}
2016-01-11 15:25:58 +00:00
2016-06-25 16:05:24 +00:00
text-transform: uppercase;
flex: 0 0 $extraPanelWidth;
color: $colorLink;
2016-01-11 15:25:58 +00:00
2016-07-08 01:03:18 +00:00
.wrapper {
display: inline-table;
}
2016-06-25 16:05:24 +00:00
.control {
display: inline-block;
padding: 0 8px;
2015-12-13 04:42:28 +00:00
2016-06-25 16:05:24 +00:00
&.active {
color: $colorHighlight;
}
2016-06-25 16:05:24 +00:00
&:last-child {
padding-right: 0;
}
}
2016-01-11 15:25:58 +00:00
2016-06-25 16:05:24 +00:00
.repeat {
position: relative;
2015-12-13 04:42:28 +00:00
2016-06-25 16:05:24 +00:00
&.REPEAT_ALL, &.REPEAT_ONE {
color: $colorHighlight;
}
2016-06-25 16:05:24 +00:00
&.REPEAT_ONE::after {
content: "1";
position: absolute;
top: 0;
left: 0;
font-weight: 700;
font-size: .5rem;
text-align: center;
width: 100%;
}
}
2015-12-13 04:42:28 +00:00
2016-06-25 16:05:24 +00:00
.like {
&:hover {
}
2015-12-13 04:42:28 +00:00
2016-06-25 16:05:24 +00:00
&.liked {
color: $colorHeart;
}
2015-12-13 04:42:28 +00:00
}
2016-06-25 16:05:24 +00:00
@media only screen and (max-width: 768px) {
position: absolute !important;
right: 0;
top: 0;
2016-07-08 01:03:18 +00:00
height: 100%;
2016-06-26 10:59:10 +00:00
width: 188px;
2016-06-25 16:05:24 +00:00
&::before {
display: none;
}
.queue {
display: none;
}
.control {
padding: 0 8px;
}
2015-12-13 04:42:28 +00:00
}
2016-06-25 16:05:24 +00:00
}
2016-06-26 10:59:10 +00:00
@media only screen and (max-width: 768px) {
height: $footerHeightMobile;
}
2016-06-25 16:05:24 +00:00
}
#playerControls {
@include vertical-center();
flex: 0 0 256px;
font-size: 1.8rem;
background: $colorPlayerControlsBgr;
@include hasSoftGradientOnTop($colorSidebarBgr);
.prev, .next {
transition: .3s;
}
.play, .pause {
font-size: 2rem;
display: inline-block;
width: 42px;
height: 42px;
border-radius: 50%;
line-height: 40px;
text-align: center;
border: 1px solid #a0a0a0;
margin: 0 16px;
text-indent: 2px;
}
.pause {
text-indent: 0;
font-size: 18px;
}
.enabled {
opacity: 1;
}
@media only screen and (max-width: 768px) {
flex: 1;
&::before {
display: none;
}
}
}
.middle-pane {
flex: 1;
display: flex;
.album-thumb {
flex: 0 0 $footerHeight;
height: $footerHeight;
background: url(/public/img/covers/unknown-album.png);
background-size: $footerHeight;
position: relative;
}
@include hasSoftGradientOnTop($colorMainBgr);
@media only screen and (max-width: 768px) {
width: 100%;
position: absolute;
top: 0;
left: 0;
height: 8px;
.album-thumb {
display: none;
2015-12-13 04:42:28 +00:00
}
2016-06-25 16:05:24 +00:00
::before {
display: none;
2015-12-13 04:42:28 +00:00
}
2016-06-25 16:05:24 +00:00
}
}
#progressPane {
flex: 1;
text-align: center;
padding-top: 16px;
line-height: 18px;
background: rgba(1, 1, 1, .2);
position: relative;
.meta {
font-size: .9rem;
a {
&:hover {
color: $colorHighlight;
}
}
}
// Some little tweaks here and there
.plyr {
width: 100%;
position: absolute;
top: 0;
left: 0;
}
2016-08-07 13:05:35 +00:00
.plyr__progress {
overflow: hidden;
height: 1px;
html.touch &, .middle-pane:hover & {
overflow: visible;
height: $plyr-volume-track-height;
}
}
2016-06-25 16:05:24 +00:00
.plyr__controls {
position: absolute;
top: 0;
left: 0;
width: 100%;
padding: 0;
}
.plyr__controls--left, .plyr__controls--right {
display: none;
}
@media only screen and (max-width: 768px) {
.meta, .title {
display: none;
2015-12-13 04:42:28 +00:00
}
2016-06-26 10:59:10 +00:00
top: -15px;
2016-06-25 16:05:24 +00:00
padding-top: 0;
2016-06-26 10:59:10 +00:00
width: 100%;
position: absolute;
2016-06-26 10:59:10 +00:00
.plyr {
&__progress {
height: 16px;
2016-06-26 10:59:10 +00:00
&--buffer[value],
&--played[value],
&--seek[type='range'] {
height: 16px;
2015-12-13 04:42:28 +00:00
}
2016-06-26 10:59:10 +00:00
}
2015-12-13 04:42:28 +00:00
}
2016-06-25 16:05:24 +00:00
}
}
2015-12-13 04:42:28 +00:00
</style>