From 63b717adfb83da518bc6c59fbb1be46bdfc6592f Mon Sep 17 00:00:00 2001 From: Prayag Prajapati Date: Tue, 16 Jan 2024 21:47:55 +0530 Subject: [PATCH] chore(web): Add new album page #243 --- src/components/carouselSlide/index.jsx | 5 +- src/routes/album/album.module.scss | 169 +++++++++++++++- src/routes/album/index.jsx | 257 ++++++++++++++++++++++--- src/routes/artist/index.jsx | 4 +- src/routes/home/index.jsx | 8 +- src/routes/library/index.jsx | 11 +- src/routes/search/index.jsx | 2 +- src/routes/series/series.module.scss | 1 - 8 files changed, 408 insertions(+), 49 deletions(-) diff --git a/src/components/carouselSlide/index.jsx b/src/components/carouselSlide/index.jsx index b826a2e..2dd362b 100644 --- a/src/components/carouselSlide/index.jsx +++ b/src/components/carouselSlide/index.jsx @@ -135,12 +135,11 @@ const CarouselSlide = ({ item }) => { animationDirection === "right" ? "translateX(-60px)" : "translateX(60px)", - opacity: 0, }} transition={{ - duration: 0.25, - ease: "easeInOut", + duration: 0.35, + ease: "anticipate", }} key={item.Id} variant="h2" diff --git a/src/routes/album/album.module.scss b/src/routes/album/album.module.scss index 466bfe3..0992c56 100644 --- a/src/routes/album/album.module.scss +++ b/src/routes/album/album.module.scss @@ -1,6 +1,11 @@ $border-radius: 20px; +.item-album{ + .item-hero-image-container{ + width: 22% !important; + } +} .item-detail-album { &-track { display: grid; @@ -10,13 +15,14 @@ $border-radius: 20px; gap: 0.5em; width: 100%; padding: 0.25em 0; - background: hsl(256, 100%, 4%, 40%); + background: rgb(0 0 0 / 0.4); transition: background $transition-time-default; backdrop-filter: blur(5px); &:first-child { border-radius: $border-radius $border-radius 8px 8px; cursor: default !important; + } &:last-child { @@ -33,7 +39,7 @@ $border-radius: 20px; } &:hover { - background: hsl(256, 100%, 4%, 50%); + background: rgb(0 0 0 / 0.5); cursor: pointer; } @@ -42,3 +48,162 @@ $border-radius: 20px; } } } + +.item { + gap: 1em; + &-hero { + height: 50vh; + gap: 2em; + position: relative; + align-items: center; + &-image { + opacity: 0; + width: 100%; + object-fit: contain; + transition: opacity $transition-time-default; + &-container { + height: fit-content; + max-height: 100%; + overflow: hidden; + border-radius: $border-radius-default; + box-shadow: $shadow-card; + flex-grow: 1; + flex-shrink: 0; + position: relative; + } + &-blurhash { + position: absolute !important; + width: 100% !important; + height: 100% !important; + z-index: -1; + } + } + &-logo { + max-width: 42rem; + max-height: 10rem; + opacity: 0; + transition: opacity $transition-time-default; + object-position: bottom; + } + &-detail { + width: 100%; + align-items: flex-start; + gap: 1em; + justify-content: end; + } + &-buttons { + &-container { + align-items: center; + justify-content: space-between; + width: 100%; + } + } + &-backdrop { + width: 100%; + height: 100%; + object-fit: cover; + object-position: top; + opacity: 0; + transition: opacity $transition-time-default; + &-container { + filter: brightness(0.8); + position: absolute; + top: -4.4em; + left: -1.6em; + width: 100vw; + height: calc(50vh + 4.4em); + z-index: -1; + mask-image: linear-gradient(to top, transparent, black); + -webkit-mask-image: linear-gradient( + to top, + transparent, + black + ); + } + } + } + + &-detail { + display: grid; + grid-template-columns: 1fr 5px 35%; + justify-items: center; + align-items: start; + gap: 1em; + + &-cast { + max-height: 50vh; + overflow-y: auto; + mask-image: linear-gradient(to top, transparent, black 1.2em); + -webkit-mask-image: linear-gradient(to top, transparent, black 1.2em); + &-title { + position: sticky; + top: 0; + background: $clr-background-dark; + padding: 0.35em; + border-radius: 10px; + z-index: 1; + } + &-container { + display: flex; + flex-direction: column; + gap: 1em; + } + &-grid { + display: grid; + gap: 1em; + margin-bottom: 1em; + grid-template-columns: repeat(2, minmax(0, 1fr)) !important; + } + &-card { + display: grid; + grid-template-columns: 6em 1fr; + gap: 0.5em; + align-items: center; + color: white !important; + text-decoration: none; + padding: 0.5em; + background: rgb(255 255 255 / 0); + transition: background $transition-time-default; + border-radius: $border-radius-default; + &:hover { + background: rgb(255 255 255 / 0.1); + } + &-image, + &-icon { + width: 6em; + height: 6em; + object-fit: cover; + border-radius: 100%; + box-shadow: $shadow-card-image; + } + &-icon { + display: flex; + align-items: center; + justify-content: center; + font-size: 1em; + background: rgb(255 255 255 / 0.1); + .material-symbols-rounded { + font-size: 3em; + } + } + } + } + &-link { + color: white; + text-decoration-color: rgb(255 255 255 / 0.5); + &:hover { + text-decoration-color: white; + } + } + } +} + +@media (max-width: 1320px) { + .item-album .item-detail { + &-cast { + &-grid { + grid-template-columns: 1fr; + } + } + } +} \ No newline at end of file diff --git a/src/routes/album/index.jsx b/src/routes/album/index.jsx index 9ff7ec4..12db136 100644 --- a/src/routes/album/index.jsx +++ b/src/routes/album/index.jsx @@ -1,12 +1,15 @@ import PropTypes from "prop-types"; -import React, { useEffect } from "react"; +import React, { useEffect, useLayoutEffect } from "react"; import Box from "@mui/material/Box"; +import Chip from "@mui/material/Chip"; import CircularProgress from "@mui/material/CircularProgress"; +import Divider from "@mui/material/Divider"; import Paper from "@mui/material/Paper"; +import Stack from "@mui/material/Stack"; import Typography from "@mui/material/Typography"; -import { useParams } from "react-router-dom"; +import { Link, NavLink, useParams } from "react-router-dom"; import { motion } from "framer-motion"; @@ -20,16 +23,20 @@ import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api"; import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api"; import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api"; +import { Blurhash } from "react-blurhash"; + import { useQuery } from "@tanstack/react-query"; -import { getRuntimeMusic } from "../../utils/date/time"; +import { endsAt, getRuntime, getRuntimeMusic } from "../../utils/date/time"; import { Card } from "../../components/card/card"; import { CardScroller } from "../../components/cardScroller/cardScroller"; -import Hero from "../../components/layouts/item/hero"; import LikeButton from "../../components/buttons/likeButton"; +import MarkPlayedButton from "../../components/buttons/markPlayedButton"; +import PlayButton from "../../components/buttons/playButton"; import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice"; +import { getTypeIcon } from "../../components/utils/iconsCollection"; import { useApi } from "../../utils/store/api"; import { useAudioPlayback } from "../../utils/store/audioPlayback"; import { useBackdropStore } from "../../utils/store/backdrop"; @@ -151,17 +158,14 @@ const MusicAlbumTitlePage = () => { const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]); - useEffect(() => { + useLayoutEffect(() => { if (item.isSuccess) { setAppBackdrop( - item.data.Type === BaseItemKind.MusicAlbum || - item.data.Type === BaseItemKind.Episode - ? `${api.basePath}/Items/${item.data.ParentBackdropItemId}/Images/Backdrop` - : `${api.basePath}/Items/${item.data.Id}/Images/Backdrop`, + `${api.basePath}/Items/${item.data.ParentBackdropItemId}/Images/Backdrop`, item.data.Id, ); } - }); + }, [item.isSuccess]); if (item.isPending || similarItems.isPending) { return ( @@ -192,24 +196,203 @@ const MusicAlbumTitlePage = () => { duration: 0.25, ease: "easeInOut", }} - className="scrollY" - style={{ - padding: "5em 2em 2em 1em", - display: "flex", - flexDirection: "column", - gap: "0.5em", - }} + className="scrollY padded-top item-album" > - +
+
+ {item.data.BackdropImageTags ? ( + {item.data.Name} { + e.currentTarget.style.opacity = 1; + }} + /> + ) : ( + <> + )} +
+
+ {Object.keys(item.data.ImageTags).includes("Primary") ? ( + <> + + {item.data.Name} { + e.currentTarget.style.opacity = 1; + }} + className="item-hero-image" + /> + + ) : ( + <> + )} +
+
+ {item.data.Name} + + + + + {item.data.ProductionYear ?? ""} + + + {item.data.ChildCount > 1 + ? `${item.data.ChildCount} Tracks` + : `${item.data.ChildCount}`} + + {item.data.RunTimeTicks && ( + + {getRuntime(item.data.RunTimeTicks)} + + )} + + + {item.data.Genres.join(", ")} + + +
+
+ +
+
+ +
+
+
+
+
+
+ + {item.data.Overview ?? ""} + + + +
+ {item.data.ExternalUrls.map((url) => ( + + {url.Name} + + ))} +
+
+ +
+
+ {item.data.ArtistItems.length > 0 && ( +
+ + Artists + +
+ {item.data.ArtistItems.map((artist) => ( + +
+ {artist.Name} + +
+ {getTypeIcon("Person")} +
+
+
+ + {artist.Name} + + + {artist.Role} + +
+
+ ))} +
+
+ )} +
+
+
{musicTracks.isPending ? ( <> ) : ( @@ -217,6 +400,7 @@ const MusicAlbumTitlePage = () => { @@ -225,7 +409,7 @@ const MusicAlbumTitlePage = () => { className="item-detail-album-track" style={{ padding: "0.75em 0 ", - background: "hsl(256, 100%, 4%, 60%)", + background: "rgb(0 0 0 / 0.6)", }} > { variant="subtitle1" style={{ justifySelf: "end", + display: "flex", + alignItems: "center", + justifyContent: "center", }} > - {track.IndexNumber ? track.IndexNumber : "-"} + {(currentTrackItem.Id === track.Id && + currentTrackItem.ParentId === track.ParentId ? ( +
+ equalizer +
+ ) : ( + track.IndexNumber + )) ?? "-"}
{ setActiveArtistTab(2); } } - }); + }, []); const [animationDirection, setAnimationDirection] = useState("forward"); @@ -174,7 +174,7 @@ const ArtistTitlePage = () => { item.data.Id, ); } - }); + }, []); if (item.isPending) { return ( diff --git a/src/routes/home/index.jsx b/src/routes/home/index.jsx index f4a5bad..244f139 100644 --- a/src/routes/home/index.jsx +++ b/src/routes/home/index.jsx @@ -21,7 +21,7 @@ import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api"; import { useNavigate } from "react-router-dom"; -import { useBackdropStore } from "../../utils/store/backdrop"; +import { setBackdrop, useBackdropStore } from "../../utils/store/backdrop"; import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client"; import Typography from "@mui/material/Typography"; @@ -153,8 +153,6 @@ const Home = () => { }); } - const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]); - if (user.isPaused) { user.refetch(); console.log(user.isError); @@ -181,12 +179,12 @@ const Home = () => { onChange={(now) => { if (latestMedia.isSuccess && latestMedia.data.length > 0) { if (latestMedia.data[now]?.ParentBackdropImageTags) { - setAppBackdrop( + setBackdrop( `${api.basePath}/Items/${latestMedia.data[now].ParentBackdropItemId}/Images/Backdrop`, latestMedia.data[now].Id, ); } else { - setAppBackdrop( + setBackdrop( `${api.basePath}/Items/${latestMedia.data[now].Id}/Images/Backdrop`, latestMedia.data[now].Id, ); diff --git a/src/routes/library/index.jsx b/src/routes/library/index.jsx index fa93775..7cfd248 100644 --- a/src/routes/library/index.jsx +++ b/src/routes/library/index.jsx @@ -1,5 +1,5 @@ import { motion } from "framer-motion"; -import React, { useState, useEffect } from "react"; +import React, { useState, useEffect, useLayoutEffect } from "react"; import { useParams } from "react-router-dom"; import { useQuery } from "@tanstack/react-query"; @@ -120,7 +120,7 @@ const LibraryView = () => { */ const [viewType, setViewType] = useState([]); - useEffect(() => { + useLayoutEffect(() => { if (currentLib.isError) { console.error(currentLib.error); } @@ -211,8 +211,7 @@ const LibraryView = () => { ]); } } - }); - + }, [currentLib.isSuccess]); const [filterArray, setFilterArray] = useState([]); const [videoTypes, setVideoTypes] = useState([]); @@ -330,10 +329,10 @@ const LibraryView = () => { const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]); - useState(() => { + useEffect(() => { // Remove App backdrop in library page setAppBackdrop("", ""); - console.log(items.isSuccess); + // console.log(items.isSuccess); }, []); if (items.isError) { diff --git a/src/routes/search/index.jsx b/src/routes/search/index.jsx index bfd008a..9a17408 100644 --- a/src/routes/search/index.jsx +++ b/src/routes/search/index.jsx @@ -148,7 +148,7 @@ const SearchPage = () => { useEffect(() => { // Removing app's backdrop setBackdrop("", ""); - }); + }, []); return (