├── .eslintrc.js ├── .github └── workflows │ ├── ci.yml │ └── codeql-analysis.yml ├── .gitignore ├── .prettierignore ├── .prettierrc ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── assets ├── images │ ├── noResults.gif │ ├── pixelsHashLogo.png │ ├── pixelsHashLogo2.png │ └── pixelsHashLogoDark.png └── svgs │ ├── CalendarIcon.jsx │ ├── ChevDoubleUpIcon.jsx │ ├── ChevLeftIcon.jsx │ ├── ChevRightIcon.jsx │ ├── DownloadIcon.jsx │ ├── GithubIcon.jsx │ ├── GridIcon.jsx │ ├── InstagramIcon.jsx │ ├── InternetIcon.jsx │ ├── ListIcon.jsx │ ├── MapIcon.jsx │ ├── MoonIcon.jsx │ ├── SunIcon.jsx │ └── TwitterIcon.jsx ├── components ├── Alert │ └── Alert.jsx ├── BioDetails │ └── BioDetails.jsx ├── CardFooter │ └── CardFooter.jsx ├── CreatorDetails │ └── CreatorDetails.jsx ├── DarkModeToggleButton │ └── DarkModeToggleButton.jsx ├── GridViewImage │ └── GridViewImage.jsx ├── GridViewToggleButton │ └── GridViewToggleButton.jsx ├── ImageCard │ ├── ImageCard.jsx │ └── utils.js ├── ImageDetails │ └── ImageDetails.jsx ├── ImageListing │ ├── ImageListing.jsx │ ├── imageListingReducer.js │ └── utils.js ├── InfiniteScroll │ └── InfiniteScroll.jsx ├── ListViewImage │ └── ListViewImage.jsx ├── Loader │ └── Loader.jsx ├── Location │ └── Location.jsx ├── Modal │ └── Modal.jsx ├── Navbar │ └── Navbar.jsx ├── NoResults │ └── NoResults.jsx ├── ProfileDetails │ └── ProfileDetails.jsx ├── ScrollToTopButton │ └── ScrollToTopButton.jsx ├── SocialLinks │ └── SocialLinks.jsx └── Tags │ └── Tags.jsx ├── data ├── constants.js └── strings.js ├── next.config.js ├── package.json ├── pages ├── 404.js ├── _app.js ├── index.css └── index.js ├── postcss.config.js ├── public ├── android-icon-144x144.png ├── android-icon-192x192.png ├── android-icon-36x36.png ├── android-icon-48x48.png ├── android-icon-72x72.png ├── android-icon-96x96.png ├── apple-icon-114x114.png ├── apple-icon-120x120.png ├── apple-icon-144x144.png ├── apple-icon-152x152.png ├── apple-icon-180x180.png ├── apple-icon-57x57.png ├── apple-icon-60x60.png ├── apple-icon-72x72.png ├── apple-icon-76x76.png ├── apple-icon-precomposed.png ├── apple-icon.png ├── browserconfig.xml ├── favicon-16x16.png ├── favicon-32x32.png ├── favicon-96x96.png ├── favicon.ico ├── manifest.json ├── ms-icon-144x144.png ├── ms-icon-150x150.png ├── ms-icon-310x310.png ├── ms-icon-70x70.png ├── pixelsHashLogo.png └── vercel.svg ├── tailwind.config.js ├── utils ├── formatDate.js └── hooks │ └── useIntersectionObserver.js └── yarn.lock /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | browser: true, 4 | es6: true, 5 | node: true, 6 | }, 7 | "ignorePatterns": [ "**/src/*"], 8 | parser: "babel-eslint", 9 | extends: [ 10 | "eslint:recommended", 11 | "plugin:react/recommended", 12 | "prettier", 13 | ], 14 | parserOptions: { 15 | ecmaVersion: "2017", 16 | ecmaFeatures: { 17 | experimentalObjectRestSpread: true, 18 | jsx: true, 19 | }, 20 | sourceType: "module", 21 | }, 22 | plugins: ["babel", "react", "import","react-hooks"], 23 | rules: { 24 | "import/no-duplicates": "error", 25 | "import/no-unresolved": "off", 26 | "import/named": "error", 27 | "react/no-typos": "error", 28 | "react/jsx-no-bind": "off", 29 | "react-hooks/rules-of-hooks": "error", // Checks rules of Hooks 30 | "react-hooks/exhaustive-deps": "warn", // Checks effect dependencies 31 | "react/jsx-uses-react": "off", 32 | "react/react-in-jsx-scope": "off", 33 | "array-callback-return": "error", 34 | "consistent-return": "error", 35 | "babel/no-invalid-this": "error", 36 | "no-unused-vars": ["error", { argsIgnorePattern: "^_" }], 37 | "react/prop-types": "off", 38 | "react/no-unescaped-entities":"off" 39 | }, 40 | settings: { 41 | react: { 42 | pragma: "React", 43 | version: "detect", 44 | flowVersion: "0.63.1", 45 | }, 46 | }, 47 | }; -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Build and Test 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | test: 13 | runs-on: ${{matrix.os}} 14 | strategy: 15 | matrix: 16 | os: 17 | - ubuntu-latest 18 | - macos-latest 19 | - windows-latest 20 | 21 | node-version: 22 | - 14.x 23 | - 16.x 24 | 25 | steps: 26 | - name: Checkout 27 | uses: actions/checkout@master 28 | 29 | - name: setup node ${{matrix.node-version}} 30 | uses: actions/setup-node@v1.4.4 31 | with: 32 | node-version: ${{matrix.node-version}} 33 | 34 | - name: Get yarn cache directory path 35 | id: yarn-cache-dir-path 36 | run: echo "::set-output name=dir::$(yarn cache dir)" 37 | 38 | - uses: actions/cache@v2 39 | id: yarn-cache 40 | with: 41 | path: ${{ steps.yarn-cache-dir-path.outputs.dir }} 42 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 43 | restore-keys: | 44 | ${{ runner.os }}-yarn- 45 | - name: Install dependencies 46 | run: yarn 47 | 48 | - name: Build the project 49 | run: yarn build 50 | 51 | - name: Lint 52 | run: yarn lint 53 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL analysis" 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | schedule: 9 | - cron: '0 16 * * 3' 10 | 11 | jobs: 12 | analyze: 13 | name: Analyze 14 | runs-on: ubuntu-latest 15 | 16 | strategy: 17 | fail-fast: false 18 | matrix: 19 | language: ['javascript'] 20 | 21 | steps: 22 | - name: Checkout repository 23 | uses: actions/checkout@v2 24 | with: 25 | fetch-depth: 2 26 | 27 | - run: git checkout HEAD^2 28 | if: ${{ github.event_name == 'pull_request' }} 29 | 30 | - name: Initialize CodeQL 31 | uses: github/codeql-action/init@v1 32 | with: 33 | languages: ${{ matrix.language }} 34 | 35 | - name: Perform CodeQL Analysis 36 | uses: github/codeql-action/analyze@v1 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | # local env files 28 | .env.local 29 | .env.development.local 30 | .env.test.local 31 | .env.production.local 32 | 33 | # vercel 34 | .vercel 35 | 36 | .env.local 37 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | build 3 | dist 4 | coverage 5 | .eslintrc.js 6 | .next -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "printWidth": 100, 4 | "useTabs": true, 5 | "tabWidth": 4, 6 | "trailingComma": "all", 7 | "singleQuote": true 8 | } -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | sohamshah456@gmail.com. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to **pixelsHash 📸** 2 | 3 | This documentation contains a set of guidelines to help you during the contribution process. We are happy to welcome all the contributions from anyone willing to improve/add new scripts to this project. Thank you for helping out and remember, no contribution is too small. 4 | 5 | ## How to contribute 6 | 7 | **Step 1**: Fork the Project 8 | 9 | - Fork this Repository. This will create a Local Copy of this Repository on your Github Profile. Keep a reference to the original project in upstream remote. 10 | 11 | ``` 12 | git clone https://github.com//pixelsHash 13 | cd pixelsHash 14 | git remote add upstream https://github.com/sohamsshah/pixelsHash 15 | ``` 16 | 17 | **Step 2**: Keep yourself Updated 18 | 19 | ``` 20 | git remote update 21 | git checkout 22 | git rebase upstream/ 23 | ``` 24 | 25 | **Step 3**: Create a feature branch and work remotely 26 | 27 | ``` 28 | git checkout -b branch_name 29 | ``` 30 | 31 | **Step 4**: Work on the assigned issue 32 | 33 | - Work on the issue(s) assigned to you. 34 | - Add all the files/folders needed. 35 | - After you've made changes or made your contribution to the project add changes to the branch you've just created by: 36 | 37 | ``` 38 | # To add all new files to branch Branch_Name 39 | git add . 40 | 41 | # To add only a few files to Branch_Name 42 | git add 43 | ``` 44 | 45 | **Step 5**: Commit 46 | 47 | This message get associated with all files you have changed 48 | 49 | ``` 50 | git commit -m "message" 51 | ``` 52 | 53 | **Step 6**: Work Remotely 54 | 55 | - Now you are ready to your work to the remote repository. 56 | - When your work is ready and complies with the project conventions, upload your changes to your fork: 57 | 58 | ``` 59 | # To push your work to your remote repository 60 | git push -u origin Branch_Name 61 | ``` 62 | 63 | **Step 7**: Make a PR 64 | 65 | - Go to your repository in browser and click on compare and pull requests. Then add a title and description to your pull request that explains your contribution. 66 | 67 | - Voila! Your Pull Request has been submitted and will be reviewed by the moderators and merged.🥳 Make sure you make a PR to `develop` branch as the base. 68 | 69 | ## Run Tests 70 | 71 | Before Raising a PR, make sure you run `yarn lint:fix` in order to avoid any linting or formatting inconsistensies. 72 | 73 | Also check for any tests if any. 74 | 75 | ## Code of Conduct 76 | 77 | We have adopted the [Contributor Covenant](https://www.contributor-covenant.org/) as its Code of Conduct, and we expect project contributors to adhere to it. Please read the full text so that you can understand what actions will and will not be tolerated. 78 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Soham Shah 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | pixelsHash Logo

3 |

4 | 5 |

pixelsHash 📸

6 | 7 |

8 | 9 | pixelsHash licence 10 | 11 | 12 | pixelsHash forks 13 | 14 | 15 | pixelsHash stars 16 | 17 | 18 | pixelsHash issues 19 | 20 | 21 | pixelsHash pull-requests 22 | 23 | 24 |

25 | 26 |

27 | pixelsHash 28 | · 29 | Report Bug 30 | · 31 | Request Feature 32 |

33 | 34 | --- 35 | 36 | ## **Introducing pixelsHash 📸** 37 | 38 | The Go-to place for High Quality, Beautiful and Picturesque 3-D matrices of Pixels - hashed perfectly for you to describe your thoughts in high resolution! 🖼⚡ You can view, search and download everything that you want! Powered By [Unsplash](https://unsplash.com/)! 39 | 40 | ## **🚀 Demo** 41 | 42 | ![image](https://user-images.githubusercontent.com/47717492/129268568-b11171ca-1132-4b39-b194-27004fd975c8.png) 43 | 44 | ### [pixelsHash](https://github.com/sohamsshah/pixelsHash) is LIVE! 45 | 46 | ## **🧐 Features** 47 | 48 | There are multiple features implemented on pixelsHash to make high quality pictures accessible to you easier like never before. 49 | 50 | > 🖼 **pixelsHash** has: 51 | 52 | - 🔎 **Search from over 2 million free high-resolution images** (powered by [Unsplash API](https://unsplash.com/documentation)) 53 | - ♾ **Infinite Scrolling** 54 | - 💾 **Save your search History** 55 | - ⚡ **Blazing Fast on all devices** 56 | - 🔖 **Toggle between different Views** 57 | - 💻 **Fully Responsive** 58 | - ⤵️ **Download Pictures with a click** 59 | - 🙈 **Profanity Filter** (Clean search and content, always) 60 | - 🌘 **Dark mode** 61 | 62 | ## **⚡Lighthouse Report** 63 | ![image](https://user-images.githubusercontent.com/47717492/129396568-7faa5f0e-769a-410b-9d36-c4f740a52c36.png) 64 | 65 | 66 | ## 🛠️ **Spinning Up Development Environment** 67 | 68 | 1. Clone the repository 69 | 70 | ```bash 71 | git clone https://github.com/sohamsshah/pixelsHash.git 72 | ``` 73 | 74 | 2. Change the working directory 75 | 76 | ```bash 77 | cd pixelsHash 78 | ``` 79 | 80 | 3. Install dependencies 81 | 82 | ```bash 83 | yarn 84 | ``` 85 | 86 | 4. Create `.env.local` file in root and add your variables 87 | 88 | ```bash 89 | NEXT_PUBIC_UNSPLASH_API_ACCESS_KEY='your unsplash api key here' 90 | ``` 91 | 92 | 5. Run pixelsHash 93 | 94 | ```bash 95 | yarn run dev 96 | ``` 97 | 98 | You are all set! Open [localhost:3000](http://localhost:3000/) to see the app. 99 | 100 | ## **💖 We love Contributions** 101 | 102 | - **pixelsHash** is truly Open Source. Any sort of contribution to this project are highly appreciated. Create a branch, add commits, and [open a pull request](https://github.com/sohamsshah/pixelsHash/compare). 103 | 104 | - Please read [`CONTRIBUTING`](CONTRIBUTING.md) for details on our [`CODE OF CONDUCT`](CODE_OF_CONDUCT.md), and the process for submitting pull requests to **pixelsHash**. 105 | 106 | ## **💻 Built with** 107 | 108 | - [Next JS](https://nextjs.org/) 109 | - [Next Image](https://nextjs.org/docs/api-reference/next/image): for lazy loading images and optimized Images 110 | - [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API): for smooth infinite scrolling 111 | - [React Loading Skeleton](https://www.npmjs.com/package/react-loading-skeleton): for effective skeleton loading 112 | - [Bad Words](https://www.npmjs.com/package/naughty-words): for Profanity Check 🙏 113 | - [React Select](https://www.npmjs.com/package/react-select): for interactive search box 114 | - [Vercel](http://vercel.com/): for hosting 115 | - [Tailwind CSS](https://tailwindcss.com/): for beautiful UI styling 116 | 117 | ## **🌈Upcoming Features** 118 | 119 | A lot of features are in the pipeline for pixelsHash. Some of them are 120 | 121 | - 🥁 **Share Images** 122 | - 👀 **Visual Search** 123 | - 🎙 **Audio Search** 124 | - 💖 **Favourites** 125 | 126 | Have a feature in mind? Please create an issue [here](https://github.com/sohamsshah/pixelsHash/issues). Let's talk! 127 | 128 | ## 🛡️ License 129 | 130 | This project is licensed under the MIT License - see the [`LICENSE`](LICENSE) file for details. 131 | 132 | ## 🦄 Deploy 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | --- 145 | 146 | ## **👨‍💻 Author** 147 | 148 | ### 👤 Soham Shah 149 | 150 | - Twitter: [@sohamsshah\_](https://twitter.com/sohamsshah_) 151 | - Github: [@sohamsshah](https://github.com/sohamsshah) 152 | - Hashnode: [@sohamsshah](https://hashnode.com/@sohamsshah) 153 | - LinkedIN: [@sohamshah456](https://www.linkedin.com/in/sohamshah456/) 154 | 155 | --- 156 | 157 |

158 | Liked pixelsHash📸? 159 | 160 | O Stargazer✨! Can you ⭐️ this too? 161 | 162 |

163 | -------------------------------------------------------------------------------- /assets/images/noResults.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/assets/images/noResults.gif -------------------------------------------------------------------------------- /assets/images/pixelsHashLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/assets/images/pixelsHashLogo.png -------------------------------------------------------------------------------- /assets/images/pixelsHashLogo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/assets/images/pixelsHashLogo2.png -------------------------------------------------------------------------------- /assets/images/pixelsHashLogoDark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/assets/images/pixelsHashLogoDark.png -------------------------------------------------------------------------------- /assets/svgs/CalendarIcon.jsx: -------------------------------------------------------------------------------- 1 | export function MdiCalendarMonth(props) { 2 | return ( 3 | 4 | 8 | 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /assets/svgs/ChevDoubleUpIcon.jsx: -------------------------------------------------------------------------------- 1 | export function MdiChevronDoubleUp(props) { 2 | return ( 3 | 4 | 8 | 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /assets/svgs/ChevLeftIcon.jsx: -------------------------------------------------------------------------------- 1 | export function MdiChevronLeft(props) { 2 | return ( 3 | 4 | 8 | 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /assets/svgs/ChevRightIcon.jsx: -------------------------------------------------------------------------------- 1 | export function MdiChevronRight(props) { 2 | return ( 3 | 4 | 8 | 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /assets/svgs/DownloadIcon.jsx: -------------------------------------------------------------------------------- 1 | export function MdiDownload(props) { 2 | return ( 3 | 4 | 5 | 6 | ) 7 | } 8 | -------------------------------------------------------------------------------- /assets/svgs/GithubIcon.jsx: -------------------------------------------------------------------------------- 1 | export function MdiGithub(props) { 2 | return ( 3 | 4 | 8 | 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /assets/svgs/GridIcon.jsx: -------------------------------------------------------------------------------- 1 | export function MdiGrid(props) { 2 | return ( 3 | 4 | 8 | 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /assets/svgs/InstagramIcon.jsx: -------------------------------------------------------------------------------- 1 | export function MdiInstagram(props) { 2 | return ( 3 | 4 | 8 | 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /assets/svgs/InternetIcon.jsx: -------------------------------------------------------------------------------- 1 | export function MdiWeb(props) { 2 | return ( 3 | 4 | 8 | 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /assets/svgs/ListIcon.jsx: -------------------------------------------------------------------------------- 1 | export function MdiFormatListBulletedSquare(props) { 2 | return ( 3 | 4 | 8 | 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /assets/svgs/MapIcon.jsx: -------------------------------------------------------------------------------- 1 | export function MdiMapMarker(props) { 2 | return ( 3 | 4 | 8 | 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /assets/svgs/MoonIcon.jsx: -------------------------------------------------------------------------------- 1 | export function MdiMoonWaningCrescent(props) { 2 | return ( 3 | 4 | 8 | 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /assets/svgs/SunIcon.jsx: -------------------------------------------------------------------------------- 1 | export function MdiWeatherSunny(props) { 2 | return ( 3 | 4 | 8 | 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /assets/svgs/TwitterIcon.jsx: -------------------------------------------------------------------------------- 1 | export function MdiTwitter(props) { 2 | return ( 3 | 4 | 8 | 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /components/Alert/Alert.jsx: -------------------------------------------------------------------------------- 1 | const Alert = ({ bgColor, color, children }) => { 2 | return ( 3 |
4 |
{creatorDetailsStrings.bioText} 6 |
{bio}
7 |
8 | ) 9 | } 10 | 11 | export default BioDetails 12 | -------------------------------------------------------------------------------- /components/CardFooter/CardFooter.jsx: -------------------------------------------------------------------------------- 1 | import { MdiDownload } from '../../assets/svgs/DownloadIcon' 2 | import { creatorDetailsStrings } from '../../data/strings' 3 | const CardFooter = ({ image }) => { 4 | return ( 5 | <> 6 |
7 | {creatorDetailsStrings.title}{' '} 8 | 9 | 10 | {`${image.user.first_name}`}{' '} 11 | 12 | 13 |
14 | 21 | 22 | ) 23 | } 24 | 25 | export default CardFooter 26 | -------------------------------------------------------------------------------- /components/CreatorDetails/CreatorDetails.jsx: -------------------------------------------------------------------------------- 1 | import BioDetails from '../BioDetails/BioDetails' 2 | import ProfileDetails from '../ProfileDetails/ProfileDetails' 3 | import SocialLinks from '../SocialLinks/SocialLinks' 4 | import { creatorDetailsStrings } from '../../data/strings' 5 | const CreatorDetails = ({ image: { user } }) => { 6 | return ( 7 |
8 |
{creatorDetailsStrings.title}
9 | 10 | 11 | 12 | {user.bio && } 13 |
14 | ) 15 | } 16 | 17 | export default CreatorDetails 18 | -------------------------------------------------------------------------------- /components/DarkModeToggleButton/DarkModeToggleButton.jsx: -------------------------------------------------------------------------------- 1 | import { useTheme } from 'next-themes' 2 | import { MdiWeatherSunny } from '../../assets/svgs/SunIcon' 3 | import { MdiMoonWaningCrescent } from '../../assets/svgs/MoonIcon' 4 | 5 | const DarkModeToggleButton = () => { 6 | const { theme, setTheme } = useTheme() 7 | return ( 8 |
9 | 17 |
18 | ) 19 | } 20 | 21 | export default DarkModeToggleButton 22 | -------------------------------------------------------------------------------- /components/GridViewImage/GridViewImage.jsx: -------------------------------------------------------------------------------- 1 | import CardFooter from '../CardFooter/CardFooter' 2 | import Image from 'next/image' 3 | 4 | const GridViewImage = ({ image, setShowModal }) => { 5 | return ( 6 |
7 |
8 |
setShowModal(true)} className="h-full card-zoom cursor-zoom-in"> 9 |
10 | { 20 |
21 |
22 |
23 |
24 | 25 |
26 |
27 | ) 28 | } 29 | 30 | export default GridViewImage 31 | -------------------------------------------------------------------------------- /components/GridViewToggleButton/GridViewToggleButton.jsx: -------------------------------------------------------------------------------- 1 | import { MdiFormatListBulletedSquare } from '../../assets/svgs/ListIcon' 2 | import { MdiGrid } from '../../assets/svgs/GridIcon' 3 | const GridViewToggleButton = ({ onClick, isGridView }) => { 4 | return ( 5 |
6 | 13 |
14 | ) 15 | } 16 | 17 | export default GridViewToggleButton 18 | -------------------------------------------------------------------------------- /components/ImageCard/ImageCard.jsx: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from 'react' 2 | import Modal from '../Modal/Modal' 3 | import GridViewImage from '../GridViewImage/GridViewImage' 4 | import ListViewImage from '../ListViewImage/ListViewImage' 5 | import { nextModalImage, prevModalImage } from './utils' 6 | 7 | const ImageCard = ({ image, images, index, isGridView }) => { 8 | const [currModalImageIndex, setCurrModalImageIndex] = useState(index) 9 | const [showModal, setShowModal] = useState(false) 10 | const [modalImage, setModalImage] = useState(images[index]) 11 | useEffect(() => { 12 | setCurrModalImageIndex(index) 13 | setModalImage(images[index]) 14 | }, [showModal]) 15 | return ( 16 | <> 17 | {showModal && ( 18 | 21 | prevModalImage({ 22 | currModalImageIndex, 23 | images, 24 | setModalImage, 25 | setCurrModalImageIndex, 26 | }) 27 | } 28 | nextModalImage={() => 29 | nextModalImage({ 30 | currModalImageIndex, 31 | images, 32 | setModalImage, 33 | setCurrModalImageIndex, 34 | }) 35 | } 36 | closeModal={() => setShowModal(false)} 37 | /> 38 | )} 39 | {isGridView ? ( 40 | 41 | ) : ( 42 | 43 | )} 44 | 45 | ) 46 | } 47 | 48 | export default ImageCard 49 | -------------------------------------------------------------------------------- /components/ImageCard/utils.js: -------------------------------------------------------------------------------- 1 | export const nextModalImage = ({ 2 | currModalImageIndex, 3 | images, 4 | setModalImage, 5 | setCurrModalImageIndex, 6 | }) => { 7 | if (currModalImageIndex < images.length - 1) { 8 | setModalImage(images[currModalImageIndex + 1]) 9 | setCurrModalImageIndex((prev) => prev + 1) 10 | } 11 | } 12 | 13 | export const prevModalImage = ({ 14 | currModalImageIndex, 15 | images, 16 | setModalImage, 17 | setCurrModalImageIndex, 18 | }) => { 19 | if (currModalImageIndex > 0) { 20 | setModalImage(images[currModalImageIndex - 1]) 21 | setCurrModalImageIndex((prev) => prev - 1) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /components/ImageDetails/ImageDetails.jsx: -------------------------------------------------------------------------------- 1 | import { MdiCalendarMonth } from '../../assets/svgs/CalendarIcon' 2 | import { formatDate } from '../../utils/formatDate' 3 | import Location from './../Location/Location' 4 | import Tags from './../Tags/Tags' 5 | import { imageDetailsStrings } from '../../data/strings' 6 | 7 | const ImageDetails = ({ image: { user, created_at, tags, description } }) => { 8 | return ( 9 |
10 |
{imageDetailsStrings.title}
11 | {description} 12 | {user.location !== null && } 13 |
14 | 15 | {imageDetailsStrings.publishText}{' '} 16 | {formatDate(created_at)} 17 | 18 |
19 | {tags.length !== 0 && } 20 |
21 | ) 22 | } 23 | 24 | export default ImageDetails 25 | -------------------------------------------------------------------------------- /components/ImageListing/ImageListing.jsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useReducer, useRef } from 'react' 2 | import InfiniteScroll from '../InfiniteScroll/InfiniteScroll' 3 | import ImageCard from '../ImageCard/ImageCard' 4 | import Loader from '../Loader/Loader' 5 | import Navbar from '../Navbar/Navbar' 6 | import NoResults from '../NoResults/NoResults' 7 | import { getOptions, searchImages } from './utils' 8 | import { DEFAULT_QUERY, PER_PAGE, defaultOptions, VISIBILITY_THRESHOLD } from '../../data/constants' 9 | import { imageListingReducer } from './imageListingReducer' 10 | import axios from 'axios' 11 | 12 | const ImageListing = ({ data }) => { 13 | const isMounted = useRef(false) 14 | const [ 15 | { images, hasMore, options, page, query, isGridView, selectedOption, isLoading }, 16 | imageListingDispatch, 17 | ] = useReducer(imageListingReducer, { 18 | images: [...data.results], 19 | hasMore: true, 20 | query: DEFAULT_QUERY, 21 | isGridView: true, 22 | selectedOption: null, 23 | options: defaultOptions, 24 | isLoading: false, 25 | page: 2, // initialize with page 2 because page 1 was fetched via SSG 26 | }) 27 | 28 | useEffect(() => { 29 | const res = getOptions() 30 | imageListingDispatch({ type: 'SET_OPTIONS', payload: res.slice(0, 5) }) 31 | }, []) 32 | 33 | useEffect(() => { 34 | ;(async function () { 35 | if (isMounted.current) { 36 | await getMoreImages() 37 | } else { 38 | isMounted.current = true 39 | } 40 | })() 41 | }, [query]) 42 | 43 | const getMoreImages = async () => { 44 | // make an API call to get more images 45 | try { 46 | imageListingDispatch({ type: 'SET_LOADING', payload: true }) 47 | const response = await axios.get( 48 | `https://api.unsplash.com/search/photos?client_id=${process.env.NEXT_PUBLIC_UNSPLASH_API_ACCESS_KEY}&query=${query}&page=${page}&per_page=${PER_PAGE}`, 49 | ) 50 | if (response.status === 200) { 51 | const newPosts = response.data 52 | if (newPosts.total_pages < page) { 53 | imageListingDispatch({ type: 'SET_HAS_MORE', payload: false }) 54 | } else { 55 | imageListingDispatch({ type: 'SET_HAS_MORE', payload: true }) 56 | imageListingDispatch({ type: 'ADD_MORE_IMAGES', payload: newPosts.results }) 57 | } 58 | } 59 | } catch (error) { 60 | console.log(error.response) 61 | } finally { 62 | imageListingDispatch({ type: 'SET_LOADING', payload: false }) 63 | } 64 | } 65 | return ( 66 | <> 67 |
68 | 71 | searchImages(e, selectedOption, imageListingDispatch, getMoreImages) 72 | } 73 | selectedOption={selectedOption} 74 | setSelectedOption={(value) => 75 | imageListingDispatch({ type: 'SET_SELECTED_OPTION', payload: value }) 76 | } 77 | options={options} 78 | imageListingDispatch={imageListingDispatch} 79 | /> 80 |
81 | 82 | 6 && } 87 | threshold={VISIBILITY_THRESHOLD} 88 | > 89 |
90 |
95 | {images.map((image, index) => ( 96 | 103 | ))} 104 |
105 |
106 | {images.length === 0 && !isLoading && } 107 |
108 | 109 | ) 110 | } 111 | 112 | export default ImageListing 113 | -------------------------------------------------------------------------------- /components/ImageListing/imageListingReducer.js: -------------------------------------------------------------------------------- 1 | export const imageListingReducer = (state, action) => { 2 | switch (action.type) { 3 | case 'ADD_MORE_IMAGES': 4 | return { 5 | ...state, 6 | images: [...state.images, ...action.payload], 7 | page: state.page + 1, 8 | } 9 | case 'RESET_IMAGES': 10 | return { ...state, images: [], page: 1 } 11 | case 'SET_HAS_MORE': 12 | return { ...state, hasMore: action.payload } 13 | case 'SET_QUERY': 14 | return { ...state, query: action.payload } 15 | case 'TOGGLE_VIEW': 16 | return { ...state, isGridView: !state.isGridView } 17 | case 'SET_SELECTED_OPTION': 18 | return { ...state, selectedOption: action.payload } 19 | case 'SET_OPTIONS': 20 | return { ...state, options: action.payload } 21 | case 'SET_LOADING': 22 | return { ...state, isLoading: action.payload } 23 | default: 24 | return { ...state } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /components/ImageListing/utils.js: -------------------------------------------------------------------------------- 1 | import { defaultOptions, REPLACED_PROFANE_WORD } from '../../data/constants' 2 | import englishBadWords from 'naughty-words/en.json' 3 | 4 | export const getOptions = () => { 5 | // get select options from local storage history 6 | const history = localStorage.getItem('history') 7 | if (history === null) { 8 | return defaultOptions 9 | } 10 | return JSON.parse(history) 11 | } 12 | 13 | const saveQueryToHistory = (query, imageListingDispatch) => { 14 | // some browsers don't have localStorage API so handle error 15 | try { 16 | // check if history exists, if not save default options to history 17 | if (localStorage.getItem('history') === null) { 18 | localStorage.setItem('history', JSON.stringify(defaultOptions)) 19 | } 20 | let userHistory = JSON.parse(localStorage.getItem('history')) 21 | const newHistoryItem = { value: query, label: query } 22 | // if same history value already exists, remove it 23 | userHistory = userHistory.filter((item) => item.value != newHistoryItem.value) 24 | // add new history item to the first index of userHistory - stack implementation 25 | userHistory.unshift(newHistoryItem) 26 | localStorage.setItem('history', JSON.stringify(userHistory)) 27 | imageListingDispatch({ type: 'SET_OPTIONS', payload: userHistory.slice(0, 5) }) 28 | imageListingDispatch({ type: 'SET_SELECTED_OPTION', payload: newHistoryItem }) 29 | } catch (err) { 30 | console.log(err) 31 | } 32 | } 33 | 34 | export const searchImages = async (e, selectedOption, imageListingDispatch) => { 35 | // if enter is pressed 36 | if (e.keyCode === 13) { 37 | // if enter is pressed 38 | if (e.target.value === '') { 39 | if (selectedOption !== null) { 40 | e.target.value = selectedOption.value 41 | } 42 | } else { 43 | if (isBadWord(e.target.value)) { 44 | // Replace search value with REPLACED word and search for that query instead 45 | e.target.value = REPLACED_PROFANE_WORD 46 | imageListingDispatch({ type: 'SET_QUERY', payload: REPLACED_PROFANE_WORD }) 47 | } else { 48 | // search input query 49 | imageListingDispatch({ type: 'SET_QUERY', payload: e.target.value }) 50 | } 51 | // empty images array in state and add to history 52 | imageListingDispatch({ type: 'RESET_IMAGES' }) 53 | saveQueryToHistory(e.target.value, imageListingDispatch) 54 | imageListingDispatch({ type: 'SET_HAS_MORE', payload: true }) 55 | } 56 | } 57 | } 58 | 59 | export const isBadWord = (word) => { 60 | // returns true if the word is bad word, else false 61 | let englishBadWordsArray = [] 62 | for (let i in englishBadWords) { 63 | englishBadWordsArray.push(englishBadWords[i]) 64 | } 65 | return englishBadWordsArray.find((item) => item === word) 66 | } 67 | -------------------------------------------------------------------------------- /components/InfiniteScroll/InfiniteScroll.jsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useRef } from 'react' 2 | import { useIntersectionObserver } from './../../utils/hooks/useIntersectionObserver' 3 | const InfiniteScroll = ({ dataLength, hasMore = false, next, loader, threshold = 1, children }) => { 4 | const ref = useRef(null) 5 | const isBottomVisible = useIntersectionObserver( 6 | ref, 7 | { 8 | threshold, 9 | }, 10 | false, 11 | ) 12 | 13 | useEffect(() => { 14 | ;(async function () { 15 | if (isBottomVisible && dataLength !== 0) { 16 | await next() 17 | } 18 | })() 19 | }, [isBottomVisible]) 20 | 21 | return ( 22 |
23 | {children} 24 | {hasMore ?
{loader}
: ''} 25 |
26 | ) 27 | } 28 | 29 | export default InfiniteScroll 30 | -------------------------------------------------------------------------------- /components/ListViewImage/ListViewImage.jsx: -------------------------------------------------------------------------------- 1 | import Image from 'next/image' 2 | import CardFooter from '../CardFooter/CardFooter' 3 | import ImageDetails from '../ImageDetails/ImageDetails' 4 | 5 | const ListViewImage = ({ image, setShowModal }) => { 6 | return ( 7 |
8 |
setShowModal(true)} className="list-card-zoom cursor-zoom-in"> 9 |
10 | {image.alt_description 18 |
19 |
20 |
21 | 22 | 23 |
24 | 25 |
26 |
27 |
28 | ) 29 | } 30 | 31 | export default ListViewImage 32 | -------------------------------------------------------------------------------- /components/Loader/Loader.jsx: -------------------------------------------------------------------------------- 1 | import Skeleton, { SkeletonTheme } from 'react-loading-skeleton' 2 | import { useTheme } from 'next-themes' 3 | 4 | const Loader = ({ numberOfItems, isGridView }) => { 5 | const { theme } = useTheme() 6 | return ( 7 | <> 8 | {isGridView ? ( 9 | 10 | ) : ( 11 | 12 | )} 13 | 14 | ) 15 | } 16 | 17 | const GridViewLoader = ({ theme, numberOfItems }) => { 18 | return ( 19 |
20 |
21 | {[...Array(numberOfItems)].map((_, i) => ( 22 |
23 |
24 |
25 | 29 | 30 | 31 |
32 |
33 | 37 | 38 | 39 |
40 |
41 |
42 | ))} 43 |
44 |
45 | ) 46 | } 47 | const ListViewLoader = ({ theme, numberOfItems }) => { 48 | return ( 49 |
50 |
51 | {[...Array(numberOfItems)].map((_, i) => ( 52 |
56 |
57 | 61 | 62 | 63 |
64 |
65 |
66 |
67 |
68 | 72 | 73 | 74 |
75 |
76 | 80 | 81 | 82 |
83 |
84 | 88 | 89 | 90 |
91 |
92 |
93 |
94 |
95 | 99 | 100 | 101 |
102 |
103 |
104 |
105 | ))} 106 |
107 |
108 | ) 109 | } 110 | 111 | export default Loader 112 | -------------------------------------------------------------------------------- /components/Location/Location.jsx: -------------------------------------------------------------------------------- 1 | import { MdiMapMarker } from './../../assets/svgs/MapIcon' 2 | 3 | const Location = ({ location }) => { 4 | return ( 5 |
6 | 7 |
8 | {location} 9 |
10 |
11 | ) 12 | } 13 | 14 | export default Location 15 | -------------------------------------------------------------------------------- /components/Modal/Modal.jsx: -------------------------------------------------------------------------------- 1 | import ImageDetails from '../ImageDetails/ImageDetails' 2 | import Image from 'next/image' 3 | import { MdiChevronLeft } from '../../assets/svgs/ChevLeftIcon' 4 | import { MdiChevronRight } from '../../assets/svgs/ChevRightIcon' 5 | import CreatorDetails from '../CreatorDetails/CreatorDetails' 6 | 7 | const Modal = ({ image, closeModal, prevModalImage, nextModalImage }) => { 8 | return ( 9 | <> 10 |
11 |
12 | 21 |
22 | 29 |
30 |
31 | 38 |
39 |
40 |
41 |
42 |
43 | { 55 |
56 |
57 |
58 | 59 |
60 |
61 | 62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | 71 | ) 72 | } 73 | 74 | export default Modal 75 | -------------------------------------------------------------------------------- /components/Navbar/Navbar.jsx: -------------------------------------------------------------------------------- 1 | import Creatable from 'react-select/creatable' 2 | import pixelsHashLogo from './../../assets/images/pixelsHashLogo.png' 3 | import pixelsHashLogoDark from './../../assets/images/pixelsHashLogoDark.png' 4 | import { MdiGithub } from '../../assets/svgs/GithubIcon' 5 | import Image from 'next/image' 6 | import { repositoryLink } from '../../data/strings' 7 | import DarkModeToggleButton from './../DarkModeToggleButton/DarkModeToggleButton' 8 | import { useTheme } from 'next-themes' 9 | import GridViewToggleButton from '../GridViewToggleButton/GridViewToggleButton' 10 | const Navbar = ({ 11 | isGridView, 12 | searchImages, 13 | selectedOption, 14 | setSelectedOption, 15 | options, 16 | imageListingDispatch, 17 | }) => { 18 | const { theme } = useTheme() 19 | return ( 20 |
21 | {theme === 'dark' ? ( 22 |
23 | PixelsHash Logo Dark 29 |
30 | ) : ( 31 |
32 | PixelsHash Logo 33 |
34 | )} 35 |
36 | searchImages(e)} 43 | onChange={(value) => setSelectedOption(value)} 44 | options={options} 45 | id="input-value" 46 | className="w-80 m-3" 47 | formatCreateLabel={() => `Search this...`} 48 | styles={{ 49 | singleValue: (base, state) => ({ 50 | ...base, 51 | color: state.selectProps.menuIsOpen ? 'transparent' : base.color, 52 | }), 53 | }} 54 | theme={(boxTheme) => { 55 | if (theme === 'dark') { 56 | return { 57 | ...boxTheme, 58 | colors: { 59 | ...boxTheme.colors, 60 | primary50: '#4B5563', 61 | primary25: '#4B5563', 62 | neutral20: '#4B5563', 63 | neutral50: '#4B5563', 64 | neutral0: '#121212', 65 | neutral80: 'white', 66 | neutral30: '#4B5563', 67 | }, 68 | } 69 | } 70 | return { ...boxTheme } 71 | }} 72 | /> 73 |
74 | imageListingDispatch({ type: 'TOGGLE_VIEW' })} 77 | /> 78 | 79 | 80 | 81 |
82 | 93 |
94 |
95 |
96 |
97 | ) 98 | } 99 | 100 | export default Navbar 101 | -------------------------------------------------------------------------------- /components/NoResults/NoResults.jsx: -------------------------------------------------------------------------------- 1 | import Alert from './../Alert/Alert' 2 | import noResults from './../../assets/images/noResults.gif' 3 | import Image from 'next/image' 4 | import { noResultsString } from '../../data/strings' 5 | const NoResults = () => { 6 | return ( 7 |
8 | no results image 15 | 16 |
17 | 18 | {noResultsString} 19 | 20 |
21 |
22 | ) 23 | } 24 | 25 | export default NoResults 26 | -------------------------------------------------------------------------------- /components/ProfileDetails/ProfileDetails.jsx: -------------------------------------------------------------------------------- 1 | import Image from 'next/image' 2 | const ProfileDetails = ({ user: { name, id, profile_image, username, links } }) => { 3 | return ( 4 |
5 |
6 | {`Profile 14 |
15 |
16 |
{name}
17 | 18 | 19 | @{username} 20 | 21 | 22 |
23 |
24 | ) 25 | } 26 | 27 | export default ProfileDetails 28 | -------------------------------------------------------------------------------- /components/ScrollToTopButton/ScrollToTopButton.jsx: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from 'react' 2 | import { MdiChevronDoubleUp } from './../../assets/svgs/ChevDoubleUpIcon' 3 | const ScrollToTopButton = () => { 4 | const [visible, setVisible] = useState(false) 5 | useEffect(() => { 6 | window.addEventListener('scroll', toggleVisible) 7 | }, []) 8 | const toggleVisible = () => { 9 | const scrolled = document.documentElement.scrollTop 10 | if (scrolled > 300) { 11 | setVisible(true) 12 | } else if (scrolled <= 300) { 13 | setVisible(false) 14 | } 15 | } 16 | 17 | const scrollToTop = () => { 18 | window.scrollTo({ 19 | top: 0, 20 | behavior: 'smooth', 21 | }) 22 | } 23 | 24 | return ( 25 |
26 | 35 |
36 | ) 37 | } 38 | 39 | export default ScrollToTopButton 40 | -------------------------------------------------------------------------------- /components/SocialLinks/SocialLinks.jsx: -------------------------------------------------------------------------------- 1 | import { MdiTwitter } from './../../assets/svgs/TwitterIcon' 2 | import { MdiInstagram } from './../../assets/svgs/InstagramIcon' 3 | import { MdiWeb } from './../../assets/svgs/InternetIcon' 4 | import { socialLinksStrings } from './../../data/strings' 5 | 6 | const SocialLinks = ({ social }) => { 7 | return ( 8 |
9 | {social.instagram_username !== null && ( 10 | 20 | )} 21 | 22 | {social.twitter_username && ( 23 | 33 | )} 34 | {social.portfolio_url && ( 35 | 41 | )} 42 |
43 | ) 44 | } 45 | 46 | export default SocialLinks 47 | -------------------------------------------------------------------------------- /components/Tags/Tags.jsx: -------------------------------------------------------------------------------- 1 | const Tags = ({ tags }) => { 2 | return ( 3 |
4 | {tags.map((tag, index) => { 5 | return ( 6 |
7 | {tag.title} 8 |
9 | ) 10 | })} 11 |
12 | ) 13 | } 14 | 15 | export default Tags 16 | -------------------------------------------------------------------------------- /data/constants.js: -------------------------------------------------------------------------------- 1 | export const DEFAULT_QUERY = 'code' 2 | export const PER_PAGE = '10' 3 | export const defaultOptions = [ 4 | { value: 'nature', label: 'Nature' }, 5 | { value: 'people', label: 'People' }, 6 | { value: 'wallpapers', label: 'Wallpapers' }, 7 | ] 8 | export const REPLACED_PROFANE_WORD = 'bad word' 9 | export const VISIBILITY_THRESHOLD = 0.2 10 | -------------------------------------------------------------------------------- /data/strings.js: -------------------------------------------------------------------------------- 1 | // Modal Strings 2 | 3 | export const imageDetailsStrings = { 4 | title: 'About this Image', 5 | publishText: 'Published On', 6 | } 7 | 8 | export const creatorDetailsStrings = { 9 | title: 'Picture 📸 by', 10 | bioText: 'Bio', 11 | } 12 | 13 | export const repositoryLink = 'https://github.com/sohamsshah/pixelsHash/' 14 | 15 | export const socialLinksStrings = { 16 | twitter: 'https://twitter.com/', 17 | instagram: 'https://www.instagram.com/', 18 | } 19 | 20 | // No Results String 21 | export const noResultsString = 22 | 'Sorry, no results match your search! Try searching for other keywords 😅' 23 | -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | images: { 3 | domains: ['images.unsplash.com'], 4 | }, 5 | i18n: { 6 | locales: ['en-US'], // for accessibility 7 | defaultLocale: 'en-US', 8 | }, 9 | } 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "next dev", 5 | "build": "next build", 6 | "start": "next start", 7 | "commit": "cz", 8 | "prettify": "yarn prettier \"**/*.*(js|jsx)\" --ignore-path=.prettierignore --write", 9 | "lint": "eslint --ext .js,.jsx && yarn prettify", 10 | "lint:fix": "eslint --ext .js,.jsx --fix && yarn prettify" 11 | }, 12 | "dependencies": { 13 | "axios": "^0.21.1", 14 | "babel-eslint": "^10.1.0", 15 | "commitizen": "^4.2.4", 16 | "cz-conventional-changelog": "^3.3.0", 17 | "eslint-plugin-babel": "^5.3.1", 18 | "naughty-words": "^1.2.0", 19 | "next": "latest", 20 | "next-themes": "^0.0.15", 21 | "postcss-preset-env": "^6.7.0", 22 | "react": "^17.0.2", 23 | "react-dom": "^17.0.2", 24 | "react-loading-skeleton": "^2.2.0", 25 | "react-select": "^4.3.1" 26 | }, 27 | "devDependencies": { 28 | "autoprefixer": "^10.2.6", 29 | "eslint": "^7.32.0", 30 | "eslint-config-airbnb": "^18.2.1", 31 | "eslint-config-next": "^11.0.1", 32 | "eslint-config-prettier": "^8.3.0", 33 | "eslint-plugin-import": "^2.23.4", 34 | "eslint-plugin-jsx-a11y": "^6.4.1", 35 | "eslint-plugin-prettier": "^3.4.0", 36 | "eslint-plugin-react": "^7.24.0", 37 | "eslint-plugin-react-hooks": "^4.2.0", 38 | "postcss": "^8.3.5", 39 | "prettier": "^2.3.2", 40 | "tailwindcss": "^2.2.7" 41 | }, 42 | "config": { 43 | "commitizen": { 44 | "path": "cz-conventional-changelog" 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /pages/404.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link' 2 | 3 | const NotFound = () => { 4 | return ( 5 |
6 |
7 |

Ooops...

8 |

That page cannot be found :(

9 |

10 | Go back to the{' '} 11 | 12 | Homepage 13 | 14 |

15 |
16 |
17 | ) 18 | } 19 | 20 | export default NotFound 21 | -------------------------------------------------------------------------------- /pages/_app.js: -------------------------------------------------------------------------------- 1 | import 'tailwindcss/tailwind.css' 2 | import './index.css' 3 | import { ThemeProvider } from 'next-themes' 4 | 5 | function MyApp({ Component, pageProps }) { 6 | return ( 7 | 8 | 9 | 10 | ) 11 | } 12 | 13 | export default MyApp 14 | -------------------------------------------------------------------------------- /pages/index.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | .card { 6 | @apply relative m-3 overflow-hidden shadow-xl rounded-2xl; 7 | } 8 | .card-zoom { 9 | @apply relative transition-all duration-500 ease-in-out flex items-center justify-center m-3 w-80; 10 | } 11 | 12 | .card-zoom-image { 13 | @apply max-h-72 lg:max-h-80 transform; 14 | } 15 | 16 | .list-card-zoom { 17 | @apply relative transition-all duration-500 ease-in-out flex items-center justify-center m-3 w-80 h-56 lg:w-100 lg:h-80; 18 | } 19 | 20 | .card-zoom:hover { 21 | @apply scale-105; 22 | } 23 | 24 | .list-card-zoom:hover { 25 | @apply scale-105; 26 | } 27 | -------------------------------------------------------------------------------- /pages/index.js: -------------------------------------------------------------------------------- 1 | import Head from 'next/head' 2 | import axios from 'axios' 3 | import ImageListing from '../components/ImageListing/ImageListing' 4 | import ScrollToTopButton from '../components/ScrollToTopButton/ScrollToTopButton' 5 | export default function Home({ imageData }) { 6 | return ( 7 | <> 8 | 9 | pixelsHash 10 | 14 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |
44 | {imageData === null ? ( 45 |
46 |
47 |

Ooops...

48 |

49 | Something went wrong. Try again later :( 50 |

51 |
52 |
53 | ) : ( 54 |
55 | 56 | 57 |
58 | )} 59 |
60 | 61 | ) 62 | } 63 | 64 | export const getStaticProps = async () => { 65 | let imageData = null 66 | try { 67 | const response = await axios.get( 68 | `https://api.unsplash.com/search/photos?client_id=${process.env.NEXT_PUBLIC_UNSPLASH_API_ACCESS_KEY}&query=code&page=1&per_page=10`, 69 | ) 70 | if (response.status === 200) { 71 | imageData = response.data 72 | } 73 | } catch (error) { 74 | console.log(error.response) 75 | } 76 | return { 77 | props: { imageData }, 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | // If you want to use other PostCSS plugins, see the following: 2 | // https://tailwindcss.com/docs/using-with-preprocessors 3 | module.exports = { 4 | plugins: ['tailwindcss', 'postcss-preset-env'], 5 | } 6 | -------------------------------------------------------------------------------- /public/android-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/android-icon-144x144.png -------------------------------------------------------------------------------- /public/android-icon-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/android-icon-192x192.png -------------------------------------------------------------------------------- /public/android-icon-36x36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/android-icon-36x36.png -------------------------------------------------------------------------------- /public/android-icon-48x48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/android-icon-48x48.png -------------------------------------------------------------------------------- /public/android-icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/android-icon-72x72.png -------------------------------------------------------------------------------- /public/android-icon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/android-icon-96x96.png -------------------------------------------------------------------------------- /public/apple-icon-114x114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/apple-icon-114x114.png -------------------------------------------------------------------------------- /public/apple-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/apple-icon-120x120.png -------------------------------------------------------------------------------- /public/apple-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/apple-icon-144x144.png -------------------------------------------------------------------------------- /public/apple-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/apple-icon-152x152.png -------------------------------------------------------------------------------- /public/apple-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/apple-icon-180x180.png -------------------------------------------------------------------------------- /public/apple-icon-57x57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/apple-icon-57x57.png -------------------------------------------------------------------------------- /public/apple-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/apple-icon-60x60.png -------------------------------------------------------------------------------- /public/apple-icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/apple-icon-72x72.png -------------------------------------------------------------------------------- /public/apple-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/apple-icon-76x76.png -------------------------------------------------------------------------------- /public/apple-icon-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/apple-icon-precomposed.png -------------------------------------------------------------------------------- /public/apple-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/apple-icon.png -------------------------------------------------------------------------------- /public/browserconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | #ffffff -------------------------------------------------------------------------------- /public/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/favicon-16x16.png -------------------------------------------------------------------------------- /public/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/favicon-32x32.png -------------------------------------------------------------------------------- /public/favicon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/favicon-96x96.png -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/favicon.ico -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "App", 3 | "icons": [ 4 | { 5 | "src": "\/android-icon-36x36.png", 6 | "sizes": "36x36", 7 | "type": "image\/png", 8 | "density": "0.75" 9 | }, 10 | { 11 | "src": "\/android-icon-48x48.png", 12 | "sizes": "48x48", 13 | "type": "image\/png", 14 | "density": "1.0" 15 | }, 16 | { 17 | "src": "\/android-icon-72x72.png", 18 | "sizes": "72x72", 19 | "type": "image\/png", 20 | "density": "1.5" 21 | }, 22 | { 23 | "src": "\/android-icon-96x96.png", 24 | "sizes": "96x96", 25 | "type": "image\/png", 26 | "density": "2.0" 27 | }, 28 | { 29 | "src": "\/android-icon-144x144.png", 30 | "sizes": "144x144", 31 | "type": "image\/png", 32 | "density": "3.0" 33 | }, 34 | { 35 | "src": "\/android-icon-192x192.png", 36 | "sizes": "192x192", 37 | "type": "image\/png", 38 | "density": "4.0" 39 | } 40 | ] 41 | } -------------------------------------------------------------------------------- /public/ms-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/ms-icon-144x144.png -------------------------------------------------------------------------------- /public/ms-icon-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/ms-icon-150x150.png -------------------------------------------------------------------------------- /public/ms-icon-310x310.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/ms-icon-310x310.png -------------------------------------------------------------------------------- /public/ms-icon-70x70.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/ms-icon-70x70.png -------------------------------------------------------------------------------- /public/pixelsHashLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sohamsshah/pixelsHash/98233c71811f5f692b54dbd9a98c4afb5023307b/public/pixelsHashLogo.png -------------------------------------------------------------------------------- /public/vercel.svg: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | mode: 'jit', 3 | purge: ['./pages/**/*.{js,ts,jsx,tsx}', './components/**/*.{js,ts,jsx,tsx}'], 4 | darkMode: 'class', 5 | theme: { 6 | extend: { 7 | cursor: { 8 | 'zoom-in': 'zoom-in', 9 | }, 10 | width: { 11 | 100: '40rem', 12 | 125: '50rem', 13 | 150: '60rem', 14 | }, 15 | height: { 16 | 100: '30rem', 17 | 125: '50rem', 18 | }, 19 | }, 20 | }, 21 | variants: { 22 | extend: {}, 23 | }, 24 | plugins: [require('tailwindcss'), require('autoprefixer')], 25 | } 26 | -------------------------------------------------------------------------------- /utils/formatDate.js: -------------------------------------------------------------------------------- 1 | export const formatDate = (date) => { 2 | let d = new Date(date) 3 | let ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d) 4 | let mo = new Intl.DateTimeFormat('en', { month: 'long' }).format(d) 5 | let da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(d) 6 | return `${da} ${mo} ${ye}` 7 | } 8 | -------------------------------------------------------------------------------- /utils/hooks/useIntersectionObserver.js: -------------------------------------------------------------------------------- 1 | import { useState, useRef, useEffect } from 'react' 2 | 3 | export function useIntersectionObserver(ref, options, forward = true) { 4 | const [element, setElement] = useState(null) 5 | const [isIntersecting, setIsIntersecting] = useState(false) 6 | const observer = useRef(null) 7 | 8 | const cleanOb = () => { 9 | if (observer.current) { 10 | observer.current.disconnect() 11 | } 12 | } 13 | 14 | useEffect(() => { 15 | setElement(ref.current) 16 | }, [ref]) 17 | 18 | useEffect(() => { 19 | if (!element) return 20 | cleanOb() 21 | observer.current = new IntersectionObserver( 22 | ([entry]) => { 23 | const isElementIntersecting = entry.isIntersecting 24 | if (!forward) { 25 | setIsIntersecting(isElementIntersecting) 26 | } else if (forward && !isIntersecting && isElementIntersecting) { 27 | setIsIntersecting(isElementIntersecting) 28 | cleanOb() 29 | } 30 | }, 31 | { ...options }, 32 | ) 33 | const ob = observer.current 34 | ob.observe(element) 35 | ;() => { 36 | cleanOb() 37 | } 38 | }, [element, options, isIntersecting, forward]) 39 | 40 | return isIntersecting 41 | } 42 | --------------------------------------------------------------------------------