Giter Site home page Giter Site logo

canriquez / my-weather-app Goto Github PK

View Code? Open in Web Editor NEW
10.0 0.0 2.0 7.37 MB

Weather Data Site using a weather API on Vanilla JavaScript

License: MIT License

JavaScript 73.45% CSS 26.55%
html5 css3 webpack eslint stylelint javascript unsplash-api openweathermap-api ipstack

my-weather-app's Introduction

My Weather App alt textalt textalt textalt text

Dynamic Weather App. Built with JavaScript HTML/CSS and API services.

Project Details

The app uses information from the following main APIs:

  • Openweathermap.org API for worldwide city weather information. You will need to create an account and generate a private API key.
  • Cloudflare for Fetching client's current public IP.
  • FreeGeoIp.app for Public IP to City & Country name service API. Initially I have used ipstack service, but since the free tier does not offer secure session connectivity, http fetch calls created 'mixed content' problems, and browsers would block this source. With FreeGEoIp I have fixed this issue.
  • Unsplash for great weather images service API. You will need to create an account and generate a private API key.

live demo

live app @Netlify

Key design information

  • The app uses myCity factory function to store key weather information and basic methods used to manage app logic sequences.
  • All API services are managed using function collections hosted in specific files (components), exposed using the module pattern.
  • applogic.js contains the main functions organizing the initial session weather search. #initSessionWeather() method would organize the module methods to get the user's IP (IPv6 / IPv4), coordinates, and a final query to the open weather map API to get the initial nearby city for the first weather readout. initCityQueryWeather() would organize an Adhoc query for a specific city.
  • DisplayController module contains all functions to handle the screen renders.
  • The Barometer Arrow uses a set of formulas to "translate" the weather description id openweathermap.org weather conditions codes into correspondent degrees used by the CSS transform property "rotate", to point to the right weather description icon.
            case (id >= 800 && id <= 804):
                return ((-8.249289925 * id * id) + (13208.61119 * id) - 5287208.395);
            case (id >= 701 && id <= 781):
                return ((-1.57282646E-3 * id * id) + (1.82322848 * id) - 465.3239501);
            case (id >= 200 && id <= 232):
                return ((2.079436717E-2 * id * id) + (-10.08168264 * id) + 1121.535281);
            case (id >= 300 && id <= 321):
                return ((-5.028726802E-2 * id * id) + (30.48646455 * id) - 4632.223787);
            case (id >= 500 && id <= 531):
                return ((1.112129237E-2 * id * id) + (-12.52634698 * id) + 3454.698266);
            case (id >= 600 && id <= 622):
                return ((-5.678032989E-2 * id * id) + (68.48273427 * id) - 20770.321);
  • The details for these equations and the data source used for the calculations are hosted in the /src/docs folder.

User Story

  • The user accesses the live link, and immediately the app fetches the current user IP and queries estimated nearby city weather. This initial information gets displayed on the weather dashboard from the start.

  • The user can change the city by clicking/touching the city name displayed on the dashboard.

  • If the new city name is found, the dashboard will render the current weather information.

  • The barometer arrow (simil analogic arrow) and the wind arrow alt text icon will turn pointing to the current weather description after a new city is searched and found.

  • Temperature and Wind units will toggle between metric and imperial system, by clicking / touching the icon alt text . The temperature units will toggle between Centigrades and Faranhaid on each click of the icon. The same will ocurr for wid speed between km/h and mph units.

Dashboard design inspiration:

Background photography credits (Unsplash)

  • The app sources random background pictures using the 'weather description' as a keyword for the picture theme.
  • Each image is properly credited dynamically. Picture's creator username and portfolio link display at the bottom of the main app screen.

Built With

  • HTML/CSS, Javascript, Webpack, NPM, yarn.
  • ESlint, Stylelint
  • VSCode

Getting Started

To get a local copy up and running, follow these simple example steps.

Prerequisites

  • To install the app in your system, make sure you have node/npm installed. get npm

Setup

  • Clone the repository in your system by using:

git clone

  • The app uses the library "dotenv-webpack" to handle all secrets and API keys for every used service.
  • After cloning the repo, create a file .env to include all the necesary api keys. Create the accounts in each service and complete the .env file as follows:
WEATHER_API_KEY =<add your API key>
UNS_API=<add your API key>

Install

  • Next step is to CD into the local repository and run:

  • npm install

  • npm run build

Author

๐Ÿ‘ค Carlos Anriquez

๐Ÿค Contributing

Contributions, issues, and feature requests are welcome!

Feel free to check the issues page.

Show your support

Give a โญ๏ธ if you like this project!

Acknowledgments

  • Family, always my family.
  • @Torres-ssf helping me out troubleshoot IPv6 Edge cases from Curitiba / Brasil! Thanks Sergio!
  • The Beagles!

๐Ÿ“ License

This project is MIT licensed.

my-weather-app's People

Contributors

canriquez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

my-weather-app's Issues

Feedback from Beagles

We like the application.
Clifton: The best feature is the barometer arrow and the algorithmic solution.

  • Add the C to F switch.
  • Feature: Add the feature to query weather API using city ID (reworking cities Json File).
  • Feature: Add additional AI to check random Unsplash image so dash contrast does not get messed up and is still visible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.