koel/resources/assets/js/components/playlist/PlaylistSidebarList.vue

65 lines
1.9 KiB
Vue
Raw Normal View History

2022-04-15 14:24:30 +00:00
<template>
<section id="playlists">
2022-07-15 07:23:55 +00:00
<h1>
<span>Playlists</span>
<icon
:icon="faCirclePlus"
class="control create"
data-testid="sidebar-create-playlist-btn"
2022-04-15 14:24:30 +00:00
role="button"
title="Create a new playlist or folder"
@click.stop.prevent="requestContextMenu"
2022-07-15 07:23:55 +00:00
/>
2022-04-15 14:24:30 +00:00
</h1>
<ul>
<PlaylistSidebarItem :list="{ name: 'Favorites', songs: favorites }"/>
<PlaylistSidebarItem :list="{ name: 'Recently Played', songs: [] }"/>
<PlaylistFolderSidebarItem v-for="folder in folders" :key="folder.id" :folder="folder"/>
<PlaylistSidebarItem v-for="playlist in orphanPlaylists" :key="playlist.id" :list="playlist"/>
2022-04-15 14:24:30 +00:00
</ul>
</section>
</template>
2022-04-15 17:00:08 +00:00
<script lang="ts" setup>
2022-07-15 07:23:55 +00:00
import { faCirclePlus } from '@fortawesome/free-solid-svg-icons'
import { computed, toRef } from 'vue'
import { favoriteStore, playlistFolderStore, playlistStore } from '@/stores'
import { eventBus, requireInjection } from '@/utils'
import { MessageToasterKey } from '@/symbols'
2022-04-15 14:24:30 +00:00
import PlaylistSidebarItem from '@/components/playlist/PlaylistSidebarItem.vue'
import PlaylistFolderSidebarItem from '@/components/playlist/PlaylistFolderSidebarItem.vue'
2022-04-15 14:24:30 +00:00
const toaster = requireInjection(MessageToasterKey)
2022-04-15 14:24:30 +00:00
const folders = toRef(playlistFolderStore.state, 'folders')
2022-04-20 12:41:50 +00:00
const playlists = toRef(playlistStore.state, 'playlists')
const favorites = toRef(favoriteStore.state, 'songs')
2022-04-15 14:24:30 +00:00
const orphanPlaylists = computed(() => playlists.value.filter(playlist => playlist.folder_id === null))
2022-04-15 17:00:08 +00:00
const requestContextMenu = (event: MouseEvent) => eventBus.emit('CREATE_NEW_PLAYLIST_CONTEXT_MENU_REQUESTED', event)
2022-04-15 14:24:30 +00:00
</script>
<style lang="scss">
#playlists {
2022-07-15 07:23:55 +00:00
h1 {
display: flex;
align-items: center;
span {
flex: 1;
}
}
2022-04-15 14:24:30 +00:00
.control.create {
transition: .3s;
&.creating {
transform: rotate(135deg);
}
}
}
</style>