Update card component #153
This commit is contained in:
7 files changed
+122
-144
No files matched your search
@@ -33,19 +33,32 @@ 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";
|
||||||
|
|
||||||
|
const cardImageAspectRatios = {
|
||||||
|
thumb: 1.777,
|
||||||
|
portrait: 0.666,
|
||||||
|
square: 1,
|
||||||
|
};
|
||||||
|
|
||||||
export const Card = ({
|
export const Card = ({
|
||||||
itemId,
|
itemId,
|
||||||
itemParentId,
|
itemType,
|
||||||
itemName,
|
itemName,
|
||||||
imageTags,
|
|
||||||
imageType = "Primary",
|
imageType = "Primary",
|
||||||
parentImageType,
|
cardType,
|
||||||
imageAspectRatio,
|
secondaryText,
|
||||||
}) => {
|
}) => {
|
||||||
const ref = useRef();
|
const ref = useRef();
|
||||||
const isVisible = useIntersecting(ref);
|
const isVisible = useIntersecting(ref);
|
||||||
return (
|
return (
|
||||||
<Box mr={2} ref={ref} sx={{ height: "100%", overflow: "visible" }}>
|
<Box
|
||||||
|
padding={1}
|
||||||
|
ref={ref}
|
||||||
|
sx={{
|
||||||
|
height: "100%",
|
||||||
|
overflow: "visible",
|
||||||
|
alignItems: "flex-start",
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Stack
|
<Stack
|
||||||
className={isVisible ? "card isVisible" : "card"}
|
className={isVisible ? "card isVisible" : "card"}
|
||||||
sx={{
|
sx={{
|
||||||
@@ -61,11 +74,15 @@ export const Card = ({
|
|||||||
<Box
|
<Box
|
||||||
className="card-image-container"
|
className="card-image-container"
|
||||||
sx={{
|
sx={{
|
||||||
aspectRatio: imageAspectRatio,
|
aspectRatio: cardImageAspectRatios[cardType],
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
|
height: "auto",
|
||||||
|
width: "100%",
|
||||||
}}
|
}}
|
||||||
height="85%"
|
|
||||||
>
|
>
|
||||||
|
<Box className="card-image-icon-container">
|
||||||
|
{TypeIconCollectionCard[itemType]}
|
||||||
|
</Box>
|
||||||
<img
|
<img
|
||||||
src={window.api.getItemImageUrl(
|
src={window.api.getItemImageUrl(
|
||||||
itemId,
|
itemId,
|
||||||
@@ -78,18 +95,32 @@ export const Card = ({
|
|||||||
)}
|
)}
|
||||||
style={{
|
style={{
|
||||||
height: "100%",
|
height: "100%",
|
||||||
|
width: "100%",
|
||||||
|
opacity: 0,
|
||||||
}}
|
}}
|
||||||
|
loading="lazy"
|
||||||
|
onLoad={(e) => (e.target.style.opacity = 1)}
|
||||||
className="card-image"
|
className="card-image"
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Box className="card-text-container" height="15%">
|
<Box className="card-text-container" height="15%">
|
||||||
<Typography
|
<Typography
|
||||||
variant="h5"
|
variant="h6"
|
||||||
|
fontWeight={400}
|
||||||
|
noWrap
|
||||||
|
textAlign="center"
|
||||||
|
sx={{ opacity: 0.9 }}
|
||||||
|
>
|
||||||
|
{itemName}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
variant="subtitle1"
|
||||||
fontWeight={300}
|
fontWeight={300}
|
||||||
noWrap
|
noWrap
|
||||||
textAlign="center"
|
textAlign="center"
|
||||||
|
sx={{ opacity: 0.6 }}
|
||||||
>
|
>
|
||||||
{itemName}
|
{secondaryText}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -4,11 +4,32 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
|
transition: opacity $transition-time-fast;
|
||||||
|
position: absolute;
|
||||||
|
z-index: 1;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
&-container {
|
&-container {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-radius: $border-radius-default;
|
border-radius: $border-radius-default;
|
||||||
box-shadow: 0 4px 8px rgb(0 0 0 / 0.2);
|
box-shadow: 0 4px 8px rgb(0 0 0 / 0.2);
|
||||||
}
|
}
|
||||||
|
&-icon {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
font-size: 3.4em !important;
|
||||||
|
fill: url(#clr-gradient-default) !important;
|
||||||
|
color: transparent;
|
||||||
|
&-container {
|
||||||
|
background: $clr-gradient-dark;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
position: relative;
|
||||||
|
z-index: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,7 +83,7 @@ const CarouselSlide = ({ item }) => {
|
|||||||
punch={1}
|
punch={1}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<img
|
<motion.img
|
||||||
className="hero-carousel-background-image"
|
className="hero-carousel-background-image"
|
||||||
src={
|
src={
|
||||||
!!item.ParentBackdropItemId
|
!!item.ParentBackdropItemId
|
||||||
@@ -107,8 +107,8 @@ const CarouselSlide = ({ item }) => {
|
|||||||
initial={{
|
initial={{
|
||||||
transform:
|
transform:
|
||||||
animationDirection == "right"
|
animationDirection == "right"
|
||||||
? "translateX(50px)"
|
? "translateX(40px)"
|
||||||
: "translateX(-50px)",
|
: "translateX(-40px)",
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
}}
|
}}
|
||||||
animate={{
|
animate={{
|
||||||
@@ -118,13 +118,13 @@ const CarouselSlide = ({ item }) => {
|
|||||||
exit={{
|
exit={{
|
||||||
transform:
|
transform:
|
||||||
animationDirection == "right"
|
animationDirection == "right"
|
||||||
? "translateX(-50px)"
|
? "translateX(-40px)"
|
||||||
: "translateX(50px)",
|
: "translateX(40px)",
|
||||||
|
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
}}
|
}}
|
||||||
transition={{
|
transition={{
|
||||||
duration: 0.2,
|
duration: 0.25,
|
||||||
}}
|
}}
|
||||||
className="hero-carousel-detail"
|
className="hero-carousel-detail"
|
||||||
>
|
>
|
||||||
@@ -140,7 +140,7 @@ const CarouselSlide = ({ item }) => {
|
|||||||
{!item.ImageTags.Logo ? (
|
{!item.ImageTags.Logo ? (
|
||||||
item.Name
|
item.Name
|
||||||
) : (
|
) : (
|
||||||
<img
|
<motion.img
|
||||||
className="hero-carousel-text-logo"
|
className="hero-carousel-text-logo"
|
||||||
src={
|
src={
|
||||||
window.api.basePath +
|
window.api.basePath +
|
||||||
@@ -156,7 +156,7 @@ const CarouselSlide = ({ item }) => {
|
|||||||
onLoad={(e) =>
|
onLoad={(e) =>
|
||||||
(e.target.style.opacity = 1)
|
(e.target.style.opacity = 1)
|
||||||
}
|
}
|
||||||
></img>
|
/>
|
||||||
)}
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Stack
|
<Stack
|
||||||
|
|||||||
@@ -44,15 +44,20 @@ export const LatestMediaSection = ({ latestMediaLib }) => {
|
|||||||
>
|
>
|
||||||
{data.data.map((item, index) => {
|
{data.data.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
<></>
|
<Card
|
||||||
// <Card
|
key={index}
|
||||||
// key={index}
|
itemName={item.Name}
|
||||||
// itemName={
|
itemId={item.Id}
|
||||||
// !!item.SeriesId
|
itemType={item.Type}
|
||||||
// ? item.SeriesName
|
imageType="Primary"
|
||||||
// : item.Name
|
cardType={
|
||||||
// }
|
item.Type == BaseItemKind.MusicAlbum ||
|
||||||
// ></Card>
|
item.Type == BaseItemKind.Audio
|
||||||
|
? "square"
|
||||||
|
: "portrait"
|
||||||
|
}
|
||||||
|
secondaryText={item.ProductionYear}
|
||||||
|
></Card>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
|
|||||||
@@ -108,4 +108,5 @@ export const TypeIconCollectionCard = {
|
|||||||
Video: <MdiFilmstrip className="card-image-icon" />,
|
Video: <MdiFilmstrip className="card-image-icon" />,
|
||||||
Year: <MdiMultimedia className="card-image-icon" />,
|
Year: <MdiMultimedia className="card-image-icon" />,
|
||||||
Genre: <MdiDramaMasks className="card-image-icon" />,
|
Genre: <MdiDramaMasks className="card-image-icon" />,
|
||||||
|
Library: <MdiMultimedia className="card-image-icon" />,
|
||||||
};
|
};
|
||||||
+26
-57
@@ -38,7 +38,7 @@ import { useNavigate } from "react-router-dom";
|
|||||||
import { useBackdropStore } from "../../utils/store/backdrop";
|
import { useBackdropStore } from "../../utils/store/backdrop";
|
||||||
|
|
||||||
import CarouselSlide from "../../components/carouselSlide";
|
import CarouselSlide from "../../components/carouselSlide";
|
||||||
import { ItemFields } from "@jellyfin/sdk/lib/generated-client";
|
import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client";
|
||||||
const Home = () => {
|
const Home = () => {
|
||||||
const authUser = useQuery({
|
const authUser = useQuery({
|
||||||
queryKey: ["home", "authenticateUser"],
|
queryKey: ["home", "authenticateUser"],
|
||||||
@@ -100,8 +100,8 @@ const Home = () => {
|
|||||||
fields: [
|
fields: [
|
||||||
ItemFields.Overview,
|
ItemFields.Overview,
|
||||||
ItemFields.ParentId,
|
ItemFields.ParentId,
|
||||||
|
"ParentIndexNumber",
|
||||||
ItemFields.SeasonUserData,
|
ItemFields.SeasonUserData,
|
||||||
ItemFields.RecursiveItemCount,
|
|
||||||
ItemFields.IsHd,
|
ItemFields.IsHd,
|
||||||
],
|
],
|
||||||
enableUserData: true,
|
enableUserData: true,
|
||||||
@@ -254,9 +254,9 @@ const Home = () => {
|
|||||||
key={index}
|
key={index}
|
||||||
itemName={item.Name}
|
itemName={item.Name}
|
||||||
itemId={item.Id}
|
itemId={item.Id}
|
||||||
imageAspectRatio={
|
itemType="Library"
|
||||||
item.PrimaryImageAspectRatio
|
imageType="Primary"
|
||||||
}
|
cardType="thumb"
|
||||||
></Card>
|
></Card>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -277,10 +277,9 @@ const Home = () => {
|
|||||||
key={index}
|
key={index}
|
||||||
itemName={item.Name}
|
itemName={item.Name}
|
||||||
itemId={item.Id}
|
itemId={item.Id}
|
||||||
|
itemType={item.Type}
|
||||||
imageType="Primary"
|
imageType="Primary"
|
||||||
imageAspectRatio={
|
cardType="thumb"
|
||||||
item.PrimaryImageAspectRatio
|
|
||||||
}
|
|
||||||
></Card>
|
></Card>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -303,14 +302,20 @@ const Home = () => {
|
|||||||
key={index}
|
key={index}
|
||||||
itemName={item.Name}
|
itemName={item.Name}
|
||||||
itemId={item.Id}
|
itemId={item.Id}
|
||||||
|
itemType={item.Type}
|
||||||
imageType={
|
imageType={
|
||||||
!!item.SeriesName
|
item.Type ==
|
||||||
|
BaseItemKind.Episode
|
||||||
? "Primary"
|
? "Primary"
|
||||||
: "Backdrop"
|
: "Backdrop"
|
||||||
}
|
}
|
||||||
imageAspectRatio={
|
secondaryText={
|
||||||
item.PrimaryImageAspectRatio
|
item.Type ==
|
||||||
|
BaseItemKind.Episode
|
||||||
|
? `S${item.ParentIndexNumber}:E${item.IndexNumber} ${item.SeriesName}`
|
||||||
|
: item.ProductionYear
|
||||||
}
|
}
|
||||||
|
cardType="thumb"
|
||||||
></Card>
|
></Card>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -331,55 +336,19 @@ const Home = () => {
|
|||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
key={index}
|
key={index}
|
||||||
itemName={
|
itemName={item.Name}
|
||||||
!!item.SeriesId
|
itemId={item.Id}
|
||||||
? item.SeriesName
|
itemType={item.Type}
|
||||||
: item.Name
|
imageType={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Episode
|
||||||
|
? "Primary"
|
||||||
|
: "Backdrop"
|
||||||
}
|
}
|
||||||
itemId={
|
secondaryText={
|
||||||
!!item.SeriesId
|
|
||||||
? item.SeriesId
|
|
||||||
: item.Id
|
|
||||||
}
|
|
||||||
// imageTags={false}
|
|
||||||
imageTags={
|
|
||||||
!!item.ImageTags
|
|
||||||
.Primary
|
|
||||||
}
|
|
||||||
iconType={item.Type}
|
|
||||||
subText={
|
|
||||||
item.ProductionYear
|
item.ProductionYear
|
||||||
}
|
}
|
||||||
playedPercent={
|
cardType="thumb"
|
||||||
item.UserData
|
|
||||||
.PlayedPercentage
|
|
||||||
}
|
|
||||||
cardOrientation="sqaure"
|
|
||||||
blurhash={
|
|
||||||
item.ImageBlurHashes ==
|
|
||||||
{}
|
|
||||||
? ""
|
|
||||||
: !!item
|
|
||||||
.ImageTags
|
|
||||||
.Primary
|
|
||||||
? !!item
|
|
||||||
.ImageBlurHashes
|
|
||||||
.Primary
|
|
||||||
? item
|
|
||||||
.ImageBlurHashes
|
|
||||||
.Primary[
|
|
||||||
item
|
|
||||||
.ImageTags
|
|
||||||
.Primary
|
|
||||||
]
|
|
||||||
: ""
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
currentUser={user.data}
|
|
||||||
favourite={
|
|
||||||
item.UserData
|
|
||||||
.IsFavorite
|
|
||||||
}
|
|
||||||
></Card>
|
></Card>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -942,11 +942,11 @@ const LibraryView = () => {
|
|||||||
md={1}
|
md={1}
|
||||||
component={motion.div}
|
component={motion.div}
|
||||||
initial={{
|
initial={{
|
||||||
scale: 0.8,
|
transform: "scale(0.8)",
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
}}
|
}}
|
||||||
animate={{
|
animate={{
|
||||||
scale: 1,
|
transform: "scale(1)",
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
}}
|
}}
|
||||||
transition={{
|
transition={{
|
||||||
@@ -956,68 +956,17 @@ const LibraryView = () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Card
|
<Card
|
||||||
|
key={index}
|
||||||
itemName={item.Name}
|
itemName={item.Name}
|
||||||
itemId={item.Id}
|
itemId={item.Id}
|
||||||
imageTags={
|
imageType="Primary"
|
||||||
!!item.ImageTags.Primary
|
cardType={
|
||||||
}
|
|
||||||
subText={
|
|
||||||
item.Type.includes(
|
|
||||||
"Music",
|
|
||||||
)
|
|
||||||
? item.AlbumArtist
|
|
||||||
: item.ProductionYear
|
|
||||||
}
|
|
||||||
iconType={item.Type}
|
|
||||||
playedPercent={
|
|
||||||
!!item.UserData
|
|
||||||
? item.UserData
|
|
||||||
.PlayedPercentage
|
|
||||||
: 0
|
|
||||||
}
|
|
||||||
cardOrientation={
|
|
||||||
item.Type ==
|
item.Type ==
|
||||||
"MusicArtist" ||
|
BaseItemKind.MusicAlbum ||
|
||||||
item.Type ==
|
item.Type ==
|
||||||
"MusicAlbum" ||
|
BaseItemKind.Audio
|
||||||
item.Type ==
|
|
||||||
"MusicGenre" ||
|
|
||||||
item.Type == "Playlist"
|
|
||||||
? "square"
|
? "square"
|
||||||
: "portait"
|
: "portrait"
|
||||||
}
|
|
||||||
watchedStatus={
|
|
||||||
!!item.UserData
|
|
||||||
? item.UserData
|
|
||||||
.Played
|
|
||||||
: false
|
|
||||||
}
|
|
||||||
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>
|
||||||
</Grid2>
|
</Grid2>
|
||||||
@@ -1046,11 +995,13 @@ const LibraryView = () => {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
initial={{
|
initial={{
|
||||||
scale: 0.8,
|
transform:
|
||||||
|
"scale(0.8)",
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
}}
|
}}
|
||||||
animate={{
|
animate={{
|
||||||
scale: 1,
|
transform:
|
||||||
|
"scale(1)",
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
}}
|
}}
|
||||||
transition={{
|
transition={{
|
||||||
|
|||||||
Reference in new issue
Block a user