Skip to content

Commit 6f909c2

Browse files
author
Oleksandr Ratushnyi
committed
Enhance Collage component with masonry layout support and update styles for full-size images
1 parent c5fe5b6 commit 6f909c2

File tree

5 files changed

+63
-7
lines changed

5 files changed

+63
-7
lines changed

.claude/settings.local.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"permissions": {
33
"allow": [
4-
"Bash(ls:*)"
4+
"Bash(ls:*)",
5+
"Bash(npm run build:*)"
56
]
67
}
78
}

src/app/globals.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@ a, button {
114114
}
115115

116116
/* full size image */
117+
.medium-zoom-overlay {
118+
width: 100vw !important;
119+
height: 100vh !important;
120+
}
117121
.medium-zoom-image--opened {
122+
top: 10vh;
123+
left: 10vw;
118124
cursor: zoom-out;
119125
object-fit: contain !important;
120126
height: 90vh !important;

src/app/page.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ import photo1 from "../images/a00008.jpg";
6363
import photo7 from "../images/IMG_2349.jpeg";
6464
import photo9 from "../images/IMG_3055.jpeg";
6565
import photo10 from "../images/IMG_3058.jpeg";
66+
import catPhoto1 from "../images/37FABF81-6070-4FE3-9EF1-443B478C9C20_1_105_c.jpeg";
67+
import catPhoto2 from "../images/8102D5E0-2690-40AC-8887-08BC2D26BE9A_1_105_c.jpeg";
68+
import catPhoto3 from "../images/A6CD5315-D301-48C5-940E-4C535D1E53DB_1_105_c.jpeg";
69+
import catPhoto4 from "../images/B252D2F4-CF7F-4F45-A3ED-F5AF00F39049_1_105_c.jpeg";
6670
import beetroot from "../images/beetroot.png";
6771
import cert1 from "../images/c1.png";
6872
import cert3 from "../images/c3.png";
@@ -304,9 +308,13 @@ export default function Home() {
304308
<Collage className={styles['mb-0']}>
305309
<Photo src={photo9} paddingHack={170} vertical grid caption="Whole squad" />
306310
<Photo src={photo10} paddingHack={170} vertical grid caption="Lapsi and Luna" />
307-
<Photo src={photo5} paddingHack={85} offset={{y: -20}} grid caption="Platon and Luna" />
308-
<Photo src={photo7} grid caption="Lapsi" />
309-
<Photo src={photo6} paddingHack={100} offset={{y: -34}} grid caption="Lastick & Platon" />
311+
<Photo src={photo7} grid caption="Lapsi" />
312+
<Photo src={photo6} paddingHack={100} grid caption="Lastick & Platon" />
313+
<Photo src={catPhoto1} paddingHack={170} grid caption="Lapsi, Platon and Misty" />
314+
<Photo src={catPhoto2} paddingHack={80} grid caption="Platon and Misty" />
315+
<Photo src={photo5} paddingHack={85} grid caption="Platon and Luna" />
316+
<Photo src={catPhoto3} paddingHack={100} grid caption="Me and Lapsi found mushroom" />
317+
<Photo src={catPhoto4} paddingHack={100} grid caption="Platon and Lapsi" />
310318
</Collage>
311319
</section>
312320
<section id="my-work">

src/components/Collage/Collage.module.css

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,37 @@
137137
.row > * {
138138
max-width: initial;
139139
}
140+
}
141+
142+
/* Masonry layout for 6-20 images */
143+
.masonry {
144+
display: block;
145+
column-gap: 1.5rem;
146+
columns: 2;
147+
}
148+
149+
.masonry > * {
150+
break-inside: avoid;
151+
margin-bottom: 1.5rem;
152+
display: block;
153+
}
154+
155+
/* Responsive columns based on image count */
156+
@media screen and (min-width: 768px) {
157+
.masonry {
158+
columns: 3;
159+
}
160+
}
161+
162+
@media screen and (min-width: 1024px) {
163+
.masonry {
164+
columns: 4;
165+
}
166+
}
167+
168+
/* Adjust columns for larger collections */
169+
@media screen and (min-width: 1280px) {
170+
.masonry {
171+
columns: 4;
172+
}
140173
}

src/components/Collage/Collage.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ interface ICollageProps {
88
mirror?: boolean;
99
variant?: number;
1010
row?: boolean;
11+
masonry?: boolean;
1112
}
1213

1314
export const Collage = function Collage({
@@ -16,18 +17,25 @@ export const Collage = function Collage({
1617
mirror,
1718
variant = 1,
1819
row,
20+
masonry,
1921
}: ICollageProps) {
2022
const size = React.Children.count(children);
23+
const useMasonry = masonry || size > 5;
2124

2225
return (
2326
<div
2427
className={clsx(
2528
styles.collage,
26-
styles[`variant-${variant}`],
27-
styles[`s-${size}`],
28-
{ [styles.mirror]: mirror, [styles.row]: row },
29+
!useMasonry && styles[`variant-${variant}`],
30+
!useMasonry && styles[`s-${size}`],
31+
{
32+
[styles.mirror]: mirror,
33+
[styles.row]: row && !useMasonry,
34+
[styles.masonry]: useMasonry,
35+
},
2936
className
3037
)}
38+
style={useMasonry ? { "--masonry-count": Math.min(size, 20) } as React.CSSProperties : undefined}
3139
>
3240
{children}
3341
</div>

0 commit comments

Comments
 (0)