├── public
├── favicon.ico
├── icons
│ ├── 01d.png
│ ├── 01n.png
│ ├── 02d.png
│ ├── 02n.png
│ ├── 03d.png
│ ├── 03n.png
│ ├── 04d.png
│ ├── 04n.png
│ ├── 09d.png
│ ├── 09n.png
│ ├── 10d.png
│ ├── 10n.png
│ ├── 11d.png
│ ├── 11n.png
│ ├── 13d.png
│ ├── 13n.png
│ ├── 50d.png
│ ├── 50n.png
│ └── unknown.png
├── logo192.png
├── logo512.png
├── robots.txt
├── manifest.json
└── index.html
├── src
├── index.js
├── index.css
├── api.js
├── App.js
├── Components
│ └── WeatherCard.jsx
├── App.css
└── logo.svg
├── .gitignore
├── package.json
└── README.md
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/public/icons/01d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/icons/01d.png
--------------------------------------------------------------------------------
/public/icons/01n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/icons/01n.png
--------------------------------------------------------------------------------
/public/icons/02d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/icons/02d.png
--------------------------------------------------------------------------------
/public/icons/02n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/icons/02n.png
--------------------------------------------------------------------------------
/public/icons/03d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/icons/03d.png
--------------------------------------------------------------------------------
/public/icons/03n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/icons/03n.png
--------------------------------------------------------------------------------
/public/icons/04d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/icons/04d.png
--------------------------------------------------------------------------------
/public/icons/04n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/icons/04n.png
--------------------------------------------------------------------------------
/public/icons/09d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/icons/09d.png
--------------------------------------------------------------------------------
/public/icons/09n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/icons/09n.png
--------------------------------------------------------------------------------
/public/icons/10d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/icons/10d.png
--------------------------------------------------------------------------------
/public/icons/10n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/icons/10n.png
--------------------------------------------------------------------------------
/public/icons/11d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/icons/11d.png
--------------------------------------------------------------------------------
/public/icons/11n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/icons/11n.png
--------------------------------------------------------------------------------
/public/icons/13d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/icons/13d.png
--------------------------------------------------------------------------------
/public/icons/13n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/icons/13n.png
--------------------------------------------------------------------------------
/public/icons/50d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/icons/50d.png
--------------------------------------------------------------------------------
/public/icons/50n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/icons/50n.png
--------------------------------------------------------------------------------
/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/logo192.png
--------------------------------------------------------------------------------
/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/logo512.png
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/public/icons/unknown.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imtiyazCode/weatherApp/HEAD/public/icons/unknown.png
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom/client';
3 | import './index.css';
4 | import App from './App';
5 |
6 | const root = ReactDOM.createRoot(document.getElementById('root'));
7 | root.render(
8 |
9 |
10 |
11 | );
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/src/api.js:
--------------------------------------------------------------------------------
1 | import axios from "axios";
2 |
3 | export async function fetchWeather(city, setError) {
4 | console.log(process.env.REACT_APP_API_KEY);
5 | const url = `https://api.openweathermap.org/data/2.5/weather?q=${city}&appid=${process.env.REACT_APP_API_KEY}`;
6 |
7 | try {
8 | const response = await axios.get(url);
9 | setError("");
10 | return response.data;
11 | } catch (error) {
12 | setError("City Not Found!");
13 | return error;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/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/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
14 | Weather App
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "weather-app",
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": "^13.5.0",
9 | "axios": "^1.2.4",
10 | "dotenv": "^16.0.3",
11 | "react": "^18.2.0",
12 | "react-dom": "^18.2.0",
13 | "react-scripts": "5.0.1",
14 | "web-vitals": "^2.1.4"
15 | },
16 | "scripts": {
17 | "start": "react-scripts start",
18 | "build": "react-scripts build",
19 | "test": "react-scripts test",
20 | "eject": "react-scripts eject"
21 | },
22 | "eslintConfig": {
23 | "extends": [
24 | "react-app",
25 | "react-app/jest"
26 | ]
27 | },
28 | "browserslist": {
29 | "production": [
30 | ">0.2%",
31 | "not dead",
32 | "not op_mini all"
33 | ],
34 | "development": [
35 | "last 1 chrome version",
36 | "last 1 firefox version",
37 | "last 1 safari version"
38 | ]
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import './App.css';
2 | import { useState } from 'react';
3 | import { fetchWeather } from './api';
4 | import WeatherCard from './Components/WeatherCard';
5 |
6 | function App() {
7 | const [city, setCity] = useState('');
8 | const [weather, setWeather] = useState(null)
9 | const [error, setError] = useState('')
10 |
11 | const handleChange = (event) => {
12 | setCity(event.target.value);
13 | };
14 |
15 | const handleSubmit = async (event) => {
16 | event.preventDefault();
17 | try {
18 | const weather = await fetchWeather(city, setError);
19 | setWeather(weather);
20 | } catch (error) {
21 | setError("City not found");
22 | }
23 | };
24 |
25 | return (
26 |
27 |
Weather App
28 |
37 |
38 | {error ? (
39 |
{error}
40 | ) : (
41 |
42 | )}
43 |
44 | );
45 | }
46 |
47 | export default App;
48 |
--------------------------------------------------------------------------------
/src/Components/WeatherCard.jsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | const WeatherCard = ({ weather }) => {
4 | return (
5 |
6 |
7 |
8 |
9 | {weather ? weather.name + " " + weather.sys.country : "-"}
10 |
11 | {weather ? weather.weather[0].description : "-"}
12 |
13 |

15 |
16 |
17 |
18 | {weather ? Math.round(weather.main?.temp - 273.15) : ""}°C
19 |
20 |
21 | Details
22 |
23 |
24 | Feels Like:
25 |
26 | {weather ? (weather.main?.feels_like - 273.15).toFixed(2) : "-"} °C
27 |
28 |
29 |
30 | Humidity:
31 |
32 | {weather ? weather.main?.humidity : "-"} %
33 |
34 |
35 | Pressure:
36 |
37 | {weather ? weather.main?.pressure : "-"} hPs
38 |
39 |
40 |
41 |
42 | );
43 | };
44 |
45 | export default WeatherCard;
--------------------------------------------------------------------------------
/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | font-family: "Roboto", Arial, sans-serif !important;
3 | -webkit-font-smoothing: antialiased;
4 | -moz-osx-font-smoothing: grayscale;
5 | }
6 |
7 | form {
8 | display: flex;
9 | align-items: center;
10 | justify-content: center;
11 | margin-top: 50px;
12 | }
13 |
14 | input {
15 | padding: 10px;
16 | font-size: 18px;
17 | margin-right: 10px;
18 | border-radius: 6px;
19 | }
20 |
21 | button {
22 | padding: 10px 20px;
23 | font-size: 18px;
24 | background-color: #333;
25 | color: white;
26 | border: none;
27 | cursor: pointer;
28 | border-radius: 6px;
29 | }
30 |
31 | .app_heading {
32 | margin-top: 50px;
33 | text-align: center;
34 | }
35 |
36 | .weather-data {
37 | display: flex;
38 | flex-wrap: wrap;
39 | justify-content: center;
40 | margin-top: 50px;
41 | }
42 |
43 | .weather-data p {
44 | font-size: 18px;
45 | margin: 10px;
46 | }
47 |
48 | p.error {
49 | color: red;
50 | text-align: center;
51 | margin-top: 50px;
52 | font-size: 1.2rem;
53 | }
54 |
55 | /* hdfgd */
56 | .weather-card {
57 | width: 300px;
58 | border-radius: 6px;
59 | box-shadow: 10px -2px 20px 2px rgb(0 0 0 / 30%);
60 | color: #fff;
61 | background-color: #333;
62 | margin: 20px auto 0 auto;
63 | padding: 0 20px 20px 20px;
64 | }
65 |
66 | .card-header,
67 | .card-body {
68 | display: flex;
69 | justify-content: space-between;
70 | align-items: center;
71 | }
72 |
73 | .weather-city {
74 | font-weight: 600;
75 | font-size: 18px;
76 | line-height: 1;
77 | margin: 0;
78 | letter-spacing: 1px;
79 | }
80 |
81 | .weather-description {
82 | font-weight: 400;
83 | font-size: 14px;
84 | line-height: 1;
85 | margin: 0;
86 | }
87 |
88 | .weather-icon {
89 | width: 100px;
90 | }
91 |
92 | .weather-temp {
93 | font-weight: 600;
94 | font-size: 70px;
95 | width: auto;
96 | letter-spacing: -5px;
97 | margin: 10px 0;
98 | }
99 |
100 | .weather-details {
101 | width: 100%;
102 | padding-left: 20px;
103 | }
104 |
105 | .parameters {
106 | display: flex;
107 | justify-content: space-between;
108 | }
109 |
110 | .param-label {
111 | text-align: left;
112 | font-weight: 400;
113 | font-size: 12px;
114 | }
115 |
116 | .param-val {
117 | text-align: right;
118 | font-weight: 600;
119 | font-size: 12px;
120 | }
--------------------------------------------------------------------------------
/src/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Create React App
2 |
3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4 |
5 | ## Available Scripts
6 |
7 | In the project directory, you can run:
8 |
9 | ### `npm start`
10 |
11 | Runs the app in the development mode.\
12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13 |
14 | The page will reload when you make changes.\
15 | You may also see any lint errors in the console.
16 |
17 | ### `npm test`
18 |
19 | Launches the test runner in the interactive watch mode.\
20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21 |
22 | ### `npm run build`
23 |
24 | Builds the app for production to the `build` folder.\
25 | It correctly bundles React in production mode and optimizes the build for the best performance.
26 |
27 | The build is minified and the filenames include the hashes.\
28 | Your app is ready to be deployed!
29 |
30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31 |
32 | ### `npm run eject`
33 |
34 | **Note: this is a one-way operation. Once you `eject`, you can't go back!**
35 |
36 | If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37 |
38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
39 |
40 | You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
41 |
42 | ## Learn More
43 |
44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45 |
46 | To learn React, check out the [React documentation](https://reactjs.org/).
47 |
48 | ### Code Splitting
49 |
50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51 |
52 | ### Analyzing the Bundle Size
53 |
54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55 |
56 | ### Making a Progressive Web App
57 |
58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59 |
60 | ### Advanced Configuration
61 |
62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63 |
64 | ### Deployment
65 |
66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67 |
68 | ### `npm run build` fails to minify
69 |
70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
71 |
--------------------------------------------------------------------------------