diff --git a/README.md b/README.md index 5d92520..f9dfc26 100644 --- a/README.md +++ b/README.md @@ -30,4 +30,5 @@ | 22 | Suleiman | [Profile](profiles/suleiman-2023.md) | | 23 | Chris Achinga | [Profile](profiles/chris-achinga-2021.md) | | 24 | Patrick Mwangi | [Profile](profiles/patrick-mwangi.md) | -| 25 | Nickson Simiyu | [Profile](profiles/Nickson-Simiyu_2024.md) | \ No newline at end of file +| 25 | Nickson Simiyu | [Profile](profiles/Nickson-Simiyu_2024.md) | +| 26 | Milka Warigia | [Profile](profiles/milka-2024.md) | diff --git a/app/Gallery/page.tsx b/app/Gallery/page.tsx index 7d47810..91dbecc 100644 --- a/app/Gallery/page.tsx +++ b/app/Gallery/page.tsx @@ -1,26 +1,94 @@ -import React from "react"; +"use client"; +import React, { useState, useEffect } from "react"; import Link from "next/link"; -const images = [ +// Define a type for gallery images +interface Image { + src: string; + description: string; +} + +// Initial gallery images +const initialImages: Image[] = [ { src: "/gallery/team-event.jpg", description: "Team event at Swahilipot Hub during ICP hackathon. This event brought together participants from various backgrounds to collaborate and innovate." }, { src: "/gallery/tech-kids.jpeg", description: "Kids from highschool showcasing their projects" }, { src: "/gallery/tabiya-hackathon.JPG", description: "Coding session during Hackathon where developers shared ideas and solved problems together." }, - // Add more images with descriptions here ]; +// UploadButton component for adding new images +interface UploadButtonProps { + onUpload: (files: File[]) => void; +} + +const UploadButton: React.FC = ({ onUpload }) => { + const handleFileChange = (event: React.ChangeEvent) => { + const files = event.target.files; + if (files) { + const fileArray = Array.from(files); + onUpload(fileArray); // Pass files to parent component + } + }; + + return ( +
+ +
+ ); +}; + +// Main Gallery component export default function Gallery() { + const [images, setImages] = useState(() => { + // Load images from local storage or use initial images + const storedImages = localStorage.getItem("galleryImages"); + return storedImages ? JSON.parse(storedImages) : initialImages; + }); + + // Save images to local storage whenever the images state changes + useEffect(() => { + localStorage.setItem("galleryImages", JSON.stringify(images)); + }, [images]); + + const handleUpload = (files: File[]) => { + // Create URLs for each uploaded image and add them to the gallery with a custom caption + const newImages = files.map((file): Image => { + const src = URL.createObjectURL(file); + const description = prompt("Enter a caption for this image:") || "No caption provided"; + return { src, description }; + }); + setImages((prevImages: Image[]) => [...prevImages, ...newImages]); + }; + return (
{/* Back to Home Link */} ← Back to Home

SPH Gallery

- {images.map(({ src, description }, index) => ( -
{/* Medium sized box */} - {description} {/* Image width */} -
{/* Description container */} -

{description}

- {/* Caption removed */} -
+ + {/* Upload Button */} + + + {/* Display images */} + {images.map(({ src, description }: Image, index: number) => ( +
+ {description} +

{description}

))}
diff --git a/app/data/contributors.ts b/app/data/contributors.ts index bc5794b..71a1e9c 100644 --- a/app/data/contributors.ts +++ b/app/data/contributors.ts @@ -18,5 +18,10 @@ export const contributors = [ { "name": "Patrick Mwangi", "github": "frashid17" + }, + { + "name": "Milka Warigia", + "github": "MilkaWarigia" } + ] \ No newline at end of file diff --git a/app/page.tsx b/app/page.tsx index cef9a0f..8dbb41f 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -29,4 +29,4 @@ export default function Home() { ); -} +} \ No newline at end of file diff --git a/profiles/milka-2024.md b/profiles/milka-2024.md new file mode 100644 index 0000000..3cd8f14 --- /dev/null +++ b/profiles/milka-2024.md @@ -0,0 +1,9 @@ +# Milka Warigia + +## GitHub Username +[MilkaWarigia](https://github.com/MilkaWarigia) + +## Favorite Programming Languages + +- Python +- JavaScript \ No newline at end of file