refactor the "SEE ALL" button into a component

This commit is contained in:
geoffrey45
2023-01-02 15:29:40 +03:00
committed by Mungai Njoroge
parent 070dc92733
commit 688e7d8282
14 changed files with 84 additions and 101 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
.album-grid-view { .card-grid-view {
height: 100%; height: 100%;
.scrollable { .scrollable {
+4 -14
View File
@@ -2,15 +2,13 @@
<div class="artist-albums"> <div class="artist-albums">
<h3> <h3>
<span>{{ title }} </span> <span>{{ title }} </span>
<span <SeeAll
class="see-all"
v-if="maxAbumCards <= albums.length" v-if="maxAbumCards <= albums.length"
:route="route"
@click=" @click="
!favorites ? useArtistDiscographyStore().setPage(albumType) : null !favorites ? useArtistDiscographyStore().setPage(albumType) : null
" "
> />
<RouterLink :to="route">SEE ALL</RouterLink>
</span>
</h3> </h3>
<div class="cards"> <div class="cards">
<AlbumCard v-for="a in albums.slice(0, maxAbumCards)" :album="a" /> <AlbumCard v-for="a in albums.slice(0, maxAbumCards)" :album="a" />
@@ -25,6 +23,7 @@ import { discographyAlbumTypes } from "@/composables/enums";
import useArtistDiscographyStore from "@/stores/pages/artistDiscog"; import useArtistDiscographyStore from "@/stores/pages/artistDiscog";
import AlbumCard from "../shared/AlbumCard.vue"; import AlbumCard from "../shared/AlbumCard.vue";
import SeeAll from "../shared/SeeAll.vue";
defineProps<{ defineProps<{
title: string; title: string;
@@ -45,15 +44,6 @@ defineProps<{
align-items: center; align-items: center;
padding: 0 $medium; padding: 0 $medium;
margin-bottom: $small; margin-bottom: $small;
.see-all {
font-size: $medium;
a:hover {
text-decoration: underline;
cursor: pointer !important;
}
}
} }
.cards { .cards {
-53
View File
@@ -1,53 +0,0 @@
<template>
<div class="albums-list">
<div class="section-title">
<b>
{{ title }}
</b>
<div class="see-all"><b>SEE ALL</b></div>
</div>
<div class="cars">
<AlbumCard
v-for="album in search.albums.value.slice(0, 6)"
:album="album"
:key="Math.random()"
/>
</div>
</div>
</template>
<script setup lang="ts">
import AlbumCard from "../shared/AlbumCard.vue";
import useSearchStore from "@/stores/search";
defineProps<{
// albums: Album[];
title: string;
}>();
const search = useSearchStore();
// TODO: use AlbumView's ArtistAlbums component instead of this
</script>
<style lang="scss">
.albums-list {
.section-title {
margin: 0;
margin-bottom: -$small;
.see-all {
float: right;
font-size: small;
opacity: 0.5;
}
}
.cars {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
// padding: 1rem 0;
// gap: 2rem 0;
}
}
</style>
+2 -12
View File
@@ -2,9 +2,7 @@
<div class="artist-top-tracks"> <div class="artist-top-tracks">
<h3 class="section-title"> <h3 class="section-title">
{{ title }} {{ title }}
<span class="see-all"> <SeeAll :route="route" />
<RouterLink :to="route">SEE ALL</RouterLink>
</span>
</h3> </h3>
<div class="tracks" :class="{ isSmall, isMedium }"> <div class="tracks" :class="{ isSmall, isMedium }">
<SongItem <SongItem
@@ -22,6 +20,7 @@
import SongItem from "../shared/SongItem.vue"; import SongItem from "../shared/SongItem.vue";
import { Track } from "@/interfaces"; import { Track } from "@/interfaces";
import { isMedium, isSmall } from "@/stores/content-width"; import { isMedium, isSmall } from "@/stores/content-width";
import SeeAll from "../shared/SeeAll.vue";
defineProps<{ defineProps<{
tracks: Track[]; tracks: Track[];
@@ -49,14 +48,5 @@ defineProps<{
justify-content: space-between; justify-content: space-between;
padding-left: 1rem !important; // applies to favorite page padding-left: 1rem !important; // applies to favorite page
} }
.see-all {
font-size: $medium;
a:hover {
text-decoration: underline;
cursor: pointer !important;
}
}
} }
</style> </style>
+5 -4
View File
@@ -1,6 +1,6 @@
<template> <template>
<div class="f-container rounded"> <div class="f-container rounded">
<div id="f-items" class="rounded lislt-mode"> <div id="f-items" class="rounded">
<FolderItem <FolderItem
v-for="folder in folders" v-for="folder in folders"
:key="JSON.stringify(folder)" :key="JSON.stringify(folder)"
@@ -28,12 +28,11 @@ defineProps<{
} }
#f-items.list-mode { #f-items.list-mode {
grid-template-columns: repeat(auto-fill, minmax(100%, 1fr)); grid-template-columns: 1fr;
gap: 0; gap: 0;
.f-item { .f-item {
// background-color: $red; height: 3.25rem;
height: 4rem;
border-radius: $small; border-radius: $small;
background-color: transparent; background-color: transparent;
} }
@@ -43,3 +42,5 @@ defineProps<{
} }
} }
</style> </style>
<!-- TODO: ADD BUTTON TO TOGGLE LIST MODE -->
+7 -4
View File
@@ -1,6 +1,9 @@
<template> <template>
<div class="f-artists"> <div class="f-artists">
<h3>{{ title }} <span class="see-all">SEE ALL</span></h3> <h3>
{{ title }}
<SeeAll :route="route" />
</h3>
<div class="artist-list"> <div class="artist-list">
<ArtistCard <ArtistCard
v-for="artist in artists.slice(0, maxAbumCards)" v-for="artist in artists.slice(0, maxAbumCards)"
@@ -15,10 +18,12 @@
import ArtistCard from "@/components/shared/ArtistCard.vue"; import ArtistCard from "@/components/shared/ArtistCard.vue";
import { Artist } from "@/interfaces"; import { Artist } from "@/interfaces";
import { maxAbumCards } from "@/stores/content-width"; import { maxAbumCards } from "@/stores/content-width";
import SeeAll from "../shared/SeeAll.vue";
defineProps<{ defineProps<{
artists: Artist[]; artists: Artist[];
title: string; title: string;
route: string;
}>(); }>();
</script> </script>
@@ -31,9 +36,7 @@ defineProps<{
align-items: center; align-items: center;
margin-bottom: $small; margin-bottom: $small;
.see-all {
font-size: $medium;
}
} }
.artist-list { .artist-list {
+23
View File
@@ -0,0 +1,23 @@
<template>
<span class="see-all">
<RouterLink :to="route"> SEE ALL </RouterLink>
</span>
</template>
<script setup lang="ts">
defineProps<{
route: string;
}>();
</script>
<style lang="scss">
.see-all {
font-size: $medium;
opacity: 0.75;
a:hover {
cursor: pointer !important;
text-decoration: underline;
}
}
</style>
+8
View File
@@ -142,6 +142,12 @@ const favoriteTracks = {
component: () => import("@/views/FavoriteTracks.vue"), component: () => import("@/views/FavoriteTracks.vue"),
}; };
const favoriteArtists = {
path: "/favorites/artists",
name: "FavoriteArtists",
component: () => import("@/views/FavoriteArtists.vue"),
};
const notFound = { const notFound = {
name: "NotFound", name: "NotFound",
path: "/:pathMatch(.*)", path: "/:pathMatch(.*)",
@@ -166,6 +172,7 @@ const routes = [
favorites, favorites,
favoriteAlbums, favoriteAlbums,
favoriteTracks, favoriteTracks,
favoriteArtists,
]; ];
const Routes = { const Routes = {
@@ -186,6 +193,7 @@ const Routes = {
favorites: favorites.name, favorites: favorites.name,
favoriteAlbums: favoriteAlbums.name, favoriteAlbums: favoriteAlbums.name,
favoriteTracks: favoriteTracks.name, favoriteTracks: favoriteTracks.name,
favoriteArtists: favoriteArtists.name,
}; };
export { routes, Routes }; export { routes, Routes };
+4
View File
@@ -34,3 +34,7 @@ export const contextChildrenShowModeStrings = <S>{
show_mode: "Show context children on", show_mode: "Show context children on",
}, },
}; };
export const showFoldersAsStrings = <S>{
settings: { show_folders_as: "Show folders as" },
};
+2 -2
View File
@@ -1,5 +1,5 @@
<template> <template>
<div class="album-grid-view v-scroll-page"> <div class="card-grid-view v-scroll-page">
<div class="scrollable"> <div class="scrollable">
<AlbumCard <AlbumCard
v-for="album in artist.toShow" v-for="album in artist.toShow"
@@ -11,8 +11,8 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import useArtistDiscographyStore from "@/stores/pages/artistDiscog";
import AlbumCard from "@/components/shared/AlbumCard.vue"; import AlbumCard from "@/components/shared/AlbumCard.vue";
import useArtistDiscographyStore from "@/stores/pages/artistDiscog";
import { onMounted } from "vue"; import { onMounted } from "vue";
import { onBeforeRouteLeave, useRoute } from "vue-router"; import { onBeforeRouteLeave, useRoute } from "vue-router";
-4
View File
@@ -180,9 +180,5 @@ onBeforeRouteLeave(async () => {
margin: 1rem; margin: 1rem;
padding-left: 1rem; padding-left: 1rem;
} }
.see-all {
opacity: 0.75;
}
} }
</style> </style>
+2 -2
View File
@@ -1,5 +1,5 @@
<template> <template>
<div class="album-grid-view v-scroll-page"> <div class="card-grid-view v-scroll-page">
<div class="scrollable"> <div class="scrollable">
<AlbumCard <AlbumCard
v-for="album in albums" v-for="album in albums"
@@ -11,8 +11,8 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, Ref, ref } from "vue";
import { getFavAlbums } from "@/composables/fetch/favorite"; import { getFavAlbums } from "@/composables/fetch/favorite";
import { onMounted, Ref, ref } from "vue";
import AlbumCard from "@/components/shared/AlbumCard.vue"; import AlbumCard from "@/components/shared/AlbumCard.vue";
import { Album } from "@/interfaces"; import { Album } from "@/interfaces";
+25
View File
@@ -0,0 +1,25 @@
<template>
<div class="card-grid-view v-scroll-page">
<div class="scrollable">
<ArtistCard
v-for="artist in artists"
:artist="artist"
:key="artist.artisthash"
/>
</div>
</div>
</template>
<script setup lang="ts">
import { getFavArtists } from "@/composables/fetch/favorite";
import { onMounted, Ref, ref } from "vue";
import ArtistCard from "@/components/shared/ArtistCard.vue";
import { Artist } from "@/interfaces";
const artists: Ref<Artist[]> = ref([]);
onMounted(() => {
getFavArtists(0).then((data) => (artists.value = data));
});
</script>
+1 -5
View File
@@ -18,7 +18,7 @@
</div> </div>
<div class="fav-artists" v-if="favArtists.length"> <div class="fav-artists" v-if="favArtists.length">
<FeaturedArtists :artists="favArtists" :title="'Artists ❤️'" /> <FeaturedArtists :artists="favArtists" :title="'Artists ❤️'" :route="'/favorites/artists'"/>
</div> </div>
</div> </div>
</template> </template>
@@ -67,10 +67,6 @@ async function handlePlay(index: number) {
margin-top: 0; margin-top: 0;
} }
.see-all {
opacity: 0.75;
}
.fav-tracks { .fav-tracks {
margin-bottom: 2rem; margin-bottom: 2rem;