From 002d92d8addc5d5b3e862b9c397b58403382d693 Mon Sep 17 00:00:00 2001 From: Prayag Prajapati Date: Sat, 26 Aug 2023 13:29:47 +0530 Subject: [PATCH] Update card component #153 --- src/components/card/card.jsx | 49 +++++++++-- src/components/card/card.module.scss | 21 +++++ src/components/carouselSlide/index.jsx | 16 ++-- .../homeSection/latestMediaSection.jsx | 23 +++-- src/components/utils/iconsCollection.jsx | 1 + src/routes/home/index.jsx | 83 ++++++------------- src/routes/library/index.jsx | 73 +++------------- 7 files changed, 122 insertions(+), 144 deletions(-) diff --git a/src/components/card/card.jsx b/src/components/card/card.jsx index 0b1b277..4318a62 100644 --- a/src/components/card/card.jsx +++ b/src/components/card/card.jsx @@ -33,19 +33,32 @@ import { MdiHeartOutline } from "../icons/mdiHeartOutline"; import { MdiHeart } from "../icons/mdiHeart"; import useIntersecting from "../../utils/hooks/useIntersecting"; +const cardImageAspectRatios = { + thumb: 1.777, + portrait: 0.666, + square: 1, +}; + export const Card = ({ itemId, - itemParentId, + itemType, itemName, - imageTags, imageType = "Primary", - parentImageType, - imageAspectRatio, + cardType, + secondaryText, }) => { const ref = useRef(); const isVisible = useIntersecting(ref); return ( - + + + {TypeIconCollectionCard[itemType]} + (e.target.style.opacity = 1)} className="card-image" /> + {itemName} + + - {itemName} + {secondaryText} diff --git a/src/components/card/card.module.scss b/src/components/card/card.module.scss index 85e9591..cab05bc 100644 --- a/src/components/card/card.module.scss +++ b/src/components/card/card.module.scss @@ -4,11 +4,32 @@ width: 100%; height: 100%; object-fit: cover; + transition: opacity $transition-time-fast; + position: absolute; + z-index: 1; + top: 0; + left: 0; &-container { position: relative; width: 100%; border-radius: $border-radius-default; box-shadow: 0 4px 8px rgb(0 0 0 / 0.2); } + &-icon { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 3.4em !important; + fill: url(#clr-gradient-default) !important; + color: transparent; + &-container { + background: $clr-gradient-dark; + height: 100%; + width: 100%; + position: relative; + z-index: 0; + } + } } } diff --git a/src/components/carouselSlide/index.jsx b/src/components/carouselSlide/index.jsx index 68e432f..82dd037 100644 --- a/src/components/carouselSlide/index.jsx +++ b/src/components/carouselSlide/index.jsx @@ -83,7 +83,7 @@ const CarouselSlide = ({ item }) => { punch={1} /> )} - { initial={{ transform: animationDirection == "right" - ? "translateX(50px)" - : "translateX(-50px)", + ? "translateX(40px)" + : "translateX(-40px)", opacity: 0, }} animate={{ @@ -118,13 +118,13 @@ const CarouselSlide = ({ item }) => { exit={{ transform: animationDirection == "right" - ? "translateX(-50px)" - : "translateX(50px)", + ? "translateX(-40px)" + : "translateX(40px)", opacity: 0, }} transition={{ - duration: 0.2, + duration: 0.25, }} className="hero-carousel-detail" > @@ -140,7 +140,7 @@ const CarouselSlide = ({ item }) => { {!item.ImageTags.Logo ? ( item.Name ) : ( - { onLoad={(e) => (e.target.style.opacity = 1) } - > + /> )} { > {data.data.map((item, index) => { return ( - <> - // + ); })} diff --git a/src/components/utils/iconsCollection.jsx b/src/components/utils/iconsCollection.jsx index f64f37a..97af6b0 100644 --- a/src/components/utils/iconsCollection.jsx +++ b/src/components/utils/iconsCollection.jsx @@ -108,4 +108,5 @@ export const TypeIconCollectionCard = { Video: , Year: , Genre: , + Library: , }; diff --git a/src/routes/home/index.jsx b/src/routes/home/index.jsx index 05a1f79..ca79c4c 100644 --- a/src/routes/home/index.jsx +++ b/src/routes/home/index.jsx @@ -38,7 +38,7 @@ import { useNavigate } from "react-router-dom"; import { useBackdropStore } from "../../utils/store/backdrop"; import CarouselSlide from "../../components/carouselSlide"; -import { ItemFields } from "@jellyfin/sdk/lib/generated-client"; +import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client"; const Home = () => { const authUser = useQuery({ queryKey: ["home", "authenticateUser"], @@ -100,8 +100,8 @@ const Home = () => { fields: [ ItemFields.Overview, ItemFields.ParentId, + "ParentIndexNumber", ItemFields.SeasonUserData, - ItemFields.RecursiveItemCount, ItemFields.IsHd, ], enableUserData: true, @@ -254,9 +254,9 @@ const Home = () => { key={index} itemName={item.Name} itemId={item.Id} - imageAspectRatio={ - item.PrimaryImageAspectRatio - } + itemType="Library" + imageType="Primary" + cardType="thumb" > ); }, @@ -277,10 +277,9 @@ const Home = () => { key={index} itemName={item.Name} itemId={item.Id} + itemType={item.Type} imageType="Primary" - imageAspectRatio={ - item.PrimaryImageAspectRatio - } + cardType="thumb" > ); }, @@ -303,14 +302,20 @@ const Home = () => { key={index} itemName={item.Name} itemId={item.Id} + itemType={item.Type} imageType={ - !!item.SeriesName + item.Type == + BaseItemKind.Episode ? "Primary" : "Backdrop" } - imageAspectRatio={ - item.PrimaryImageAspectRatio + secondaryText={ + item.Type == + BaseItemKind.Episode + ? `S${item.ParentIndexNumber}:E${item.IndexNumber} ${item.SeriesName}` + : item.ProductionYear } + cardType="thumb" > ); }, @@ -331,55 +336,19 @@ const Home = () => { return ( ); }, diff --git a/src/routes/library/index.jsx b/src/routes/library/index.jsx index 54dde92..0bde7ef 100644 --- a/src/routes/library/index.jsx +++ b/src/routes/library/index.jsx @@ -942,11 +942,11 @@ const LibraryView = () => { md={1} component={motion.div} initial={{ - scale: 0.8, + transform: "scale(0.8)", opacity: 0, }} animate={{ - scale: 1, + transform: "scale(1)", opacity: 1, }} transition={{ @@ -956,68 +956,17 @@ const LibraryView = () => { }} > @@ -1046,11 +995,13 @@ const LibraryView = () => { }, }} initial={{ - scale: 0.8, + transform: + "scale(0.8)", opacity: 0, }} animate={{ - scale: 1, + transform: + "scale(1)", opacity: 1, }} transition={{