From 38a7369650aa03cb78a3786d7ba47a539ee870c8 Mon Sep 17 00:00:00 2001 From: Prayag Prajapati Date: Sun, 27 Aug 2023 17:03:22 +0530 Subject: [PATCH] Update card and carousel #153 --- src/components/buttons/likeButton.jsx | 2 +- src/components/buttons/markPlayedButton.jsx | 2 +- src/components/card/card.jsx | 162 +++++++++++------- src/components/card/card.module.scss | 24 ++- src/components/carousel/index.jsx | 14 +- .../homeSection/latestMediaSection.jsx | 6 +- src/routes/home/index.jsx | 54 +++++- 7 files changed, 193 insertions(+), 71 deletions(-) diff --git a/src/components/buttons/likeButton.jsx b/src/components/buttons/likeButton.jsx index 9e6ca12..ec40208 100644 --- a/src/components/buttons/likeButton.jsx +++ b/src/components/buttons/likeButton.jsx @@ -66,7 +66,7 @@ const LikeButton = ({ itemId, isFavorite, queryKey, userId, itemName }) => { }, }); return ( - + {isFavorite ? ( ) : ( diff --git a/src/components/buttons/markPlayedButton.jsx b/src/components/buttons/markPlayedButton.jsx index 85523fa..482d770 100644 --- a/src/components/buttons/markPlayedButton.jsx +++ b/src/components/buttons/markPlayedButton.jsx @@ -65,7 +65,7 @@ const MarkPlayedButton = ({ itemId, isPlayed, queryKey, userId, itemName }) => { }, }); return ( - + { const ref = useRef(); const isVisible = useIntersecting(ref); + const navigate = useNavigate(); + const defaultOnClick = () => navigate(`/item/${itemId}`); return ( - - - - - {TypeIconCollectionCard[itemType]} - - (e.target.style.opacity = 1)} - className="card-image" - /> - - - - {itemName} - - - {secondaryText} - - - - + + {TypeIconCollectionCard[itemType]} + + (e.target.style.opacity = 1)} + className="card-image" + /> + {!disableOverlay && ( + + + + + )} + + + + {itemName} + + + {secondaryText} + + + + + ); }; diff --git a/src/components/card/card.module.scss b/src/components/card/card.module.scss index cab05bc..39fd370 100644 --- a/src/components/card/card.module.scss +++ b/src/components/card/card.module.scss @@ -6,7 +6,7 @@ object-fit: cover; transition: opacity $transition-time-fast; position: absolute; - z-index: 1; + z-index: 0; top: 0; left: 0; &-container { @@ -32,4 +32,26 @@ } } } + &-overlay { + position: absolute; + width: 100%; + height: 100%; + left: 0; + top: 0; + background: rgb(0 0 0 / 0.6); + z-index: 10; + opacity: 0; + transition: opacity $transition-time-default; + display: flex; + align-items: flex-end; + justify-content: flex-end; + padding: 0.5em; + } + &-container:hover, + &-container:focus, + &-container:focus-within { + .card-overlay { + opacity: 1; + } + } } diff --git a/src/components/carousel/index.jsx b/src/components/carousel/index.jsx index 1a0a10d..dfbb9a4 100644 --- a/src/components/carousel/index.jsx +++ b/src/components/carousel/index.jsx @@ -99,7 +99,10 @@ const Carousel = ({ content, onChange }) => { ? "white" : "rgb(255 255 255 / 0.5)", }} - onClick={() => setCurrentSlide(0)} + onClick={() => { + setDirection("left"); + setCurrentSlide(0); + }} /> {content.map((item, index) => ( { ? "white" : "rgb(255 255 255 / 0.5)", }} - onClick={() => setCurrentSlide(index + 1)} + onClick={() => { + if (currentSlide > index) { + setDirection("left"); + } else if (currentSlide <= index) { + setDirection("right"); + } + setCurrentSlide(index + 1); + }} /> ))} diff --git a/src/components/homeSection/latestMediaSection.jsx b/src/components/homeSection/latestMediaSection.jsx index e9457bf..5006598 100644 --- a/src/components/homeSection/latestMediaSection.jsx +++ b/src/components/homeSection/latestMediaSection.jsx @@ -11,7 +11,7 @@ import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client"; export const LatestMediaSection = ({ latestMediaLib }) => { const user = useQuery({ - queryKey: ["home", "user"], + queryKey: ["user"], queryFn: async () => { let usr = await getUserApi(window.api).getCurrentUser(); return usr.data; @@ -57,6 +57,10 @@ export const LatestMediaSection = ({ latestMediaLib }) => { : "portrait" } secondaryText={item.ProductionYear} + isFavorite={item.UserData.IsFavorite} + queryKey={["home", "resume", "video"]} + isPlayed={item.UserData.Played} + userId={user.data.Id} > ); })} diff --git a/src/routes/home/index.jsx b/src/routes/home/index.jsx index ca79c4c..e82a2d8 100644 --- a/src/routes/home/index.jsx +++ b/src/routes/home/index.jsx @@ -257,6 +257,12 @@ const Home = () => { itemType="Library" imageType="Primary" cardType="thumb" + disableOverlay + onClick={() => + navigate( + `/library/${item.Id}`, + ) + } > ); }, @@ -280,6 +286,19 @@ const Home = () => { itemType={item.Type} imageType="Primary" cardType="thumb" + isFavorite={ + item.UserData + .IsFavorite + } + queryKey={[ + "home", + "resume", + "video", + ]} + isPlayed={ + item.UserData.Played + } + userId={user.data.Id} > ); }, @@ -300,7 +319,12 @@ const Home = () => { return ( { secondaryText={ item.Type == BaseItemKind.Episode - ? `S${item.ParentIndexNumber}:E${item.IndexNumber} ${item.SeriesName}` + ? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}` : item.ProductionYear } cardType="thumb" + isFavorite={ + item.UserData + .IsFavorite + } + queryKey={[ + "home", + "resume", + "video", + ]} + isPlayed={ + item.UserData.Played + } + userId={user.data.Id} > ); }, @@ -349,6 +386,19 @@ const Home = () => { item.ProductionYear } cardType="thumb" + isFavorite={ + item.UserData + .IsFavorite + } + queryKey={[ + "home", + "resume", + "video", + ]} + isPlayed={ + item.UserData.Played + } + userId={user.data.Id} > ); },