From 9149792ed95ceca5b45029b581bbc3e45b16d49a Mon Sep 17 00:00:00 2001 From: Prayag Prajapati Date: Fri, 19 Jan 2024 18:56:27 +0530 Subject: [PATCH] chore(web): Implement new ArtistPage and add new TracksList component #243 --- src/App.tsx | 2 +- .../layouts/artist/albumArtist.scss | 14 +- src/components/layouts/artist/artistAlbum.jsx | 119 ++++++++---- src/components/layouts/tracksList/index.tsx | 89 +++++++++ .../layouts/tracksList/tracksList.module.scss | 38 ++++ src/components/showMoreText/index.jsx | 56 ++++++ src/routes/album/album.module.scss | 74 +++++++- src/routes/album/index.jsx | 151 ++------------- src/routes/artist/artist.module.scss | 136 ++++++++++++++ src/routes/artist/index.jsx | 173 ++++++++++++++---- src/routes/episode/episode.module.scss | 32 ++-- src/routes/episode/index.jsx | 8 +- src/routes/item/index.jsx | 10 +- src/routes/item/item.module.scss | 6 +- src/routes/person/index.jsx | 3 +- src/routes/person/person.module.scss | 6 +- src/routes/series/index.jsx | 8 +- src/routes/series/series.module.scss | 42 ++--- src/styles/global.scss | 14 +- src/styles/variables.scss | 2 + tsconfig.json | 5 +- 21 files changed, 704 insertions(+), 284 deletions(-) create mode 100644 src/components/layouts/tracksList/index.tsx create mode 100644 src/components/layouts/tracksList/tracksList.module.scss create mode 100644 src/components/showMoreText/index.jsx diff --git a/src/App.tsx b/src/App.tsx index d624dff..f60294b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -402,7 +402,7 @@ function AppReady() { opacity: 0, }} animate={{ - opacity: backdropLoading ? 0 : 0.6, + opacity: backdropLoading ? 0 : 1, }} exit={{ opacity: 0, diff --git a/src/components/layouts/artist/albumArtist.scss b/src/components/layouts/artist/albumArtist.scss index 481f431..be9149c 100644 --- a/src/components/layouts/artist/albumArtist.scss +++ b/src/components/layouts/artist/albumArtist.scss @@ -2,17 +2,19 @@ .album { &-image { aspect-ratio: 1; - border-radius: 10px; + border-radius: 20px; overflow: hidden; - width: 12em; - box-shadow: 0 0 10px rgb(0 0 0 /0.2); + width: 16em; + height: 16em; + box-shadow: $shadow-card-image; position: relative; - height: 12em; &-icon { - fill: url(#clr-gradient-default) !important; + color: rgb(255 255 255 / 0.5); + font-variation-settings: "FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40; + &-container { - background: $clr-gradient-dark; + background: $clr-background-card-icon; position: absolute; width: 100%; height: 100%; diff --git a/src/components/layouts/artist/artistAlbum.jsx b/src/components/layouts/artist/artistAlbum.jsx index 87ae8c9..40d0cd3 100644 --- a/src/components/layouts/artist/artistAlbum.jsx +++ b/src/components/layouts/artist/artistAlbum.jsx @@ -16,6 +16,9 @@ import { SortOrder } from "@jellyfin/sdk/lib/generated-client"; import { useApi } from "../../../utils/store/api"; import { useAudioPlayback } from "../../../utils/store/audioPlayback"; import LikeButton from "../../buttons/likeButton"; +import PlayButton from "../../buttons/playButton"; + +import TrackList from "../tracksList/index"; import "./albumArtist.scss"; export const ArtistAlbum = ({ user, album, boxProps }) => { @@ -35,8 +38,6 @@ export const ArtistAlbum = ({ user, album, boxProps }) => { networkMode: "always", }); - const [imgLoaded, setImgLoaded] = useState(false); - const [ currentTrackItem, setCurrentAudioTrack, @@ -75,57 +76,109 @@ export const ArtistAlbum = ({ user, album, boxProps }) => { {!!album.ImageTags?.Primary && (
{album.Name} setImgLoaded(true)} + onLoad={(e) => (e.currentTarget.style.opacity = 1)} />
- schedule + album
)} - - - {album.ProductionYear} - - +
+ + {album.ProductionYear} + + + {album.Name} + +
+
- {album.Name} - - + + + +
+ {albumTracks.isSuccess && ( - -
+ )} +
+ ); +}; + +{ + /*
{ Name schedule -
- {albumTracks.data.Items.map((track, index) => { + + {/*albumTracks.data.Items.map((track, index) => { return (
{
); - })} -
- )} - - ); -}; + })*/ +} diff --git a/src/components/layouts/tracksList/index.tsx b/src/components/layouts/tracksList/index.tsx new file mode 100644 index 0000000..76272ba --- /dev/null +++ b/src/components/layouts/tracksList/index.tsx @@ -0,0 +1,89 @@ +import Typography from "@mui/material/Typography"; +import React from "react"; + +// Types +import { BaseItemDto, UserDto } from "@jellyfin/sdk/lib/generated-client"; + +import { getRuntimeMusic } from "../../../utils/date/time"; +import { useApi } from "../../../utils/store/api"; +import { useAudioPlayback } from "../../../utils/store/audioPlayback"; +import LikeButton from "../../buttons/likeButton"; +import "./tracksList.module.scss"; + +export default function TracksList({ + tracks, + user, + queryKey, +}: { tracks: BaseItemDto[]; user: UserDto; queryKey: [] }) { + const [api] = useApi((state) => [state.api]); + + const [ + currentItem, + setCurrentAudioTrack, + setAudioUrl, + setAudioDisplay, + setAudioItem, + setAudioTracks, + ] = useAudioPlayback((state) => [ + state.item, + state.setCurrentTrack, + state.setUrl, + state.setDisplay, + state.setItem, + state.setTracks, + ]); + const playTrack = (index: number) => { + setAudioTracks(tracks); + setCurrentAudioTrack(index); + setAudioUrl( + `${api.basePath}/Audio/${tracks[index].Id}/universal?deviceId=${api.deviceInfo.id}&userId=${user.Id}&api_key=${api.accessToken}`, + ); + setAudioItem(tracks[index]); + setAudioDisplay(true); + }; + return ( +
+
+ # +
{""}
+ + Name + + schedule +
+ {tracks.map((track, index) => ( +
playTrack(index)} + > + {currentItem.Id === track.Id ? ( + equalizer + ) : ( + {track.IndexNumber ?? "-"} + )} + + + {track.Name} + + {getRuntimeMusic(track.RunTimeTicks)} +
+ ))} +
+ ); +} diff --git a/src/components/layouts/tracksList/tracksList.module.scss b/src/components/layouts/tracksList/tracksList.module.scss new file mode 100644 index 0000000..5fda427 --- /dev/null +++ b/src/components/layouts/tracksList/tracksList.module.scss @@ -0,0 +1,38 @@ +.track{ + display: grid; + grid-template-columns: 4% 1fr 80% 1fr; + align-items: center; + justify-items: center; + gap: 0.5em; + width: 100%; + transition: background $transition-time-default; + padding: 0.4em; + border-bottom: 1px solid rgb(255 255 255 / 0.1); + cursor: pointer; + box-sizing: border-box; + + &:hover{ + background: rgb(255 255 255 / 0.1); + } + &.playing { + background: rgb(255 255 255 / 0.2); + } + + &-list { + background: rgb(0 0 0 / 0.4); + backdrop-filter: blur(5px); + border-radius: 20px; + overflow: hidden; + border: 1px solid rgb(255 255 255 / 0.2); + } + &-header{ + background: rgb(0 0 0 / 0.4) !important; + padding: 0.8em 0.4em; + } + > *:first-child { + justify-self: end; + } + &:last-child { + border-bottom: 0px solid !important; + } +} \ No newline at end of file diff --git a/src/components/showMoreText/index.jsx b/src/components/showMoreText/index.jsx new file mode 100644 index 0000000..fc268fd --- /dev/null +++ b/src/components/showMoreText/index.jsx @@ -0,0 +1,56 @@ +import Button from "@mui/material/Button"; +import Typography from "@mui/material/Typography"; +import { useEffect, useRef, useState } from "react"; + +const ShowMoreText = ({ content, collapsedLines, extraProps }) => { + const [displayFull, setDisplayFull] = useState(false); + const [isOverflowing, setIsOverflowing] = useState(false); + const textRef = useRef(null); + + useEffect(() => { + if (textRef.current) { + if (textRef.current.offsetHeight < textRef.current.scrollHeight) { + setIsOverflowing(true); + } else { + setIsOverflowing(false); + } + // textRef.current. + } + }, []); + return ( +
+ + {content} + + {content.length > 0 && isOverflowing && ( + + )} +
+ ); +}; +export default ShowMoreText; diff --git a/src/routes/album/album.module.scss b/src/routes/album/album.module.scss index 89c7ed0..3fcdc89 100644 --- a/src/routes/album/album.module.scss +++ b/src/routes/album/album.module.scss @@ -107,9 +107,9 @@ $border-radius: 20px; } } -.item { +.item-album.item { gap: 1em; - &-hero { + .item-hero { height: 50vh; gap: 2em; position: relative; @@ -181,14 +181,72 @@ $border-radius: 20px; } } - &-detail { + .item-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: black; + border:1px solid rgb(255 255 255 / 0.2) ; + 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)); + } + &-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); @@ -196,6 +254,14 @@ $border-radius: 20px; text-decoration-color: white; } } + &-episodes-container { + display: grid; + grid-template-columns: repeat(4, minmax(0, 1fr)); + gap: 0.25em; + margin-top: 0.5em; + align-items: start; + justify-items: center; + } } } diff --git a/src/routes/album/index.jsx b/src/routes/album/index.jsx index c0f0896..3d93f76 100644 --- a/src/routes/album/index.jsx +++ b/src/routes/album/index.jsx @@ -35,7 +35,10 @@ import { CardScroller } from "../../components/cardScroller/cardScroller"; import LikeButton from "../../components/buttons/likeButton"; import MarkPlayedButton from "../../components/buttons/markPlayedButton"; import PlayButton from "../../components/buttons/playButton"; +import TrackList from "../../components/layouts/tracksList"; import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice"; +import ShowMoreText from "../../components/showMoreText"; + import { getTypeIcon } from "../../components/utils/iconsCollection"; import { useApi } from "../../utils/store/api"; import { useAudioPlayback } from "../../utils/store/audioPlayback"; @@ -196,7 +199,7 @@ const MusicAlbumTitlePage = () => { duration: 0.25, ease: "easeInOut", }} - className="scrollY padded-top item-album" + className="scrollY padded-top item item-album" >
@@ -301,12 +304,17 @@ const MusicAlbumTitlePage = () => {
-
+
- - {item.data.Overview ?? ""} - - +
{ ))}
- +
{
- {musicTracks.isPending ? ( - <> - ) : ( - musicTracks.data.TotalRecordCount > 0 && ( - -
- - # - -
- - Name - - schedule -
- {musicTracks.data.Items.map((track, index) => { - return ( -
playTrack(index)} - > - - {(currentTrackItem.Id === track.Id && - currentTrackItem.ParentId === track.ParentId ? ( -
- equalizer -
- ) : ( - track.IndexNumber - )) ?? "-"} -
- - - -
- - {track.Name} - - {track.AlbumArtist === "Various Artists" && ( - - {track.ArtistItems.map((artist) => artist.Name).join( - ", ", - )} - - )} -
- - {getRuntimeMusic(track.RunTimeTicks)} - -
- ); - })} - - ) + {musicTracks.isSuccess && musicTracks.data.TotalRecordCount > 0 && ( + )} {similarItems.data.TotalRecordCount > 0 && ( diff --git a/src/routes/artist/artist.module.scss b/src/routes/artist/artist.module.scss index 9e4f37a..2a702d5 100644 --- a/src/routes/artist/artist.module.scss +++ b/src/routes/artist/artist.module.scss @@ -1,4 +1,140 @@ +.item-artist.item { + gap: 1em; + .item-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; + width: 18% !important; + } + &-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 + ); + } + } + } + .item-detail { + display: grid; + grid-template-columns: 1fr 5px 35%; + justify-items: center; + align-items: start; + gap: 1em; + + &-cast { + &-container { + display: flex; + flex-direction: column; + gap: 1em; + } + &-grid { + display: grid; + grid-template-columns: repeat(5, minmax(0, 1fr)); + gap: 1em; + margin-bottom: 1em; + } + &-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; + } + } + } +} .item-detail-artist { &-container { position: relative; diff --git a/src/routes/artist/index.jsx b/src/routes/artist/index.jsx index b1f2bd5..b8a30aa 100644 --- a/src/routes/artist/index.jsx +++ b/src/routes/artist/index.jsx @@ -1,15 +1,16 @@ import PropTypes from "prop-types"; -import React, { useState, useEffect } from "react"; +import React, { useState, useEffect, useLayoutEffect } from "react"; import Box from "@mui/material/Box"; import CircularProgress from "@mui/material/CircularProgress"; import Divider from "@mui/material/Divider"; import Tab from "@mui/material/Tab"; import Tabs from "@mui/material/Tabs"; +import Typography from "@mui/material/Typography"; import { AnimatePresence, motion } from "framer-motion"; -import { useParams } from "react-router-dom"; +import { Link, useParams } from "react-router-dom"; import { BaseItemKind, @@ -22,14 +23,17 @@ import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api" import { useQuery } from "@tanstack/react-query"; +import { Blurhash } from "react-blurhash"; +import LikeButton from "../../components/buttons/likeButton"; import { Card } from "../../components/card/card"; -import Hero from "../../components/layouts/item/hero"; +import meshBg from "../../assets/herobg.png"; import { ArtistAlbum } from "../../components/layouts/artist/artistAlbum"; import MusicTrack from "../../components/musicTrack"; import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice"; +import ShowMoreText from "../../components/showMoreText"; import { useApi } from "../../utils/store/api"; -import { useBackdropStore } from "../../utils/store/backdrop"; +import { setBackdrop, useBackdropStore } from "../../utils/store/backdrop"; import "./artist.module.scss"; function TabPanel(props) { @@ -98,7 +102,6 @@ const ArtistTitlePage = () => { return result.data; }, enabled: item.isSuccess && item.data.Type === BaseItemKind.MusicArtist, - networkMode: "always", }); const artistSongs = useQuery({ @@ -116,7 +119,6 @@ const ArtistTitlePage = () => { return result.data; }, enabled: item.isSuccess && item.data.Type === BaseItemKind.MusicArtist, - networkMode: "always", }); const artistAppearances = useQuery({ @@ -134,7 +136,6 @@ const ArtistTitlePage = () => { return result.data; }, enabled: item.isSuccess && item.data.Type === BaseItemKind.MusicArtist, - networkMode: "always", }); const artistTabs = [ @@ -144,7 +145,7 @@ const ArtistTitlePage = () => { ]; const [activeArtistTab, setActiveArtistTab] = useState(0); - useEffect(() => { + useLayoutEffect(() => { if ( artistDiscography.isSuccess && artistSongs.isSuccess && @@ -158,23 +159,22 @@ const ArtistTitlePage = () => { setActiveArtistTab(2); } } - }, []); + }, [ + artistDiscography.isSuccess, + artistSongs.isSuccess, + artistAppearances.isSuccess, + ]); const [animationDirection, setAnimationDirection] = useState("forward"); - const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]); - useEffect(() => { 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`, + setBackdrop( + `${api.basePath}/Items/${item.data.Id}/Images/Backdrop`, item.data.Id, ); } - }, []); + }, [item.isSuccess]); if (item.isPending) { return ( @@ -205,23 +205,132 @@ const ArtistTitlePage = () => { duration: 0.25, ease: "easeInOut", }} - className="scrollY" - style={{ - padding: "5em 2em 2em 1em", - display: "flex", - flexDirection: "column", - gap: "0.5em", - }} + className="scrollY item item-artist" > - +
+
+ {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" + /> + + ) : ( + <> + )} +
+
+ {Object.keys(item.data.ImageTags).includes("Logo") ? ( + {item.data.Name} { + e.currentTarget.style.opacity = 1; + }} + className="item-hero-logo" + /> + ) : ( + {item.data.Name} + )} + +
+
+
+
+ +
+ {item.data.ExternalUrls.map((url) => ( + + {url.Name} + + ))} +
+
+ +
+ {item.data.PremiereDate && ( + <> + Born + + {new Date(item.data.PremiereDate).toDateString()} + + + )} + {item.data.EndDate && ( + <> + + Death + + + {new Date(item.data.EndDate).toDateString()} + + + )} +
+
{ {item.data.Taglines[0] ?? ""} - - {item.data.Overview ?? ""} - + {writers.length > 0 && (
{ duration: 0.25, ease: "easeInOut", }} - className="scrollY padded-top flex flex-column item" + className="scrollY padded-top flex flex-column item item-default" >
@@ -586,9 +587,10 @@ const ItemDetail = () => { {item.data.Taglines[0] ?? ""} - - {item.data.Overview ?? ""} - + {writers.length > 0 && (
{ duration: 0.25, ease: "easeInOut", }} - className="scrollY padded-top" + className="scrollY padded-top item item-person" >
diff --git a/src/routes/person/person.module.scss b/src/routes/person/person.module.scss index b15576e..8e54c41 100644 --- a/src/routes/person/person.module.scss +++ b/src/routes/person/person.module.scss @@ -20,9 +20,9 @@ grid-template-columns: repeat(4, minmax(0, 1fr)); } -.item { +.item-person.item { gap: 1em; - &-hero { + .item-hero { height: 50vh; gap: 2em; position: relative; @@ -95,7 +95,7 @@ } } - &-detail { + .item-detail { display: grid; grid-template-columns: 1fr 5px 35%; justify-items: center; diff --git a/src/routes/series/index.jsx b/src/routes/series/index.jsx index 4c9126e..bd2c4f6 100644 --- a/src/routes/series/index.jsx +++ b/src/routes/series/index.jsx @@ -48,6 +48,7 @@ import { NavLink } from "react-router-dom"; import LikeButton from "../../components/buttons/likeButton"; import MarkPlayedButton from "../../components/buttons/markPlayedButton"; import PlayButton from "../../components/buttons/playButton"; +import ShowMoreText from "../../components/showMoreText"; import { SeasonSelectorSkeleton } from "../../components/skeleton/seasonSelector"; import TextLink from "../../components/textLink"; import { getTypeIcon } from "../../components/utils/iconsCollection"; @@ -501,9 +502,10 @@ const SeriesTitlePage = () => { {item.data.Taglines[0] ?? ""} - - {item.data.Overview ?? ""} - + {writers.length > 0 && (