Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_API_KEY=731a6fa24765316e8e44e6e18157a6bd
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally you don't check .env into your repo cause it exposes things that shouldn't be public like keys. you would want to put this in your .gitignore

18 changes: 18 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
"wesbos"
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
"no-console": 2,
},
}
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
## Weather Project
# Redux Weather App

This project has been created by a student at Parsity, an online software engineering course. The work in this repository is wholly of the student based on a sample starter project that can be accessed by looking at the repository that this project forks.
Search a city name and get back three graphs displaying the temperature, pressure, humidity, and corresponding averages for that city over the next 5 days. This app was built with React using Vite, Redux, and utilizes the [OpenWeather API](https://openweathermap.org/).

If you have any questions about this project or the program in general, visit [parsity.io](https://parsity.io/) or email [email protected].
## Run Locally

To run locally, fork and clone this repository. `cd` into the directory you created and execute the following commands:

```
npm install
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice job on the readme! it is great to put all instructions on how to run the app in here.

npm run dev
```

Now you can type a city name into the input box and retrieve weather data about it. If you get an error, check your spelling. If the city you want isn't coming up, enter the city, state, and two-letter country ISO code (for example, "Chicago, Illinois, US").
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
40,725 changes: 3,886 additions & 36,839 deletions package-lock.json

Large diffs are not rendered by default.

56 changes: 29 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
{
"name": "redux-weather",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.10",
"@testing-library/react": "^11.2.6",
"@testing-library/user-event": "^12.8.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"web-vitals": "^1.1.1"
},
"version": "0.0.0",
"type": "module",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"dev": "vite",
"build": "vite build",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"preview": "vite preview"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
"wesbos"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
"dependencies": {
"@reduxjs/toolkit": "^1.9.7",
"axios": "^1.5.1",
"bootstrap": "^5.3.2",
"eslint-config-wesbos": "^3.2.3",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-bootstrap": "^2.9.1",
"react-dom": "^18.2.0",
"react-redux": "^8.1.3",
"react-sparklines": "^1.7.0"
},
"devDependencies": {
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.3",
"eslint": "^8.45.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"vite": "^4.4.5"
}
}
Binary file removed public/favicon.ico
Binary file not shown.
43 changes: 0 additions & 43 deletions public/index.html

This file was deleted.

Binary file removed public/logo192.png
Binary file not shown.
Binary file removed public/logo512.png
Binary file not shown.
25 changes: 0 additions & 25 deletions public/manifest.json

This file was deleted.

3 changes: 0 additions & 3 deletions public/robots.txt

This file was deleted.

1 change: 1 addition & 0 deletions public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 0 additions & 38 deletions src/App.css

This file was deleted.

25 changes: 0 additions & 25 deletions src/App.js

This file was deleted.

62 changes: 62 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { useState } from 'react';
import Container from 'react-bootstrap/Container';
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
import Button from 'react-bootstrap/Button';
import Form from 'react-bootstrap/Form';
import InputGroup from 'react-bootstrap/InputGroup';

import { useDispatch } from 'react-redux';
import WeatherTable from './components/WeatherTable';
import { searchForCity } from './reducers/weatherSlice';

function App() {
const [search, setSearch] = useState('');
const dispatch = useDispatch();

const handleInput = (event) => {
setSearch(event.target.value);
};

const handleSearchButton = () => {
if (search !== '') {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be simplified to if (search) - review the concept of truthy and falsy

dispatch(searchForCity(search));
setSearch('');
}
};

const handleEnterKey = (event) => {
if (event.key === 'Enter' && search !== '') {
dispatch(searchForCity(search));
setSearch('');
}
};

return (
<Container fluid="md">
<Row>
<Col>
<InputGroup className="mb-3 mt-3">
<Form.Control
placeholder="Search for a city"
aria-label="Search for a city"
value={search}
onChange={handleInput}
onKeyDown={handleEnterKey}
/>
<Button
variant="outline-secondary"
id="search-button"
onClick={handleSearchButton}
>
Search
</Button>
</InputGroup>
</Col>
</Row>
<WeatherTable />
</Container>
);
}

export default App;
8 changes: 0 additions & 8 deletions src/App.test.js

This file was deleted.

29 changes: 29 additions & 0 deletions src/components/WeatherTable.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';

import { useSelector } from 'react-redux';
import WeatherTableList from './WeatherTableList';

export default function WeatherTable() {
const currentCity = useSelector((state) => state.weather.currentSearch);

return (
<>
<hr />
<Row className="text-center">
<Col>City</Col>
<Col>Temperature (F)</Col>
<Col>Pressure (hPa)</Col>
<Col>Humidity (%)</Col>
</Row>
<hr />
{currentCity !== '' ? (
<WeatherTableList />
) : (
<h4 className="text-center">
Search for a city to see weather data displayed here
</h4>
)}
</>
);
}
Loading