koel/resources/assets/js/components/main-wrapper/main-content/home.vue

158 lines
4.2 KiB
Vue
Raw Normal View History

2016-02-07 04:23:12 +00:00
<template>
<section id="homeWrapper">
<h1 class="heading">
<span>{{ greeting }}</span>
</h1>
<div class="main-scroll-wrap">
<section class="recent">
<h1>Recently Played</h1>
<song-list
v-show="songState.recent.length"
:items="songState.recent"
:sortable="false">
</song-list>
<p class="none" v-show="!songState.recent.length">No songs played yet. What ya waiting for?</p>
</section>
<section v-if="topSongs.length">
2016-02-07 04:23:12 +00:00
<h1>Most Played Songs</h1>
2016-02-08 14:33:07 +00:00
<song-list :items="topSongs" :sortable="false" type="top-songs"></song-list>
2016-02-07 04:23:12 +00:00
</section>
<section class="top-artists" v-if="topArtists.length">
2016-02-07 04:23:12 +00:00
<h1>Top Artists</h1>
<div class="wrapper">
<artist-item v-for="artist in topArtists" :artist="artist"></artist-item>
<span class="item"></span>
</div>
</section>
<section class="top-albums" v-if="topAlbums.length">
2016-02-07 04:23:12 +00:00
<h1>Top Albums</h1>
<div class="wrapper">
<album-item v-for="album in topAlbums" :album="album"></album-item>
<span class="item"></span>
</div>
</section>
</div>
</section>
</template>
<script>
import _ from 'lodash';
import isMobile from 'ismobilejs';
import playback from '../../../services/playback';
import songStore from '../../../stores/song';
import albumStore from '../../../stores/album';
import artistStore from '../../../stores/artist';
import userStore from '../../../stores/user';
import albumItem from '../../shared/album-item.vue';
import artistItem from '../../shared/artist-item.vue';
import hasSongList from '../../../mixins/has-song-list';
export default {
mixins: [hasSongList],
components: { albumItem, artistItem },
data () {
return {
isPhone: isMobile.phone,
songState: songStore.state,
greetings: [
'Oh hai!',
'Hey, %s!',
'Howdy, %s!',
'Yo!',
'Hows it going, %s?',
'Sup, %s?',
'Hows life, %s?',
'Hows your day, %s?',
'How have you been, %s?',
],
};
},
computed: {
greeting() {
return _.sample(this.greetings).replace('%s', userStore.current().name);
},
2016-02-08 13:14:51 +00:00
/**
* The most played songs.
*
* @return {Array.<Object>}
*/
2016-02-07 04:23:12 +00:00
topSongs() {
return songStore.getMostPlayed();
},
2016-02-08 13:14:51 +00:00
/**
* The most played albums.
*
* @return {Array.<Object>}
*/
2016-02-07 04:23:12 +00:00
topAlbums() {
return albumStore.getMostPlayed();
},
2016-02-08 13:14:51 +00:00
/**
* The most played artists.
* @return {Array.<Object>}
*/
2016-02-07 04:23:12 +00:00
topArtists() {
return artistStore.getMostPlayed();
},
},
};
</script>
<style lang="sass">
@import "resources/assets/sass/partials/_vars.scss";
@import "resources/assets/sass/partials/_mixins.scss";
#homeWrapper {
button.play-shuffle, button.del {
i {
margin-right: 0 !important;
}
}
.song-list-wrap {
padding: 0 !important;
}
.none {
color: $color2ndText;
padding: 0;
a {
color: $colorHighlight;
}
}
.top-artists .wrapper, .top-albums .wrapper {
@include artist-album-wrapper();
}
.main-scroll-wrap {
section {
margin-bottom: 48px;
}
h1 {
font-size: 18px;
margin: 0 0 24px;
font-weight: $fontWeight_UltraThin;
}
}
}
</style>