From f0d4f1c3b085a19b32b9615b4a3c8e316cc21086 Mon Sep 17 00:00:00 2001 From: Ondrej Zara Date: Wed, 11 Mar 2020 22:46:28 +0100 Subject: [PATCH] library wip --- app/css/cyp.less | 2 + app/css/elements/artist.less | 3 + app/css/elements/library.less | 3 + app/cyp.css | 2 +- app/icons/checkbox-marked-outline.svg | 1 + app/icons/chevron-double-right.svg | 1 + app/index.html | 14 +--- app/js/component.js | 12 --- app/js/elements/app.js | 9 ++- app/js/elements/artist.js | 17 ++++ app/js/elements/library.js | 63 +++++++++++++++ app/js/elements/playlist.js | 2 +- app/js/elements/song.js | 2 +- app/js/icons.js | 112 ++++++++++++++------------ app/js/item.js | 14 ++++ app/js/mpd-mock.js | 12 +-- app/js/selection.js | 2 +- 17 files changed, 178 insertions(+), 93 deletions(-) create mode 100644 app/css/elements/artist.less create mode 100644 app/css/elements/library.less create mode 100644 app/icons/checkbox-marked-outline.svg create mode 100644 app/icons/chevron-double-right.svg create mode 100644 app/js/elements/artist.js create mode 100644 app/js/elements/library.js create mode 100644 app/js/item.js diff --git a/app/css/cyp.less b/app/css/cyp.less index 4deb827..c86400f 100644 --- a/app/css/cyp.less +++ b/app/css/cyp.less @@ -82,3 +82,5 @@ select { @import "elements/yt.less"; @import "elements/range.less"; @import "elements/playlist.less"; +@import "elements/library.less"; +@import "elements/artist.less"; diff --git a/app/css/elements/artist.less b/app/css/elements/artist.less new file mode 100644 index 0000000..e0a565d --- /dev/null +++ b/app/css/elements/artist.less @@ -0,0 +1,3 @@ +cyp-artist { + .item; +} diff --git a/app/css/elements/library.less b/app/css/elements/library.less new file mode 100644 index 0000000..0576380 --- /dev/null +++ b/app/css/elements/library.less @@ -0,0 +1,3 @@ +cyp-library { + +} diff --git a/app/cyp.css b/app/cyp.css index 5dd7573..ae2d49d 100644 --- a/app/cyp.css +++ b/app/cyp.css @@ -1 +1 @@ -*,*::before,*::after{box-sizing:inherit}html{background-color:var(--fg)}body{margin:0}main{flex:auto;overflow:auto}header,footer{flex:none;z-index:1;box-shadow:var(--box-shadow)}footer{position:relative;overflow:hidden;height:56px}@media (max-width:480px){footer{height:40px}}input,select,button{color:inherit;font:inherit}button{-webkit-appearance:none;-moz-appearance:none;appearance:none;flex-direction:row;align-items:center;flex:none;background-color:transparent;padding:0;border:none;line-height:1;cursor:pointer}button:not([hidden]){display:flex}@media (hover:hover){button:not(:disabled):not(:hover):not(.-thumb){opacity:.9}}select{background-color:transparent;border:1px solid var(--fg);border-radius:4px;padding:2px 4px}@font-face{font-family:"Lato";src:url("font/LatoLatin-Regular.woff2") format("woff2");font-style:normal;font-weight:normal}@font-face{font-family:"Lato";src:url("font/LatoLatin-Bold.woff2") format("woff2");font-style:bold;font-weight:normal}.icon{width:24px}.icon path:not([fill]),.icon polygon:not([fill]),.icon circle:not([fill]){fill:currentColor}.flex-row{flex-direction:row;align-items:center}.flex-row:not([hidden]){display:flex}.flex-column{flex-direction:column}.flex-column:not([hidden]){display:flex}.ellipsis{overflow:hidden;text-overflow:ellipsis}.selectable{border-left:var(--border-width) solid transparent;cursor:pointer}.selectable.selected{border-left-color:var(--primary);background-color:var(--primary-tint)}.item{flex-direction:row;align-items:center;border-left:var(--border-width) solid transparent;cursor:pointer;padding:8px;padding-left:calc(8px - var(--border-width))}.item:not([hidden]){display:flex}.item.selected{border-left-color:var(--primary);background-color:var(--primary-tint)}.item:nth-child(odd){background-color:var(--bg-alt)}.item>.icon{flex:none;margin-right:var(--icon-spacing);filter:drop-shadow(var(--text-shadow))}.item .title{font-size:var(--font-size-large);min-width:0;overflow:hidden;text-overflow:ellipsis}.item button:first-of-type{margin-left:auto}.item button .icon{width:32px}.component header{flex-direction:row;align-items:center;padding:var(--spacing)}.component header:not([hidden]){display:flex}.component header button{font-size:var(--font-size-large);font-weight:bold;overflow:hidden}.component header button .icon{margin-right:var(--icon-spacing)}.component ul{flex-grow:1;overflow:auto;list-style:none;margin:0;padding:0}.component li{flex-direction:row;align-items:center}.component li:not([hidden]){display:flex}.component li .info{flex-grow:1;overflow:hidden}.component li .info .icon{color:var(--primary);margin-right:var(--icon-spacing);filter:drop-shadow(var(--text-shadow))}.component li .info h2{font-size:var(--font-size-large);margin:0}.component li:not(.has-art){padding:8px}.component li button .icon{width:32px}.component li:nth-child(odd){background-color:var(--bg-alt)}#library header{flex-direction:row;align-items:center;padding:var(--spacing)}#library header:not([hidden]){display:flex}#library header button{font-size:var(--font-size-large);font-weight:bold;overflow:hidden}#library header button .icon{margin-right:var(--icon-spacing)}#library ul{flex-grow:1;overflow:auto;list-style:none;margin:0;padding:0}#library li{flex-direction:row;align-items:center}#library li:not([hidden]){display:flex}#library li .info{flex-grow:1;overflow:hidden}#library li .info .icon{color:var(--primary);margin-right:var(--icon-spacing);filter:drop-shadow(var(--text-shadow))}#library li .info h2{font-size:var(--font-size-large);margin:0}#library li:not(.has-art){padding:8px}#library li button .icon{width:32px}#library li:nth-child(odd){background-color:var(--bg-alt)}#library header{white-space:pre}#library .search{order:1}#library .search.open~*{display:none}#library .art img,#library .art .icon{width:64px}#library .art .icon{filter:drop-shadow(var(--text-shadow))}#library .group{cursor:pointer}#library .group h2{font-weight:normal}#library .tiles{display:grid;grid-template-columns:repeat(auto-fill, minmax(200px, 1fr));grid-gap:2px}#library .tiles li{text-align:center;cursor:pointer;background-color:rgba(255,255,255,0.08);height:200px}#library .tiles li h2{font-size:150%;margin:4px 0}#fs header{flex-direction:row;align-items:center;padding:var(--spacing)}#fs header:not([hidden]){display:flex}#fs header button{font-size:var(--font-size-large);font-weight:bold;overflow:hidden}#fs header button .icon{margin-right:var(--icon-spacing)}#fs ul{flex-grow:1;overflow:auto;list-style:none;margin:0;padding:0}#fs li{flex-direction:row;align-items:center}#fs li:not([hidden]){display:flex}#fs li .info{flex-grow:1;overflow:hidden}#fs li .info .icon{color:var(--primary);margin-right:var(--icon-spacing);filter:drop-shadow(var(--text-shadow))}#fs li .info h2{font-size:var(--font-size-large);margin:0}#fs li:not(.has-art){padding:8px}#fs li button .icon{width:32px}#fs li:nth-child(odd){background-color:var(--bg-alt)}#fs header{white-space:pre}#fs .search{order:1}#fs .search.open~*{display:none}#fs .group{cursor:pointer}.search{flex-direction:row;align-items:center;margin-left:auto;transition:all 300ms;width:32px;max-width:20ch}.search:not([hidden]){display:flex}.search .icon{width:32px;cursor:pointer}.search input{border:none;outline:none;color:inherit;background-color:inherit;border-bottom:1px solid var(--fg);width:0;padding:0;flex-grow:1}.search.open{flex:1}.art{margin-right:var(--icon-spacing)}.art .icon,.art img{vertical-align:top}cyp-app{--font-size-large:112.5%;--icon-spacing:4px;--primary:rgb(var(--primary-raw));--primary-tint:rgba(var(--primary-raw), .1);--box-shadow:0 0 3px #000;--border-width:4px}cyp-app[theme=light]{--fg:#333;--bg:#f0f0f0;--bg-alt:#e0e0e0;--text-shadow:none}cyp-app[theme=dark]{--fg:#f0f0f0;--bg:#333;--bg-alt:#555;--text-shadow:0 1px 1px rgba(0,0,0,0.8)}@media (prefers-color-scheme:dark){cyp-app[theme=auto]{--fg:#f0f0f0;--bg:#333;--bg-alt:#555;--text-shadow:0 1px 1px rgba(0,0,0,0.8)}}@media (prefers-color-scheme:light){cyp-app[theme=auto]{--fg:#333;--bg:#f0f0f0;--bg-alt:#e0e0e0;--text-shadow:none}}cyp-app[color=dodgerblue]{--primary-raw:30, 144, 255}cyp-app[color=darkorange]{--primary-raw:255, 140, 0}cyp-app[color=limegreen]{--primary-raw:50, 205, 50}cyp-app{flex-direction:column;box-sizing:border-box;margin:0 auto;max-width:800px;height:100vh;font-family:lato,sans-serif;line-height:1.25;background-color:var(--bg);color:var(--fg);text-shadow:var(--text-shadow);white-space:nowrap}cyp-app:not([hidden]){display:flex}cyp-menu,cyp-commands{flex-direction:row;align-items:center;height:100%}cyp-menu:not([hidden]),cyp-commands:not([hidden]){display:flex}cyp-menu button,cyp-commands button{height:100%;flex-direction:column;align-items:center;justify-content:center}cyp-menu button:not([hidden]),cyp-commands button:not([hidden]){display:flex}@media (max-width:480px){cyp-menu button,cyp-commands button{flex-direction:row}cyp-menu button span:not([id]),cyp-commands button span:not([id]){display:none}}cyp-menu button .icon+*,cyp-commands button .icon+*{margin-top:2px}cyp-menu button{flex:1 0 0;border-top:var(--border-width) solid transparent;border-bottom:var(--border-width) solid transparent}cyp-menu button .icon{margin-right:var(--icon-spacing)}cyp-menu button.active{border-top-color:var(--primary);color:var(--primary);background-color:var(--primary-tint)}cyp-commands{position:absolute;left:0;top:0;width:100%;transition:top 300ms;background-color:var(--bg)}cyp-commands[hidden]{display:flex;top:100%}cyp-commands button{flex:0 1 80px}cyp-commands button.last{order:1;margin-left:auto}cyp-song{flex-direction:row;align-items:center;border-left:var(--border-width) solid transparent;cursor:pointer;padding:8px;padding-left:calc(8px - var(--border-width))}cyp-song:not([hidden]){display:flex}cyp-song.selected{border-left-color:var(--primary);background-color:var(--primary-tint)}cyp-song:nth-child(odd){background-color:var(--bg-alt)}cyp-song>.icon{flex:none;margin-right:var(--icon-spacing);filter:drop-shadow(var(--text-shadow))}cyp-song .title{font-size:var(--font-size-large);min-width:0;overflow:hidden;text-overflow:ellipsis}cyp-song button:first-of-type{margin-left:auto}cyp-song button .icon{width:32px}cyp-song .multiline{flex-direction:column;min-width:0}cyp-song .multiline:not([hidden]){display:flex}cyp-song .multiline .subtitle{overflow:hidden;text-overflow:ellipsis}cyp-player{flex-direction:row;align-items:center;align-items:stretch}cyp-player:not([hidden]){display:flex}cyp-player:not([data-state=play]) .pause{display:none}cyp-player[data-state=play] .play{display:none}cyp-player:not([data-flags~=random]) .random,cyp-player:not([data-flags~=repeat]) .repeat{opacity:.5}cyp-player x-range{flex-grow:1;--elapsed-color:var(--primary)}cyp-player .art{margin-right:0;height:96px}cyp-player .art img,cyp-player .art .icon{width:96px}cyp-player .info{flex-grow:2;flex-basis:0;padding:0 var(--icon-spacing);overflow:hidden;flex-direction:column;justify-content:space-around}cyp-player .info:not([hidden]){display:flex}cyp-player .info h2{font-size:125%;margin:0}cyp-player .info .title,cyp-player .info .subtitle{overflow:hidden;text-overflow:ellipsis}cyp-player .timeline{flex-direction:row;align-items:center}cyp-player .timeline:not([hidden]){display:flex}cyp-player .timeline .duration,cyp-player .timeline .elapsed{flex-basis:5ch;text-align:center}cyp-player .controls{flex-grow:1;flex-basis:0;max-width:220px;flex-direction:column;justify-content:space-around}cyp-player .controls:not([hidden]){display:flex}cyp-player .controls .playback{flex-direction:row;align-items:center;justify-content:space-around}cyp-player .controls .playback:not([hidden]){display:flex}cyp-player .controls .playback .icon{width:40px}cyp-player .controls .playback .icon-play,cyp-player .controls .playback .icon-pause{width:64px}cyp-player .controls .volume{flex-direction:row;align-items:center}cyp-player .controls .volume:not([hidden]){display:flex}cyp-player .controls .volume .mute{margin-right:4px}cyp-player .misc{display:flex;flex-direction:column;align-self:stretch;justify-content:space-around}cyp-player .misc .icon{width:32px}@media (max-width:519px){cyp-player{flex-wrap:wrap;justify-content:space-between}cyp-player .info{order:1;flex-basis:100%;height:96px}}cyp-queue .current{color:var(--primary)}cyp-settings{--spacing:8px;font-size:var(--font-size-large)}cyp-settings dl{margin:var(--spacing);display:grid;grid-template-columns:max-content 1fr;align-items:center;grid-gap:var(--spacing)}cyp-settings dt{font-weight:bold}cyp-settings dd{margin:0;flex-direction:column;align-items:start}cyp-settings dd:not([hidden]){display:flex}cyp-settings label{flex-direction:row;align-items:center}cyp-settings label:not([hidden]){display:flex}cyp-settings label [type=radio],cyp-settings label [type=checkbox]{margin:0 4px 0 0}cyp-yt header{flex-direction:row;align-items:center;padding:var(--spacing)}cyp-yt header:not([hidden]){display:flex}cyp-yt header button{font-size:var(--font-size-large);font-weight:bold;overflow:hidden}cyp-yt header button .icon{margin-right:var(--icon-spacing)}cyp-yt ul{flex-grow:1;overflow:auto;list-style:none;margin:0;padding:0}cyp-yt li{flex-direction:row;align-items:center}cyp-yt li:not([hidden]){display:flex}cyp-yt li .info{flex-grow:1;overflow:hidden}cyp-yt li .info .icon{color:var(--primary);margin-right:var(--icon-spacing);filter:drop-shadow(var(--text-shadow))}cyp-yt li .info h2{font-size:var(--font-size-large);margin:0}cyp-yt li:not(.has-art){padding:8px}cyp-yt li button .icon{width:32px}cyp-yt li:nth-child(odd){background-color:var(--bg-alt)}cyp-yt header{border-bottom:1px solid var(--fg)}cyp-yt header button+button{margin-left:16px}cyp-yt .clear{margin-left:auto}cyp-yt pre{margin:.5em .5ch;flex-grow:1;overflow:auto;white-space:pre-wrap}cyp-yt.pending header{background-image:linear-gradient(var(--primary), var(--primary));background-repeat:no-repeat;background-size:25% 4px;animation:bar ease-in-out 3s alternate infinite}@keyframes bar{0%{background-position:0 100%}100%{background-position:100% 100%}}x-range{--thumb-size:8px;--thumb-color:#ddd;--thumb-shadow:#000;--thumb-hover-color:#fff;--track-size:4px;--track-color:#888;--track-shadow:#000;--elapsed-color:#ddd;--remaining-color:transparent;--radius:calc(var(--track-size)/2);display:inline-block;position:relative;width:192px;height:16px}x-range .-track,x-range .-elapsed,x-range .-remaining{position:absolute;top:calc(50% - var(--track-size)/2);height:var(--track-size);border-radius:var(--radius)}x-range .-track{width:100%;left:0;background-color:var(--track-color);box-shadow:0 0 1px var(--thumb-shadow)}x-range .-elapsed{left:0;background-color:var(--elapsed-color)}x-range .-remaining{right:0;background-color:var(--remaining-color)}x-range .-inner{position:absolute;left:var(--thumb-size);right:var(--thumb-size);top:0;bottom:0}x-range .-thumb{all:unset;position:absolute;top:50%;transform:translate(-50%, -50%);border-radius:50%;width:calc(2*var(--thumb-size));height:calc(2*var(--thumb-size));background-color:var(--thumb-color);box-shadow:0 0 2px var(--thumb-shadow)}x-range[disabled]{opacity:.5}x-range:not([disabled]) .-thumb:hover{background-color:var(--thumb-hover-color)}cyp-playlist{flex-direction:row;align-items:center;border-left:var(--border-width) solid transparent;cursor:pointer;padding:8px;padding-left:calc(8px - var(--border-width))}cyp-playlist:not([hidden]){display:flex}cyp-playlist.selected{border-left-color:var(--primary);background-color:var(--primary-tint)}cyp-playlist:nth-child(odd){background-color:var(--bg-alt)}cyp-playlist>.icon{flex:none;margin-right:var(--icon-spacing);filter:drop-shadow(var(--text-shadow))}cyp-playlist .title{font-size:var(--font-size-large);min-width:0;overflow:hidden;text-overflow:ellipsis}cyp-playlist button:first-of-type{margin-left:auto}cyp-playlist button .icon{width:32px}cyp-playlist:nth-child(odd){background-color:var(--bg-alt)} \ No newline at end of file +*,*::before,*::after{box-sizing:inherit}html{background-color:var(--fg)}body{margin:0}main{flex:auto;overflow:auto}header,footer{flex:none;z-index:1;box-shadow:var(--box-shadow)}footer{position:relative;overflow:hidden;height:56px}@media (max-width:480px){footer{height:40px}}input,select,button{color:inherit;font:inherit}button{-webkit-appearance:none;-moz-appearance:none;appearance:none;flex-direction:row;align-items:center;flex:none;background-color:transparent;padding:0;border:none;line-height:1;cursor:pointer}button:not([hidden]){display:flex}@media (hover:hover){button:not(:disabled):not(:hover):not(.-thumb){opacity:.9}}select{background-color:transparent;border:1px solid var(--fg);border-radius:4px;padding:2px 4px}@font-face{font-family:"Lato";src:url("font/LatoLatin-Regular.woff2") format("woff2");font-style:normal;font-weight:normal}@font-face{font-family:"Lato";src:url("font/LatoLatin-Bold.woff2") format("woff2");font-style:bold;font-weight:normal}.icon{width:24px}.icon path:not([fill]),.icon polygon:not([fill]),.icon circle:not([fill]){fill:currentColor}.flex-row{flex-direction:row;align-items:center}.flex-row:not([hidden]){display:flex}.flex-column{flex-direction:column}.flex-column:not([hidden]){display:flex}.ellipsis{overflow:hidden;text-overflow:ellipsis}.selectable{border-left:var(--border-width) solid transparent;cursor:pointer}.selectable.selected{border-left-color:var(--primary);background-color:var(--primary-tint)}.item{flex-direction:row;align-items:center;border-left:var(--border-width) solid transparent;cursor:pointer;padding:8px;padding-left:calc(8px - var(--border-width))}.item:not([hidden]){display:flex}.item.selected{border-left-color:var(--primary);background-color:var(--primary-tint)}.item:nth-child(odd){background-color:var(--bg-alt)}.item>.icon{flex:none;margin-right:var(--icon-spacing);filter:drop-shadow(var(--text-shadow))}.item .title{font-size:var(--font-size-large);min-width:0;overflow:hidden;text-overflow:ellipsis}.item button:first-of-type{margin-left:auto}.item button .icon{width:32px}.component header{flex-direction:row;align-items:center;padding:var(--spacing)}.component header:not([hidden]){display:flex}.component header button{font-size:var(--font-size-large);font-weight:bold;overflow:hidden}.component header button .icon{margin-right:var(--icon-spacing)}.component ul{flex-grow:1;overflow:auto;list-style:none;margin:0;padding:0}.component li{flex-direction:row;align-items:center}.component li:not([hidden]){display:flex}.component li .info{flex-grow:1;overflow:hidden}.component li .info .icon{color:var(--primary);margin-right:var(--icon-spacing);filter:drop-shadow(var(--text-shadow))}.component li .info h2{font-size:var(--font-size-large);margin:0}.component li:not(.has-art){padding:8px}.component li button .icon{width:32px}.component li:nth-child(odd){background-color:var(--bg-alt)}#library header{flex-direction:row;align-items:center;padding:var(--spacing)}#library header:not([hidden]){display:flex}#library header button{font-size:var(--font-size-large);font-weight:bold;overflow:hidden}#library header button .icon{margin-right:var(--icon-spacing)}#library ul{flex-grow:1;overflow:auto;list-style:none;margin:0;padding:0}#library li{flex-direction:row;align-items:center}#library li:not([hidden]){display:flex}#library li .info{flex-grow:1;overflow:hidden}#library li .info .icon{color:var(--primary);margin-right:var(--icon-spacing);filter:drop-shadow(var(--text-shadow))}#library li .info h2{font-size:var(--font-size-large);margin:0}#library li:not(.has-art){padding:8px}#library li button .icon{width:32px}#library li:nth-child(odd){background-color:var(--bg-alt)}#library header{white-space:pre}#library .search{order:1}#library .search.open~*{display:none}#library .art img,#library .art .icon{width:64px}#library .art .icon{filter:drop-shadow(var(--text-shadow))}#library .group{cursor:pointer}#library .group h2{font-weight:normal}#library .tiles{display:grid;grid-template-columns:repeat(auto-fill, minmax(200px, 1fr));grid-gap:2px}#library .tiles li{text-align:center;cursor:pointer;background-color:rgba(255,255,255,0.08);height:200px}#library .tiles li h2{font-size:150%;margin:4px 0}#fs header{flex-direction:row;align-items:center;padding:var(--spacing)}#fs header:not([hidden]){display:flex}#fs header button{font-size:var(--font-size-large);font-weight:bold;overflow:hidden}#fs header button .icon{margin-right:var(--icon-spacing)}#fs ul{flex-grow:1;overflow:auto;list-style:none;margin:0;padding:0}#fs li{flex-direction:row;align-items:center}#fs li:not([hidden]){display:flex}#fs li .info{flex-grow:1;overflow:hidden}#fs li .info .icon{color:var(--primary);margin-right:var(--icon-spacing);filter:drop-shadow(var(--text-shadow))}#fs li .info h2{font-size:var(--font-size-large);margin:0}#fs li:not(.has-art){padding:8px}#fs li button .icon{width:32px}#fs li:nth-child(odd){background-color:var(--bg-alt)}#fs header{white-space:pre}#fs .search{order:1}#fs .search.open~*{display:none}#fs .group{cursor:pointer}.search{flex-direction:row;align-items:center;margin-left:auto;transition:all 300ms;width:32px;max-width:20ch}.search:not([hidden]){display:flex}.search .icon{width:32px;cursor:pointer}.search input{border:none;outline:none;color:inherit;background-color:inherit;border-bottom:1px solid var(--fg);width:0;padding:0;flex-grow:1}.search.open{flex:1}.art{margin-right:var(--icon-spacing)}.art .icon,.art img{vertical-align:top}cyp-app{--font-size-large:112.5%;--icon-spacing:4px;--primary:rgb(var(--primary-raw));--primary-tint:rgba(var(--primary-raw), .1);--box-shadow:0 0 3px #000;--border-width:4px}cyp-app[theme=light]{--fg:#333;--bg:#f0f0f0;--bg-alt:#e0e0e0;--text-shadow:none}cyp-app[theme=dark]{--fg:#f0f0f0;--bg:#333;--bg-alt:#555;--text-shadow:0 1px 1px rgba(0,0,0,0.8)}@media (prefers-color-scheme:dark){cyp-app[theme=auto]{--fg:#f0f0f0;--bg:#333;--bg-alt:#555;--text-shadow:0 1px 1px rgba(0,0,0,0.8)}}@media (prefers-color-scheme:light){cyp-app[theme=auto]{--fg:#333;--bg:#f0f0f0;--bg-alt:#e0e0e0;--text-shadow:none}}cyp-app[color=dodgerblue]{--primary-raw:30, 144, 255}cyp-app[color=darkorange]{--primary-raw:255, 140, 0}cyp-app[color=limegreen]{--primary-raw:50, 205, 50}cyp-app{flex-direction:column;box-sizing:border-box;margin:0 auto;max-width:800px;height:100vh;font-family:lato,sans-serif;line-height:1.25;background-color:var(--bg);color:var(--fg);text-shadow:var(--text-shadow);white-space:nowrap}cyp-app:not([hidden]){display:flex}cyp-menu,cyp-commands{flex-direction:row;align-items:center;height:100%}cyp-menu:not([hidden]),cyp-commands:not([hidden]){display:flex}cyp-menu button,cyp-commands button{height:100%;flex-direction:column;align-items:center;justify-content:center}cyp-menu button:not([hidden]),cyp-commands button:not([hidden]){display:flex}@media (max-width:480px){cyp-menu button,cyp-commands button{flex-direction:row}cyp-menu button span:not([id]),cyp-commands button span:not([id]){display:none}}cyp-menu button .icon+*,cyp-commands button .icon+*{margin-top:2px}cyp-menu button{flex:1 0 0;border-top:var(--border-width) solid transparent;border-bottom:var(--border-width) solid transparent}cyp-menu button .icon{margin-right:var(--icon-spacing)}cyp-menu button.active{border-top-color:var(--primary);color:var(--primary);background-color:var(--primary-tint)}cyp-commands{position:absolute;left:0;top:0;width:100%;transition:top 300ms;background-color:var(--bg)}cyp-commands[hidden]{display:flex;top:100%}cyp-commands button{flex:0 1 80px}cyp-commands button.last{order:1;margin-left:auto}cyp-song{flex-direction:row;align-items:center;border-left:var(--border-width) solid transparent;cursor:pointer;padding:8px;padding-left:calc(8px - var(--border-width))}cyp-song:not([hidden]){display:flex}cyp-song.selected{border-left-color:var(--primary);background-color:var(--primary-tint)}cyp-song:nth-child(odd){background-color:var(--bg-alt)}cyp-song>.icon{flex:none;margin-right:var(--icon-spacing);filter:drop-shadow(var(--text-shadow))}cyp-song .title{font-size:var(--font-size-large);min-width:0;overflow:hidden;text-overflow:ellipsis}cyp-song button:first-of-type{margin-left:auto}cyp-song button .icon{width:32px}cyp-song .multiline{flex-direction:column;min-width:0}cyp-song .multiline:not([hidden]){display:flex}cyp-song .multiline .subtitle{overflow:hidden;text-overflow:ellipsis}cyp-player{flex-direction:row;align-items:center;align-items:stretch}cyp-player:not([hidden]){display:flex}cyp-player:not([data-state=play]) .pause{display:none}cyp-player[data-state=play] .play{display:none}cyp-player:not([data-flags~=random]) .random,cyp-player:not([data-flags~=repeat]) .repeat{opacity:.5}cyp-player x-range{flex-grow:1;--elapsed-color:var(--primary)}cyp-player .art{margin-right:0;height:96px}cyp-player .art img,cyp-player .art .icon{width:96px}cyp-player .info{flex-grow:2;flex-basis:0;padding:0 var(--icon-spacing);overflow:hidden;flex-direction:column;justify-content:space-around}cyp-player .info:not([hidden]){display:flex}cyp-player .info h2{font-size:125%;margin:0}cyp-player .info .title,cyp-player .info .subtitle{overflow:hidden;text-overflow:ellipsis}cyp-player .timeline{flex-direction:row;align-items:center}cyp-player .timeline:not([hidden]){display:flex}cyp-player .timeline .duration,cyp-player .timeline .elapsed{flex-basis:5ch;text-align:center}cyp-player .controls{flex-grow:1;flex-basis:0;max-width:220px;flex-direction:column;justify-content:space-around}cyp-player .controls:not([hidden]){display:flex}cyp-player .controls .playback{flex-direction:row;align-items:center;justify-content:space-around}cyp-player .controls .playback:not([hidden]){display:flex}cyp-player .controls .playback .icon{width:40px}cyp-player .controls .playback .icon-play,cyp-player .controls .playback .icon-pause{width:64px}cyp-player .controls .volume{flex-direction:row;align-items:center}cyp-player .controls .volume:not([hidden]){display:flex}cyp-player .controls .volume .mute{margin-right:4px}cyp-player .misc{display:flex;flex-direction:column;align-self:stretch;justify-content:space-around}cyp-player .misc .icon{width:32px}@media (max-width:519px){cyp-player{flex-wrap:wrap;justify-content:space-between}cyp-player .info{order:1;flex-basis:100%;height:96px}}cyp-queue .current{color:var(--primary)}cyp-settings{--spacing:8px;font-size:var(--font-size-large)}cyp-settings dl{margin:var(--spacing);display:grid;grid-template-columns:max-content 1fr;align-items:center;grid-gap:var(--spacing)}cyp-settings dt{font-weight:bold}cyp-settings dd{margin:0;flex-direction:column;align-items:start}cyp-settings dd:not([hidden]){display:flex}cyp-settings label{flex-direction:row;align-items:center}cyp-settings label:not([hidden]){display:flex}cyp-settings label [type=radio],cyp-settings label [type=checkbox]{margin:0 4px 0 0}cyp-yt header{flex-direction:row;align-items:center;padding:var(--spacing)}cyp-yt header:not([hidden]){display:flex}cyp-yt header button{font-size:var(--font-size-large);font-weight:bold;overflow:hidden}cyp-yt header button .icon{margin-right:var(--icon-spacing)}cyp-yt ul{flex-grow:1;overflow:auto;list-style:none;margin:0;padding:0}cyp-yt li{flex-direction:row;align-items:center}cyp-yt li:not([hidden]){display:flex}cyp-yt li .info{flex-grow:1;overflow:hidden}cyp-yt li .info .icon{color:var(--primary);margin-right:var(--icon-spacing);filter:drop-shadow(var(--text-shadow))}cyp-yt li .info h2{font-size:var(--font-size-large);margin:0}cyp-yt li:not(.has-art){padding:8px}cyp-yt li button .icon{width:32px}cyp-yt li:nth-child(odd){background-color:var(--bg-alt)}cyp-yt header{border-bottom:1px solid var(--fg)}cyp-yt header button+button{margin-left:16px}cyp-yt .clear{margin-left:auto}cyp-yt pre{margin:.5em .5ch;flex-grow:1;overflow:auto;white-space:pre-wrap}cyp-yt.pending header{background-image:linear-gradient(var(--primary), var(--primary));background-repeat:no-repeat;background-size:25% 4px;animation:bar ease-in-out 3s alternate infinite}@keyframes bar{0%{background-position:0 100%}100%{background-position:100% 100%}}x-range{--thumb-size:8px;--thumb-color:#ddd;--thumb-shadow:#000;--thumb-hover-color:#fff;--track-size:4px;--track-color:#888;--track-shadow:#000;--elapsed-color:#ddd;--remaining-color:transparent;--radius:calc(var(--track-size)/2);display:inline-block;position:relative;width:192px;height:16px}x-range .-track,x-range .-elapsed,x-range .-remaining{position:absolute;top:calc(50% - var(--track-size)/2);height:var(--track-size);border-radius:var(--radius)}x-range .-track{width:100%;left:0;background-color:var(--track-color);box-shadow:0 0 1px var(--thumb-shadow)}x-range .-elapsed{left:0;background-color:var(--elapsed-color)}x-range .-remaining{right:0;background-color:var(--remaining-color)}x-range .-inner{position:absolute;left:var(--thumb-size);right:var(--thumb-size);top:0;bottom:0}x-range .-thumb{all:unset;position:absolute;top:50%;transform:translate(-50%, -50%);border-radius:50%;width:calc(2*var(--thumb-size));height:calc(2*var(--thumb-size));background-color:var(--thumb-color);box-shadow:0 0 2px var(--thumb-shadow)}x-range[disabled]{opacity:.5}x-range:not([disabled]) .-thumb:hover{background-color:var(--thumb-hover-color)}cyp-playlist{flex-direction:row;align-items:center;border-left:var(--border-width) solid transparent;cursor:pointer;padding:8px;padding-left:calc(8px - var(--border-width))}cyp-playlist:not([hidden]){display:flex}cyp-playlist.selected{border-left-color:var(--primary);background-color:var(--primary-tint)}cyp-playlist:nth-child(odd){background-color:var(--bg-alt)}cyp-playlist>.icon{flex:none;margin-right:var(--icon-spacing);filter:drop-shadow(var(--text-shadow))}cyp-playlist .title{font-size:var(--font-size-large);min-width:0;overflow:hidden;text-overflow:ellipsis}cyp-playlist button:first-of-type{margin-left:auto}cyp-playlist button .icon{width:32px}cyp-playlist:nth-child(odd){background-color:var(--bg-alt)}cyp-artist{flex-direction:row;align-items:center;border-left:var(--border-width) solid transparent;cursor:pointer;padding:8px;padding-left:calc(8px - var(--border-width))}cyp-artist:not([hidden]){display:flex}cyp-artist.selected{border-left-color:var(--primary);background-color:var(--primary-tint)}cyp-artist:nth-child(odd){background-color:var(--bg-alt)}cyp-artist>.icon{flex:none;margin-right:var(--icon-spacing);filter:drop-shadow(var(--text-shadow))}cyp-artist .title{font-size:var(--font-size-large);min-width:0;overflow:hidden;text-overflow:ellipsis}cyp-artist button:first-of-type{margin-left:auto}cyp-artist button .icon{width:32px} \ No newline at end of file diff --git a/app/icons/checkbox-marked-outline.svg b/app/icons/checkbox-marked-outline.svg new file mode 100644 index 0000000..c0d1dda --- /dev/null +++ b/app/icons/checkbox-marked-outline.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/icons/chevron-double-right.svg b/app/icons/chevron-double-right.svg new file mode 100644 index 0000000..3f2a06b --- /dev/null +++ b/app/icons/chevron-double-right.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/index.html b/app/index.html index cb3dd65..36cc6da 100644 --- a/app/index.html +++ b/app/index.html @@ -40,17 +40,8 @@
- -
    -
    -
    -
    -
      -
      -
      -
      -
        -
        + +
        @@ -113,5 +104,6 @@ + diff --git a/app/js/component.js b/app/js/component.js index 4249b31..9a47501 100644 --- a/app/js/component.js +++ b/app/js/component.js @@ -1,4 +1,3 @@ -import * as html from "./html.js"; import Selection from "./selection.js"; export class HasApp extends HTMLElement { @@ -6,17 +5,6 @@ export class HasApp extends HTMLElement { get _mpd() { return this._app.mpd; } } -export class Item extends HasApp { - constructor() { - super(); - this.addEventListener("click", _ => this.parentNode.selection.toggle(this)); - } - - _buildTitle(title) { - return html.node("span", {className:"title"}, title, this); - } -} - export default class Component extends HasApp { constructor(options = {}) { super(); diff --git a/app/js/elements/app.js b/app/js/elements/app.js index f355c8a..b02d130 100644 --- a/app/js/elements/app.js +++ b/app/js/elements/app.js @@ -2,9 +2,6 @@ import * as mpd from "../mpd.js"; import * as mpdMock from "../mpd-mock.js"; import * as html from "../html.js"; -// import * as library from "./library.js"; -// import * as fs from "./fs.js"; - function initIcons() { Array.from(document.querySelectorAll("[data-icon]")).forEach(/** @param {HTMLElement} node */ node => { let icon = html.icon(node.dataset.icon); @@ -34,8 +31,12 @@ class App extends HTMLElement { async connectedCallback() { this.mpd = await initMpd(); - const promises = ["cyp-player"].map(name => customElements.whenDefined(name)); + const children = Array.from(this.querySelectorAll("*")); + const names = children.map(node => node.nodeName.toLowerCase()) + .filter(name => name.startsWith("cyp-")); + const unique = new Set(names); + const promises = [...unique].map(name => customElements.whenDefined(name)); await Promise.all(promises); this.dispatchEvent(new CustomEvent("load")); diff --git a/app/js/elements/artist.js b/app/js/elements/artist.js new file mode 100644 index 0000000..c6a4a70 --- /dev/null +++ b/app/js/elements/artist.js @@ -0,0 +1,17 @@ +import * as html from "../html.js"; +import Item from "../item.js"; + + +export default class Artist extends Item { + constructor(name) { + super(); + this.name = name; + } + + connectedCallback() { + html.icon("artist", this); + this._buildTitle(this.name); + } +} + +customElements.define("cyp-artist", Artist); diff --git a/app/js/elements/library.js b/app/js/elements/library.js new file mode 100644 index 0000000..867800c --- /dev/null +++ b/app/js/elements/library.js @@ -0,0 +1,63 @@ +import * as html from "../html.js"; +import Component from "../component.js"; +import Artist from "./artist.js"; + + +class Library extends Component { + constructor() { + super({selection:"multi"}); + } + + _onAppLoad() { + this._showRoot(); + } + + _onComponentChange(c, isThis) { + const wasHidden = this.hidden; + this.hidden = !isThis; + + if (!wasHidden) { this._showRoot(); } + } + + _showRoot() { + html.clear(this); + + html.button({icon:"artist"}, "Artists and albums", this) + .addEventListener("click", _ => this._listTags("AlbumArtist")); + + html.button({icon:"folder"}, "Files and directories", this) + .addEventListener("click", _ => this._listFS("")); + + html.button({icon:"magnify"}, "Search", this) + .addEventListener("click", _ => this._showSearch()); + } + + async _listTags(tag, filter = {}) { + const values = await this._mpd.listTags(tag, filter); + + html.clear(this); + + values.forEach(value => this._buildTagValue(tag, value)); + } + + async _listFS(path) { + + } + + _showSearch() { + + } + + _buildTagValue(tag, value) { + let node; + switch (tag) { + case "AlbumArtist": + node = new Artist(value); + node.onClick = () => this._listTags("Album", {[tag]:value}); + break; + } + this.appendChild(node); + } +} + +customElements.define("cyp-library", Library); diff --git a/app/js/elements/playlist.js b/app/js/elements/playlist.js index a03855e..eb6144f 100644 --- a/app/js/elements/playlist.js +++ b/app/js/elements/playlist.js @@ -1,5 +1,5 @@ import * as html from "../html.js"; -import { Item } from "../component.js"; +import Item from "../item.js"; export default class Playlist extends Item { constructor(name) { diff --git a/app/js/elements/song.js b/app/js/elements/song.js index c0a985b..8319987 100644 --- a/app/js/elements/song.js +++ b/app/js/elements/song.js @@ -1,6 +1,6 @@ import * as format from "../format.js"; import * as html from "../html.js"; -import { Item } from "../component.js"; +import Item from "../item.js"; export default class Song extends Item { constructor(data) { diff --git a/app/js/icons.js b/app/js/icons.js index 2f638ae..2e90081 100644 --- a/app/js/icons.js +++ b/app/js/icons.js @@ -1,33 +1,15 @@ let ICONS={}; -ICONS["playlist-music"] = ` - +ICONS["library-music"] = ` + +`; +ICONS["plus"] = ` + `; ICONS["folder"] = ` `; -ICONS["shuffle"] = ` - -`; -ICONS["artist"] = ` - -`; -ICONS["download"] = ` - -`; -ICONS["magnify"] = ` - -`; -ICONS["delete"] = ` - -`; -ICONS["rewind"] = ` - -`; -ICONS["account-multiple"] = ` - -`; -ICONS["cancel"] = ` - +ICONS["playlist-music"] = ` + `; ICONS["settings"] = ` @@ -35,46 +17,70 @@ ICONS["settings"] = ` ICONS["pause"] = ` `; -ICONS["arrow-down-bold"] = ` - +ICONS["artist"] = ` + `; ICONS["volume-off"] = ` `; -ICONS["close"] = ` - -`; -ICONS["music"] = ` - -`; -ICONS["minus"] = ` - -`; -ICONS["repeat"] = ` - -`; -ICONS["arrow-up-bold"] = ` - -`; -ICONS["play"] = ` - -`; -ICONS["plus"] = ` - -`; -ICONS["content-save"] = ` - -`; -ICONS["library-music"] = ` - +ICONS["cancel"] = ` + `; ICONS["fast-forward"] = ` `; +ICONS["delete"] = ` + +`; ICONS["volume-high"] = ` `; +ICONS["minus"] = ` + +`; +ICONS["play"] = ` + +`; +ICONS["magnify"] = ` + +`; +ICONS["arrow-down-bold"] = ` + +`; +ICONS["music"] = ` + +`; +ICONS["rewind"] = ` + +`; ICONS["album"] = ` `; +ICONS["download"] = ` + +`; +ICONS["account-multiple"] = ` + +`; +ICONS["close"] = ` + +`; +ICONS["content-save"] = ` + +`; +ICONS["arrow-up-bold"] = ` + +`; +ICONS["chevron-double-right"] = ` + +`; +ICONS["shuffle"] = ` + +`; +ICONS["checkbox-marked-outline"] = ` + +`; +ICONS["repeat"] = ` + +`; export default ICONS; diff --git a/app/js/item.js b/app/js/item.js new file mode 100644 index 0000000..e4b654f --- /dev/null +++ b/app/js/item.js @@ -0,0 +1,14 @@ +import * as html from "./html.js"; + +export default class Item extends HTMLElement { + constructor() { + super(); + this.addEventListener("click", _ => this.onClick()); + } + + onClick() { this.parentNode.selection.toggle(this); } + + _buildTitle(title) { + return html.node("span", {className:"title"}, title, this); + } +} diff --git a/app/js/mpd-mock.js b/app/js/mpd-mock.js index ea48f57..a396109 100644 --- a/app/js/mpd-mock.js +++ b/app/js/mpd-mock.js @@ -55,16 +55,10 @@ export async function listPath(path) { } export async function listTags(tag, filter = null) { - let tokens = ["list", tag]; - if (filter) { - tokens.push(serializeFilter(filter)); - - let fakeGroup = Object.keys(filter)[0]; // FIXME hack for MPD < 0.21.6 - tokens.push("group", fakeGroup); + switch (tag) { + case "AlbumArtist": return ["Artist 1", "Artist 2", "Artist 3"]; + case "Album": return ["Album 1", "Album 2", "Album 3"]; } - let lines = await command(tokens.join(" ")); - let parsed = parser.linesToStruct(lines); - return [].concat(tag in parsed ? parsed[tag] : []); } export async function listSongs(filter, window = null) { diff --git a/app/js/selection.js b/app/js/selection.js index 8d8b83d..4ba69e0 100644 --- a/app/js/selection.js +++ b/app/js/selection.js @@ -26,7 +26,7 @@ export default class Selection { addCommandAll() { this.addCommand(_ => { Array.from(this._component.children).forEach(node => this.add(node)); - }, {label:"Select all", icon:"plus"}); + }, {label:"Select all", icon:"checkbox-marked-outline"}); } addCommandCancel() {