-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add axios dependency and home image grid component
- Loading branch information
Showing
19 changed files
with
189 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters