react-d3-sun-indicator

1.0.1 • Public • Published

react-d3-sun-indicator

a nice little daylight indicator built with react and d3

NPM JavaScript Style Guide

This cute indicator demonstrates some techniques with React and d3. It automatically sizes to its container so it can be rendered and re-used anywhere.

Take a look here.

Install

yarn add react-d3-sun-indicator

Usage

import React, { Component } from 'react'
 
import SunIndicator from 'react-d3-sun-indicator';
 
export default class App extends Component {
  constructor(props) {
    super(props);
 
    this.state = {time: new Date()}
  }
 
  componentDidMount() {
    this.timer = setInterval(() => this.setState({
      time: new Date()
    }), 1000)
  }
 
  componentWillUnmount() {
    clearInterval(this.timer)
  }
 
  render () {
    return (
      <div>
        <SunIndicator
          time={this.state.time}
          style={{width: "50vw", height: "50vh"}} />
      </div>
    )
  }
}

License

MIT © zemnmez

Readme

Keywords

none

Package Sidebar

Install

npm i react-d3-sun-indicator

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

1.22 MB

Total Files

8

Last publish

Collaborators

  • zemnmez