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 (
|
||||
<IconButton onClick={mutation.mutate}>
|
||||
<IconButton onClick={mutation.mutate} disabled={mutation.isLoading}>
|
||||
{isFavorite ? (
|
||||
<MdiHeart sx={{ color: pink[700] }} />
|
||||
) : (
|
||||
|
||||
@@ -65,7 +65,7 @@ const MarkPlayedButton = ({ itemId, isPlayed, queryKey, userId, itemName }) => {
|
||||
},
|
||||
});
|
||||
return (
|
||||
<IconButton onClick={mutation.mutate}>
|
||||
<IconButton onClick={mutation.mutate} disabled={mutation.isLoading}>
|
||||
<MdiCheck
|
||||
sx={{
|
||||
color: isPlayed ? green[400] : "white",
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useNavigate } from "react-router-dom";
|
||||
|
||||
import Box from "@mui/material/Box";
|
||||
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 CardActionArea from "@mui/material/CardActionArea";
|
||||
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 { MdiHeart } from "../icons/mdiHeart";
|
||||
import useIntersecting from "../../utils/hooks/useIntersecting";
|
||||
import LikeButton from "../buttons/likeButton";
|
||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||
|
||||
const cardImageAspectRatios = {
|
||||
thumb: 1.777,
|
||||
@@ -43,88 +45,122 @@ export const Card = ({
|
||||
itemId,
|
||||
itemType,
|
||||
itemName,
|
||||
isFavorite,
|
||||
isPlayed,
|
||||
imageType = "Primary",
|
||||
cardType,
|
||||
secondaryText,
|
||||
queryKey,
|
||||
userId,
|
||||
|
||||
onClick,
|
||||
disableOverlay = false,
|
||||
}) => {
|
||||
const ref = useRef();
|
||||
const isVisible = useIntersecting(ref);
|
||||
const navigate = useNavigate();
|
||||
const defaultOnClick = () => navigate(`/item/${itemId}`);
|
||||
return (
|
||||
<Box
|
||||
padding={1}
|
||||
ref={ref}
|
||||
sx={{
|
||||
height: "100%",
|
||||
overflow: "visible",
|
||||
alignItems: "flex-start",
|
||||
}}
|
||||
<CardActionArea
|
||||
sx={{ padding: 1, borderRadius: "10px" }}
|
||||
className="card-container"
|
||||
onClick={!!onClick ? onClick : defaultOnClick}
|
||||
>
|
||||
<Stack
|
||||
className={isVisible ? "card isVisible" : "card"}
|
||||
<MuiCard
|
||||
ref={ref}
|
||||
sx={{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
position: "relative",
|
||||
overflow: "visible",
|
||||
alignItems: "flex-start",
|
||||
background: "transparent",
|
||||
}}
|
||||
direction="column"
|
||||
justifyContent="center"
|
||||
mr={1}
|
||||
elevation={0}
|
||||
>
|
||||
<Box
|
||||
className="card-image-container"
|
||||
<Stack
|
||||
className={isVisible ? "card isVisible" : "card"}
|
||||
sx={{
|
||||
aspectRatio: cardImageAspectRatios[cardType],
|
||||
overflow: "hidden",
|
||||
height: "auto",
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
position: "relative",
|
||||
overflow: "visible",
|
||||
}}
|
||||
direction="column"
|
||||
justifyContent="center"
|
||||
mr={1}
|
||||
>
|
||||
<Box className="card-image-icon-container">
|
||||
{TypeIconCollectionCard[itemType]}
|
||||
</Box>
|
||||
<img
|
||||
src={window.api.getItemImageUrl(
|
||||
itemId,
|
||||
imageType,
|
||||
{
|
||||
quality: 90,
|
||||
fillHeight: 512,
|
||||
fillWidth: 512,
|
||||
},
|
||||
)}
|
||||
style={{
|
||||
height: "100%",
|
||||
<Box
|
||||
className="card-image-container"
|
||||
sx={{
|
||||
aspectRatio: cardImageAspectRatios[cardType],
|
||||
overflow: "hidden",
|
||||
height: "auto",
|
||||
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}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="subtitle1"
|
||||
fontWeight={300}
|
||||
noWrap
|
||||
textAlign="center"
|
||||
sx={{ opacity: 0.6 }}
|
||||
>
|
||||
{secondaryText}
|
||||
</Typography>
|
||||
</Box>
|
||||
</Stack>
|
||||
</Box>
|
||||
<Box className="card-image-icon-container">
|
||||
{TypeIconCollectionCard[itemType]}
|
||||
</Box>
|
||||
<img
|
||||
src={window.api.getItemImageUrl(
|
||||
itemId,
|
||||
imageType,
|
||||
{
|
||||
quality: 90,
|
||||
fillHeight: 512,
|
||||
fillWidth: 512,
|
||||
},
|
||||
)}
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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) => (
|
||||
<Box
|
||||
@@ -111,7 +114,14 @@ const Carousel = ({ content, onChange }) => {
|
||||
? "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);
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</Box>
|
||||
|
||||
@@ -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}
|
||||
></Card>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -257,6 +257,12 @@ const Home = () => {
|
||||
itemType="Library"
|
||||
imageType="Primary"
|
||||
cardType="thumb"
|
||||
disableOverlay
|
||||
onClick={() =>
|
||||
navigate(
|
||||
`/library/${item.Id}`,
|
||||
)
|
||||
}
|
||||
></Card>
|
||||
);
|
||||
},
|
||||
@@ -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}
|
||||
></Card>
|
||||
);
|
||||
},
|
||||
@@ -300,7 +319,12 @@ const Home = () => {
|
||||
return (
|
||||
<Card
|
||||
key={index}
|
||||
itemName={item.Name}
|
||||
itemName={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
? item.SeriesName
|
||||
: item.Name
|
||||
}
|
||||
itemId={item.Id}
|
||||
itemType={item.Type}
|
||||
imageType={
|
||||
@@ -312,10 +336,23 @@ const Home = () => {
|
||||
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}
|
||||
></Card>
|
||||
);
|
||||
},
|
||||
@@ -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}
|
||||
></Card>
|
||||
);
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user