The Infinite Image Gallery is an interactive React application that allows users to search and explore high-quality images from Unsplash. The app features infinite scrolling, a modal view for image details, and a responsive design.
The project is organized into the following key directories and files:
infinite-scroll-gallery/
├── public/
│ ├── favicon.ico
│ ├── index.html
│ ├── logo192.png
│ ├── logo512.png
│ ├── manifest.json
│ └── robots.txt
├── src/
│ ├── assets/
│ │ ├── styles/
│ │ │ └── styles.scss
│ │ └── screenshots/
│ │ ├── home-page.png
│ │ └── image-modal.png
│ ├── components/
│ │ ├── ImageCard.tsx
│ │ ├── ImageModal.tsx
│ │ ├── SearchBar.tsx
│ │ └── ImageCard.css
│ ├── services/
│ │ └── unsplashService.ts
│ ├── utils/
│ │ └── infiniteScroll.ts
│ ├── types/
│ │ └── interfaces.ts
│ ├── App.css
│ ├── App.tsx
│ ├── index.css
│ ├── index.tsx
│ ├── react-responsive-masonry.d.ts
│ └── logo.svg
├── postcss.config.js
├── tailwind.config.js
- React: JavaScript library for building user interfaces. -
- TypeScript: Superset of JavaScript that adds static types. -
- Axios: HTTP client for making API requests.
- Tailwind CSS: Utility-first CSS framework for styling.
- Unsplash API: Provides high-quality images for the application.
- Custom Hooks: For handling infinite scrolling and other reusable logic.
Using npm:
npm install
Or using yarn:
yarn install
Create a .env
file in the root directory and add your Unsplash API
key. You can obtain your own API key by signing up at Unsplash
Developers:
REACT_APP_UNSPLASH_ACCESS_KEY=your-unsplash-access-key
Using npm:
cd .\infinite-scroll-gallery\
npm start
Or using yarn:
yarn start
This will start the development server and open the application in your default web browser.
To build the application for production:
Using npm:
npm run build
Or using yarn:
yarn build
The production build will be available in the build
directory.
Home Page
Image Modal
App
- The root component that manages state and renders child components. - Handles image fetching, search queries, and selected image state.
ImageCard
- Displays individual images in a card format. - Receives props for image URL, alt text, and tags. - Triggers the modal on click.
ImageModal
- Shows detailed information about the selected image. - Includes a close button and a download link.
SearchBar
- Allows users to input search queries and triggers image searches.
fetchImages
- Function to fetch images from Unsplash API based on search queries and pagination.
useInfiniteScroll
- Custom hook for handling infinite scrolling behavior.
UnsplashImage
- Defines the structure of an image object returned by the Unsplash API.
ImageCardProps
- Props for the
ImageCard
component.
ImageModalProps
- Props for the
ImageModal
component.
SearchBarProps
- Props for the
SearchBar
component.
FetchImagesResponse
- Structure of the response from the
fetchImages
function.
Contributions are welcome! Please follow these steps to contribute:
-
Fork the Repository
-
Create a Feature Branch
git checkout -b feature/your-feature
-
Make Your Changes
-
Commit Your Changes
git commit -am 'Add your changes'
- Push to the Branch
git push origin feature/your-feature
- Create a Pull Request
Submit a pull request to merge your changes into the main
branch.