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

react-lifecalendar

v1.0.5

Published

A React/SVG-based Life Calendar component, inspired by [this article](http://waitbutwhy.com/2014/05/life-weeks.html) written by Tim Urban.

Downloads

4

Readme

react-lifecalendar

A React/SVG-based "Life Calendar" component, inspired by this article written by Tim Urban.

Example Life Calendar

Introduction

A Life Calendar is a chart that shows your life (or someone elses!) in weeks, where each week is denoted by a square on the chart. If you haven't already, I would recommend reading this article by Tim Urban, who introduces this concept.

This component is an React-based implementation of a Life Calendar that renders to SVG, and can displayed in all modern browsers.

Running the Example

You'll need Node (preferably 5.x or higher) to be installed. Clone this repo, change into the directory, and run the following command to install all dependencies:

npm install

Once this is complete, you can run the example with:

npm start

With the server up and running, browse to http://localhost:8000 to view the component with sample data (available in ./example/components/App.js). Hover over the elements to display a tooltip corresponding with the data.

Installation

To use the component in your own React-based project:

npm i react-lifecalendar --save

To import the component:

import LifeCalendar from 'react-lifecalendar'

Usage

You should initialize the calendar with a width, height, title, and data object:

<LifeCalendar width="500" height="1000" title="Example Life Calendar" data={data}/>

A ratio of 1:2 (width:height) is recommended for the control, although it should scale accordingly.

Data

Data is passed to the calendar as a JSON object, and should compromise of the following fields:

dob (required) - Date of Birth in MM/DD/YYYY format (e.g. 01/01/1980)

lifeExpectancy (required) - Life Expectancy in years (e.g 78.1)

ranges - A collection of ranges to display in the calendar. Each range should have the following values:

start - Start date in MM/DD/YYYY format

end - End date in MM/DD/YYYY format. If the end date is not supplied, the current date will be used (useful for current events).

title - Text to show in the tooltip

color - SVG-compliant color to show. Can either be a named color, RGB value (e.g. rgb(255,255,255), or Hex value (e.g. #eeeeee).

milestones - A collection of milestones to show in the calendar. Each milestone should have the following value:

date - Date in MM/DD/YYYY format

title - Text to show in the tooltip

Overrides include:

dateFormat - Override the default date format with a moment-compatible format (e.g. DD/MM/YYYY)

milestoneColor - Override the color for milestones (shown by default as black)

Example Data

const data = {
  dob: '01/01/1978',
  lifeExpectancy: 78.74,
  ranges: [
    {start: '01/01/1978', end: '09/01/1985', title: 'Childhood', color: 'papayawhip'},
    {start: '09/01/1985', end: '09/01/1990', title: 'Elementary School', color: 'silver'},
    {start: '09/01/1990', end: '09/01/1993', title: 'Junior School', color: 'aqua'},
    {start: '09/01/1993', end: '09/01/1996', title: 'High School', color: 'brown'},
    {start: '09/01/1996', end: '09/01/2000', title: 'College', color: 'lightgreen'},
    {start: '09/01/2000', end: '05/14/2001', title: 'Internship', color: 'red'},
    {start: '05/14/2001', end: '11/20/2010', title: 'My First Job', color: 'green'},
    {start: '11/20/2010', end: '05/17/2014', title: 'My Second Job', color: 'lightblue'},
    {start: '05/17/2014', title: 'My Current Job', color: 'orange'}
  ],
  milestones: [
    {date: '10/08/2003', title: 'Published first book'},
    {date: '11/15/2013', title: 'Published second book'},
    {date: '01/01/2013', title: 'My Birthday!'}
  ]
};

License

The MIT License (MIT) Copyright (c) 2016 Simon Guest

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.