diff --git a/package-lock.json b/package-lock.json index e67897b..c512f12 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,6 @@ "react-blurhash": "^0.3.0", "react-dom": "^18.2.0", "react-error-boundary": "^4.0.10", - "react-material-ui-carousel": "^3.4.2", "react-multi-carousel": "^2.8.3", "react-player": "^2.12.0", "react-router-dom": "^6.14.0", @@ -945,31 +944,6 @@ "url": "https://opencollective.com/mui" } }, - "node_modules/@mui/icons-material": { - "version": "5.14.3", - "resolved": "https://registry.npmjs.org/@mui/icons-material/-/icons-material-5.14.3.tgz", - "integrity": "sha512-XkxWPhageu1OPUm2LWjo5XqeQ0t2xfGe8EiLkRW9oz2LHMMZmijvCxulhgquUVTF1DnoSh+3KoDLSsoAFtVNVw==", - "dependencies": { - "@babel/runtime": "^7.22.6" - }, - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/mui" - }, - "peerDependencies": { - "@mui/material": "^5.0.0", - "@types/react": "^17.0.0 || ^18.0.0", - "react": "^17.0.0 || ^18.0.0" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - } - } - }, "node_modules/@mui/lab": { "version": "5.0.0-alpha.140", "resolved": "https://registry.npmjs.org/@mui/lab/-/lab-5.0.0-alpha.140.tgz", @@ -2279,14 +2253,6 @@ "integrity": "sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw==", "optional": true }, - "node_modules/framesync": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/framesync/-/framesync-5.3.0.tgz", - "integrity": "sha512-oc5m68HDO/tuK2blj7ZcdEBRx3p1PjrgHazL8GYEpvULhrtGIFbQArN6cQS2QhW8mitffaB+VYzMjDqBxxQeoA==", - "dependencies": { - "tslib": "^2.1.0" - } - }, "node_modules/fsevents": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", @@ -2360,11 +2326,6 @@ "node": ">=4" } }, - "node_modules/hey-listen": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/hey-listen/-/hey-listen-1.0.8.tgz", - "integrity": "sha512-COpmrF2NOg4TBWUJ5UVyaCU2A88wEMkUPK4hNqyCkqHbxT92BbvfjoSozkAIIm6XhicGlJHhFdullInrdhwU8Q==" - }, "node_modules/hoist-non-react-statics": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", @@ -2694,17 +2655,6 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/popmotion": { - "version": "9.3.6", - "resolved": "https://registry.npmjs.org/popmotion/-/popmotion-9.3.6.tgz", - "integrity": "sha512-ZTbXiu6zIggXzIliMi8LGxXBF5ST+wkpXGEjeTUDUOCdSQ356hij/xjeUdv0F8zCQNeqB1+PR5/BB+gC+QLAPw==", - "dependencies": { - "framesync": "5.3.0", - "hey-listen": "^1.0.8", - "style-value-types": "4.1.4", - "tslib": "^2.1.0" - } - }, "node_modules/postcss": { "version": "8.4.27", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.27.tgz", @@ -2805,62 +2755,6 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==" }, - "node_modules/react-material-ui-carousel": { - "version": "3.4.2", - "resolved": "https://registry.npmjs.org/react-material-ui-carousel/-/react-material-ui-carousel-3.4.2.tgz", - "integrity": "sha512-jUbC5aBWqbbbUOOdUe3zTVf4kMiZFwKJqwhxzHgBfklaXQbSopis4iWAHvEOLcZtSIJk4JAGxKE0CmxDoxvUuw==", - "dependencies": { - "@emotion/react": "^11.7.1", - "@emotion/styled": "^11.6.0", - "@mui/icons-material": "^5.4.1", - "@mui/material": "^5.4.1", - "@mui/system": "^5.4.1", - "framer-motion": "^4.1.17" - }, - "peerDependencies": { - "@emotion/react": "^11.4.1", - "@emotion/styled": "^11.3.0", - "@mui/icons-material": "^5.0.0", - "@mui/material": "^5.0.0", - "@mui/system": "^5.0.0", - "react": "^17.0.1 || ^18.0.0", - "react-dom": "^17.0.2 || ^18.0.0" - } - }, - "node_modules/react-material-ui-carousel/node_modules/@emotion/is-prop-valid": { - "version": "0.8.8", - "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-0.8.8.tgz", - "integrity": "sha512-u5WtneEAr5IDG2Wv65yhunPSMLIpuKsbuOktRojfrEiEvRyC85LgPMZI63cr7NUqT8ZIGdSVg8ZKGxIug4lXcA==", - "optional": true, - "dependencies": { - "@emotion/memoize": "0.7.4" - } - }, - "node_modules/react-material-ui-carousel/node_modules/@emotion/memoize": { - "version": "0.7.4", - "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.4.tgz", - "integrity": "sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw==", - "optional": true - }, - "node_modules/react-material-ui-carousel/node_modules/framer-motion": { - "version": "4.1.17", - "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-4.1.17.tgz", - "integrity": "sha512-thx1wvKzblzbs0XaK2X0G1JuwIdARcoNOW7VVwjO8BUltzXPyONGAElLu6CiCScsOQRI7FIk/45YTFtJw5Yozw==", - "dependencies": { - "framesync": "5.3.0", - "hey-listen": "^1.0.8", - "popmotion": "9.3.6", - "style-value-types": "4.1.4", - "tslib": "^2.1.0" - }, - "optionalDependencies": { - "@emotion/is-prop-valid": "^0.8.2" - }, - "peerDependencies": { - "react": ">=16.8 || ^17.0.0", - "react-dom": ">=16.8 || ^17.0.0" - } - }, "node_modules/react-multi-carousel": { "version": "2.8.4", "resolved": "https://registry.npmjs.org/react-multi-carousel/-/react-multi-carousel-2.8.4.tgz", @@ -3057,15 +2951,6 @@ "node": ">=0.10.0" } }, - "node_modules/style-value-types": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/style-value-types/-/style-value-types-4.1.4.tgz", - "integrity": "sha512-LCJL6tB+vPSUoxgUBt9juXIlNJHtBMy8jkXzUJSBzeHWdBu6lhzHqCvLVkXFGsFIlNa2ln1sQHya/gzaFmB2Lg==", - "dependencies": { - "hey-listen": "^1.0.8", - "tslib": "^2.1.0" - } - }, "node_modules/stylis": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.2.0.tgz", diff --git a/package.json b/package.json index 8501d69..fa3e53e 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "react-blurhash": "^0.3.0", "react-dom": "^18.2.0", "react-error-boundary": "^4.0.10", - "react-material-ui-carousel": "^3.4.2", "react-multi-carousel": "^2.8.3", "react-player": "^2.12.0", "react-router-dom": "^6.14.0", diff --git a/src/App.jsx b/src/App.jsx index ce225d2..1b79fa3 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -380,7 +380,7 @@ function App() { opacity: 0, }} transition={{ - duration: 1.5, + duration: 0.5, }} onLoad={() => setBackdropLoading(false)} loading="eager" diff --git a/src/components/card/card.jsx b/src/components/card/card.jsx index 67da305..0b1b277 100644 --- a/src/components/card/card.jsx +++ b/src/components/card/card.jsx @@ -1,11 +1,11 @@ /** @format */ -import React, { useState } from "react"; +import React, { useRef, useState } from "react"; import PropTypes from "prop-types"; import { useNavigate } from "react-router-dom"; import Box from "@mui/material/Box"; -import MuiCard from "@mui/material/Card"; +import Stack from "@mui/material/Stack"; import CardContent from "@mui/material/CardContent"; import CardMedia from "@mui/material/CardMedia"; import CardActionArea from "@mui/material/CardActionArea"; @@ -31,373 +31,70 @@ import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api"; import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api"; import { MdiHeartOutline } from "../icons/mdiHeartOutline"; import { MdiHeart } from "../icons/mdiHeart"; +import useIntersecting from "../../utils/hooks/useIntersecting"; export const Card = ({ - itemName, itemId, + itemParentId, + itemName, imageTags, - iconType, - cardType = "", - subText = "", - playedPercent, - cardOrientation, - cardProps, - onClickEvent, - watchedStatus, - watchedCount, - blurhash, - currentUser, - favourite, - disableOverlay, + imageType = "Primary", + parentImageType, + imageAspectRatio, }) => { - const navigate = useNavigate(); - const [imgLoading, setImgLoading] = useState(true); - const [isWatched, setIsWatched] = useState(watchedStatus); - const [isFavorite, setisFavorite] = useState(favourite); - const [watchedCountState, setWatchedCountState] = useState(watchedCount); - const handleMarkAsPlayOrUnMarkAsPlay = async () => { - let result; - if (!isWatched) { - result = await getPlaystateApi(window.api).markPlayedItem({ - userId: currentUser.Id, - itemId: itemId, - }); - } else if (isWatched) { - result = await getPlaystateApi(window.api).markUnplayedItem({ - userId: currentUser.Id, - itemId: itemId, - }); - } - setIsWatched(result.data.Played); - setWatchedCountState(result.data.UnplayedItemCount); - }; - const handleLiking = async () => { - let result; - if (isFavorite) { - result = await getUserLibraryApi(window.api).unmarkFavoriteItem({ - userId: currentUser.Id, - itemId: itemId, - }); - } else if (!isFavorite) { - result = await getUserLibraryApi(window.api).markFavoriteItem({ - userId: currentUser.Id, - itemId: itemId, - }); - } - setisFavorite(result.data.IsFavorite); - }; - - const availableMarkButtonTypes = [ - "Audio", - "AudioBook", - "Book", - "BoxSet", - "CollectionFolder", - "Movie", - "Season", - "Series", - "Video", - "Episode", - ]; - const allowedLikeButton = [ - "Audio", - "AudioBook", - "Book", - "BoxSet", - "CollectionFolder", - "Movie", - "MusicAlbum", - "MusicVideo", - "Season", - "Series", - "Video", - "Channel", - "MusicAlbum", - "MusicArtist", - "Person", - "Photo", - "Playlist", - "Studio", - "Episode", - ]; - + const ref = useRef(); + const isVisible = useIntersecting(ref); return ( - - { - navigate(`/item/${itemId}`); - } - } - className="cardBox" + + - <> - } - sx={{ - transition: "opacity 150ms", - opacity: isWatched ? 1 : 0, - }} - /> - - {!!watchedCountState && ( - + - {imageTags && - (cardType == "thumb" ? ( - - setImgLoading(false) - } - className="card-image" - > - ) : ( - - setImgLoading(false) - } - > - ))} - - {!!blurhash && ( - - )} -
- {cardType == "lib" - ? MediaCollectionTypeIconCollectionCard[ - iconType - ] - : TypeIconCollectionCard[iconType]} -
- {!!playedPercent && ( - - )} - - {!disableOverlay && ( - - - {availableMarkButtonTypes.includes( - iconType, - ) && ( - { - e.preventDefault(); - e.stopPropagation(); - handleMarkAsPlayOrUnMarkAsPlay(); - }} - onFocus={(e) => - e.stopPropagation - } - > - - - )} - {allowedLikeButton.includes( - iconType, - ) && ( - { - e.preventDefault(); - e.stopPropagation(); - handleLiking(); - }} - onFocus={(e) => - e.stopPropagation - } - > - {isFavorite ? ( - - ) : ( - - )} - - )} - - - )} + style={{ + height: "100%", + }} + className="card-image" + />
- - + {itemName} - - - {subText} - - -
-
+ + + ); }; -Card.propTypes = { - itemName: PropTypes.string.isRequired, - itemId: PropTypes.string.isRequired, - imageTags: PropTypes.bool, - iconType: PropTypes.string.isRequired, - cardType: PropTypes.string, - subText: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), - playedPercent: PropTypes.number, - cardOrientation: PropTypes.string.isRequired, - onClickEvent: PropTypes.func, - watchedStatus: PropTypes.bool, - watchedCount: PropTypes.number, - blurhash: PropTypes.string, - currentUser: PropTypes.object, - favourite: PropTypes.bool, -}; +Card.propTypes = {}; diff --git a/src/components/card/card.module.scss b/src/components/card/card.module.scss index 69c9193..85e9591 100644 --- a/src/components/card/card.module.scss +++ b/src/components/card/card.module.scss @@ -1,92 +1,14 @@ /** @format */ - .card { - border-radius: $border-radius-default; - &-media { - &-container { - position: relative; - border-radius: $border-radius-default; - overflow: hidden; - box-shadow: 0 0 7px rgb(0 0 0 / 0.2); - } - &-overlay { - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - background: rgb(0 0 0 / 0.6); - opacity: 0; - transition: opacity $transition-time-default; - z-index: 10; - } - &-image-container { - transition: opacity $transition-time-default; - } - } - &Box:hover .card-media-overlay, - &Box:focus-within .card-media-overlay, - &Box:focus .card-media-overlay { - opacity: 1; - } &-image { - position: relative; - border-radius: $border-radius-default; - background-size: cover; - background-position: center; + width: 100%; + height: 100%; + object-fit: cover; &-container { position: relative; - border-radius: $border-radius-default; - overflow: hidden; - } - &-icon { - font-size: 4.5em !important; - fill: url(#clr-gradient-default) !important; - - &-container { - display: flex !important; - aspect-ratio: 1.777; - justify-content: center; - align-items: center; - width: 100% !important; - color: transparent; - background: $clr-gradient-dark; - border-radius: 10px; - position: absolute; - top: 0; - bottom: 0; - height: 100%; - z-index: -2; - } - } - &-blurhash { - position: absolute !important; width: 100%; - height: 100%; - top: 0; - left: 0; border-radius: $border-radius-default; - overflow: hidden; - z-index: -1; - } - } - &-text-container { - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - } - &-indicator { - position: absolute; - right: 5px; - top: 5px; - z-index: 10; - // border-radius: 100px; - background: $clr-gradient-default; - box-shadow: 0 0 5px rgb(0 0 0 / 0.4); - &-text { - aspect-ratio: 1; - padding: 5px !important; + box-shadow: 0 4px 8px rgb(0 0 0 / 0.2); } } } diff --git a/src/components/carousel/carousel.scss b/src/components/carousel/carousel.scss new file mode 100644 index 0000000..4d2a525 --- /dev/null +++ b/src/components/carousel/carousel.scss @@ -0,0 +1,35 @@ +/** @format */ + +.carousel { + &-button { + position: absolute !important; + top: 50%; + transform: translateY(-50%); + z-index: 100; + &.right { + right: 0.5em; + } + &.left { + left: 0; + } + } + &-indicator { + height: 5px; + width: 100%; + border-radius: 10px; + transition: background $transition-time-fast; + &:hover { + cursor: pointer; + background: rgb(255 255 255 / 0.8) !important; + } + &-container { + display: flex; + position: absolute; + bottom: 1em; + width: calc(100vw - 2em); + left: 1em; + right: 1em; + gap: 1em; + } + } +} diff --git a/src/components/carousel/index.jsx b/src/components/carousel/index.jsx new file mode 100644 index 0000000..1a0a10d --- /dev/null +++ b/src/components/carousel/index.jsx @@ -0,0 +1,122 @@ +/** @format */ +import { useEffect, useState } from "react"; +import { AnimatePresence, motion } from "framer-motion"; + +import Box from "@mui/material/Box"; +import IconButton from "@mui/material/IconButton"; +import { MdiChevronLeft } from "../icons/mdiChevronLeft"; +import { MdiChevronRight } from "../icons/mdiChevronRight"; + +import "./carousel.scss"; +import { useCarouselStore } from "../../utils/store/carousel"; + +const swipeConfidenceThreshold = 10000; +const swipePower = (offset, velocity) => { + return Math.abs(offset) * velocity; +}; + +const Carousel = ({ content, onChange }) => { + const [currentSlide, setCurrentSlide] = useState(0); + + const [setDirection, dir] = useCarouselStore((state) => [ + state.setDirection, + state.direction, + ]); + useEffect(() => { + onChange(currentSlide); + }, [currentSlide]); + + return ( + + { + if (currentSlide > 0) { + setDirection("left"); + setCurrentSlide((init) => init - 1); + } + }} + sx={{ + background: " rgb(200 200 200 / 0.05)", + }} + disabled={currentSlide == 0} + > + + + + { + const swipe = swipePower(offset.x, velocity.x); + + if (swipe < -swipeConfidenceThreshold) { + setDirection("right"); + setCurrentSlide((init) => init + 1); + } else if (swipe > swipeConfidenceThreshold) { + setDirection("left"); + setCurrentSlide((init) => init - 1); + } + }} + style={{ + height: "100vh", + width: "100vw", + position: "absolute", + }} + > + {content[currentSlide]} + + + { + if (currentSlide < content.length - 1) { + setDirection("right"); + setCurrentSlide((init) => init + 1); + } + }} + disabled={currentSlide == content.length - 1} + sx={{ + background: " rgb(200 200 200 / 0.05)", + }} + > + + + + setCurrentSlide(0)} + /> + {content.map((item, index) => ( + setCurrentSlide(index + 1)} + /> + ))} + + + ); +}; + +export default Carousel; diff --git a/src/components/carouselSlide/index.jsx b/src/components/carouselSlide/index.jsx index 935bfdf..68e432f 100644 --- a/src/components/carouselSlide/index.jsx +++ b/src/components/carouselSlide/index.jsx @@ -32,6 +32,7 @@ import { useSnackbar } from "notistack"; import LikeButton from "../buttons/likeButton"; import MarkPlayedButton from "../buttons/markPlayedButton"; import { theme } from "../../theme"; +import { useCarouselStore } from "../../utils/store/carousel"; const CarouselSlide = ({ item }) => { const navigate = useNavigate(); @@ -45,9 +46,9 @@ const CarouselSlide = ({ item }) => { networkMode: "always", }); - // consoe; - - // const favouriteButtonMutation = + const [animationDirection] = useCarouselStore((state) => [ + state.direction, + ]); return ( }> @@ -56,66 +57,84 @@ const CarouselSlide = ({ item }) => { sx={{ background: "transparent", px: 3, + boxShadow: "none !important", }} >
- {!!item.ImageBlurHashes.Backdrop && - Object.keys(item.ImageBlurHashes.Backdrop) - .length != 0 && ( - + {Object.keys(item.ImageBlurHashes.Backdrop) + .length != 0 && ( + + )} + + (e.target.style.opacity = 1) + } + loading="eager" /> - )} -
+ + )}
{MediaTypeIconCollection[item.Type]}
- + {!item.ImageTags.Logo ? ( @@ -130,29 +149,19 @@ const CarouselSlide = ({ item }) => { "/Images/Logo?quality=80&tag=" + item.ImageTags.Logo } + style={{ + opacity: 0, + transition: "opacity 250ms", + }} + onLoad={(e) => + (e.target.style.opacity = 1) + } > )} { )} { {/* TODO Link PLay and More info buttons in carousel */} { > {data.data.map((item, index) => { return ( - + <> + // ); })} diff --git a/src/routes/home/home.module.scss b/src/routes/home/home.module.scss index adaf919..dd713fe 100644 --- a/src/routes/home/home.module.scss +++ b/src/routes/home/home.module.scss @@ -63,7 +63,11 @@ right: 0; bottom: 0; background-position: center; - opacity: 1; + opacity: 0; + object-fit: cover; + width: 100%; + height: 100%; + transition: opacity $transition-time-fast; } &-icon { position: absolute; diff --git a/src/routes/home/index.jsx b/src/routes/home/index.jsx index 39ff9f7..05a1f79 100644 --- a/src/routes/home/index.jsx +++ b/src/routes/home/index.jsx @@ -2,28 +2,17 @@ import { useState } from "react"; -import { Blurhash } from "react-blurhash"; - import { useQuery } from "@tanstack/react-query"; import { EventEmitter as event } from "../../eventEmitter"; import { getServer } from "../../utils/storage/servers"; import { getUser, delUser } from "../../utils/storage/user"; -import { theme } from "../../theme"; import "./home.module.scss"; import Box from "@mui/material/Box"; -import Button from "@mui/material/Button"; -import Paper from "@mui/material/Paper"; -import Typography from "@mui/material/Typography"; -import Chip from "@mui/material/Chip"; -import LinearProgress from "@mui/material/LinearProgress"; -import Stack from "@mui/material/Stack"; -import { yellow } from "@mui/material/colors"; - -import Carousel from "react-material-ui-carousel"; +import Carousel from "../../components/carousel"; // Custom Components import { Card } from "../../components/card/card"; @@ -46,15 +35,10 @@ import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api"; import { useNavigate } from "react-router-dom"; -import { endsAt, getRuntime } from "../../utils/date/time"; -import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client"; - -import CarouselSlideError from "../../components/errors/carousel"; - -import { motion } from "framer-motion"; import { useBackdropStore } from "../../utils/store/backdrop"; import CarouselSlide from "../../components/carouselSlide"; +import { ItemFields } from "@jellyfin/sdk/lib/generated-client"; const Home = () => { const authUser = useQuery({ queryKey: ["home", "authenticateUser"], @@ -169,6 +153,10 @@ const Home = () => { queryFn: async () => { const upNext = await getTvShowsApi(window.api).getNextUp({ userId: user.data.Id, + fields: [ + ItemFields.PrimaryImageAspectRatio, + ItemFields.ParentId, + ], limit: 10, }); return upNext.data; @@ -225,40 +213,9 @@ const Home = () => { ) : ( - } - activeIndicatorIconButtonProps={{ - style: { - background: "rgb(255 255 255)", - }, - }} - indicatorIconButtonProps={{ - style: { - background: "rgb(255 255 255 / 0.3)", - borderRadius: "2px", - width: "100%", - flexShrink: "1", - }, - }} - indicatorContainerProps={{ - className: - "hero-carousel-indicator-container", - style: { - position: "absolute", - display: "flex", - gap: "1em", - zIndex: 1, - }, - }} - sx={{ - marginBottom: "1.5em", - }} + content={latestMedia.data?.map((item, index) => ( + + ))} onChange={(now) => { if (latestMedia.isSuccess) { if ( @@ -277,20 +234,7 @@ const Home = () => { } } }} - changeOnFirstRender={true} - duration={400} - interval={10000} - > - {latestMedia.data.length != 0 && - latestMedia.data.map((item, index) => { - return ( - - ); - })} - + /> )} { key={index} itemName={item.Name} itemId={item.Id} - // imageTags={false} - imageTags={ - !!item - .ImageTags - .Primary - } - cardType="lib" - cardOrientation="landscape" - iconType={ - item.CollectionType - } - onClickEvent={() => { - navigate( - `/library/${item.Id}`, - ); - }} - blurhash={ - item.ImageBlurHashes == - {} - ? "" - : !!item - .ImageTags - .Primary - ? !!item - .ImageBlurHashes - .Primary - ? item - .ImageBlurHashes - .Primary[ - item - .ImageTags - .Primary - ] - : "" - : "" - } - currentUser={ - user.data + imageAspectRatio={ + item.PrimaryImageAspectRatio } > ); @@ -367,58 +275,11 @@ const Home = () => { return ( ); @@ -440,69 +301,15 @@ const Home = () => { return ( ); diff --git a/src/utils/hooks/useIntersecting.jsx b/src/utils/hooks/useIntersecting.jsx new file mode 100644 index 0000000..9a5d671 --- /dev/null +++ b/src/utils/hooks/useIntersecting.jsx @@ -0,0 +1,24 @@ +/** @format */ + +import { useEffect, useMemo, useState } from "react"; + +const useIntersecting = (ref) => { + const [isIntersecting, setIntersecting] = useState(false); + + const observer = useMemo( + () => + new IntersectionObserver(([entry]) => + setIntersecting(entry.isIntersecting), + ), + [ref], + ); + + useEffect(() => { + observer.observe(ref.current); + return () => observer.disconnect(); + }, []); + + return isIntersecting; +}; + +export default useIntersecting; diff --git a/src/utils/store/carousel.js b/src/utils/store/carousel.js new file mode 100644 index 0000000..c5ef5f5 --- /dev/null +++ b/src/utils/store/carousel.js @@ -0,0 +1,8 @@ +/** @format */ + +import { create } from "zustand"; + +export const useCarouselStore = create((set) => ({ + direction: "right", + setDirection: (dir) => set(() => ({ direction: dir })), +}));