From f1394b71729cc954e2cf5d2d4fa444a93605ed24 Mon Sep 17 00:00:00 2001 From: Prayag Prajapati Date: Thu, 31 Aug 2023 18:30:01 +0530 Subject: [PATCH] Add playback indication in cards and update carousel animation #153 --- src/components/buttons/playButton.jsx | 19 ++ src/components/card/card.jsx | 58 +++++- src/components/card/card.module.scss | 7 + src/components/cardScroller/cardScroller.jsx | 8 +- .../cardScroller/cardScroller.module.scss | 2 +- src/components/carousel/index.jsx | 3 +- src/components/carouselSlide/index.jsx | 11 +- .../homeSection/latestMediaSection.jsx | 34 +++- src/routes/home/index.jsx | 180 +++++++++++++----- src/styles/variables.scss | 4 +- 10 files changed, 255 insertions(+), 71 deletions(-) create mode 100644 src/components/buttons/playButton.jsx diff --git a/src/components/buttons/playButton.jsx b/src/components/buttons/playButton.jsx new file mode 100644 index 0000000..aa91d5a --- /dev/null +++ b/src/components/buttons/playButton.jsx @@ -0,0 +1,19 @@ +/** @format */ + +import IconButton from "@mui/material/IconButton"; +import { MdiPlayOutline } from "../icons/mdiPlayOutline"; + +const PlayButton = ({ className, sx, iconProps }) => { + return ( + e.stopPropagation()} + sx={sx} + disabled + > + + + ); +}; + +export default PlayButton; diff --git a/src/components/card/card.jsx b/src/components/card/card.jsx index f4d9111..e756940 100644 --- a/src/components/card/card.jsx +++ b/src/components/card/card.jsx @@ -34,6 +34,7 @@ import { MdiHeart } from "../icons/mdiHeart"; import useIntersecting from "../../utils/hooks/useIntersecting"; import LikeButton from "../buttons/likeButton"; import MarkPlayedButton from "../buttons/markPlayedButton"; +import PlayButton from "../buttons/playButton"; const cardImageAspectRatios = { thumb: 1.777, @@ -54,6 +55,8 @@ export const Card = ({ queryKey, userId, availableImagesTypes, + playedProgress = 0, + seriesId, onClick, disableOverlay = false, @@ -97,8 +100,29 @@ export const Card = ({ overflow: "hidden", height: "auto", width: "100%", + zIndex: 0, }} > + + + {!!imageBlurhash && ( {!disableOverlay && ( + )} + {playedProgress != 0 && ( + + )} {secondaryText} diff --git a/src/components/card/card.module.scss b/src/components/card/card.module.scss index 9d4b90e..34406d8 100644 --- a/src/components/card/card.module.scss +++ b/src/components/card/card.module.scss @@ -62,4 +62,11 @@ opacity: 1; } } + &-play-button { + position: absolute !important; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + z-index: 1; + } } diff --git a/src/components/cardScroller/cardScroller.jsx b/src/components/cardScroller/cardScroller.jsx index 3fac08f..fd51f64 100644 --- a/src/components/cardScroller/cardScroller.jsx +++ b/src/components/cardScroller/cardScroller.jsx @@ -29,21 +29,25 @@ export const CardScroller = ({ breakpoint: { max: 4000, min: 3000 }, items: displayCards + 1, slidesToSlide: displayCards + 1, + partialVisibilityGutter: 40, }, desktop: { breakpoint: { max: 3000, min: 625 }, items: displayCards, slidesToSlide: displayCards, // optional, default to 1. + partialVisibilityGutter: 30, }, tablet: { breakpoint: { max: 624, min: 464 }, items: displayCards - 2, slidesToSlide: displayCards - 2, // optional, default to 1. + partialVisibilityGutter: 20, }, mobile: { breakpoint: { max: 464, min: 0 }, items: displayCards - 5, slidesToSlide: displayCards - 5, // optional, default to 1. + partialVisibilityGutter: 10, }, }; @@ -60,7 +64,7 @@ export const CardScroller = ({ } > setCarouselRef(el)} - // customButtonGroup={} - // renderButtonGroupOutside={true} className="card-scroller" > {children} diff --git a/src/components/cardScroller/cardScroller.module.scss b/src/components/cardScroller/cardScroller.module.scss index 8e5029f..98dba3f 100644 --- a/src/components/cardScroller/cardScroller.module.scss +++ b/src/components/cardScroller/cardScroller.module.scss @@ -24,7 +24,7 @@ margin-bottom: 0.25em !important; &-decoration { width: 0.75em; - height: 3px; + height: 2px; background: white; } } diff --git a/src/components/carousel/index.jsx b/src/components/carousel/index.jsx index 43e7caa..cfa5ff1 100644 --- a/src/components/carousel/index.jsx +++ b/src/components/carousel/index.jsx @@ -50,7 +50,8 @@ const Carousel = ({ content, onChange }) => { animate={{ opacity: 1 }} exit={{ opacity: 0 }} transition={{ - duration: 0.4, + duration: 0.25, + ease: "easeInOut", }} drag={"x"} dragConstraints={{ left: 0, right: 0 }} diff --git a/src/components/carouselSlide/index.jsx b/src/components/carouselSlide/index.jsx index e84db1e..a26b3b7 100644 --- a/src/components/carouselSlide/index.jsx +++ b/src/components/carouselSlide/index.jsx @@ -110,8 +110,8 @@ const CarouselSlide = ({ item }) => { initial={{ transform: animationDirection == "right" - ? "translateX(20%)" - : "translateX(-20%)", + ? "translateX(10%)" + : "translateX(-10%)", opacity: 0, }} animate={{ @@ -121,13 +121,14 @@ const CarouselSlide = ({ item }) => { exit={{ transform: animationDirection == "right" - ? "translateX(-20%)" - : "translateX(20%)", + ? "translateX(-10%)" + : "translateX(10%)", opacity: 0, }} transition={{ - duration: 0.35, + duration: 0.25, + ease: "easeInOut", }} className="hero-carousel-detail" > diff --git a/src/components/homeSection/latestMediaSection.jsx b/src/components/homeSection/latestMediaSection.jsx index fcc93d5..9da4eac 100644 --- a/src/components/homeSection/latestMediaSection.jsx +++ b/src/components/homeSection/latestMediaSection.jsx @@ -46,8 +46,13 @@ export const LatestMediaSection = ({ latestMediaLib }) => { return ( { ? "square" : "portrait" } - secondaryText={item.ProductionYear} + secondaryText={ + item.Type == BaseItemKind.Episode + ? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}` + : item.Type == BaseItemKind.Series + ? `${item.ProductionYear} - ${ + !!item.EndDate + ? new Date( + item.EndDate, + ).toLocaleString( + [], + { + year: "numeric", + }, + ) + : "Present" + }` + : item.ProductionYear + } isFavorite={item.UserData.IsFavorite} - queryKey={["home", "resume", "video"]} + queryKey={[ + "homeSection, latestMedia", + latestMediaLib, + ]} isPlayed={item.UserData.Played} userId={user.data.Id} imageBlurhash={ @@ -68,6 +93,9 @@ export const LatestMediaSection = ({ latestMediaLib }) => { )[0] ] } + playedProgress={ + item.UserData.PlayedPercentage + } > ); })} diff --git a/src/routes/home/index.jsx b/src/routes/home/index.jsx index f198e22..b00d536 100644 --- a/src/routes/home/index.jsx +++ b/src/routes/home/index.jsx @@ -214,7 +214,7 @@ const Home = () => { ) : ( ( - + ))} onChange={(now) => { if (latestMedia.isSuccess) { @@ -251,7 +251,7 @@ const Home = () => { (item, index) => { return ( { (item, index) => { return ( - ); - }, - )} - - )} - {resumeItemsVideo.isLoading ? ( - - ) : resumeItemsVideo.data.Items.length == 0 ? ( - <> - ) : ( - - {resumeItemsVideo.data.Items.map( - (item, index) => { - return ( - { item.Type == BaseItemKind.Episode ? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}` + : item.Type == + BaseItemKind.Series + ? `${ + item.ProductionYear + } - ${ + !!item.EndDate + ? new Date( + item.EndDate, + ).toLocaleString( + [], + { + year: "numeric", + }, + ) + : "Present" + }` + : item.ProductionYear + } + cardType="thumb" + isFavorite={ + item.UserData + .IsFavorite + } + queryKey={[ + "home", + "upNext", + ]} + isPlayed={ + item.UserData.Played + } + userId={user.data.Id} + imageBlurhash={ + item.ImageBlurHashes + ?.Primary[ + Object.keys( + item + .ImageBlurHashes + .Primary, + )[0] + ] + } + availableImagesTypes={ + !!item.ImageTags && + Object.keys( + item.ImageTags, + ) + } + playedProgress={ + item.UserData + .PlayedPercentage + } + > + ); + }, + )} + + )} + {resumeItemsVideo.isLoading ? ( + + ) : resumeItemsVideo.data.Items.length == 0 ? ( + <> + ) : ( + + {resumeItemsVideo.data.Items.map( + (item, index) => { + return ( + { item.ImageTags, ) } + playedProgress={ + item.UserData + .PlayedPercentage + } > ); }, @@ -414,7 +482,7 @@ const Home = () => { (item, index) => { return ( { item.Type == BaseItemKind.Episode ? "Primary" + : Object.keys( + item.ImageTags, + ).includes( + "Thumb", + ) + ? "Thumb" : "Backdrop" } secondaryText={ @@ -451,6 +525,10 @@ const Home = () => { )[0] ] } + playedProgress={ + item.UserData + .PlayedPercentage + } > ); }, diff --git a/src/styles/variables.scss b/src/styles/variables.scss index a940385..6805540 100644 --- a/src/styles/variables.scss +++ b/src/styles/variables.scss @@ -21,8 +21,8 @@ $clr-gradient-dark: linear-gradient( $clr-secondary-dark ); -$border-radius-default: 10px; -$border-radius-intensity-1: 5px; +$border-radius-default: 6px; +$border-radius-intensity-1: 4px; $transition-time-default: 250ms; $transition-time-fast: 150ms;