npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tokukarin-react-open-weather

v1.1.1

Published

React Weather component

Downloads

3

Readme

React Open Weather


Build Status Coverage Status Code Climate

React open weather is a React Component loading forecast data from OpenWeather API.

Features Implemented:

  1. Showing Today Weather
  2. Showing 5 days Weather Forecast

The Component development is in progress and will contain more features in the future versions.

Demo & Docs

Dependencies

Installation


First you will need to register and account on OpenWeather website and obtain an API key

Next, in your project directory run:

    $ npm install react-open-weather

you will need to add link to weather icons css file in your html file or require it in your build process Weather Icons, or you can directly use the CDN.

<link
  rel="stylesheet"
  href="https://cdnjs.cloudflare.com/ajax/libs/weather-icons/2.0.9/css/weather-icons.min.css"
  type="text/css"
/>

Then in your code file you can import the component

Using ES2015 import

import ReactWeather from 'react-open-weather';
//Optional include of the default css styles
import 'react-open-weather/lib/css/ReactWeather.css';

Using CommonJS

var ReactWeather = require('react-open-weather').default;
//Optional include of the default css styles
require('react-open-weather/lib/css/ReactWeather.css');

UMD build is available with script tag

<script src="node_modules/react-open-weather/lib/js/ReactWeather.js"></script>

Usage


1-Loading today weather data by city name

<ReactWeather
  forecast="today"
  apikey="YOUR_API_KEY"
  type="city"
  city="Munich"
/>

2-Loading today data by longitude and latitude

<ReactWeather
  forecast="today"
  apikey="YOUR_API_KEY"
  type="geo"
  lat="48.1351"
  lon="11.5820"
/>

3-Loading today data based on the current IP address (default)

<ReactWeather forecast="today" apikey="YOUR_API_KEY" type="auto" />

3-Loading 5 days forecast

<ReactWeather
  forecast="5days"
  apikey="YOUR_API_KEY"
  type="city"
  city="Munich"
/>

4-Changing the the units to imperial system

<ReactWeather
  forecast="today"
  unit="imperial"
  apikey="YOUR_API_KEY"
  type="city"
  city="Munich"
/>

5-Changing the language

<ReactWeather
  forecast="today"
  unit="imperial"
  apikey="YOUR_API_KEY"
  type="city"
  city="Munich"
  lang="es"
/>

Props Options

| Props | Options | Default | Description | | ------------ | --------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | type | 'city', 'geo' | city | Determine the data should be loaded by city name or longitude and latitude | | city | | | Name of the city to show forecast for, must be provided if the type='city' | | lon | | | Longitude value, must be provided if the type='geo' | | lat | | | latitude value, must be provided if the type='geo' | | forecast | 'today', '5days' | today | Determine what forecast to show, today or today plus 4 days ahead | | apikey | | | Your API key for open weather map API | | unit | 'imperial', 'meteric' | meteric | The unit system you want to use, for Meteric the temperature will be shown in Celsius and distances will be in kilometers, for Imperial the temperature will be shown in Fahrenheit and distances in miles. | | lang | lang codes | en | Returns 'condition:text' field in API in the desired language, Please pass 'lang code' from below table. e.g.: lang=es |

Translate Wind and Humidity

In lang.js you can implement the necessary translation, to correctly translate Wind and Humidity into other languages, if you want to implement another language, this is where you can do it. Remember to make a Pull request to share it with everyone

    langText: {
          en: { Wind: 'Wind', Humidity: 'Humidity',},
          es: { Wind: 'Viento', Humidity: 'Humedad',}
        }

Language and lang codes from OpenWeather

| Language | lang code | | ------------------- | --------- | | Arabic | ar | | Bengali | bn | | Bulgarian | bg | | Chinese Simplified | zh | | Chinese Traditional | zh_tw | | Czech | cs | | Danish | da | | Dutch | nl | | Finnish | fi | | French | fr | | German | de | | Greek | el | | Hindi | hi | | Hungarian | hu | | Italian | it | | Japanese | ja | | Javanese | jv | | Korean | ko | | Mandarin | zh_cmn | | Marathi | mr | | Polish | pl | | Portuguese | pt | | Punjabi | pa | | Romanian | ro | | Russian | ru | | Serbian | sr | | Sinhalese | si | | Slovak | sk | | Spanish | es | | Swedish | sv | | Tamil | ta | | Telugu | te | | Turkish | tr | | Ukrainian | uk | | Urdu | ur | | Vietnamese | vi | | Wu (Shanghainese) | zh_wuu | | Xiang | zh_hsn | | Yue (Cantonese) | zh_yue | | Zulu | zu |

Contribution

If you want to contribute to the project and make it better, your help is very welcome, create a pull request with your suggested feature/bug fix/ enhancements.