Skip to content

Commit

Permalink
Add axios dependency and home image grid component
Browse files Browse the repository at this point in the history
  • Loading branch information
pranshu05 committed Feb 18, 2024
1 parent da768fc commit 798e50c
Show file tree
Hide file tree
Showing 19 changed files with 189 additions and 17 deletions.
91 changes: 91 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"dependencies": {
"@types/firebase": "^3.2.1",
"@types/next-auth": "^3.15.0",
"axios": "^1.6.7",
"firebase": "^10.8.0",
"gray-matter": "^4.0.3",
"next": "14.1.0",
Expand Down
Binary file removed public/favicon.ico
Binary file not shown.
Binary file added public/home-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/home-2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/home-3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/home-4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/home-5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/home-6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/home-7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion public/next.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/vercel.svg

This file was deleted.

2 changes: 0 additions & 2 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

const Footer: React.FC = () => {
return (
<footer className="flex flex-col font-medium w-11/12 md:w-4/5 lg:w-3/4 xl:w-2/3 2xl:w-1/2 mx-auto my-4">
Expand Down
26 changes: 26 additions & 0 deletions src/components/HomeImageGrid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* eslint-disable @next/next/no-img-element */
import React from 'react';

const images = [
'/home-1.jpg',
'/home-2.jpg',
'/home-3.jpg',
'/home-4.jpg',
'/home-5.jpg',
'/home-6.jpg',
'/home-7.jpg',
];

const HomeImageGrid: React.FC = () => {
return (
<div className="columns-2 md:columns-3 my-2 gap-2 md:gap-4">
{images.map((src, index) => (
<div key={index} className="mb-2 md:mb-4">
<img className="h-auto max-w-full rounded-lg grayscale transition-all duration-300 ease-in-out transform hover:grayscale-0" src={src} alt="" />
</div>
))}
</div>
);
};

export default HomeImageGrid;
42 changes: 42 additions & 0 deletions src/components/ImageGallery.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* eslint-disable @next/next/no-img-element */
import { useState, useEffect } from 'react';
import axios from 'axios';

interface Image {
urls: { regular: string; };
}

const ImageGallery: React.FC = () => {
const [imageData, setImageData] = useState<Image[]>([]);

const fetchImagesFromUnsplash = async () => {
try {
const response = await axios.get('https://api.unsplash.com/users/pranshu05/photos', {
params: {
client_id: 'IpuBMtdoSBFo8bS7L1gevS7rRFBdEDN9Wp7du9QFh1A',
per_page: 30,
},
});

setImageData(response.data);
} catch (error) {
console.error('Error fetching images:', error);
}
};

useEffect(() => {
fetchImagesFromUnsplash();
}, []);

return (
<div className="columns-2 md:columns-3 gap:2 md:gap-4">
{imageData.map((image, index) => (
<div className="mb-2 md:mb-4" key={index}>
<img className='h-auto max-w-full rounded-lg grayscale transition-all duration-300 ease-in-out transform hover:grayscale-0' src={image.urls.regular} alt="" loading="lazy" />
</div>
))}
</div>
);
};

export default ImageGallery;
2 changes: 0 additions & 2 deletions src/components/MessageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const MessageList: React.FC = () => {
const data = doc.data();
return { id: doc.id, ...data, timestamp: data.timestamp.toDate(), };
}) as Message[];

setMessages(newMessages);
setLoading(false);
setError(null);
Expand All @@ -36,7 +35,6 @@ const MessageList: React.FC = () => {
setError('Error fetching messages. Please try again.');
}
});

return () => unsubscribe();
}, []);

Expand Down
17 changes: 6 additions & 11 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@ import Footer from "@/components/Footer";

export default function App({ Component, pageProps }: AppProps) {
return (
<>
<div className="min-h-dvh w-dvw p-0 m-0 text-zinc-100 flex flex-col">
<NavBar />
<div className="flex-1">
<Component {...pageProps} />
</div>
<Footer />
<div className="min-h-dvh w-dvw p-0 m-0 bg-neutral-950 text-zinc-100 flex flex-col">
<NavBar />
<div className="flex-1">
<Component {...pageProps} />
</div>
<div className="fixed left-0 top-0 -z-10 h-dvh w-dvw">
<div className="absolute top-0 left-0 z-[-2] h-screen w-screen bg-neutral-950 bg-[radial-gradient(100%_50%_at_50%_0%,rgba(0,163,255,0.2)_0,rgba(0,163,255,0.12)_50%,rgba(0,163,255,0)_100%)]"></div>
</div>
</>
<Footer />
</div>
);
}
21 changes: 21 additions & 0 deletions src/pages/gallery/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Metadata } from 'next';
import ImageGallery from '../../components/ImageGallery';

export const metadata: Metadata = {
title: 'Pranshu05 // Gallary',
description: 'My Gallary, feel free to explore!',
};

const ImageGalleryPage: React.FC = () => {
return (
<div className="w-11/12 md:w-4/5 lg:w-3/4 xl:w-2/3 2xl:w-1/2 mx-auto">
<div className="pb-8">
<h1 className="text-3xl font-bold">Gallary</h1>
<p>Welcome to my Gallary! Visit my <a href='https://unsplash.com/@pranshu05' target="_blank" className='link'>Unsplash Profile</a></p>
</div>
<ImageGallery />
</div>
);
};

export default ImageGalleryPage;
2 changes: 2 additions & 0 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { Metadata } from "next";
import { ageInYears } from '@/lib/AgeInYears';
import { useEffect, useState } from 'react';
import { getFormattedTime } from '@/lib/Time';
import HomeImageGrid from '@/components/HomeImageGrid';

const socialLinks = [
{ href: 'https://github.com/pranshu05', icon: <FaGithub />, text: 'GitHub' },
Expand Down Expand Up @@ -50,6 +51,7 @@ const Home: React.FC = () => {
</div>
))}
</div>
<HomeImageGrid />
</div>
);
};
Expand Down

0 comments on commit 798e50c

Please sign in to comment.