This is a React application that fetches and displays photos from the Unsplash API. The application includes features such as dark mode toggle, search functionality, and infinite scrolling.
To get started with this project, follow these steps:
-
Clone the repository:
git clone https://github.com/theSamyak/stock-photos-generator.git cd stock-photos-generator
-
Install dependencies:
npm install
or
yarn install
-
Set up environment variables:
Create a
.env
file in the root directory of the project and add your Unsplash API access key:REACT_APP_ACCESS_KEY=your_unsplash_access_key
To start the development server:
npm start
or
yarn start
Open your browser and navigate to http://localhost:3000 to view the application.
- Search Photos: Use the search bar to find photos.
- Infinite Scrolling: Automatically loads more photos as you scroll.
- Dark Mode: Switch between light and dark mode.
- Responsive Design: Adapted for all device sizes.
Here is an overview of the project structure:
├── public
│ └── index.html
├── src
│ ├── components
│ │ └── Photo.js
│ ├── hooks
│ │ ├── useDarkMode.js
│ │ ├── useDebounce.js
│ │ └── useFetchImages.js
│ ├── styles
│ │ └── index.css
│ ├── App.js
│ ├── index.js
│ └── .env
├── .gitignore
├── package.json
├── README.md
└── yarn.lock / package-lock.json
The app uses the Unsplash API to fetch photos. Obtain an access key from Unsplash and add it to your .env
file.
- Main URL:
https://api.unsplash.com/photos/
- Search URL:
https://api.unsplash.com/search/photos/
const clientID = `?client_id=${process.env.REACT_APP_ACCESS_KEY}`;
const mainUrl = `https://api.unsplash.com/photos/`;
const searchUrl = `https://api.unsplash.com/search/photos/`;
Contributions are welcome! Please fork the repository and create a pull request with your changes. Ensure your code follows the existing style and conventions.
-
Fork the repository.
-
Create a new branch:
git checkout -b feature-branch-name
-
Make your changes.
-
Commit your changes:
git commit -m 'Add some feature'
-
Push to the branch:
git push origin feature-branch-name
-
Open a pull request.