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 useIntersecting from "../../utils/hooks/useIntersecting";
|
||||
|
||||
const cardImageAspectRatios = {
|
||||
thumb: 1.777,
|
||||
portrait: 0.666,
|
||||
square: 1,
|
||||
};
|
||||
|
||||
export const Card = ({
|
||||
itemId,
|
||||
itemParentId,
|
||||
itemType,
|
||||
itemName,
|
||||
imageTags,
|
||||
imageType = "Primary",
|
||||
parentImageType,
|
||||
imageAspectRatio,
|
||||
cardType,
|
||||
secondaryText,
|
||||
}) => {
|
||||
const ref = useRef();
|
||||
const isVisible = useIntersecting(ref);
|
||||
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
|
||||
className={isVisible ? "card isVisible" : "card"}
|
||||
sx={{
|
||||
@@ -61,11 +74,15 @@ export const Card = ({
|
||||
<Box
|
||||
className="card-image-container"
|
||||
sx={{
|
||||
aspectRatio: imageAspectRatio,
|
||||
aspectRatio: cardImageAspectRatios[cardType],
|
||||
overflow: "hidden",
|
||||
height: "auto",
|
||||
width: "100%",
|
||||
}}
|
||||
height="85%"
|
||||
>
|
||||
<Box className="card-image-icon-container">
|
||||
{TypeIconCollectionCard[itemType]}
|
||||
</Box>
|
||||
<img
|
||||
src={window.api.getItemImageUrl(
|
||||
itemId,
|
||||
@@ -78,18 +95,32 @@ export const Card = ({
|
||||
)}
|
||||
style={{
|
||||
height: "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="h5"
|
||||
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 }}
|
||||
>
|
||||
{itemName}
|
||||
{secondaryText}
|
||||
</Typography>
|
||||
</Box>
|
||||
</Stack>
|
||||
|
||||
@@ -4,11 +4,32 @@
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
transition: opacity $transition-time-fast;
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
top: 0;
|
||||
left: 0;
|
||||
&-container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
border-radius: $border-radius-default;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user