Skip to content

Commit

Permalink
Avoid overflow of gallery images (#79)
Browse files Browse the repository at this point in the history
* fix cover images

* fix images cover
  • Loading branch information
mre authored Jun 18, 2024
1 parent e03cb5a commit 4697102
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 17 deletions.
26 changes: 24 additions & 2 deletions components/tools/toolPage/ToolGallery/ToolGallery.module.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
.galleryWrapper {
margin: 30px 0;
position: relative;
width: 100%;
overflow: hidden;
}

.splide__slide {
position: relative;
width: 100%;
height: 100%; /* Ensure the slide has a valid height */
overflow: hidden;
}

.splideSlide {
position: relative;
width: 100%;
height: 0;
padding-bottom: 56.25%; /* 16:9 aspect ratio */
overflow: hidden;
}

.screenshot {
border-radius: 6px;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
31 changes: 16 additions & 15 deletions components/tools/toolPage/ToolGallery/ToolGallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,27 @@ const ToolGallery: FC<ToolGalleryProps> = ({ tool, screenshots }) => {
screenshot.url.includes('youtube.com') ? (
<SplideSlide
key={`${screenshot.path}-${index}`}
// add youtube link if youtube video
data-splide-youtube={screenshot.url}>
<Image
className={styles.screenshot}
width={1280}
height={720}
src={screenshot.path}
alt={`${tool.name} screenshot`}
/>
<div className={styles.splideSlide}>
<Image
className={styles.screenshot}
src={screenshot.path}
alt={`${tool.name} screenshot`}
fill={true}
/>
</div>
</SplideSlide>
) : (
<SplideSlide
key={`${screenshot.path}-${index}`}>
<Image
className={styles.screenshot}
width={1280}
height={720}
src={screenshot.path}
alt={`${tool.name} screenshot`}
/>
<div className={styles.splideSlide}>
<Image
className={styles.screenshot}
src={screenshot.path}
alt={`${tool.name} screenshot`}
fill={true}
/>
</div>
</SplideSlide>
),
)}
Expand Down

0 comments on commit 4697102

Please sign in to comment.