Skip to content

Commit 1e4c03a

Browse files
committed
fix: remove image caption from PortfolioMedia and prevent default behavior on image click in Slider
1 parent dc94d06 commit 1e4c03a

2 files changed

Lines changed: 4 additions & 12 deletions

File tree

src/components/portfolio/PortfolioMedia.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { type PortfolioFrontmatter } from "~/types/frontmatter";
2-
import { useState } from "preact/hooks";
32
import Slider from "~/components/portfolio/Slider/Slider";
43

54
type Props = Pick<
@@ -8,7 +7,6 @@ type Props = Pick<
87
>;
98

109
const PortfolioMedia = ({ images, thumbnail, title, iframe }: Props) => {
11-
const [currentImageIndex, setCurrentImageIndex] = useState(0);
1210
const hasIframe = Boolean(iframe);
1311

1412
return (
@@ -24,11 +22,7 @@ const PortfolioMedia = ({ images, thumbnail, title, iframe }: Props) => {
2422
)}
2523
{!hasIframe && images && (
2624
<>
27-
<Slider
28-
isFullBleed
29-
data-testid="portfolio-media-slider"
30-
onIndexChange={setCurrentImageIndex}
31-
>
25+
<Slider isFullBleed data-testid="portfolio-media-slider">
3226
{images.map((img, i) => {
3327
return (
3428
<div key={i}>
@@ -43,11 +37,6 @@ const PortfolioMedia = ({ images, thumbnail, title, iframe }: Props) => {
4337
);
4438
})}
4539
</Slider>
46-
<div className="bg-surface-container-lowest/60 py-3 px-4 text-center">
47-
<p className="text-sm text-on-surface/70">
48-
{images[currentImageIndex]?.src.split("/").pop() || ""}
49-
</p>
50-
</div>
5140
</>
5241
)}
5342
{hasIframe && thumbnail && (

src/components/portfolio/Slider/Slider.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export default function Slider({
131131
const handleImageClick = (e: MouseEvent) => {
132132
const target = e.target as HTMLImageElement;
133133
if (target.tagName === "IMG") {
134+
e.preventDefault();
134135
setIsDialogOpen(true);
135136
}
136137
};
@@ -269,9 +270,11 @@ export default function Slider({
269270
className:
270271
"max-h-[90vh] max-w-[90vw] object-contain cursor-pointer",
271272
onClick: (e: MouseEvent) => {
273+
e.stopPropagation();
272274
const target = e.target as HTMLImageElement;
273275
if (target.src) {
274276
window.open(target.src, "_blank");
277+
setIsDialogOpen(false);
275278
}
276279
},
277280
})}

0 commit comments

Comments
 (0)