GithubHelp home page GithubHelp logo

rojahm / react-animated-weather Goto Github PK

View Code? Open in Web Editor NEW

This project forked from divyanshu013/react-animated-weather

0.0 0.0 0.0 3.19 MB

Animated weather component for React inspired by Skycons http://darkskyapp.github.io/skycons/ :sunny:

Home Page: https://divyanshu013.github.io/react-animated-weather/

License: MIT License

JavaScript 95.07% CSS 0.27% HTML 4.66%

react-animated-weather's Introduction

React Animated Weather

Animated weather component for React inspired by Skycons http://darkskyapp.github.io/skycons/ โ˜€๏ธ

Build Status npm npm

React Animated Weather

Installation

React Animated Weather is available as a node package. Get it via yarn or npm:

yarn add react-animated-weather

-or-

npm install react-animated-weather

If using npm < 5, you might want to save to your package.json:

npm install --save react-animated-weather

react-animated-weather also has peer dependencies on react, react-dom and prop-types.

Usage

Import the ReactAnimatedWeather component:

import ReactAnimatedWeather from 'react-animated-weather';

Sample usage:

import React from 'react';
import ReactAnimatedWeather from 'react-animated-weather';

const defaults = {
  icon: 'CLEAR_DAY',
  color: 'goldenrod',
  size: 512,
  animate: true
};

const App = () => (
  <ReactAnimatedWeather
    icon={defaults.icon}
    color={defaults.color}
    size={defaults.size}
    animate={defaults.animate}
  />
);

export default App;

Props:

  • icon: Takes a string to display the corresponding icon out of the following

    • CLEAR_DAY
    • CLEAR_NIGHT
    • PARTLY_CLOUDY_DAY
    • PARTLY_CLOUDY_NIGHT
    • CLOUDY
    • RAIN
    • SLEET
    • SNOW
    • WIND
    • FOG
  • color: Pass a color value or hex code to color the weather component, if not passed, by default black is picked

  • size: Pass a number to size the weather component in pixels, if not passed, by default 64 is set as the size

  • animate: Pass a boolean value, if true (by default), the weather component will animate and if false, the weather component will remain static without any animation

Here are the default props used by ReactAnimatedWeather component:

ReactAnimatedWeather.defaultProps = {
  animate: true,
  size: 64,
  color: 'black'
};

ReactAnimatedWeather.propTypes = {
  icon: PropTypes.oneOf([
    'CLEAR_DAY',
    'CLEAR_NIGHT',
    'PARTLY_CLOUDY_DAY',
    'PARTLY_CLOUDY_NIGHT',
    'CLOUDY',
    'RAIN',
    'SLEET',
    'SNOW',
    'WIND',
    'FOG'
  ]).isRequired,
  animate: PropTypes.bool,
  size: PropTypes.number,
  color: PropTypes.string
};

Development

I've added a storybook for the component since it has a small number of props and the storybook interface is quite good for testing out the component. You can fire up the storybook by running:

yarn storybook

-or-

npm run storybook

Motivation

I got inspired to write this component from darkskyapp's Skycons. It makes use of the <canvas> element to render beautiful animated weather components.

Working with <canvas> in virtual DOM is a bit tricky. ReactAnimatedWeather uses a ref to refer to the DOM holding the <canvas> element and render the weather component on componentDidMount().

If you've found any bugs, please open an issue on github.

react-animated-weather's People

Contributors

ajhenry avatar dependabot[bot] avatar divyanshu013 avatar georgelioris avatar kensodev avatar timmo001 avatar

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.