From 27e4aa5a653b4cd6a555e345c06a753e808ab9b6 Mon Sep 17 00:00:00 2001 From: Krishnakant Sahu Date: Sun, 13 Jul 2025 22:33:01 +0530 Subject: [PATCH 1/5] feat: created the gallery section --- src/components/playground/GalarySection.jsx | 46 +++++++++++++++++++++ src/components/shared/TertiaryButton.jsx | 9 ++++ src/config/galary.js | 34 +++++++++++++++ src/main.jsx | 2 + 4 files changed, 91 insertions(+) create mode 100644 src/components/playground/GalarySection.jsx create mode 100644 src/components/shared/TertiaryButton.jsx create mode 100644 src/config/galary.js diff --git a/src/components/playground/GalarySection.jsx b/src/components/playground/GalarySection.jsx new file mode 100644 index 0000000..5aaa6bf --- /dev/null +++ b/src/components/playground/GalarySection.jsx @@ -0,0 +1,46 @@ +import TButton from "../shared/TertiaryButton"; +import images from "../../config/galary"; + +export default function GalarySection() { + const getRandomImages = () => { + const shuffled = [...images].sort(() => 0.5 - Math.random()); + return shuffled; + }; + + const randomImages = getRandomImages(); + + return ( +
+ {/* Header Section */} +
+

Image Gallery

+

+ Explore our vibrant moments captured in stunning visuals. +

+ Go to Gallery > +
+ + {/* Gallery Grid */} +
+ {randomImages.map((image) => ( +
+
+ {image.alt} { + e.target.style.display = "block"; + }} + /> +
+
+ ))} +
+
+ ); +} diff --git a/src/components/shared/TertiaryButton.jsx b/src/components/shared/TertiaryButton.jsx new file mode 100644 index 0000000..645b9aa --- /dev/null +++ b/src/components/shared/TertiaryButton.jsx @@ -0,0 +1,9 @@ +const TButton = ({ children }) => { + return ( +
+ {children} +
+ ); +}; + +export default TButton; diff --git a/src/config/galary.js b/src/config/galary.js new file mode 100644 index 0000000..58f006e --- /dev/null +++ b/src/config/galary.js @@ -0,0 +1,34 @@ +const images = [ + { + id: 1, + src: "https://res.cloudinary.com/dsjxx976j/image/upload/v1752424604/image-2_yjyxwo.png", + alt: "Gallery Image 1", + }, + { + id: 2, + src: "https://res.cloudinary.com/dsjxx976j/image/upload/v1752424605/image_r6mlez.png", + alt: "Gallery Image 2", + }, + { + id: 3, + src: "https://res.cloudinary.com/dsjxx976j/image/upload/v1752424604/image-3_yezplq.png", + alt: "Gallery Image 3", + }, + { + id: 4, + src: "https://res.cloudinary.com/dsjxx976j/image/upload/v1752424604/image-4_lwzmbl.png", + alt: "Gallery Image 4", + }, + { + id: 5, + src: "https://res.cloudinary.com/dsjxx976j/image/upload/v1752424604/image-1_ruw6yy.png", + alt: "Gallery Image 5", + }, + { + id: 6, + src: "https://res.cloudinary.com/dsjxx976j/image/upload/v1752425766/e8d1afdb4d097b5c14935394e296d28109b650e4_fominv.png", + alt: "Gallery Image 6", + }, +]; + +export default images; diff --git a/src/main.jsx b/src/main.jsx index 2a0bd58..7e2ea6f 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -6,6 +6,7 @@ import App from "./App.jsx"; import Playground from "./Playground.jsx"; import Test from "./components/playground/Test.jsx"; import Home from "./pages/playground/landing-page/Home.jsx"; +import GalarySection from "./components/playground/GalarySection.jsx"; createRoot(document.getElementById("root")).render( @@ -15,6 +16,7 @@ createRoot(document.getElementById("root")).render( }> } /> } /> + } /> From f6ef8f13c8f6e1014116a9b07574a2efaf48a04d Mon Sep 17 00:00:00 2001 From: Krishnakant Sahu Date: Sun, 13 Jul 2025 22:46:05 +0530 Subject: [PATCH 2/5] feat: implemented masonary layout --- src/components/playground/GalarySection.jsx | 23 ++++++++------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/components/playground/GalarySection.jsx b/src/components/playground/GalarySection.jsx index 5aaa6bf..5cc1fac 100644 --- a/src/components/playground/GalarySection.jsx +++ b/src/components/playground/GalarySection.jsx @@ -4,7 +4,7 @@ import images from "../../config/galary"; export default function GalarySection() { const getRandomImages = () => { const shuffled = [...images].sort(() => 0.5 - Math.random()); - return shuffled; + return shuffled.slice(0, 5); }; const randomImages = getRandomImages(); @@ -21,23 +21,18 @@ export default function GalarySection() { {/* Gallery Grid */} -
+
{randomImages.map((image) => (
-
- {image.alt} { - e.target.style.display = "block"; - }} - /> -
+ {image.alt}
))}
From 182eedd62a391c60ff1230b20b4dcecec30d8c33 Mon Sep 17 00:00:00 2001 From: Krishnakant Sahu Date: Mon, 14 Jul 2025 00:00:39 +0530 Subject: [PATCH 3/5] feat: partially done Gallary page --- src/config/galary.js | 6 +++ src/config/galaryPage.js | 16 ++++++ src/main.jsx | 2 + src/pages/gallary/Gallary.jsx | 92 +++++++++++++++++++++++++++++++++++ 4 files changed, 116 insertions(+) create mode 100644 src/config/galaryPage.js create mode 100644 src/pages/gallary/Gallary.jsx diff --git a/src/config/galary.js b/src/config/galary.js index 58f006e..11e7e98 100644 --- a/src/config/galary.js +++ b/src/config/galary.js @@ -3,31 +3,37 @@ const images = [ id: 1, src: "https://res.cloudinary.com/dsjxx976j/image/upload/v1752424604/image-2_yjyxwo.png", alt: "Gallery Image 1", + year: 2025, }, { id: 2, src: "https://res.cloudinary.com/dsjxx976j/image/upload/v1752424605/image_r6mlez.png", alt: "Gallery Image 2", + year: 2025, }, { id: 3, src: "https://res.cloudinary.com/dsjxx976j/image/upload/v1752424604/image-3_yezplq.png", alt: "Gallery Image 3", + year: 2025, }, { id: 4, src: "https://res.cloudinary.com/dsjxx976j/image/upload/v1752424604/image-4_lwzmbl.png", alt: "Gallery Image 4", + year: 2024, }, { id: 5, src: "https://res.cloudinary.com/dsjxx976j/image/upload/v1752424604/image-1_ruw6yy.png", alt: "Gallery Image 5", + year: 2024, }, { id: 6, src: "https://res.cloudinary.com/dsjxx976j/image/upload/v1752425766/e8d1afdb4d097b5c14935394e296d28109b650e4_fominv.png", alt: "Gallery Image 6", + year: 2024, }, ]; diff --git a/src/config/galaryPage.js b/src/config/galaryPage.js new file mode 100644 index 0000000..d436111 --- /dev/null +++ b/src/config/galaryPage.js @@ -0,0 +1,16 @@ +const heroImages = [ + { + id: 1, + src: "https://res.cloudinary.com/dsjxx976j/image/upload/v1752424604/image-2_yjyxwo.png", + alt: "Gallery Image 1", + year: 2025, + }, + { + id: 2, + src: "https://res.cloudinary.com/dsjxx976j/image/upload/v1752425766/e8d1afdb4d097b5c14935394e296d28109b650e4_fominv.png", + alt: "Gallery Image 1", + year: 2025, + }, +]; + +export default heroImages; diff --git a/src/main.jsx b/src/main.jsx index 7e2ea6f..3814921 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -7,6 +7,7 @@ import Playground from "./Playground.jsx"; import Test from "./components/playground/Test.jsx"; import Home from "./pages/playground/landing-page/Home.jsx"; import GalarySection from "./components/playground/GalarySection.jsx"; +import GallaryPage from "./pages/gallary/Gallary.jsx"; createRoot(document.getElementById("root")).render( @@ -17,6 +18,7 @@ createRoot(document.getElementById("root")).render( } /> } /> } /> + } /> diff --git a/src/pages/gallary/Gallary.jsx b/src/pages/gallary/Gallary.jsx new file mode 100644 index 0000000..705ed15 --- /dev/null +++ b/src/pages/gallary/Gallary.jsx @@ -0,0 +1,92 @@ +import { useState } from "react"; +import images from "../../config/galary"; + +export default function GallaryPage() { + const [selectedYear, setSelectedYear] = useState("all"); + + const years = ["all", ...new Set(images.map((image) => image.year))].sort(); + + const getFilteredImages = () => { + if (selectedYear === "all") { + return [...images]; + } + return [...images].filter((image) => image.year === Number(selectedYear)); + }; + + const galleryImages = getFilteredImages(); + + return ( +
+ {/* Hero Banner */} +
+ Gallery Hero Banner +
+ + {/* Gallery Content */} +
+ {/* Year Filters and Description Section */} +
+
+
+

+ Gallery +

+
+ {years.map((year) => ( + + ))} +
+
+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Suspendisse varius enim in eros elementum tristique. Duis cursus, + mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam + libero vitae erat. +

+
+
+ + {/* Gallery Grid */} +
+ {galleryImages.map((image) => ( +
+ {image.alt} +
+ ))} +
+ + {/* No Images Message */} + {galleryImages.length === 0 && ( +
+

+ No images found for selected year. +

+
+ )} +
+
+ ); +} From d10fd3e6fd75f90d84cdd63c162efde993d75988 Mon Sep 17 00:00:00 2001 From: Krishnakant Sahu Date: Mon, 14 Jul 2025 00:06:11 +0530 Subject: [PATCH 4/5] feat: added carousel to the Hero banner --- src/pages/gallary/Gallary.jsx | 102 +++++++++++++++++++++++++++++++--- 1 file changed, 95 insertions(+), 7 deletions(-) diff --git a/src/pages/gallary/Gallary.jsx b/src/pages/gallary/Gallary.jsx index 705ed15..4693767 100644 --- a/src/pages/gallary/Gallary.jsx +++ b/src/pages/gallary/Gallary.jsx @@ -1,8 +1,18 @@ -import { useState } from "react"; +import { useState, useEffect } from "react"; import images from "../../config/galary"; +import heroImages from "../../config/galaryPage"; export default function GallaryPage() { const [selectedYear, setSelectedYear] = useState("all"); + const [currentSlide, setCurrentSlide] = useState(0); + + useEffect(() => { + const interval = setInterval(() => { + setCurrentSlide((prev) => (prev + 1) % heroImages.length); + }, 5000); + + return () => clearInterval(interval); + }, []); const years = ["all", ...new Set(images.map((image) => image.year))].sort(); @@ -17,13 +27,91 @@ export default function GallaryPage() { return (
- {/* Hero Banner */} + {/* Hero Banner Carousel */}
- Gallery Hero Banner + {/* Carousel Slides */} +
+ {heroImages.map((image, index) => ( +
+ {image.alt} +
+ ))} + + {/* Carousel Controls */} +
+ {heroImages.map((_, index) => ( +
+ + {/* Next/Prev Buttons (optional) */} + {heroImages.length > 1 && ( + <> + + + + )} +
{/* Gallery Content */} From f98a57e5480ee2b36c6633ff88497c424755c17f Mon Sep 17 00:00:00 2001 From: Krishnakant Sahu Date: Mon, 14 Jul 2025 00:12:13 +0530 Subject: [PATCH 5/5] fix: optimized the code --- src/pages/gallary/Gallary.jsx | 142 +++++++++++++++++----------------- 1 file changed, 70 insertions(+), 72 deletions(-) diff --git a/src/pages/gallary/Gallary.jsx b/src/pages/gallary/Gallary.jsx index 4693767..370e1cf 100644 --- a/src/pages/gallary/Gallary.jsx +++ b/src/pages/gallary/Gallary.jsx @@ -2,6 +2,59 @@ import { useState, useEffect } from "react"; import images from "../../config/galary"; import heroImages from "../../config/galaryPage"; +const NavButton = ({ direction, onClick }) => { + const isNext = direction === "next"; + return ( + + ); +}; + +const YearButton = ({ year, isSelected, onClick }) => ( + +); + +const GalleryItem = ({ image }) => ( +
+ {image.alt} +
+); + export default function GallaryPage() { const [selectedYear, setSelectedYear] = useState("all"); const [currentSlide, setCurrentSlide] = useState(0); @@ -10,20 +63,15 @@ export default function GallaryPage() { const interval = setInterval(() => { setCurrentSlide((prev) => (prev + 1) % heroImages.length); }, 5000); - return () => clearInterval(interval); }, []); const years = ["all", ...new Set(images.map((image) => image.year))].sort(); - const getFilteredImages = () => { - if (selectedYear === "all") { - return [...images]; - } - return [...images].filter((image) => image.year === Number(selectedYear)); - }; - - const galleryImages = getFilteredImages(); + const galleryImages = + selectedYear === "all" + ? images + : images.filter((image) => image.year === Number(selectedYear)); return (
@@ -52,63 +100,29 @@ export default function GallaryPage() {
- {/* Next/Prev Buttons (optional) */} + {/* Next/Prev Buttons */} {heroImages.length > 1 && ( <> - - + /> )}
@@ -125,18 +139,12 @@ export default function GallaryPage() {
{years.map((year) => ( - + /> ))}
@@ -152,17 +160,7 @@ export default function GallaryPage() { {/* Gallery Grid */}
{galleryImages.map((image) => ( -
- {image.alt} -
+ ))}