From 70f02d38e0e9ede9261e311b888db60e428890d2 Mon Sep 17 00:00:00 2001 From: booploops <49113086+booploops@users.noreply.github.com> Date: Wed, 12 Jan 2022 06:01:39 -0800 Subject: [PATCH 1/6] improvements to library-songs --- index.js | 7 ++ src/renderer/index.js | 47 +++++++- src/renderer/style.less | 107 ++++++++++++----- .../views/components/mediaitem-list-item.ejs | 20 +++- src/renderer/views/main.ejs | 17 ++- src/renderer/views/pages/library-songs.ejs | 112 ++++++++++++------ src/renderer/views/svg/in-library.svg | 13 ++ 7 files changed, 235 insertions(+), 88 deletions(-) create mode 100644 src/renderer/views/svg/in-library.svg diff --git a/index.js b/index.js index 1a8a4bab..ad570d3a 100644 --- a/index.js +++ b/index.js @@ -22,6 +22,13 @@ const configDefaults = { "followedArtists": [], "favoriteItems": [] }, + "libraryPrefs": { + "songs": { + "sort": "name", + "sortOrder": "asc", + "size": "normal" + } + }, "audio": { "quality": "990", "seamless_audio": true, diff --git a/src/renderer/index.js b/src/renderer/index.js index e7ca0999..8d134733 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -658,7 +658,7 @@ const app = new Vue({ }) }, select_hasMediaItem(id) { - let found = this.selectedMediaItems.find(item => item.guid == id) + let found = this.selectedMediaItems.find(item => item.id == id) if (found) { return true } else { @@ -1306,13 +1306,14 @@ const app = new Vue({ }, searchLibrarySongs() { let self = this + let prefs = this.cfg.libraryPrefs.songs function sortSongs() { // sort this.library.songs.displayListing by song.attributes[self.library.songs.sorting] in descending or ascending order based on alphabetical order and numeric order // check if song.attributes[self.library.songs.sorting] is a number and if so, sort by number if not, sort by alphabetical order ignoring case self.library.songs.displayListing.sort((a, b) => { - let aa = a.attributes[self.library.songs.sorting] - let bb = b.attributes[self.library.songs.sorting] + let aa = a.attributes[prefs.sort] + let bb = b.attributes[prefs.sort] if (self.library.songs.sorting == "genre") { aa = a.attributes.genreNames[0] bb = b.attributes.genreNames[0] @@ -1323,13 +1324,13 @@ const app = new Vue({ if (bb == null) { bb = "" } - if (self.library.songs.sortOrder == "asc") { + if (prefs.sortOrder == "asc") { if (aa.toString().match(/^\d+$/) && bb.toString().match(/^\d+$/)) { return aa - bb } else { return aa.toString().toLowerCase().localeCompare(bb.toString().toLowerCase()) } - } else if (self.library.songs.sortOrder == "desc") { + } else if (prefs.sortOrder == "desc") { if (aa.toString().match(/^\d+$/) && bb.toString().match(/^\d+$/)) { return bb - aa } else { @@ -1551,7 +1552,6 @@ const app = new Vue({ this.library.songs.downloadState = 1 this.library.downloadNotification.show = true this.library.downloadNotification.message = "Updating library songs..." - function downloadChunk() { const params = { "include[library-songs]": "catalog,artists,albums", @@ -3077,6 +3077,41 @@ const app = new Vue({ } }) +Vue.component('animated-number', { + + template:"
{{ displayNumber }}
", + props: {'number': { default:0 }}, + + data () { + return { + displayNumber:0, + interval:false + } + }, + + ready () { + this.displayNumber = this.number ? this.number : 0; + }, + + watch: { + number () { + clearInterval(this.interval); + + if(this.number == this.displayNumber) { + return; + } + + this.interval = window.setInterval(() => { + if(this.displayNumber != this.number) { + var change = (this.number - this.displayNumber) / 10; + change = change >= 0 ? Math.ceil(change) : Math.floor(change); + this.displayNumber = this.displayNumber + change; + } + }, 20); + } + } +}) + Vue.component('sidebar-library-item', { template: '#sidebar-library-item', props: { diff --git a/src/renderer/style.less b/src/renderer/style.less index 1a278f0c..aea78420 100644 --- a/src/renderer/style.less +++ b/src/renderer/style.less @@ -496,6 +496,19 @@ input[type=range].web-slider::-webkit-slider-runnable-track { background: rgb(0 0 0 / 15%); flex-direction: column; padding: 20px 0px; + + &.libraryNotification { + flex-direction: row; + padding: 0px; + .message { + flex-grow: 1; + } + .spinner { + width: 46px; + height: 30px; + margin-left: 1em; + } + } } .app-sidebar-content { @@ -1843,24 +1856,29 @@ input[type="range"].web-slider.display--small::-webkit-slider-thumb { } .md-select { - padding: 5px 10px; - font-size: 1em; + width: 100%; + padding: 6px; + border-radius: 6px; + border: 1px solid rgba(200, 200, 200, 0.1); font-family: inherit; - border-radius: 4px; - border: 1px solid rgb(100 100 100 / 35%); - box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.3), 0px 1px 1px rgba(0, 0, 0, 0.4); - background: #363636; - color: #eee; -} + font-size: 14px; + background: rgba(100, 100, 100, 0.25); + color: #c8c8c8; + font-weight: 500; -.md-select:focus { - outline: none; -} + option { + font-size: 1em; + font-family: inherit; + padding: 8px 16px; + } -.md-select > option { - font-size: 1em; - font-family: inherit; - padding: 8px 16px; + optgroup { + background: #2c2c2c; + } + + &:focus { + outline: solid 1px var(--selected); + } } .sidebar-playlist { @@ -2238,6 +2256,27 @@ input[type="range"].web-slider.display--small::-webkit-slider-thumb { } } +// Library - Songs page +.library-page { + padding: 0px; + .library-header { + position: sticky; + top: 0; + left: 0; + border-bottom: 1px solid rgba(200, 200, 200, 0.05); + z-index: 6; + background: black; + padding: 0px 2em; + backdrop-filter: blur(32px); + background: rgba(24, 24, 24, 0.15); + top: var(--navigationBarHeight); + } + + .well { + margin: 2em; + } +} + /* Album / Playlist Page */ .playlist-page { --bgColor: transparent; @@ -2835,11 +2874,11 @@ input[type="range"].web-slider.display--small::-webkit-slider-thumb { } .info-rect { - width: 100%; height: 100%; display: flex; flex-flow: column; justify-content: center; + flex-grow: 1; } .title { @@ -2848,7 +2887,7 @@ input[type="range"].web-slider.display--small::-webkit-slider-thumb { .subtitle { width: 90%; - font-size: 12px; + font-size: .8em; opacity: 0.7; } @@ -2870,21 +2909,18 @@ input[type="range"].web-slider.display--small::-webkit-slider-thumb { justify-content: center; } - .content-rating { - text-transform: uppercase; - font-size: 10px; - border-radius: 3px; - background: rgb(200 200 200 / 15%); - width: 60px; - text-align: center; - padding: 5px; - margin-right: 12px; - flex: 0 0 auto; - font-weight: 500; - color: #ccc; + .explicit-icon { + background-image: url("./assets/explicit.svg"); + height: 12px; + width: 36px; + filter: contrast(0); + background-repeat: no-repeat; } .isLibrary { + flex: 0 0 auto; + width: 40px; + text-align: center; button { appearance: none; border: 0px; @@ -2913,6 +2949,19 @@ input[type="range"].web-slider.display--small::-webkit-slider-thumb { box-shadow: var(--mediaItemShadow); color: #eee; } + +// list item compact + &.compact { + height: 40px; + font-size: 12px; + .artwork { + display: none; + } + + .info-rect { + padding-left: 1em; + } + } } /* mediaitem-hrect */ diff --git a/src/renderer/views/components/mediaitem-list-item.ejs b/src/renderer/views/components/mediaitem-list-item.ejs index bd6f27fb..16764e82 100644 --- a/src/renderer/views/components/mediaitem-list-item.ejs +++ b/src/renderer/views/components/mediaitem-list-item.ejs @@ -8,7 +8,7 @@ :data-guid="guid" :data-islibrary="this.item.attributes.playParams.isLibrary ?? false" class="cd-mediaitem-list-item" - :class="{'mediaitem-selected': app.select_hasMediaItem(guid)}"> + :class="[{'mediaitem-selected': app.select_hasMediaItem(item.id)}, addClasses]">