├── .env.example
├── .gitignore
├── .prettierrc.json
├── README.md
├── package.json
├── pnpm-lock.yaml
├── public
├── favicon.ico
├── index.html
├── logo192.png
├── logo512.png
├── manifest.json
└── robots.txt
├── src
├── App.js
├── components
│ ├── layout
│ │ ├── Alert.jsx
│ │ ├── Footer.jsx
│ │ ├── Navbar.jsx
│ │ ├── Spinner.jsx
│ │ └── assets
│ │ │ └── spinner.gif
│ ├── repos
│ │ ├── RepoItem.jsx
│ │ └── RepoList.jsx
│ └── users
│ │ ├── UserItem.jsx
│ │ ├── UserResults.jsx
│ │ └── UserSearch.jsx
├── context
│ ├── alert
│ │ ├── AlertContext.js
│ │ └── AlertReducer.js
│ └── github
│ │ ├── GithubActions.js
│ │ ├── GithubContext.js
│ │ └── GithubReducer.js
├── index.css
├── index.js
└── pages
│ ├── About.jsx
│ ├── Home.jsx
│ ├── NotFound.jsx
│ └── User.jsx
└── tailwind.config.js
/.env.example:
--------------------------------------------------------------------------------
1 | REACT_APP_GITHUB_URL = "https://api.github.com"
2 | REACT_APP_GITHUB_TOKEN="ADD_YOUR_TOKEN"
--------------------------------------------------------------------------------
/.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 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env
17 | .env.local
18 | .env.development.local
19 | .env.test.local
20 | .env.production.local
21 |
22 | npm-debug.log*
23 | yarn-debug.log*
24 | yarn-error.log*
25 |
--------------------------------------------------------------------------------
/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 80,
3 | "tabWidth": 2,
4 | "useTabs": false,
5 | "semi": false,
6 | "singleQuote": true,
7 | "bracketSpacing": true,
8 | "jsxSingleQuote": true,
9 | "trailingComma": "es5"
10 | }
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Github Finder App
2 |
3 | App to search Github users and display their info. This is part of my React Front To Back 2022 course and is the most up to date version of this project.
4 |
5 | ---
6 |
7 | ### Bug Fixes, corrections and code FAQ
8 |
9 | The repository code here on the main branch has been updated due to bugs and issues found by students since the course was released.
10 | If you are looking for exact code from the course then please check out the [originalcoursecode branch](https://github.com/bradtraversy/github-finder-app/tree/originalcoursecode) of this repository.
11 |
12 | The updates here aim to be a reference and resource for common questions asked
13 | by students in the Udemy Q&A and for those wishing to make corrections to the
14 | project.
15 |
16 | #### Q: How do I remove the user stats scroll bars that show on mobile devices
17 |
18 | Code changes for this fix can be seen in [User.jsx](src/pages/User.jsx)
19 |
20 | #### BUG: I can't see the alert text
21 |
22 | Most likely you have the default light theme provided by DaisyUI. The theme is
23 | set based on a `prefers-colorscheme` media query, so you may have a light theme
24 | if you have a light browser theme or OS theme. In which case you won't see the
25 | text in the alert show.
26 | Code changes to fix this can be seen in [Alert.jsx](src/components/layout/Alert.jsx)
27 | The changes here use a [ DaisyUI Alert component ](https://daisyui.com/components/alert/) so will adapt with a change in theme.
28 | We also now conditionally set the element visibility to **'visible'** or
29 | **'hidden'** rather than conditionally render, which prevents content shift when
30 | the alert shows for a smoother UX.
31 |
32 | #### Q: Why doesn't Craco work?
33 |
34 | You don't need to use craco if you are using react-scripts version 5 or greater.
35 |
36 | When Brad recorded the course react-scripts was at version 4 and didn't support postcss, now react-scripts is at version 5 and does support postcss.
37 | So just check what version of react-scripts you have...
38 |
39 | npm list react-scripts
40 |
41 | If it's at version 5 or greater then follow the [ Tailwind version 3 ](https://tailwindcss.com/docs/guides/create-react-app) docs to setup.
42 |
43 | If react-scripts is at version 4 then follow the [ Tailwind version 2 ](https://v2.tailwindcss.com/docs/guides/create-react-app) docs to setup, which is what you see Brad doing in the course.
44 |
45 | #### BUG: Linking to users websites
46 |
47 | Some users from Github have already prefixed their websites with `http://` or
48 | `https://` so we need to check in [User.jsx](src/pages/User.jsx) if their
49 | website url starts with `http` before constructing the external link.
50 | Code changes can be see in [User.jsx](src/pages/User.jsx#L48)
51 |
52 | #### BUG: Light theme RepoItem background is too dark
53 |
54 | The theme is set based on a `prefers-colorscheme` media query, so you may have a light theme
55 | if you have a light browser theme or OS theme.
56 | When the browser's preferred color scheme is light, the gray background is too dark on the RepoItem component, and the content is not visible.
57 |
58 | Using `base-200` and `base-300` backgrounds, will make the component's background change according to the browser's preference.
59 |
60 | > Code changes can be seen in
61 | > [RepoItem.jsx](src/components/repos/RepoItem.jsx#L17)
62 |
63 | ---
64 |
65 | ## Usage
66 |
67 | Rename **_.env.example_** to **_.env_**
68 |
69 | You can use the Github API without a personal token, but if you want to use your token, add it to the .env file
70 |
71 | Learn how to create a token [here](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)
72 |
73 | ### Install Dependencies
74 |
75 | ```
76 | npm install
77 | ```
78 |
79 | ### Run
80 |
81 | ```
82 | npm start
83 | ```
84 |
85 | Tailwind UI created by [Hassib Moddasser](https://twitter.com/hassibmoddasser)
86 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "github-finder",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.16.5",
7 | "@testing-library/react": "^13.4.0",
8 | "@testing-library/user-event": "^14.4.3",
9 | "axios": "^1.3.2",
10 | "daisyui": "^2.50.0",
11 | "prop-types": "^15.8.1",
12 | "react": "^18.2.0",
13 | "react-dom": "^18.2.0",
14 | "react-icons": "^4.7.1",
15 | "react-router-dom": "^6.8.1",
16 | "react-scripts": "5.0.1",
17 | "web-vitals": "^3.1.1"
18 | },
19 | "scripts": {
20 | "start": "react-scripts start",
21 | "build": "react-scripts build",
22 | "test": "react-scripts test",
23 | "eject": "react-scripts eject"
24 | },
25 | "eslintConfig": {
26 | "extends": [
27 | "react-app",
28 | "react-app/jest"
29 | ]
30 | },
31 | "browserslist": {
32 | "production": [
33 | ">0.2%",
34 | "not dead",
35 | "not op_mini all"
36 | ],
37 | "development": [
38 | "last 1 chrome version",
39 | "last 1 firefox version",
40 | "last 1 safari version"
41 | ]
42 | },
43 | "devDependencies": {
44 | "tailwindcss": "^3.2.6"
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bradtraversy/github-finder-app/f0901777345a630e10f35c2ad8b8b1b7086fd74f/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | Github Finder
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bradtraversy/github-finder-app/f0901777345a630e10f35c2ad8b8b1b7086fd74f/public/logo192.png
--------------------------------------------------------------------------------
/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bradtraversy/github-finder-app/f0901777345a630e10f35c2ad8b8b1b7086fd74f/public/logo512.png
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import { BrowserRouter as Router, Route, Routes } from 'react-router-dom'
2 | import Navbar from './components/layout/Navbar'
3 | import Footer from './components/layout/Footer'
4 | import Alert from './components/layout/Alert'
5 | import Home from './pages/Home'
6 | import About from './pages/About'
7 | import User from './pages/User'
8 | import NotFound from './pages/NotFound'
9 | import { GithubProvider } from './context/github/GithubContext'
10 | import { AlertProvider } from './context/alert/AlertContext'
11 |
12 | // NOTE: Alert is only used on the '/' route moving to that route we can prevent
13 | // content shift when alert shows by hiding and unhiding the Alert rather than
14 | // conditionally rendering
15 |
16 | function App() {
17 | return (
18 |
19 |
20 |
21 |
44 |
45 |
46 |
47 | )
48 | }
49 |
50 | export default App
51 |
--------------------------------------------------------------------------------
/src/components/layout/Alert.jsx:
--------------------------------------------------------------------------------
1 | import { useContext } from 'react'
2 | import AlertContext from '../../context/alert/AlertContext'
3 |
4 | // NOTE: here we are using the alert component from DaisyUI which works better
5 | // with DaisyUI themes. If you have the Light theme from DaisyUI and can't see
6 | // the text in the alert then this is the change you need.
7 | // We also now conditionally hide the containing div rather than conditionally
8 | // render the alert, this prevents content shift when the alert shows.
9 |
10 | function Alert() {
11 | const { alert } = useContext(AlertContext)
12 |
13 | return (
14 |