Coder Social home page Coder Social logo

arunghosh / react-time-line Goto Github PK

View Code? Open in Web Editor NEW
73.0 5.0 24.0 3.44 MB

A react component to display event in a vertical timeline format

License: MIT License

JavaScript 67.79% HTML 3.42% CSS 22.28% TypeScript 6.50%
react timline component reactjs

react-time-line's Introduction

react-time-line

Build Status

A react component to display event in a vertical timeline format. This is based on the timeline found in AdminLte.

Live example here.

alt tag

Installation

npm install react-time-line

Usage

const events = [
  {ts: "2017-09-17T12:22:46.587Z", text: 'Logged in'},
  {ts: "2017-09-17T12:21:46.587Z", text: 'Clicked Home Page'},
  {ts: "2017-09-17T12:20:46.587Z", text: 'Edited Profile'},
  {ts: "2017-09-16T12:22:46.587Z", text: 'Registred'},
  {ts: "2017-09-16T12:21:46.587Z", text: 'Clicked Cart'},
  {ts: "2017-09-16T12:20:46.587Z", text: 'Clicked Checkout'},
];

// default format is "hh:mm"
<Timeline items={events} format="hh:mm a" />

The events should be ordered in a way you need.

For time formatting options check momentjs format docs.

Style

Currently there is no proper way to set the style. As a hack you can override the default style. Check for the default style in src/style.scss.

For developers

To make new build

npm run build

To run dev server

npm run dev

To run test

npm run test

Buy Me A Coffee

react-time-line's People

Contributors

9renpoto avatar arunghosh avatar dependabot-preview[bot] avatar dependabot-support avatar imgbotapp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

react-time-line's Issues

Date sort

Maybe you can sort items before creating your array by day in your getFormattedData(items), like:
items.sort((itemA, itemB) => {
if(moment(itemA.ts).isBefore(itemB.ts)) {
return -1;
} else if(moment(itemB.ts).isBefore(itemA.ts)) {
return 1;
} else {
return 0;
}
}).forEach(....

Custom Props & component.

THis is actually good library, that has been able to group together by date, it would have been great, if we could pass custom Component and props

Use military 24H clock or display AM/PM

The component looks great but doesn't differentiate between AM/PM. or show 24 hour clock

This example

<Timeline items={[
          {ts: new Date(), text: 'date obj'},
          {ts: `${new Date()}`, text: 'interpolated'},
          {ts: new Date().toISOString(), text: 'iso'},
          {ts: new Date().toGMTString(), text: 'gmt'},
          {ts: new Date().toDateString(), text: 'date'}
        ]} />

Outputs the times
date obj = 03:15
interpolated = 03:15
iso = 03:15
gmt = 03:15
date = 12:00

  • Regardless of morning or afternoon/evening (Tested this at separate times from 8 am to 3pm)

Request to fix is in the Timeline.js, line 13: change date.format('hh:mm'), to date.format('HH:mm'), or date.format('hh:mm a').

Alternatively, allow users option to pass time format specified in module docs or by referring user to Moment.js docs.

Change the date format hh:mm to HH:mm:ss

Hi,

Currently the time show in the range 12-hour. So could you change to 24-hour
Maybe I think just change hh:mm to HH:mm:ss

Thank you for your consideration.

Invalid Date

I am passing date in this format yyyy-mm-ddTHH:MM but it says Invalid date.

image

Also tried sending as Moment object but still doesn't work.

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.