✨ feat: add responsive masonry layout for projects display
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import Masonry, { ResponsiveMasonry } from "react-responsive-masonry";
|
||||||
|
|
||||||
interface Project {
|
interface Project {
|
||||||
slug: string;
|
slug: string;
|
||||||
@@ -47,41 +48,41 @@ export default function Projects() {
|
|||||||
fetchProjects();
|
fetchProjects();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const numberOfProjects = projects.length;
|
|
||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
id="projects"
|
id="projects"
|
||||||
className={`p-10 ${isVisible ? "animate-fly-in" : "opacity-0"}`}
|
className={`p-10 ${isVisible ? "animate-fly-in" : "opacity-0"}`}
|
||||||
>
|
>
|
||||||
<h2 className="text-3xl font-bold text-center text-gray-800">Projects</h2>
|
<h2 className="text-3xl font-bold text-center text-gray-800">Projects</h2>
|
||||||
<div className="mt-6 grid grid-cols-1 md:grid-cols-2 gap-6">
|
<div className="mt-6">
|
||||||
{projects.map((project, index) => (
|
<ResponsiveMasonry
|
||||||
<Link
|
columnsCountBreakPoints={{350: 1, 750: 2, 900: 3}}
|
||||||
key={project.id}
|
gutterBreakpoints={{350: "12px", 750: "16px", 900: "24px"}} >
|
||||||
href={{
|
<Masonry >
|
||||||
pathname: `/projects/${project.slug}`,
|
{projects.map((project, index) => (
|
||||||
query: { project: JSON.stringify(project) },
|
<Link
|
||||||
}}
|
key={project.id}
|
||||||
className="cursor-pointer"
|
href={{
|
||||||
>
|
pathname: `/projects/${project.slug}`,
|
||||||
<div
|
query: { project: JSON.stringify(project) },
|
||||||
className={`p-4 border shadow-lg bg-white/45 rounded-2xl animate-fly-in`}
|
}}
|
||||||
style={{ animationDelay: `${index * 0.1}s` }}
|
className="cursor-pointer w-full"
|
||||||
>
|
>
|
||||||
<h3 className="text-2xl font-bold text-gray-800">
|
<div
|
||||||
{project.title}
|
className="project-card"
|
||||||
</h3>
|
style={{ animationDelay: `${index * 0.1}s` }}
|
||||||
<p className="mt-2 text-gray-500">{project.meta_description}</p>
|
>
|
||||||
</div>
|
<h3 className="text-2xl font-bold text-gray-800">
|
||||||
</Link>
|
{project.title}
|
||||||
))}
|
</h3>
|
||||||
<div
|
<p className="mt-2 text-gray-500">
|
||||||
className={`p-4 border shadow-lg bg-white/45 rounded-2xl animate-fly-in`}
|
{project.meta_description}
|
||||||
style={{ animationDelay: `${(numberOfProjects + 1) * 0.1}s` }}
|
</p>
|
||||||
>
|
</div>
|
||||||
<h3 className="text-2xl font-bold text-gray-800">More to come</h3>
|
</Link>
|
||||||
<p className="mt-2 text-gray-500">...</p>
|
))}
|
||||||
</div>
|
</Masonry>
|
||||||
|
</ResponsiveMasonry>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -197,3 +197,20 @@ body {
|
|||||||
.animate-fade-out {
|
.animate-fade-out {
|
||||||
animation: fadeOut 3s forwards;
|
animation: fadeOut 3s forwards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.project-card {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
background: rgba(255, 255, 255, 0.45);
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 16px;
|
||||||
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||||
|
transition: transform 0.3s ease;
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-card:hover {
|
||||||
|
transform: translateY(-5px);
|
||||||
|
}
|
||||||
|
|||||||
9
package-lock.json
generated
9
package-lock.json
generated
@@ -18,7 +18,8 @@
|
|||||||
"node-fetch": "^3.3.2",
|
"node-fetch": "^3.3.2",
|
||||||
"nodemailer": "^6.10.0",
|
"nodemailer": "^6.10.0",
|
||||||
"react": "^19.0.0",
|
"react": "^19.0.0",
|
||||||
"react-dom": "^19.0.0"
|
"react-dom": "^19.0.0",
|
||||||
|
"react-responsive-masonry": "^2.7.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/eslintrc": "^3",
|
"@eslint/eslintrc": "^3",
|
||||||
@@ -9249,6 +9250,12 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/react-responsive-masonry": {
|
||||||
|
"version": "2.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-responsive-masonry/-/react-responsive-masonry-2.7.1.tgz",
|
||||||
|
"integrity": "sha512-Q+u+nOH87PzjqGFd2PgTcmLpHPZnCmUPREHYoNBc8dwJv6fi51p9U6hqwG8g/T8MN86HrFjrU+uQU6yvETU7cA==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/read-cache": {
|
"node_modules/read-cache": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
"node-fetch": "^3.3.2",
|
"node-fetch": "^3.3.2",
|
||||||
"nodemailer": "^6.10.0",
|
"nodemailer": "^6.10.0",
|
||||||
"react": "^19.0.0",
|
"react": "^19.0.0",
|
||||||
"react-dom": "^19.0.0"
|
"react-dom": "^19.0.0",
|
||||||
|
"react-responsive-masonry": "^2.7.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/eslintrc": "^3",
|
"@eslint/eslintrc": "^3",
|
||||||
|
|||||||
Reference in New Issue
Block a user