Skip to content

katiaipduarte/react-weather-app

Repository files navigation

React Weather App

Welcome to my Weather App, where you can enter a location to fetch the current weather or see the weather in you current location. You can also add a new city to the favourites, and also delete it.

Demo at: https://katiaipduarte.github.io/react-weather-app/#/

The app was created with create-react-app, redux, typescript and styled-components for styling. See the full create-react-app guide, redux and redux toolkit. Thank you for using my app.

Table of Contents

Installation

To use this app, first clone from GitHub via 'git clone https://github.com/katiaipduarte/react-weather-app.git' at your terminal, cd to the new directory, then run npm install. Before running this project, you will need to create a .env.local file, with the same env as the ones in the .env.example. At last, run npm run start to launch your http server.

API Keys

This project is connected to 3 external API.

Future Work

[ ] Add more unit tests and integration ones
[ ] Add page transition loader
[ ] Have just one API to deal with locations and coordinates
[ ] Add authentication
[ ] Connect the website to a database, so we can save the favourites for each user (currently done via cookies)
[ ] Add different background and card images, taking into account the location selected
[ ] Add cookies to save recently viewed locations

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/katiaipduarte/react-weather-app. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The code is available as open source under the terms of the MIT License.

Folder Structure

After creation, your project should look like this:

my-app/
  README.md
  node_modules/
  package.json
  public/
    index.html
    favicon.ico
  src/
    assets/
    components/
    interfaces/
      dto/
    lib/
    pages/
    store/
    styles/
      index.ts
    utils/
    App.tsx
    index.css
    index.tsx

For the project to build, these files must exist with exact filenames:

  • public/index.html is the page template;
  • src/index.tsx is the TypeScript entry point.
  • src/components is the folder that houses all the components used.
  • src/interfaces is the folder with all the interfaces/type files used in the components.
  • src/lib is the folder for all the services/providers.
  • src/pages is the folder that contains the files with the initial logic used for each route.
  • src/store is the folder with the redux logic.
  • src/style is the folder with typography, reset and any other style rules shared by all React components.
  • src/utils is the folder with helper functions.

You may create subdirectories inside src. For faster rebuilds, only files inside src are processed by Webpack.
You need to put any TypeScript and styles files inside src, otherwise Webpack won’t see them.

Only files inside public can be used from public/index.html.

Routes

/
/current-location
/favourites
/:city/:country

The last route can be accessed by two ways, using the search bar and selecting one option or putting directly in a city and country in the url path.

Available Scripts

In the project directory, you can run:

yarn start or npm start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

yarn test or npm test

Launches the test runner in the interactive watch mode.
See the section about running tests for more information.

yarn build or npm run build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about deployment for more information.

yarn eject or npm run eject

Note: this is a one-way operation. Once you eject, you can’t go back!

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.

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.

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.

npm run lint

Automatic linting, with rules to work with TypeScript and React. The src/serviceWorker.ts file and the node_modulesm folder are not included.

This is runned each time you do a commit and a push it to your branch.

For more information see the ESLint documentation.

npm run format

Command to format the code according to the rules that can be found in .prettierrc. The node_modules folder is not included.

This will be automatically run each time you do a commit.

For more information see the Prettier documentation.

npm run predeploy

This commands basically, runs the npm run build command. To read more just check yarn build or npm run build.

npm run deploy

Command to deploy the current application using Github Pages. If you forked this project onto a repository of your own, do not forget to create a gh-pages branch, before running this command.

To learn more about how to deploy a CRA app using Github Pages, go to this link.