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

bastille-react-svg-timeline

v0.24.3

Published

React Timeline Component

Downloads

27

Readme

react-svg-timeline GitHub license npm version

A React event timeline component based on SVG.

  • Event Points & Periods
  • Event Tooltips
  • Event Lanes
  • Semantic Zoom (10 Years, 1 Year, 1 Week, 1 Day, etc)
  • Custom "rubber band" Zoom
  • Panning

Demo

Out of the box – plain & simple:

Explore our interactive demo for more details on customizations. The demo code can be found in the react-svg-timeline-demo repository.

Alternatively, you are free to use just the zooming & panning interaction logic, e.g. as a layer of the awesome Nivo line chart:

Installation

yarn add react-svg-timeline

or

npm install react-svg-timeline

Note that react and react-dom (version >=16.3) must already be installed.

Usage

This is the simplest possible way to get started:

import * as React from 'react'
import { Timeline } from 'react-svg-timeline'

export const App = () => {
  const laneId = 'demo-lane'
  const lanes = [
    {
      laneId,
      label: 'Demo Lane',
    },
  ]
  const events = [
    {
      eventId: 'event-1',
      tooltip: 'Event 1',
      laneId,
      startTimeMillis: 1167606000000,
      endTimeMillis: 1230698892000,
    },
    {
      eventId: 'event-2',
      tooltip: 'Event 2',
      laneId: laneId,
      startTimeMillis: 1399845600000,
    },
  ]
  const dateFormat = (ms: number) => new Date(ms).toLocaleString()
  return <Timeline width={600} height={300} events={events} lanes={lanes} dateFormat={dateFormat} />
}

Please check the react-svg-timeline-demo repository for a full-fledged feature demonstration.

Theming

To override the default theme, you can use the theme property.

If your project is using Material UI, the deriveTimelineTheme convenience function makes it particularly easy to use the MUI theme as a basis:

import * as React from 'react'

// MUI v4
import { useTheme } from '@material-ui/core'

// MUI v5
import { useTheme } from '@mui/material'

import { Timeline } from 'react-svg-timeline'

const App = () => {
  const materialTheme = useTheme()

  // MUI v4
  const type = materialTheme.palette.type

  // MUI v5
  const type = materialTheme.palette.mode

  const theme = deriveTimelineTheme(materialTheme.palette.mode, materialTheme)
  return <Timeline theme={theme} /** all other props here **/ />
}

If you would just like to override certain aspects of the default timeline theme, use the createTimelineTheme helper function:

const theme = createTimelineTheme({ event: { markFillColor: 'pink' } })

Library Development

Local Development

To run the timeline locally with HMR, execute the following command:

yarn start

Storybook

To run the storybook locally, execute the following command:

yarn storybook

Testing

To run the tests, execute the following command:

yarn test

Building

To build the library, execute the following command:

yarn build

Testing a release candidate

While making changes to this library in the context of a consuming project, yalc can be very handy:

In react-svg-timeline:

yalc publish

In your project consuming the library:

yalc add react-svg-timeline

Note: If you previously had react-svg-timeline added via yalc, you need to remove it first:

yalc remove react-svg-timeline
yarn install
yalc add react-svg-timeline

Publishing a release

Before publishing a release, make sure to update the version number in package.json.

git tag vX.Y.Z
(yarn npm login)
yarn npm publish
git push --tags

After publishing and pushing the tag, you can add a release on GitHub with autogenerated release notes.

Acknowledgements

Thank you:

License

Licensed under MIT License.

© Rahel Lüthy & Jan Azzati 2022