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-img-timeline

v3.2.19

Published

[![CircleCI](https://circleci.com/gh/aaron9000/react-image-timeline/tree/master.svg?style=svg)](https://circleci.com/gh/aaron9000/react-image-timeline/tree/master)

Downloads

15

Readme

CircleCI

React Image Timeline

An image-centric timeline component for React.js. View chronological events in a pleasant way.

View Sample Timeline

Features:

  • Responsive layout
  • Graceful handling of non-uniform content
  • Customizable (use your own CSS and components)
  • Memoized, pure, & typed (Typescript definitions included)
  • Only 32kb
  • Zero extra dependencies

screenshot

How to Use

npm install react-image-timeline --save

import React from 'react';
import ReactDOM from 'react-dom';
import Timeline from 'react-image-timeline';
require('react-image-timeline/dist/timeline.css'); // .scss also available

const events = [
    {
        date: new Date(2013, 9, 27),
        text: "Sed leo elit, pellentesque sit amet congue quis, ornare nec lorem.",
        title: "Cairo, Egypt",
        buttonText: 'Click Me',
        imageUrl: "http://github.com/aaron9000/react-image-timeline/blob/master/src/assets/cairo.jpg?raw=true",
        onClick: console.log,
    }
];

ReactDOM.render(<Timeline events={events} />, document.getElementById('root'));

Customization

Custom Styles

To customize the timeline, add your own CSS to override the default styles.

Event Metadata

To pass extra data into custom components, use extras on TimelineEvent.

Custom Dot Pattern

The dots are defined in CSS using a base64-encoded image. Encode a new image and override the corresponding CSS class.

Custom Components

For more advanced customization, you can pass in custom components to replace the defaults. Custom components will be passed a TimelineEvent model in props.


const CustomHeader = (props) => {

    const {title, extras} = props.event;
    const {customField} = extras;

    return <div className="custom-header">
        <h1>{title}</h1>
        <p>{customField}</p>
    </div>;
};

ReactDOM.render(<Timeline events={events} customComponents={{header: CustomHeader}}/>, document.getElementById('root'));

Run Example Project (you will need create-react-app to run)

*install create-react-app*
*clone repository*
yarn
yarn --debug
yarn start

Run Tests

*clone repository*
yarn test

TypeScript & Models

Typescript definitions are included in the library.


Importing TypeScript Definitions

import {
    TimelineProps, 
    TimelineEventProps, 
    TimelineEvent, 
    TimelineCustomComponents
} from 'react-image-timeline';

TimelineProps

export interface TimelineProps {
    customComponents?: TimelineCustomComponents | null;
    events: Array<TimelineEvent>;
    reverseOrder?: boolean;
    denseLayout?: boolean;
}

| Key | Type | Required? |--------------------------|--------------------------|--------------------------| | events | Array | Yes | | customComponents |TimelineCustomComponents | | | reverseOrder | boolean | | | denseLayout | boolean | |


TimelineCustomComponents

export interface TimelineCustomComponents {
    topLabel?: React.PureComponent<TimelineEventProps> | React.ReactNode | null;
    bottomLabel?: React.PureComponent<TimelineEventProps> | React.ReactNode | null;
    header?: React.PureComponent<TimelineEventProps> | React.ReactNode | null;
    imageBody?: React.PureComponent<TimelineEventProps> | React.ReactNode | null;
    textBody?: React.PureComponent<TimelineEventProps> | React.ReactNode | null;
    footer?: React.PureComponent<TimelineEventProps> | React.ReactNode | null;
}

| Key | Type | Required? |--------------------------|--------------------------|--------------------------| | topLabel | component | | | bottomLabel | component | | | header | component | | | imageBody | component | | | textBody | component | | | footer | component | |


TimelineEventProps

export interface TimelineEventProps {
    event: TimelineEvent;
}

| Key | Type | Required? |--------------------------|--------------------------|--------------------------| | event | TimelineEvent | Yes |


TimelineEvent

export interface TimelineEvent {
    date: Date;
    title: string;
    imageUrl: string;
    text: string;
    onClick?: TimelineEventClickHandler | null;
    buttonText?: string | null;
    extras?: object | null;
}

| Key | Type | Required? |--------------------------|--------------------------|--------------------------| | date | date | Yes | | title | string | Yes | | imageUrl | string | Yes | | text | string | Yes | | onClick | function | | | buttonText | string | | | extras | object | |