From e907ddceef270bd71eff00924b78eb78b6151f2e Mon Sep 17 00:00:00 2001 From: Prayag Prajapati Date: Tue, 9 Jan 2024 20:13:26 +0530 Subject: [PATCH] Update Episode page #243 --- src/routes/episode/episode.module.scss | 150 +++- src/routes/episode/index.jsx | 966 +++++++++++++++++++++++-- src/routes/item/index.jsx | 8 +- src/routes/item/item.module.scss | 8 +- src/routes/search/index.jsx | 14 +- src/routes/series/index.jsx | 30 +- src/routes/series/series.module.scss | 10 +- src/styles/global.scss | 12 + 8 files changed, 1105 insertions(+), 93 deletions(-) diff --git a/src/routes/episode/episode.module.scss b/src/routes/episode/episode.module.scss index 9886df6..d29989f 100644 --- a/src/routes/episode/episode.module.scss +++ b/src/routes/episode/episode.module.scss @@ -1,5 +1,151 @@ /** @format */ -.episode .item-detail-primaryImage { - align-self: center; +.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; + width: fit-content; + 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 { + &-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-episode { + .item-hero { + &-image-container { + width: 26% !important; + max-width: 26% !important; + } + &-detail { + gap: 0.5em; + } + } } diff --git a/src/routes/episode/index.jsx b/src/routes/episode/index.jsx index 2d81d61..f9f1adf 100644 --- a/src/routes/episode/index.jsx +++ b/src/routes/episode/index.jsx @@ -1,11 +1,21 @@ /** @format */ -import React, { useState, useEffect } from "react"; +import React, { useState, useLayoutEffect } from "react"; import PropTypes from "prop-types"; import Box from "@mui/material/Box"; +import Stack from "@mui/material/Stack"; +import Typography from "@mui/material/Typography"; import CircularProgress from "@mui/material/CircularProgress"; +import Chip from "@mui/material/Chip"; +import TextField from "@mui/material/TextField"; +import MenuItem from "@mui/material/MenuItem"; +import Divider from "@mui/material/Divider"; +import LinearProgress from "@mui/material/LinearProgress"; +import { red, green, yellow } from "@mui/material/colors"; -import { useParams } from "react-router-dom"; +import { Blurhash } from "react-blurhash"; + +import { useParams, Link, NavLink } from "react-router-dom"; import { motion } from "framer-motion"; @@ -20,15 +30,19 @@ import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api"; import { useQuery } from "@tanstack/react-query"; -import Hero from "../../components/layouts/item/hero"; import { Card } from "../../components/card/card"; import { CardScroller } from "../../components/cardScroller/cardScroller"; import "./episode.module.scss"; import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice"; import { useBackdropStore } from "../../utils/store/backdrop"; -import { ActorCard } from "../../components/card/actorCards"; import { useApi } from "../../utils/store/api"; +import { endsAt, getRuntime } from "../../utils/date/time"; +import PlayButton from "../../components/buttons/playButton"; +import LikeButton from "../../components/buttons/likeButton"; +import MarkPlayedButton from "../../components/buttons/markPlayedButton"; +import TextLink from "../../components/textLink"; +import { getTypeIcon } from "../../components/utils/iconsCollection"; function TabPanel(props) { const { children, value, index, ...other } = props; @@ -82,6 +96,22 @@ const EpisodeTitlePage = () => { refetchOnWindowFocus: true, }); + const upcomingEpisodes = useQuery({ + queryKey: ["item", id, "episode", "upcomingEpisodes"], + queryFn: async () => { + const result = await getItemsApi(api).getItems({ + userId: user.data.Id, + parentId: item.data.ParentId, + startIndex: item.data.IndexNumber, + }); + return result.data; + }, + enabled: item.isSuccess && item.data.Type == BaseItemKind.Episode, + networkMode: "always", + }); + + const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]); + const [videoTracks, setVideoTracks] = useState([]); const [audioTracks, setAudioTracks] = useState([]); const [subtitleTracks, setSubtitleTracks] = useState([]); @@ -105,7 +135,11 @@ const EpisodeTitlePage = () => { return false; }; - useEffect(() => { + const [selectedVideoTrack, setSelectedVideoTrack] = useState(null); + const [selectedAudioTrack, setSelectedAudioTrack] = useState(null); + const [selectedSubtitleTrack, setSelectedSubtitleTrack] = useState(null); + + useLayoutEffect(() => { if (item.isSuccess && !!item.data.MediaStreams) { let videos = item.data.MediaStreams.filter( filterMediaStreamVideo, @@ -117,31 +151,21 @@ const EpisodeTitlePage = () => { filterMediaStreamSubtitle, ); + setSelectedVideoTrack(videos[0]?.Index ?? null); + setSelectedAudioTrack(audios[0]?.Index ?? null); + setSelectedSubtitleTrack(subs[0]?.Index ?? null); + setVideoTracks(videos); setAudioTracks(audios); setSubtitleTracks(subs); } }, [item.isSuccess]); - const upcomingEpisodes = useQuery({ - queryKey: ["item", id, "episode", "upcomingEpisodes"], - queryFn: async () => { - const result = await getItemsApi(api).getItems({ - userId: user.data.Id, - parentId: item.data.ParentId, - startIndex: item.data.IndexNumber, - }); - return result.data; - }, - enabled: item.isSuccess && item.data.Type == BaseItemKind.Episode, - networkMode: "always", - }); - - const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]); - const [directors, setDirectors] = useState([]); const [writers, setWriters] = useState([]); - useEffect(() => { + const [actors, setActors] = useState([]); + const [producers, setProducers] = useState([]); + useLayoutEffect(() => { if (item.isSuccess) { setAppBackdrop( item.data.Type === BaseItemKind.MusicAlbum || @@ -158,9 +182,74 @@ const EpisodeTitlePage = () => { (itm) => itm.Type == "Writer", ); setWriters(writeTp); + let producerTp = item.data.People.filter( + (itm) => itm.Type == "Producer", + ); + setProducers(producerTp); + let actorTp = item.data.People.filter( + (itm) => itm.Type == "Actor", + ); + setActors(actorTp); } }, [item.isSuccess]); + const qualityLabel = () => { + if ( + videoTracks[0]?.DisplayTitle.toLocaleLowerCase().includes( + "2160p", + ) || + videoTracks[0]?.DisplayTitle.toLocaleLowerCase().includes("4k") + ) { + return 4k; + } else if ( + videoTracks[0]?.DisplayTitle.toLocaleLowerCase().includes( + "1080p", + ) || + videoTracks[0]?.DisplayTitle.toLocaleLowerCase().includes("hd") + ) { + return full_hd; + } else { + return hd; + } + }; + + const atmosLabel = () => { + if ( + audioTracks[0]?.DisplayTitle.toLocaleLowerCase().includes( + "atmos", + ) && + audioTracks[0]?.DisplayTitle.toLocaleLowerCase().includes( + "truehd", + ) + ) { + return `TrueHD | Atmos`; + } else if ( + audioTracks[0]?.DisplayTitle.toLocaleLowerCase().includes( + "atmos", + ) + ) { + return "Atmos"; + } else if ( + audioTracks[0]?.DisplayTitle.toLocaleLowerCase().includes( + "truehd", + ) + ) { + return "TrueHD"; + } else { + return ""; + } + }; + + const surroundSoundLabel = () => { + if (audioTracks[0]?.DisplayTitle.includes("7.1")) { + return "7.1"; + } else if (audioTracks[0]?.DisplayTitle.includes("5.1")) { + return "5.1"; + } else { + return "2.0"; + } + }; + if (item.isPending) { return ( { duration: 0.25, ease: "easeInOut", }} - className="scrollY episode" - style={{ - padding: "5em 2em 2em 1em", - display: "flex", - flexDirection: "column", - gap: "0.5em", - }} + className="scrollY padded-top flex flex-column item item-episode" > - - {item.data.People.length > 0 && ( - +
+ {item.data.BackdropImageTags ? ( + + (e.currentTarget.style.opacity = 1) + } + /> + ) : ( + <> + )} +
+
- {item.data.People.map((person) => { - return ( - + - ); - })} - - )} + + (e.currentTarget.style.opacity = 1) + } + className="item-hero-image" + /> + + ) : ( + <> + )} +
+
+ + {item.data.ParentLogoItemId.length > 0 ? ( + + (e.currentTarget.style.opacity = 1) + } + className="item-hero-logo" + /> + ) : ( + item.data.SeriesName + )} + + + S{item.data.ParentIndexNumber ?? 0}:E + {item.data.IndexNumber} {item.data.Name} + + + + {!!qualityLabel() && ( + + )} + {!!surroundSoundLabel() && ( + + {surroundSoundLabel()} + + } + sx={{ + borderRadius: + "8px !important", + "& .MuiChip-label": { + fontSize: "2.2em", + }, + }} + /> + )} + {!!videoTracks[0]?.VideoRangeType && ( + + { + videoTracks[0] + .VideoRangeType + } + + } + sx={{ + borderRadius: + "8px !important", + "& .MuiChip-label": { + fontSize: "2.2em", + }, + }} + /> + )} + {!!atmosLabel() && ( + + {atmosLabel()} + + } + sx={{ + borderRadius: + "8px !important", + "& .MuiChip-label": { + fontSize: "2.2em", + }, + }} + /> + )} + {!!subtitleTracks.length > 0 && ( + + // CC + // + + closed_caption + + } + sx={{ + borderRadius: + "8px !important", + "& .MuiChip-label": { + fontSize: "2.2em", + }, + }} + /> + )} + + + + {item.data.ProductionYear ?? ""} + + {item.data.OfficialRating && ( + + )} + + {item.data.CommunityRating && ( +
+
+ star +
+ + {Math.round( + item.data + .CommunityRating * + 10, + ) / 10} + +
+ )} + {item.data.CriticRating && ( +
+
+ 50 + ? green[400] + : red[400], + fontVariationSettings: + '"FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40', + }} + > + {item.data.CriticRating > 50 + ? "thumb_up" + : "thumb_down"} +
+ + {item.data.CriticRating} + +
+ )} + + {item.data.RunTimeTicks && ( + + {getRuntime( + item.data.RunTimeTicks, + )} + + )} + {item.data.RunTimeTicks && ( + + {endsAt( + item.data.RunTimeTicks - + item.data.UserData + .PlaybackPositionTicks, + )} + + )} +
+ + {item.data.Genres.join(", ")} + + +
+
+ +
+
+ + +
+
+
+ +
+
+ {item.data.UserData.PlaybackPositionTicks > 0 && ( +
+ + {getRuntime( + item.data.RunTimeTicks - + item.data.UserData + .PlaybackPositionTicks, + )}{" "} + left + + +
+ )} + + {item.data.Taglines[0] ?? ""} + + + {item.data.Overview ?? ""} + + {writers.length > 0 && ( +
+ + Written by + +
+ {writers.map((writer, index) => ( + <> + + {writer.Name} + + {index != + writers.length - + 1 && ( + + ,{" "} + + )} + + ))} +
+
+ )} + {directors.length > 0 && ( +
+ + Directed by + +
+ {directors.map( + (director, index) => ( + <> + + {director.Name} + + {index != + directors.length - + 1 && ( + + ,{" "} + + )} + + ), + )} +
+
+ )} +
+ +
+ {videoTracks.length > 0 && ( + + setSelectedVideoTrack( + e.target.value, + ) + } + > + {videoTracks.map((track) => ( + + {track.DisplayTitle} + + ))} + + )} + {audioTracks.length > 0 && ( + + setSelectedAudioTrack( + e.target.value, + ) + } + > + {audioTracks.map((track) => ( + + {track.DisplayTitle} + + ))} + + )} + {subtitleTracks.length > 0 && ( + + setSelectedSubtitleTrack( + e.target.value, + ) + } + > + + No Subtitle + + {subtitleTracks.map((track) => ( + + {track.DisplayTitle} + + ))} + + )} +
+ {item.data.ExternalUrls.map((url) => ( + + {url.Name} + + ))} +
+
+
+ {upcomingEpisodes.isSuccess && upcomingEpisodes.data.Items.length > 0 && ( { )} )} +
+ + Cast & Crew + + {actors.length > 0 && ( +
+ Actors +
+ {actors.map((actor) => ( + + {actor.PrimaryImageTag ? ( + + ) : ( +
+ {getTypeIcon( + "Person", + )} +
+ )} +
+ + {actor.Name} + + + {actor.Role} + +
+
+ ))} +
+
+ )} + {writers.length > 0 && ( +
+ Writers +
+ {writers.map((actor) => ( + + {actor.PrimaryImageTag ? ( + + ) : ( +
+ {getTypeIcon( + "Person", + )} +
+ )} +
+ + {actor.Name} + + + {actor.Role} + +
+
+ ))} +
+
+ )} + {directors.length > 0 && ( +
+ + Directors + +
+ {directors.map((actor) => ( + + {actor.PrimaryImageTag ? ( + + ) : ( +
+ {getTypeIcon( + "Person", + )} +
+ )} +
+ + {actor.Name} + + + {actor.Role} + +
+
+ ))} +
+
+ )} + {producers.length > 0 && ( +
+ + Producers + +
+ {producers.map((actor) => ( + + {actor.PrimaryImageTag ? ( + + ) : ( +
+ {getTypeIcon( + "Person", + )} +
+ )} +
+ + {actor.Name} + + + {actor.Role} + +
+
+ ))} +
+
+ )} +
); } diff --git a/src/routes/item/index.jsx b/src/routes/item/index.jsx index d29dccd..db2ffeb 100644 --- a/src/routes/item/index.jsx +++ b/src/routes/item/index.jsx @@ -1,5 +1,5 @@ /** @format */ -import React, { useState, useEffect, useLayoutEffect } from "react"; +import React, { useState, useLayoutEffect } from "react"; import PropTypes from "prop-types"; import Box from "@mui/material/Box"; @@ -15,7 +15,7 @@ import { red, green, yellow } from "@mui/material/colors"; import { Blurhash } from "react-blurhash"; -import { useParams } from "react-router-dom"; +import { useParams, Link, NavLink } from "react-router-dom"; import { motion } from "framer-motion"; @@ -30,7 +30,6 @@ import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api"; import { useQuery } from "@tanstack/react-query"; -import Hero from "../../components/layouts/item/hero"; import { Card } from "../../components/card/card"; import { CardScroller } from "../../components/cardScroller/cardScroller"; @@ -39,7 +38,6 @@ import "./item.module.scss"; import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice"; import { useBackdropStore } from "../../utils/store/backdrop"; -import { ActorCard } from "../../components/card/actorCards"; import { useApi } from "../../utils/store/api"; import { endsAt, getRuntime } from "../../utils/date/time"; import PlayButton from "../../components/buttons/playButton"; @@ -47,8 +45,6 @@ import LikeButton from "../../components/buttons/likeButton"; import MarkPlayedButton from "../../components/buttons/markPlayedButton"; import TextLink from "../../components/textLink"; import { getTypeIcon } from "../../components/utils/iconsCollection"; -import { NavLink } from "react-router-dom"; -import { Link } from "react-router-dom"; function TabPanel(props) { const { children, value, index, ...other } = props; diff --git a/src/routes/item/item.module.scss b/src/routes/item/item.module.scss index 5693185..f386b07 100644 --- a/src/routes/item/item.module.scss +++ b/src/routes/item/item.module.scss @@ -1,18 +1,20 @@ /** @format */ + .item { gap: 1em; &-hero { height: 50vh; gap: 2em; position: relative; + align-items: center; &-image { - height: 100%; opacity: 0; width: 100%; object-fit: contain; transition: opacity $transition-time-default; &-container { - height: 100%; + height: fit-content; + max-height: 100%; overflow: hidden; border-radius: $border-radius-default; width: fit-content; @@ -20,7 +22,7 @@ flex-grow: 1; flex-shrink: 0; position: relative; - max-width: 26%; + width: 20%; } &-blurhash { position: absolute !important; diff --git a/src/routes/search/index.jsx b/src/routes/search/index.jsx index 37f0ae5..200e5b8 100644 --- a/src/routes/search/index.jsx +++ b/src/routes/search/index.jsx @@ -54,7 +54,7 @@ const SearchPage = () => { }); return result.data; }, - enabled: user.isSuccess && Boolean(searchParam), + enabled: user.isSuccess, cacheTime: 0, }); const series = useQuery({ @@ -69,7 +69,7 @@ const SearchPage = () => { }); return result.data; }, - enabled: user.isSuccess && Boolean(searchParam), + enabled: user.isSuccess, cacheTime: 0, }); const musicAlbum = useQuery({ @@ -84,7 +84,7 @@ const SearchPage = () => { }); return result.data; }, - enabled: user.isSuccess && Boolean(searchParam), + enabled: user.isSuccess, cacheTime: 0, }); const audio = useQuery({ @@ -99,7 +99,7 @@ const SearchPage = () => { }); return result.data; }, - enabled: user.isSuccess && Boolean(searchParam), + enabled: user.isSuccess, cacheTime: 0, }); const book = useQuery({ @@ -114,7 +114,7 @@ const SearchPage = () => { }); return result.data; }, - enabled: user.isSuccess && Boolean(searchParam), + enabled: user.isSuccess, cacheTime: 0, }); const musicArtists = useQuery({ @@ -129,7 +129,7 @@ const SearchPage = () => { }); return result.data; }, - enabled: user.isSuccess && Boolean(searchParam), + enabled: user.isSuccess, cacheTime: 0, }); const person = useQuery({ @@ -142,7 +142,7 @@ const SearchPage = () => { }); return result.data; }, - enabled: user.isSuccess && Boolean(searchParam), + enabled: user.isSuccess, cacheTime: 0, }); diff --git a/src/routes/series/index.jsx b/src/routes/series/index.jsx index 0b4a07d..c0722b1 100644 --- a/src/routes/series/index.jsx +++ b/src/routes/series/index.jsx @@ -1100,8 +1100,12 @@ const SeriesTitlePage = () => { "10px", animationDelay: `${ index * - 0.15 + 0.2 }s`, + animationDuration: + "1.4s", + animationName: + "pulse", }} /> @@ -1120,8 +1124,12 @@ const SeriesTitlePage = () => { sx={{ animationDelay: `${ index * - 0.15 + 0.2 }s`, + animationDuration: + "1.4s", + animationName: + "pulse", }} /> @@ -1132,8 +1140,12 @@ const SeriesTitlePage = () => { sx={{ animationDelay: `${ index * - 0.15 + 0.2 }s`, + animationDuration: + "1.4s", + animationName: + "pulse", }} /> { sx={{ animationDelay: `${ index * - 0.15 + 0.2 }s`, + animationDuration: + "1.4s", + animationName: + "pulse", }} /> @@ -1151,8 +1167,12 @@ const SeriesTitlePage = () => { sx={{ animationDelay: `${ index * - 0.15 + 0.2 }s`, + animationDuration: + "1.4s", + animationName: + "pulse", }} /> diff --git a/src/routes/series/series.module.scss b/src/routes/series/series.module.scss index 20e0a16..0bbf7a8 100644 --- a/src/routes/series/series.module.scss +++ b/src/routes/series/series.module.scss @@ -1,19 +1,19 @@ /** @format */ -/** @format */ .item { gap: 1em; &-hero { height: 50vh; gap: 2em; position: relative; + align-items: center; &-image { - height: 100%; opacity: 0; width: 100%; object-fit: contain; transition: opacity $transition-time-default; &-container { - height: 100%; + height: fit-content; + max-height: 100%; overflow: hidden; border-radius: $border-radius-default; width: fit-content; @@ -21,7 +21,6 @@ flex-grow: 1; flex-shrink: 0; position: relative; - max-width: 26%; } &-blurhash { position: absolute !important; @@ -159,6 +158,9 @@ } .item-series { + .item-hero-image-container { + width: 18% !important; + } .item-detail-cast { max-height: 50vh; overflow-y: auto; diff --git a/src/styles/global.scss b/src/styles/global.scss index 0ff755e..a16f4fc 100644 --- a/src/styles/global.scss +++ b/src/styles/global.scss @@ -220,3 +220,15 @@ h1 { justify-content: center; } } + +@keyframes pulse { + 0% { + opacity: 0.1; + } + 50% { + opacity: 1; + } + 100% { + opacity: 0.1; + } +}