koel/resources/assets/js/components/main-wrapper/sidebar/index.vue

268 lines
7.7 KiB
Vue
Raw Normal View History

2015-12-13 04:42:28 +00:00
<template>
<nav class="side side-nav" id="sidebar" :class="{ showing: showing }">
<section class="music">
<h1>Your Music</h1>
<ul class="menu">
<li>
2015-12-24 09:50:56 +00:00
<a class="queue"
:class="[currentView == 'queue' ? 'active' : '']"
@click.prevent="$root.loadMainView('queue')"
@dragleave="removeDroppableState"
@dragover.prevent="allowDrop"
@drop.stop="handleDrop($event)">Current Queue</a>
2015-12-13 04:42:28 +00:00
</li>
<li>
<a class="songs" :class="[currentView == 'songs' ? 'active' : '']"
@click.prevent="$root.loadMainView('songs')">All Songs</a>
</li>
<li>
<a class="albums" :class="[currentView == 'albums' ? 'active' : '']"
@click.prevent="$root.loadMainView('albums')">Albums</a>
</li>
<li>
<a class="artists" :class="[currentView == 'artists' ? 'active' : '']"
@click.prevent="$root.loadMainView('artists')">Artists</a>
</li>
</ul>
</section>
<playlists :current-view="currentView"></playlists>
<section v-if="user.current.is_admin" class="manage">
<h1>Manage</h1>
<ul class="menu">
<li>
<a class="settings" :class="[currentView == 'settings' ? 'active' : '']"
@click.prevent="$root.loadMainView('settings')">Settings</a>
</li>
<li>
<a class="users" :class="[currentView == 'users' ? 'active' : '']"
@click.prevent="$root.loadMainView('users')">Users</a>
</li>
</ul>
</section>
2015-12-27 14:06:10 +00:00
<a
href="https://github.com/phanan/koel/releases"
target="_blank"
v-show="user.current.is_admin && sharedState.currentVersion < sharedState.latestVersion"
class="new-ver">
Koel version {{ sharedState.latestVersion }} is available!
</a>
2015-12-13 04:42:28 +00:00
</nav>
</template>
<script>
import isMobile from 'ismobilejs';
2015-12-24 09:50:56 +00:00
import $ from 'jquery';
2015-12-13 04:42:28 +00:00
import playlists from './playlists.vue';
import userStore from '../../../stores/user';
2015-12-24 09:50:56 +00:00
import songStore from '../../../stores/song';
import queueStore from '../../../stores/queue';
2015-12-27 14:06:10 +00:00
import sharedStore from '../../../stores/shared';
2015-12-13 04:42:28 +00:00
export default {
components: { playlists },
data() {
return {
currentView: 'queue',
user: userStore.state,
showing: !isMobile.phone,
2015-12-27 14:06:10 +00:00
sharedState: sharedStore.state,
2015-12-13 04:42:28 +00:00
};
},
2015-12-24 09:50:56 +00:00
methods: {
/**
* Remove the droppable state when a dragleave event occurs on the playlist's DOM element.
*
* @param {Object} e The dragleave event.
*/
removeDroppableState(e) {
$(e.target).removeClass('droppable');
},
/**
* Add a "droppable" class and set the drop effect when an item is dragged over "Queue" menu.
*
* @param {Object} e The dragover event.
*/
allowDrop(e) {
$(e.target).addClass('droppable');
e.dataTransfer.dropEffect = 'move';
return false;
},
/**
* Handle songs dropped to our Queue menu item.
*
* @param {Object} e The event
*
* @return {False}
*/
handleDrop(e) {
this.removeDroppableState(e);
var songs = songStore.byIds(e.dataTransfer.getData('text/plain').split(','));
if (!songs.length) {
return false;
}
queueStore.queue(songs);
return false;
},
},
2015-12-13 04:42:28 +00:00
events: {
'main-content-view:load': function (view) {
this.currentView = view;
// Hide the sidebar if on mobile
if (isMobile.phone) {
this.showing = false;
}
return true;
2015-12-13 04:42:28 +00:00
},
/**
* Listen to sidebar:toggle event to show or hide the sidebar.
* This should only be triggered on a mobile device.
*/
'sidebar:toggle': function () {
this.showing = !this.showing;
},
},
};
</script>
<style lang="sass">
@import "resources/assets/sass/partials/_vars.scss";
@import "resources/assets/sass/partials/_mixins.scss";
#sidebar {
flex: 0 0 256px;
background-color: $colorSidebarBgr;
padding: 22px 0 0;
max-height: calc(100vh - #{$headerHeight + $footerHeight});
overflow: auto;
2015-12-20 15:55:32 +00:00
// Enable scroll with momentum on touch devices
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
2015-12-24 09:50:56 +00:00
a.droppable {
transform: scale(1.2);
transition: .3s;
transform-origin: center left;
color: $colorMainText;
background-color: rgba(0, 0, 0, .3);
}
2015-12-13 04:42:28 +00:00
section {
margin-bottom: 32px;
h1 {
text-transform: uppercase;
letter-spacing: 1px;
padding: 0 16px;
margin-bottom: 12px;
i {
float: right;
}
}
a {
display: block;
height: 36px;
line-height: 36px;
padding: 0 12px 0 16px;
border-left: 4px solid transparent;
&.active, &:hover {
border-left-color: $colorHighlight;
color: $colorLinkHovered;
background: rgba(255, 255, 255, .05);
}
&:hover {
border-left-color: darken($colorHighlight, 20%);
}
&::before {
width: 24px;
display: inline-block;
font-family: FontAwesome;
}
&.queue::before {
content: "\f0cb";
}
&.songs::before {
content: "\f001";
}
&.albums::before {
content: "\f152";
}
&.artists::before {
content: "\f130";
}
&.settings::before {
content: "\f013";
}
&.users::before {
content: "\f0c0";
}
}
}
2015-12-27 14:06:10 +00:00
.new-ver {
margin: 16px;
padding: 16px;
border: 1px solid $color2ndText;
color: $colorMainText;
opacity: .3;
font-size: 90%;
display: block;
transition: .3s;
&:hover {
opacity: .7;
}
}
2015-12-13 04:42:28 +00:00
@media only screen
2016-01-06 16:41:59 +00:00
and (max-device-width : 667px) {
2015-12-13 04:42:28 +00:00
position: fixed;
height: calc(100vh - #{$headerHeight + $footerHeight});
padding-bottom: $footerHeight; // make sure the footer can never overlap the content
width: 100%;
z-index: 99;
top: $headerHeight;
left: -100%;
transition: left .3s ease-in;
&.showing {
left: 0;
}
}
}
</style>