add filters to search

- move global to center
This commit is contained in:
geoffrey45
2021-12-28 15:07:26 +03:00
parent 741e34c5ee
commit 2b6bb2c0cb
8 changed files with 334 additions and 121 deletions
+5 -4
View File
@@ -12,15 +12,16 @@
<PinnedStuff :collapsed="collapsed" />
</div>
<div class="content">
<router-view />
</div>
<div class="r-sidebar">
<div class="m-np">
<Search
v-model:search="search"
@expandSearch="expandSearch"
@collapseSearch="collapseSearch"
/>
<div class="separator" style="border: none"></div>
<router-view />
</div>
<div class="r-sidebar">
<div class="m-np">
<NowPlaying />
</div>
<UpNext v-model:up_next="up_next" @expandQueue="expandQueue" />
+4
View File
@@ -44,6 +44,10 @@ a {
margin: $small 0 $small 0;
}
.no-border {
border: none;
}
.hidden {
display: none;
}
+1
View File
@@ -0,0 +1 @@
<svg fill="#ffffff" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path d="M 39.486328 6.9785156 A 1.50015 1.50015 0 0 0 38.439453 7.4394531 L 24 21.878906 L 9.5605469 7.4394531 A 1.50015 1.50015 0 0 0 8.484375 6.984375 A 1.50015 1.50015 0 0 0 7.4394531 9.5605469 L 21.878906 24 L 7.4394531 38.439453 A 1.50015 1.50015 0 1 0 9.5605469 40.560547 L 24 26.121094 L 38.439453 40.560547 A 1.50015 1.50015 0 1 0 40.560547 38.439453 L 26.121094 24 L 40.560547 9.5605469 A 1.50015 1.50015 0 0 0 39.486328 6.9785156 z"></path></svg>

After

Width:  |  Height:  |  Size: 533 B

+3
View File
@@ -0,0 +1,3 @@
<svg viewBox="1.533 3.788 500.308 492.43" width="500.308" height="492.43">
<path d="M 479.264 3.794 C 473.442 3.93 467.912 6.326 463.879 10.46 L 251.687 219.318 L 39.492 10.46 C 35.341 6.254 29.636 3.879 23.678 3.879 C 6.707 3.883 -3.894 21.968 4.593 36.431 C 5.611 38.163 6.864 39.748 8.323 41.141 L 220.515 249.998 L 8.323 458.855 C -3.92 470.424 1.153 490.698 17.453 495.348 C 25.327 497.594 33.816 495.355 39.492 489.535 L 251.687 280.678 L 463.879 489.535 C 475.633 501.584 496.231 496.592 500.955 480.547 C 503.238 472.799 500.962 464.443 495.05 458.855 L 282.856 249.998 L 495.05 41.141 C 507.293 29.574 502.225 9.3 485.925 4.647 C 483.762 4.03 481.514 3.741 479.264 3.794 Z" style="fill: rgb(255, 255, 255);"></path>
</svg>

After

Width:  |  Height:  |  Size: 734 B

+1 -1
View File
@@ -1 +1 @@
<svg fill="#ffffff" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48px" height="48px"><path d="M 23.951172 4 A 1.50015 1.50015 0 0 0 23.072266 4.3222656 L 8.859375 15.519531 C 7.0554772 16.941163 6 19.113506 6 21.410156 L 6 40.5 C 6 41.863594 7.1364058 43 8.5 43 L 18.5 43 C 19.863594 43 21 41.863594 21 40.5 L 21 30.5 C 21 30.204955 21.204955 30 21.5 30 L 26.5 30 C 26.795045 30 27 30.204955 27 30.5 L 27 40.5 C 27 41.863594 28.136406 43 29.5 43 L 39.5 43 C 40.863594 43 42 41.863594 42 40.5 L 42 21.410156 C 42 19.113506 40.944523 16.941163 39.140625 15.519531 L 24.927734 4.3222656 A 1.50015 1.50015 0 0 0 23.951172 4 z M 24 7.4101562 L 37.285156 17.876953 C 38.369258 18.731322 39 20.030807 39 21.410156 L 39 40 L 30 40 L 30 30.5 C 30 28.585045 28.414955 27 26.5 27 L 21.5 27 C 19.585045 27 18 28.585045 18 30.5 L 18 40 L 9 40 L 9 21.410156 C 9 20.030807 9.6307412 18.731322 10.714844 17.876953 L 24 7.4101562 z"/></svg>
<svg fill="#ffffff" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48px" height="48px"><path d="M 23.951172 4 A 1.50015 1.50015 0 0 0 23.072266 4.3222656 L 8.859375 15.519531 C 7.0554772 16.941163 6 19.113506 6 21.410156 L 6 40.5 C 6 41.863594 7.1364058 43 8.5 43 L 18.5 43 C 19.863594 43 21 41.863594 21 40.5 L 21 30.5 C 21 30.204955 21.204955 30 21.5 30 L 26.5 30 C 26.795045 30 27 30.204955 27 30.5 L 27 40.5 C 27 41.863594 28.136406 43 29.5 43 L 39.5 43 C 40.863594 43 42 41.863594 42 40.5 L 42 21.410156 C 42 19.113506 40.944523 16.941163 39.140625 15.519531 L 24.927734 4.3222656 A 1.50015 1.50015 0 0 0 23.951172 4 z M 24 7.4101562 L 37.285156 17.876953 C 38.369258 18.731322 39 20.030807 39 21.410156 L 39 40 L 30 40 L 30 30.5 C 30 28.585045 28.414955 27 26.5 27 L 21.5 27 C 19.585045 27 18 28.585045 18 30.5 L 18 40 L 9 40 L 9 21.410156 C 9 20.030807 9.6307412 18.731322 10.714844 17.876953 L 24 7.4101562 z"/></svg>

Before

Width:  |  Height:  |  Size: 941 B

After

Width:  |  Height:  |  Size: 942 B

+1
View File
@@ -0,0 +1 @@
<svg fill="#ffffff" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48px" height="48px"><path d="M 20.5 6 C 12.509634 6 6 12.50964 6 20.5 C 6 28.49036 12.509634 35 20.5 35 C 23.956359 35 27.133709 33.779044 29.628906 31.75 L 39.439453 41.560547 A 1.50015 1.50015 0 1 0 41.560547 39.439453 L 31.75 29.628906 C 33.779044 27.133709 35 23.956357 35 20.5 C 35 12.50964 28.490366 6 20.5 6 z M 20.5 9 C 26.869047 9 32 14.130957 32 20.5 C 32 23.602612 30.776198 26.405717 28.791016 28.470703 A 1.50015 1.50015 0 0 0 28.470703 28.791016 C 26.405717 30.776199 23.602614 32 20.5 32 C 14.130953 32 9 26.869043 9 20.5 C 9 14.130957 14.130953 9 20.5 9 z"/></svg>

After

Width:  |  Height:  |  Size: 663 B

+309 -115
View File
@@ -1,14 +1,55 @@
<template>
<div class="right-search">
<input
type="search"
id="search"
placeholder="find your music"
v-model="query"
/>
<div
class="right-search"
@mouseenter="magic_flag = true"
@mouseleave="toggleMagicFlag"
>
<div class="input">
<div class="search-icon image"></div>
<div class="filter">
<div
class="item"
v-for="filter in filters"
:key="filter"
@click="removeFilter(filter)"
>
{{ filter }}<span class="cancel image"></span>
</div>
</div>
<input
type="search"
id="search"
placeholder="find your music"
v-model="query"
/>
<div
class="suggestions"
:class="{
v00: !filters.length && !query,
v11: filters.length || query,
}"
>
<div class="item">Kenny Rogers</div>
<div class="item">Jim Reeves</div>
<div class="item">Juice Wrld</div>
<div class="item">Dolly Parton</div>
</div>
</div>
<div class="separator no-border"></div>
<div class="options" v-if="magic_flag || query || filters.length">
<div class="item info">I'm looking for:</div>
<div
class="item"
v-for="option in options"
:key="option"
@click="addFilter(option.icon)"
>
{{ option.title }}
</div>
</div>
<div class="scrollable" :class="{ v0: !is_hidden, v1: is_hidden }">
<div class="tracks-results">
<h3 class="heading">TRACKS<span class="more">SEE ALL</span></h3>
<div class="heading">TRACKS<span class="more">SEE ALL</span></div>
<div class="result-item" v-for="song in songs" :key="song">
<div class="album-art image"></div>
<div class="tags">
@@ -20,31 +61,22 @@
</div>
<!-- -->
<div class="albums-results">
<h3 class="heading">ALBUMS <span class="more">SEE ALL</span></h3>
<div class="heading">ALBUMS <span class="more">SEE ALL</span></div>
<div class="grid">
<div
class="result-item result-item3"
v-for="album in albums"
:key="album"
>
<div class="result-item" v-for="album in albums" :key="album">
<div class="album-art image"></div>
<div class="title ellipsis">{{ album }}</div>
<div class="title ellip">{{ album }}</div>
</div>
</div>
</div>
<div class="separator no-border"></div>
<!-- -->
<div class="artists-results" v-if="artists">
<h3 class="heading">
ARTISTS <span class="more" v-if="artists.length > 3">SEE ALL</span>
</h3>
<div class="heading">ARTISTS <span class="more">SEE ALL</span></div>
<div class="grid">
<div
class="result-item result-item3"
v-for="artist in artists"
:key="artist"
>
<div class="result-item" v-for="artist in artists" :key="artist">
<div class="image"></div>
<div class="name ellipsis">{{ artist }}</div>
<div class="title ellip">{{ artist }}</div>
</div>
</div>
</div>
@@ -69,19 +101,59 @@ export default {
artist: "Michael jackson",
},
];
const options = [
{
title: "🎵 Track",
icon: "🎵",
},
{
title: "💿 Album",
icon: "💿",
},
{
title: "🙄 Artist",
icon: "🙄",
},
{
title: "😍 Playlist",
icon: "😍",
},
{
title: "📁 Folder",
icon: "📁",
},
{
title: "🈁 this page",
icon: "🈁",
},
];
const filters = ref([]);
const albums = [
"Smooth Criminal like wtf ... and im serious",
"Xscape",
"USA for Africa",
];
const artists = ["Michael Jackson", "Jackson 5"];
const artists = ["Michael Jackson waihenya", "Jackson 5"];
const query = ref(null);
const magic_flag = ref(false);
const is_hidden = toRefs(props).search;
function addFilter(filter) {
if (!filters.value.includes(filter)) {
filters.value.push(filter);
}
}
function removeFilter(filter) {
filters.value = filters.value.filter((f) => f !== filter);
}
function toggleMagicFlag() {
setTimeout(() => {
magic_flag.value = false;
}, 1000);
}
watch(query, (new_query) => {
if (new_query.length > 0) {
emit("expandSearch");
@@ -90,15 +162,24 @@ export default {
}
});
return { songs, albums, artists, query, is_hidden };
return {
addFilter,
toggleMagicFlag,
removeFilter,
songs,
albums,
artists,
query,
is_hidden,
magic_flag,
options,
filters,
};
},
};
</script>
<style>
.right-search {
z-index: 10;
}
<style lang="scss">
.right-search .v0 {
max-height: 0em;
transition: max-height 0.5s ease;
@@ -113,19 +194,111 @@ export default {
position: relative;
border-radius: 1rem;
margin: 0.5rem 0 0 0;
padding: 0.75rem;
padding: $small $small 0 0;
background-color: #131313b2;
overflow: hidden;
.input {
display: flex;
align-items: center;
position: relative;
.filter {
display: flex;
margin-left: 3rem;
.item {
position: relative;
background-color: rgb(39, 37, 37);
padding: 0.5rem;
border-radius: 0.5rem;
cursor: pointer;
margin: 0 $small 0 0;
display: flex;
align-items: center;
&:hover {
background-color: rgb(170, 50, 50);
width: 4rem;
.cancel {
position: absolute;
right: 0.5rem;
width: 1.5rem;
height: 1.5rem;
background-image: url(../../assets/icons/a.svg);
background-size: 70%;
}
}
}
}
}
.search-icon {
position: absolute;
height: 2.5rem;
width: 2.5rem;
background-image: url(../../assets/icons/search.svg);
background-size: 70%;
}
.v11 {
opacity: 0;
transform: translateY(-3rem);
transition: all 0.2s ease-in;
}
.v00 {
opacity: 1;
max-height: 3rem;
transition: all 0.2s ease-in;
}
.suggestions {
display: flex;
gap: 0.5rem;
margin-left: 1rem;
position: absolute;
right: 0;
.item {
cursor: pointer;
background-color: rgb(75, 70, 70);
padding: $small;
border-radius: $small;
&:hover {
background-color: rgb(170, 50, 50);
}
}
.item::before {
content: "#";
color: grey;
}
}
}
.right-search .options {
display: flex;
.item {
background-color: rgb(39, 37, 37);
padding: 0.5rem;
border-radius: 0.5rem;
cursor: pointer;
margin: $small;
&:hover {
background-color: rgb(170, 50, 50);
}
}
}
.right-search .scrollable {
height: 26rem;
overflow-y: scroll;
scroll-behavior: smooth;
}
.right-search .scrollable::-webkit-scrollbar {
display: none;
padding: 0 $small 0 0;
}
.right-search .heading {
@@ -144,16 +317,16 @@ export default {
}
.right-search .heading .more:hover {
background: rgb(62, 69, 77);
background: $blue;
border-radius: 0.5rem;
cursor: pointer;
}
.right-search input {
width: 100%;
height: 2.5rem;
border: none;
border-radius: 0.5rem;
padding-left: 1rem;
background-color: #4645456c;
background-color: transparent;
color: rgba(255, 255, 255, 0.479);
font-size: 1rem;
line-height: 3rem;
@@ -163,43 +336,50 @@ export default {
.right-search input:focus {
transition: all 0.5s ease;
color: rgb(255, 255, 255);
outline: 0.1rem solid #fafafa52;
}
outline: none;
.right-search input::-webkit-search-cancel-button {
position: relative;
right: 1rem;
cursor: pointer;
&::placeholder {
display: none;
}
}
/* */
.right-search .tracks-results {
border-radius: 0.5rem;
overflow: hidden;
}
background-color: rgba(8, 3, 1, 0.274);
padding: $small;
.right-search .tracks-results .heading {
padding: 0.5rem;
}
.result-item {
display: flex;
align-items: center;
height: 4.5rem;
width: 100%;
background-color: rgba(20, 20, 20, 0.479);
.right-search .tracks-results .result-item {
display: flex;
align-items: center;
height: 4.5rem;
background-color: rgba(20, 20, 20, 0.733);
}
.album-art {
width: 3.5rem;
height: 3.5rem;
background-color: rgb(27, 150, 74);
border-radius: 0.5rem;
margin: 0 $small 0 $small;
background-image: url(../../assets/images/thriller.jpg);
}
.right-search .tracks-results .result-item:nth-child(odd) {
background-color: rgba(27, 26, 27, 0.589);
}
.right-search .tracks-results .result-item .album-art {
width: 4rem;
height: 4rem;
background-color: rgb(27, 150, 74);
border-radius: 0.5rem;
margin: 0 0.5rem 0 0.25rem;
background-image: url(../../assets/images/thriller.jpg);
.tags .artist {
font-size: small;
color: rgba(255, 255, 255, 0.63);
}
&:nth-child(odd) {
background-color: transparent;
}
&:hover {
background-color: $blue;
border-radius: $small;
}
}
}
.right-search hr {
@@ -207,42 +387,45 @@ export default {
border: none;
}
.right-search .tracks-results .result-item .tags .artist {
font-size: small;
color: rgba(255, 255, 255, 0.63);
}
/* */
.right-search .albums-results {
border-radius: 0.5rem;
background-color: rgba(8, 3, 1, 0.274);
margin-top: 1rem;
}
.right-search .albums-results .grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
}
.grid {
display: flex;
flex-wrap: wrap;
padding: 0 0 0 $small;
gap: $small;
.right-search .result-item3 {
display: flex;
flex-direction: column;
align-items: center;
}
.result-item {
display: flex;
flex-direction: column;
align-items: center;
padding: $small;
border-radius: $small;
background-color: rgb(24, 23, 23);
margin-bottom: 1rem;
.right-search .albums-results .result-item .album-art {
height: 7rem;
width: 7rem;
background-color: rgba(26, 26, 26, 0.452);
border-radius: 0.5rem;
margin-bottom: 0.5rem;
background-image: url(../../assets/images/thriller.jpg);
}
.album-art {
height: 7rem;
width: 7rem;
background-color: rgba(26, 26, 26, 0.452);
border-radius: 0.5rem;
margin-bottom: 0.5rem;
background-image: url(../../assets/images/thriller.jpg);
}
.right-search .albums-results .result-item .title {
width: 7rem;
text-align: center;
margin-bottom: 0.5rem;
.title {
width: 7rem;
text-align: center;
margin-bottom: 0.5rem;
font-size: 0.9rem;
}
}
}
}
/* */
@@ -250,28 +433,39 @@ export default {
.right-search .artists-results {
border-radius: 0.5rem;
background-color: rgba(8, 3, 1, 0.274);
}
.right-search .artists-results .grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
}
.grid {
padding: 0 0 0 $small;
display: flex;
gap: 1rem;
.right-search .artists-results .result-item .image {
height: 7rem;
width: 7rem;
border-radius: 50%;
background-color: rgba(16, 65, 14, 0.356);
margin-bottom: 0.5rem;
background-image: url(../../assets/icons/logo-small.svg);
background-size: 50%;
background-image: url(../../assets/images/thriller.jpg);
background-size: cover;
}
.result-item {
display: flex;
flex-direction: column;
align-items: center;
padding: $small;
border-radius: $small;
background-color: rgb(24, 23, 23);
margin-bottom: 1rem;
.right-search .artists-results .result-item .name {
width: 7rem;
text-align: center;
margin-bottom: 0.5rem;
.image {
height: 7rem;
width: 7rem;
border-radius: 50%;
background-color: rgba(16, 65, 14, 0.356);
margin-bottom: 0.5rem;
background-size: 50%;
background-image: url(../../assets/images/thriller.jpg);
background-size: cover;
}
.title {
width: 7rem;
text-align: center;
margin-bottom: 0.5rem;
font-size: 0.9rem;
}
}
}
}
</style>
+10 -1
View File
@@ -120,4 +120,13 @@ watch(current, (new_current, old_current) => {
localStorage.setItem("prev", JSON.stringify(prev.value));
});
export default { putCommas, doThat, readQueue, focusCurrent, current, queue, next, prev };
export default {
putCommas,
doThat,
readQueue,
focusCurrent,
current,
queue,
next,
prev,
};