Add new hero carousel and start working on cards #153
This commit is contained in:
13 files changed
+355
-916
No files matched your search
+48
-351
@@ -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 (
|
||||
<MuiCard
|
||||
className={"card " + cardOrientation}
|
||||
sx={{
|
||||
background: "transparent",
|
||||
borderRadius: borderRadiusDefault,
|
||||
mr: 1,
|
||||
}}
|
||||
elevation={0}
|
||||
{...cardProps}
|
||||
>
|
||||
<CardActionArea
|
||||
sx={{ p: "1px" }}
|
||||
component={Box}
|
||||
onClick={
|
||||
!!onClickEvent
|
||||
? onClickEvent
|
||||
: () => {
|
||||
navigate(`/item/${itemId}`);
|
||||
}
|
||||
}
|
||||
className="cardBox"
|
||||
<Box mr={2} ref={ref} sx={{ height: "100%", overflow: "visible" }}>
|
||||
<Stack
|
||||
className={isVisible ? "card isVisible" : "card"}
|
||||
sx={{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
position: "relative",
|
||||
overflow: "visible",
|
||||
}}
|
||||
direction="column"
|
||||
justifyContent="center"
|
||||
mr={1}
|
||||
>
|
||||
<Box
|
||||
className="card-media-container"
|
||||
className="card-image-container"
|
||||
sx={{
|
||||
position: "relative",
|
||||
m: 1,
|
||||
aspectRatio:
|
||||
cardOrientation == "landscape"
|
||||
? "1.777"
|
||||
: cardOrientation == "portait"
|
||||
? "0.666"
|
||||
: "1",
|
||||
aspectRatio: imageAspectRatio,
|
||||
overflow: "hidden",
|
||||
}}
|
||||
height="85%"
|
||||
>
|
||||
<>
|
||||
<Chip
|
||||
className="card-indicator"
|
||||
label={<MdiCheck />}
|
||||
sx={{
|
||||
transition: "opacity 150ms",
|
||||
opacity: isWatched ? 1 : 0,
|
||||
}}
|
||||
/>
|
||||
|
||||
{!!watchedCountState && (
|
||||
<Chip
|
||||
className="card-indicator card-indicator-text"
|
||||
label={watchedCountState}
|
||||
></Chip>
|
||||
<img
|
||||
src={window.api.getItemImageUrl(
|
||||
itemId,
|
||||
imageType,
|
||||
{
|
||||
quality: 90,
|
||||
fillHeight: 512,
|
||||
fillWidth: 512,
|
||||
},
|
||||
)}
|
||||
<div
|
||||
className="card-media-image-container"
|
||||
style={{ opacity: imgLoading ? 0 : 1 }}
|
||||
// style={{ opacity: 1 }}
|
||||
>
|
||||
{imageTags &&
|
||||
(cardType == "thumb" ? (
|
||||
<CardMedia
|
||||
component="img"
|
||||
image={
|
||||
window.api.basePath +
|
||||
"/Items/" +
|
||||
itemId +
|
||||
"/Images/Backdrop?fillHeight=300&fillWidth=532&quality=96"
|
||||
}
|
||||
alt={itemName}
|
||||
sx={{
|
||||
width: "100%",
|
||||
aspectRatio:
|
||||
cardOrientation ==
|
||||
"landscape"
|
||||
? "1.777"
|
||||
: cardOrientation ==
|
||||
"portait"
|
||||
? "0.666"
|
||||
: "1",
|
||||
borderRadius:
|
||||
borderRadiusDefault,
|
||||
overflow: "hidden",
|
||||
}}
|
||||
onLoad={() =>
|
||||
setImgLoading(false)
|
||||
}
|
||||
className="card-image"
|
||||
></CardMedia>
|
||||
) : (
|
||||
<CardMedia
|
||||
component="img"
|
||||
image={
|
||||
iconType == "User"
|
||||
? window.api
|
||||
.basePath +
|
||||
"/Users/" +
|
||||
itemId +
|
||||
"/Images/Primary?fillHeight=532&fillWidth=300&quality=96"
|
||||
: window.api
|
||||
.basePath +
|
||||
"/Items/" +
|
||||
itemId +
|
||||
"/Images/Primary?fillHeight=532&fillWidth=300&quality=96"
|
||||
}
|
||||
alt={itemName}
|
||||
sx={{
|
||||
width: "100%",
|
||||
aspectRatio:
|
||||
cardOrientation ==
|
||||
"landscape"
|
||||
? "1.777"
|
||||
: cardOrientation ==
|
||||
"portait"
|
||||
? "0.666"
|
||||
: "1",
|
||||
}}
|
||||
className="card-image"
|
||||
onLoad={() =>
|
||||
setImgLoading(false)
|
||||
}
|
||||
></CardMedia>
|
||||
))}
|
||||
</div>
|
||||
{!!blurhash && (
|
||||
<Blurhash
|
||||
hash={blurhash}
|
||||
width="100%"
|
||||
height="100%"
|
||||
resolutionX={24}
|
||||
resolutionY={24}
|
||||
style={{
|
||||
aspectRatio:
|
||||
cardOrientation == "landscape"
|
||||
? "1.777"
|
||||
: cardOrientation ==
|
||||
"portait"
|
||||
? "0.666"
|
||||
: "1",
|
||||
}}
|
||||
className="card-image-blurhash"
|
||||
/>
|
||||
)}
|
||||
<div className="card-image-icon-container">
|
||||
{cardType == "lib"
|
||||
? MediaCollectionTypeIconCollectionCard[
|
||||
iconType
|
||||
]
|
||||
: TypeIconCollectionCard[iconType]}
|
||||
</div>
|
||||
{!!playedPercent && (
|
||||
<LinearProgress
|
||||
variant="determinate"
|
||||
value={playedPercent}
|
||||
sx={{
|
||||
width: "90%",
|
||||
position: "absolute",
|
||||
left: "5%",
|
||||
bottom: "5%",
|
||||
borderRadius: "100px",
|
||||
height: "5px",
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
{!disableOverlay && (
|
||||
<Box
|
||||
className="card-media-overlay"
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "flex-end",
|
||||
justifyContent: "flex-end",
|
||||
p: 1,
|
||||
}}
|
||||
>
|
||||
<ButtonGroup>
|
||||
{availableMarkButtonTypes.includes(
|
||||
iconType,
|
||||
) && (
|
||||
<IconButton
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
handleMarkAsPlayOrUnMarkAsPlay();
|
||||
}}
|
||||
onFocus={(e) =>
|
||||
e.stopPropagation
|
||||
}
|
||||
>
|
||||
<MdiCheck
|
||||
sx={{
|
||||
color: isWatched
|
||||
? green[400]
|
||||
: "white",
|
||||
}}
|
||||
/>
|
||||
</IconButton>
|
||||
)}
|
||||
{allowedLikeButton.includes(
|
||||
iconType,
|
||||
) && (
|
||||
<IconButton
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
handleLiking();
|
||||
}}
|
||||
onFocus={(e) =>
|
||||
e.stopPropagation
|
||||
}
|
||||
>
|
||||
{isFavorite ? (
|
||||
<MdiHeart
|
||||
sx={{
|
||||
color: pink[700],
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<MdiHeartOutline />
|
||||
)}
|
||||
</IconButton>
|
||||
)}
|
||||
</ButtonGroup>
|
||||
</Box>
|
||||
)}
|
||||
style={{
|
||||
height: "100%",
|
||||
}}
|
||||
className="card-image"
|
||||
/>
|
||||
</Box>
|
||||
|
||||
<CardContent
|
||||
className="card-text-container"
|
||||
sx={{
|
||||
padding: "0 0.5em",
|
||||
backgroundColor: "transparent",
|
||||
}}
|
||||
>
|
||||
<Box className="card-text-container" height="15%">
|
||||
<Typography
|
||||
gutterBottom={false}
|
||||
variant="h6"
|
||||
component="div"
|
||||
color="white"
|
||||
fontWeight={500}
|
||||
textAlign="left"
|
||||
variant="h5"
|
||||
fontWeight={300}
|
||||
noWrap
|
||||
width="fit-content"
|
||||
maxWidth="100%"
|
||||
textAlign="center"
|
||||
>
|
||||
{itemName}
|
||||
</Typography>
|
||||
|
||||
<Typography
|
||||
gutterBottom
|
||||
variant="subtitle1"
|
||||
component="div"
|
||||
textAlign="left"
|
||||
width="fit-content"
|
||||
maxWidth="100%"
|
||||
noWrap
|
||||
sx={{ opacity: 0.5 }}
|
||||
>
|
||||
{subText}
|
||||
</Typography>
|
||||
</CardContent>
|
||||
</CardActionArea>
|
||||
</MuiCard>
|
||||
</Box>
|
||||
</Stack>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
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 = {};
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 (
|
||||
<Box className="carousel" position="relative" height="100vh">
|
||||
<IconButton
|
||||
className="carousel-button left"
|
||||
onClick={() => {
|
||||
if (currentSlide > 0) {
|
||||
setDirection("left");
|
||||
setCurrentSlide((init) => init - 1);
|
||||
}
|
||||
}}
|
||||
sx={{
|
||||
background: " rgb(200 200 200 / 0.05)",
|
||||
}}
|
||||
disabled={currentSlide == 0}
|
||||
>
|
||||
<MdiChevronLeft />
|
||||
</IconButton>
|
||||
<AnimatePresence>
|
||||
<motion.div
|
||||
key={currentSlide}
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
transition={{
|
||||
duration: 0.5,
|
||||
}}
|
||||
drag="x"
|
||||
dragConstraints={{ left: 0, right: 0 }}
|
||||
dragElastic={1}
|
||||
onDragEnd={(e, { offset, velocity }) => {
|
||||
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]}
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
<IconButton
|
||||
className="carousel-button right"
|
||||
onClick={() => {
|
||||
if (currentSlide < content.length - 1) {
|
||||
setDirection("right");
|
||||
setCurrentSlide((init) => init + 1);
|
||||
}
|
||||
}}
|
||||
disabled={currentSlide == content.length - 1}
|
||||
sx={{
|
||||
background: " rgb(200 200 200 / 0.05)",
|
||||
}}
|
||||
>
|
||||
<MdiChevronRight />
|
||||
</IconButton>
|
||||
<Box className="carousel-indicator-container">
|
||||
<Box
|
||||
className="carousel-indicator"
|
||||
sx={{
|
||||
background:
|
||||
currentSlide == 0
|
||||
? "white"
|
||||
: "rgb(255 255 255 / 0.5)",
|
||||
}}
|
||||
onClick={() => setCurrentSlide(0)}
|
||||
/>
|
||||
{content.map((item, index) => (
|
||||
<Box
|
||||
className="carousel-indicator"
|
||||
key={index}
|
||||
sx={{
|
||||
background:
|
||||
currentSlide == index + 1
|
||||
? "white"
|
||||
: "rgb(255 255 255 / 0.5)",
|
||||
}}
|
||||
onClick={() => setCurrentSlide(index + 1)}
|
||||
/>
|
||||
))}
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default Carousel;
|
||||
@@ -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 (
|
||||
<ErrorBoundary fallback={<CarouselSlideError itemName={item.Name} />}>
|
||||
@@ -56,66 +57,84 @@ const CarouselSlide = ({ item }) => {
|
||||
sx={{
|
||||
background: "transparent",
|
||||
px: 3,
|
||||
boxShadow: "none !important",
|
||||
}}
|
||||
>
|
||||
<div className="hero-carousel-background-container">
|
||||
{!!item.ImageBlurHashes.Backdrop &&
|
||||
Object.keys(item.ImageBlurHashes.Backdrop)
|
||||
.length != 0 && (
|
||||
<Blurhash
|
||||
hash={
|
||||
item.ImageBlurHashes.Backdrop[
|
||||
Object.keys(
|
||||
item.ImageBlurHashes
|
||||
.Backdrop,
|
||||
)[0]
|
||||
]
|
||||
{!!item.ImageBlurHashes.Backdrop && (
|
||||
<>
|
||||
{Object.keys(item.ImageBlurHashes.Backdrop)
|
||||
.length != 0 && (
|
||||
<Blurhash
|
||||
hash={
|
||||
item.ImageBlurHashes.Backdrop[
|
||||
Object.keys(
|
||||
item.ImageBlurHashes
|
||||
.Backdrop,
|
||||
)[0]
|
||||
]
|
||||
}
|
||||
// hash="LEHV6nWB2yk8pyo0adR*.7kCMdnj"
|
||||
width="1080"
|
||||
height="720"
|
||||
resolutionX={64}
|
||||
resolutionY={96}
|
||||
className="hero-carousel-background-blurhash"
|
||||
punch={1}
|
||||
/>
|
||||
)}
|
||||
<img
|
||||
className="hero-carousel-background-image"
|
||||
src={
|
||||
!!item.ParentBackdropItemId
|
||||
? `${window.api.basePath}/Items/${item.ParentBackdropItemId}/Images/Backdrop`
|
||||
: `${window.api.basePath}/Items/${item.Id}/Images/Backdrop`
|
||||
}
|
||||
// hash="LEHV6nWB2yk8pyo0adR*.7kCMdnj"
|
||||
width="1080"
|
||||
height="720"
|
||||
resolutionX={64}
|
||||
resolutionY={96}
|
||||
className="hero-carousel-background-blurhash"
|
||||
punch={1}
|
||||
onLoad={(e) =>
|
||||
(e.target.style.opacity = 1)
|
||||
}
|
||||
loading="eager"
|
||||
/>
|
||||
)}
|
||||
<div
|
||||
className="hero-carousel-background-image"
|
||||
style={{
|
||||
backgroundImage: !!item.ParentBackdropItemId
|
||||
? `url('${window.api.basePath}/Items/${item.ParentBackdropItemId}/Images/Backdrop')`
|
||||
: `url('${window.api.basePath}/Items/${item.Id}/Images/Backdrop')`,
|
||||
}}
|
||||
></div>
|
||||
</>
|
||||
)}
|
||||
<div className="hero-carousel-background-icon-container">
|
||||
{MediaTypeIconCollection[item.Type]}
|
||||
</div>
|
||||
</div>
|
||||
<Box className="hero-carousel-detail">
|
||||
<Box
|
||||
component={motion.div}
|
||||
// variants={slideAnim}
|
||||
initial={{
|
||||
transform:
|
||||
animationDirection == "right"
|
||||
? "translateX(50px)"
|
||||
: "translateX(-50px)",
|
||||
opacity: 0,
|
||||
}}
|
||||
animate={{
|
||||
transform: "translateX(0px)",
|
||||
opacity: 1,
|
||||
}}
|
||||
exit={{
|
||||
transform:
|
||||
animationDirection == "right"
|
||||
? "translateX(-50px)"
|
||||
: "translateX(50px)",
|
||||
|
||||
opacity: 0,
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.2,
|
||||
}}
|
||||
className="hero-carousel-detail"
|
||||
>
|
||||
<Typography
|
||||
component={motion.h2}
|
||||
key={item.Id}
|
||||
variant="h2"
|
||||
className="hero-carousel-text"
|
||||
sx={{
|
||||
mb: 2.5,
|
||||
}}
|
||||
initial={{
|
||||
y: 10,
|
||||
opacity: 0,
|
||||
}}
|
||||
exit={{
|
||||
y: 10,
|
||||
opacity: 0,
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.35,
|
||||
}}
|
||||
whileInView={{
|
||||
y: 0,
|
||||
opacity: 1,
|
||||
}}
|
||||
overflow="visible"
|
||||
>
|
||||
{!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)
|
||||
}
|
||||
></img>
|
||||
)}
|
||||
</Typography>
|
||||
<Stack
|
||||
component={motion.div}
|
||||
direction="row"
|
||||
gap={1}
|
||||
initial={{
|
||||
y: 10,
|
||||
opacity: 0,
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.25,
|
||||
delay: 0.1,
|
||||
}}
|
||||
exit={{
|
||||
y: 10,
|
||||
opacity: 0,
|
||||
}}
|
||||
whileInView={{
|
||||
y: 0,
|
||||
opacity: 1,
|
||||
}}
|
||||
divider={
|
||||
<Box
|
||||
sx={{
|
||||
@@ -216,29 +225,12 @@ const CarouselSlide = ({ item }) => {
|
||||
)}
|
||||
</Stack>
|
||||
<Typography
|
||||
component={motion.div}
|
||||
initial={{
|
||||
y: 10,
|
||||
opacity: 0,
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.25,
|
||||
delay: 0.2,
|
||||
}}
|
||||
whileInView={{
|
||||
y: 0,
|
||||
opacity: 0.7,
|
||||
}}
|
||||
exit={{
|
||||
y: 10,
|
||||
opacity: 0,
|
||||
}}
|
||||
variant="subtitle1"
|
||||
className="hero-carousel-text"
|
||||
sx={{
|
||||
display: "-webkit-box",
|
||||
maxWidth: "70%",
|
||||
maxHeight: "30%",
|
||||
maxHeight: "50%",
|
||||
textOverflow: "ellipsis",
|
||||
overflow: "hidden",
|
||||
WebkitLineClamp: "4",
|
||||
@@ -250,23 +242,6 @@ const CarouselSlide = ({ item }) => {
|
||||
|
||||
{/* TODO Link PLay and More info buttons in carousel */}
|
||||
<Stack
|
||||
component={motion.div}
|
||||
initial={{
|
||||
y: 10,
|
||||
opacity: 0,
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.25,
|
||||
delay: 0.4,
|
||||
}}
|
||||
whileInView={{
|
||||
y: 0,
|
||||
opacity: 1,
|
||||
}}
|
||||
exit={{
|
||||
y: 10,
|
||||
opacity: 0,
|
||||
}}
|
||||
mt={3}
|
||||
direction="row"
|
||||
gap={3}
|
||||
|
||||
@@ -44,54 +44,15 @@ export const LatestMediaSection = ({ latestMediaLib }) => {
|
||||
>
|
||||
{data.data.map((item, index) => {
|
||||
return (
|
||||
<Card
|
||||
key={index}
|
||||
itemName={
|
||||
!!item.SeriesId
|
||||
? item.SeriesName
|
||||
: item.Name
|
||||
}
|
||||
itemId={
|
||||
!!item.SeriesId
|
||||
? item.SeriesId
|
||||
: item.Id
|
||||
}
|
||||
// imageTags={false}
|
||||
imageTags={!!item.ImageTags.Primary}
|
||||
iconType={item.Type}
|
||||
subText={item.ProductionYear}
|
||||
playedPercent={
|
||||
item.UserData.PlayedPercentage
|
||||
}
|
||||
cardOrientation={
|
||||
item.PrimaryImageAspectRatio == 1
|
||||
? "sqaure"
|
||||
: "portait"
|
||||
}
|
||||
watchedStatus={
|
||||
item.Type == BaseItemKind.Audio
|
||||
? false
|
||||
: item.UserData.Played
|
||||
}
|
||||
watchedCount={
|
||||
item.UserData.UnplayedItemCount
|
||||
}
|
||||
blurhash={
|
||||
item.ImageBlurHashes == {}
|
||||
? ""
|
||||
: !!item.ImageTags.Primary
|
||||
? !!item.ImageBlurHashes.Primary
|
||||
? item.ImageBlurHashes
|
||||
.Primary[
|
||||
item.ImageTags
|
||||
.Primary
|
||||
]
|
||||
: ""
|
||||
: ""
|
||||
}
|
||||
currentUser={user.data}
|
||||
favourite={item.UserData.IsFavorite}
|
||||
></Card>
|
||||
<></>
|
||||
// <Card
|
||||
// key={index}
|
||||
// itemName={
|
||||
// !!item.SeriesId
|
||||
// ? item.SeriesName
|
||||
// : item.Name
|
||||
// }
|
||||
// ></Card>
|
||||
);
|
||||
})}
|
||||
</CardScroller>
|
||||
|
||||
Reference in new issue
Block a user