Skip to content

Commit cb80b7e

Browse files
author
Oleksandr Ratushnyi
committed
Refactor Photo component styles and layout for improved responsiveness and alignment
1 parent db6dfc4 commit cb80b7e

File tree

8 files changed

+68
-35
lines changed

8 files changed

+68
-35
lines changed

src/app/globals.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ a, button {
116116
/* full size image */
117117
.medium-zoom-image--opened {
118118
cursor: zoom-out;
119+
object-fit: contain !important;
120+
height: 90vh !important;
121+
width: 90vw !important;
119122
}
120123

121124
.white {

src/app/page.module.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
.section {
5757
padding-top: var(--SECTION_OFFSET);
5858
}
59+
.section-- {
60+
padding-top: var(--SECTION_OFFSET);
61+
}
5962

6063
.projectsList {
6164
list-style: none;
@@ -108,3 +111,7 @@
108111
.singleVerticalImage {
109112
max-width: 25%;
110113
}
114+
115+
.mb-0 {
116+
margin-bottom: 0 !important;
117+
}

src/app/page.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ import photo6 from "../images/a00001.jpeg";
5959
import photo2 from "../images/a00002.jpeg";
6060
import photo4 from "../images/a00003.jpeg";
6161
import photo3 from "../images/a00004.jpeg";
62-
import photo5 from "../images/a00006.jpeg";
62+
import photo5 from "../images/IMG_3059.jpeg";
6363
import photo1 from "../images/a00008.jpg";
6464
import photo7 from "../images/IMG_2349.jpeg";
6565
import photo9 from "../images/IMG_3055.jpeg";
66+
import photo10 from "../images/IMG_3058.jpeg";
6667
import beetroot from "../images/beetroot.png";
6768
import cert1 from "../images/c1.png";
6869
import cert3 from "../images/c3.png";
@@ -302,14 +303,15 @@ export default function Home() {
302303
<Paragraph>
303304
At my home, there are three cats 🐈🐈🐈 and one dog 🦮.
304305
</Paragraph>
305-
<Collage row>
306-
<Photo src={photo9} vertical grid caption="Whole squad" />
307-
<Photo src={photo5} vertical grid caption="I'm working with Platon" />
308-
<Photo src={photo6} vertical grid caption="Lastick & Platon" />
309-
<Photo src={photo7} vertical grid caption="Lapsi" />
306+
<Collage className={styles['mb-0']}>
307+
<Photo src={photo9} paddingHack={170} vertical grid caption="Whole squad" />
308+
<Photo src={photo10} paddingHack={170} vertical grid caption="Lapsi and Luna" />
309+
<Photo src={photo5} paddingHack={85} offset={{y: -20}} grid caption="Platon and Luna" />
310+
<Photo src={photo7} grid caption="Lapsi" />
311+
<Photo src={photo6} paddingHack={100} offset={{y: -34}} grid caption="Lastick & Platon" />
310312
</Collage>
311313
</section>
312-
<section id="my-work" className={styles.section}>
314+
<section id="my-work">
313315
<h2 className={styles.heading}>my work 🗂️</h2>
314316
<Paragraph>
315317
I began my journey in web engineering in early 2018. Over the years,

src/components/Collage/Collage.module.css

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,26 +89,33 @@
8989
grid-row: 1 / 4;
9090
}
9191

92-
/* variant 2 is mirror of variant 1 */
93-
.variant-2.s-4 {
94-
grid-template-columns: 1fr 2fr 1fr;
95-
grid-template-rows: 1fr 2fr 1fr;
92+
.s-5 {
93+
grid-template-columns: 1fr 1fr 1fr 1fr;
94+
grid-template-rows: 1fr 1fr;
9695
}
97-
.variant-2.s-4 > *:nth-child(1) {
96+
97+
.s-5 > *:nth-child(1) {
9898
grid-column: 1 / 2;
99-
grid-row: 1 / 4;
99+
grid-row: 1 / 2;
100100
}
101-
.variant-2.s-4 > *:nth-child(2) {
101+
.s-5 > *:nth-child(2) {
102102
grid-column: 2 / 3;
103-
grid-row: 3 / 4;
103+
grid-row: 1 / 2;
104104
}
105-
.variant-2.s-4 > *:nth-child(3) {
106-
grid-column: 3 / 4;
107-
grid-row: 3 / 4;
105+
106+
.s-5 > *:nth-child(3) {
107+
grid-column: 1 / 3;
108+
grid-row: 2 / 3;
108109
}
109-
.variant-2.s-4 > *:nth-child(4) {
110-
grid-column: 2 / 4;
111-
grid-row: 1 / 3;
110+
111+
.s-5 > *:nth-child(4) {
112+
grid-column: 3 / 5;
113+
grid-row: 1 / 2;
114+
}
115+
116+
.s-5 > *:nth-child(5) {
117+
grid-column: 3 / 5;
118+
grid-row: 2 / 3;
112119
}
113120

114121
.row {

src/components/Photo/Photo.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
color: var(--N400);
3232
}
3333

34-
.vertical .image {
34+
.vertical:not(.paddingHack) .image {
3535
height: 100%;
3636
}

src/components/Photo/Photo.tsx

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { StaticImport } from 'next/dist/shared/lib/get-img-props';
2-
import Image from 'next/image';
3-
import styles from './Photo.module.css';
4-
import clsx from 'clsx';
1+
import { StaticImport } from "next/dist/shared/lib/get-img-props";
2+
import Image from "next/image";
3+
import styles from "./Photo.module.css";
4+
import clsx from "clsx";
55

66
export const getAlt = (text: string) => `Oleksandr Ratushnyi ${text}`;
77

@@ -14,8 +14,12 @@ interface IPhotoProps {
1414
test?: boolean;
1515
grid?: boolean;
1616
className?: string;
17-
loading?: 'lazy' | 'eager';
17+
loading?: "lazy" | "eager";
1818
priority?: boolean;
19+
offset?: {
20+
x?: number;
21+
y?: number;
22+
};
1923
}
2024

2125
export const Photo = function Photo({
@@ -27,30 +31,40 @@ export const Photo = function Photo({
2731
test,
2832
grid,
2933
className,
30-
loading = 'lazy',
31-
priority
34+
loading = "lazy",
35+
priority,
36+
offset = {
37+
x: 0,
38+
y: 0,
39+
},
3240
}: IPhotoProps) {
3341
return (
3442
<figure
43+
style={{
44+
transform: `translate(${offset.x || 0}%, ${offset.y || 0}%)`,
45+
}}
3546
className={clsx(
3647
styles.figure,
37-
grid ? '' : styles.single,
38-
vertical ? styles.vertical : '',
39-
className,
48+
grid ? "" : styles.single,
49+
vertical ? styles.vertical : "",
50+
{[styles.paddingHack]: paddingHack},
51+
className
4052
)}
4153
>
4254
<div
4355
className={styles.image}
4456
style={{
45-
paddingBottom: `${vertical ? paddingHack || 100 : paddingHack || 66.7}%`,
46-
backgroundColor: test ? 'red' : 'transparent',
57+
paddingBottom: `${
58+
vertical ? paddingHack || 100 : paddingHack || 66.7
59+
}%`,
60+
backgroundColor: test ? "red" : "transparent",
4761
}}
4862
>
4963
<Image
5064
data-zoomable
5165
src={src}
5266
alt={getAlt(alt || caption)}
53-
style={{ objectFit: 'cover', objectPosition: 'center' }}
67+
style={{ objectFit: "cover", objectPosition: "center" }}
5468
fill
5569
placeholder="blur"
5670
loading={loading}

src/images/IMG_3058.jpeg

170 KB
Loading

src/images/IMG_3059.jpeg

113 KB
Loading

0 commit comments

Comments
 (0)