Update card and carousel #153
This commit is contained in:
7 files changed
+193
-71
No files matched your search
@@ -66,7 +66,7 @@ const LikeButton = ({ itemId, isFavorite, queryKey, userId, itemName }) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
<IconButton onClick={mutation.mutate}>
|
<IconButton onClick={mutation.mutate} disabled={mutation.isLoading}>
|
||||||
{isFavorite ? (
|
{isFavorite ? (
|
||||||
<MdiHeart sx={{ color: pink[700] }} />
|
<MdiHeart sx={{ color: pink[700] }} />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ const MarkPlayedButton = ({ itemId, isPlayed, queryKey, userId, itemName }) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
<IconButton onClick={mutation.mutate}>
|
<IconButton onClick={mutation.mutate} disabled={mutation.isLoading}>
|
||||||
<MdiCheck
|
<MdiCheck
|
||||||
sx={{
|
sx={{
|
||||||
color: isPlayed ? green[400] : "white",
|
color: isPlayed ? green[400] : "white",
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { useNavigate } from "react-router-dom";
|
|||||||
|
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
import CardContent from "@mui/material/CardContent";
|
import MuiCard from "@mui/material/Card";
|
||||||
import CardMedia from "@mui/material/CardMedia";
|
import CardMedia from "@mui/material/CardMedia";
|
||||||
import CardActionArea from "@mui/material/CardActionArea";
|
import CardActionArea from "@mui/material/CardActionArea";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
@@ -32,6 +32,8 @@ import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api"
|
|||||||
import { MdiHeartOutline } from "../icons/mdiHeartOutline";
|
import { MdiHeartOutline } from "../icons/mdiHeartOutline";
|
||||||
import { MdiHeart } from "../icons/mdiHeart";
|
import { MdiHeart } from "../icons/mdiHeart";
|
||||||
import useIntersecting from "../../utils/hooks/useIntersecting";
|
import useIntersecting from "../../utils/hooks/useIntersecting";
|
||||||
|
import LikeButton from "../buttons/likeButton";
|
||||||
|
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||||
|
|
||||||
const cardImageAspectRatios = {
|
const cardImageAspectRatios = {
|
||||||
thumb: 1.777,
|
thumb: 1.777,
|
||||||
@@ -43,88 +45,122 @@ export const Card = ({
|
|||||||
itemId,
|
itemId,
|
||||||
itemType,
|
itemType,
|
||||||
itemName,
|
itemName,
|
||||||
|
isFavorite,
|
||||||
|
isPlayed,
|
||||||
imageType = "Primary",
|
imageType = "Primary",
|
||||||
cardType,
|
cardType,
|
||||||
secondaryText,
|
secondaryText,
|
||||||
|
queryKey,
|
||||||
|
userId,
|
||||||
|
|
||||||
|
onClick,
|
||||||
|
disableOverlay = false,
|
||||||
}) => {
|
}) => {
|
||||||
const ref = useRef();
|
const ref = useRef();
|
||||||
const isVisible = useIntersecting(ref);
|
const isVisible = useIntersecting(ref);
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const defaultOnClick = () => navigate(`/item/${itemId}`);
|
||||||
return (
|
return (
|
||||||
<Box
|
<CardActionArea
|
||||||
padding={1}
|
sx={{ padding: 1, borderRadius: "10px" }}
|
||||||
ref={ref}
|
className="card-container"
|
||||||
sx={{
|
onClick={!!onClick ? onClick : defaultOnClick}
|
||||||
height: "100%",
|
|
||||||
overflow: "visible",
|
|
||||||
alignItems: "flex-start",
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Stack
|
<MuiCard
|
||||||
className={isVisible ? "card isVisible" : "card"}
|
ref={ref}
|
||||||
sx={{
|
sx={{
|
||||||
width: "100%",
|
|
||||||
height: "100%",
|
height: "100%",
|
||||||
position: "relative",
|
|
||||||
overflow: "visible",
|
overflow: "visible",
|
||||||
|
alignItems: "flex-start",
|
||||||
|
background: "transparent",
|
||||||
}}
|
}}
|
||||||
direction="column"
|
elevation={0}
|
||||||
justifyContent="center"
|
|
||||||
mr={1}
|
|
||||||
>
|
>
|
||||||
<Box
|
<Stack
|
||||||
className="card-image-container"
|
className={isVisible ? "card isVisible" : "card"}
|
||||||
sx={{
|
sx={{
|
||||||
aspectRatio: cardImageAspectRatios[cardType],
|
|
||||||
overflow: "hidden",
|
|
||||||
height: "auto",
|
|
||||||
width: "100%",
|
width: "100%",
|
||||||
|
height: "100%",
|
||||||
|
position: "relative",
|
||||||
|
overflow: "visible",
|
||||||
}}
|
}}
|
||||||
|
direction="column"
|
||||||
|
justifyContent="center"
|
||||||
|
mr={1}
|
||||||
>
|
>
|
||||||
<Box className="card-image-icon-container">
|
<Box
|
||||||
{TypeIconCollectionCard[itemType]}
|
className="card-image-container"
|
||||||
</Box>
|
sx={{
|
||||||
<img
|
aspectRatio: cardImageAspectRatios[cardType],
|
||||||
src={window.api.getItemImageUrl(
|
overflow: "hidden",
|
||||||
itemId,
|
height: "auto",
|
||||||
imageType,
|
|
||||||
{
|
|
||||||
quality: 90,
|
|
||||||
fillHeight: 512,
|
|
||||||
fillWidth: 512,
|
|
||||||
},
|
|
||||||
)}
|
|
||||||
style={{
|
|
||||||
height: "100%",
|
|
||||||
width: "100%",
|
width: "100%",
|
||||||
opacity: 0,
|
|
||||||
}}
|
}}
|
||||||
loading="lazy"
|
|
||||||
onLoad={(e) => (e.target.style.opacity = 1)}
|
|
||||||
className="card-image"
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
<Box className="card-text-container" height="15%">
|
|
||||||
<Typography
|
|
||||||
variant="h6"
|
|
||||||
fontWeight={400}
|
|
||||||
noWrap
|
|
||||||
textAlign="center"
|
|
||||||
sx={{ opacity: 0.9 }}
|
|
||||||
>
|
>
|
||||||
{itemName}
|
<Box className="card-image-icon-container">
|
||||||
</Typography>
|
{TypeIconCollectionCard[itemType]}
|
||||||
<Typography
|
</Box>
|
||||||
variant="subtitle1"
|
<img
|
||||||
fontWeight={300}
|
src={window.api.getItemImageUrl(
|
||||||
noWrap
|
itemId,
|
||||||
textAlign="center"
|
imageType,
|
||||||
sx={{ opacity: 0.6 }}
|
{
|
||||||
>
|
quality: 90,
|
||||||
{secondaryText}
|
fillHeight: 512,
|
||||||
</Typography>
|
fillWidth: 512,
|
||||||
</Box>
|
},
|
||||||
</Stack>
|
)}
|
||||||
</Box>
|
style={{
|
||||||
|
height: "100%",
|
||||||
|
width: "100%",
|
||||||
|
opacity: 0,
|
||||||
|
}}
|
||||||
|
loading="lazy"
|
||||||
|
onLoad={(e) => (e.target.style.opacity = 1)}
|
||||||
|
className="card-image"
|
||||||
|
/>
|
||||||
|
{!disableOverlay && (
|
||||||
|
<Box className="card-overlay">
|
||||||
|
<LikeButton
|
||||||
|
itemId={itemId}
|
||||||
|
itemName={itemName}
|
||||||
|
isFavorite={isFavorite}
|
||||||
|
queryKey={queryKey}
|
||||||
|
userId={userId}
|
||||||
|
/>
|
||||||
|
<MarkPlayedButton
|
||||||
|
itemId={itemId}
|
||||||
|
itemName={itemName}
|
||||||
|
isPlayed={isPlayed}
|
||||||
|
queryKey={queryKey}
|
||||||
|
userId={userId}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
<Box className="card-text-container" height="15%">
|
||||||
|
<Typography
|
||||||
|
variant="h6"
|
||||||
|
fontWeight={400}
|
||||||
|
noWrap
|
||||||
|
textAlign="center"
|
||||||
|
sx={{ opacity: 0.9 }}
|
||||||
|
>
|
||||||
|
{itemName}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
variant="subtitle1"
|
||||||
|
fontWeight={300}
|
||||||
|
noWrap
|
||||||
|
textAlign="center"
|
||||||
|
sx={{ opacity: 0.6 }}
|
||||||
|
>
|
||||||
|
{secondaryText}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
</Stack>
|
||||||
|
</MuiCard>
|
||||||
|
</CardActionArea>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
transition: opacity $transition-time-fast;
|
transition: opacity $transition-time-fast;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 1;
|
z-index: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
&-container {
|
&-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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,10 @@ const Carousel = ({ content, onChange }) => {
|
|||||||
? "white"
|
? "white"
|
||||||
: "rgb(255 255 255 / 0.5)",
|
: "rgb(255 255 255 / 0.5)",
|
||||||
}}
|
}}
|
||||||
onClick={() => setCurrentSlide(0)}
|
onClick={() => {
|
||||||
|
setDirection("left");
|
||||||
|
setCurrentSlide(0);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
{content.map((item, index) => (
|
{content.map((item, index) => (
|
||||||
<Box
|
<Box
|
||||||
@@ -111,7 +114,14 @@ const Carousel = ({ content, onChange }) => {
|
|||||||
? "white"
|
? "white"
|
||||||
: "rgb(255 255 255 / 0.5)",
|
: "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);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
|||||||
|
|
||||||
export const LatestMediaSection = ({ latestMediaLib }) => {
|
export const LatestMediaSection = ({ latestMediaLib }) => {
|
||||||
const user = useQuery({
|
const user = useQuery({
|
||||||
queryKey: ["home", "user"],
|
queryKey: ["user"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
let usr = await getUserApi(window.api).getCurrentUser();
|
let usr = await getUserApi(window.api).getCurrentUser();
|
||||||
return usr.data;
|
return usr.data;
|
||||||
@@ -57,6 +57,10 @@ export const LatestMediaSection = ({ latestMediaLib }) => {
|
|||||||
: "portrait"
|
: "portrait"
|
||||||
}
|
}
|
||||||
secondaryText={item.ProductionYear}
|
secondaryText={item.ProductionYear}
|
||||||
|
isFavorite={item.UserData.IsFavorite}
|
||||||
|
queryKey={["home", "resume", "video"]}
|
||||||
|
isPlayed={item.UserData.Played}
|
||||||
|
userId={user.data.Id}
|
||||||
></Card>
|
></Card>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -257,6 +257,12 @@ const Home = () => {
|
|||||||
itemType="Library"
|
itemType="Library"
|
||||||
imageType="Primary"
|
imageType="Primary"
|
||||||
cardType="thumb"
|
cardType="thumb"
|
||||||
|
disableOverlay
|
||||||
|
onClick={() =>
|
||||||
|
navigate(
|
||||||
|
`/library/${item.Id}`,
|
||||||
|
)
|
||||||
|
}
|
||||||
></Card>
|
></Card>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -280,6 +286,19 @@ const Home = () => {
|
|||||||
itemType={item.Type}
|
itemType={item.Type}
|
||||||
imageType="Primary"
|
imageType="Primary"
|
||||||
cardType="thumb"
|
cardType="thumb"
|
||||||
|
isFavorite={
|
||||||
|
item.UserData
|
||||||
|
.IsFavorite
|
||||||
|
}
|
||||||
|
queryKey={[
|
||||||
|
"home",
|
||||||
|
"resume",
|
||||||
|
"video",
|
||||||
|
]}
|
||||||
|
isPlayed={
|
||||||
|
item.UserData.Played
|
||||||
|
}
|
||||||
|
userId={user.data.Id}
|
||||||
></Card>
|
></Card>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -300,7 +319,12 @@ const Home = () => {
|
|||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
key={index}
|
key={index}
|
||||||
itemName={item.Name}
|
itemName={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Episode
|
||||||
|
? item.SeriesName
|
||||||
|
: item.Name
|
||||||
|
}
|
||||||
itemId={item.Id}
|
itemId={item.Id}
|
||||||
itemType={item.Type}
|
itemType={item.Type}
|
||||||
imageType={
|
imageType={
|
||||||
@@ -312,10 +336,23 @@ const Home = () => {
|
|||||||
secondaryText={
|
secondaryText={
|
||||||
item.Type ==
|
item.Type ==
|
||||||
BaseItemKind.Episode
|
BaseItemKind.Episode
|
||||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} ${item.SeriesName}`
|
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||||
: item.ProductionYear
|
: item.ProductionYear
|
||||||
}
|
}
|
||||||
cardType="thumb"
|
cardType="thumb"
|
||||||
|
isFavorite={
|
||||||
|
item.UserData
|
||||||
|
.IsFavorite
|
||||||
|
}
|
||||||
|
queryKey={[
|
||||||
|
"home",
|
||||||
|
"resume",
|
||||||
|
"video",
|
||||||
|
]}
|
||||||
|
isPlayed={
|
||||||
|
item.UserData.Played
|
||||||
|
}
|
||||||
|
userId={user.data.Id}
|
||||||
></Card>
|
></Card>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -349,6 +386,19 @@ const Home = () => {
|
|||||||
item.ProductionYear
|
item.ProductionYear
|
||||||
}
|
}
|
||||||
cardType="thumb"
|
cardType="thumb"
|
||||||
|
isFavorite={
|
||||||
|
item.UserData
|
||||||
|
.IsFavorite
|
||||||
|
}
|
||||||
|
queryKey={[
|
||||||
|
"home",
|
||||||
|
"resume",
|
||||||
|
"video",
|
||||||
|
]}
|
||||||
|
isPlayed={
|
||||||
|
item.UserData.Played
|
||||||
|
}
|
||||||
|
userId={user.data.Id}
|
||||||
></Card>
|
></Card>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user