Git Product home page Git Product logo

react-event-timeline's Introduction

react-event-timeline

React component to generate a responsive vertical event timeline

npm version Build Status codecov license

alt tag

Storybook demos here: https://rcdexta.github.io/react-event-timeline

CodeSandbox version to play with examples (in typescript):

Edit Timeline Example

Note: CodeSandbox version has predefined styles and icons loaded in index.html for better presentation!

Features

  • Is lightweight
  • Responsive and extensible
  • Configurable and customizable

Getting started

To install as npm dependency

npm install --save react-event-timeline

or if you use yarn

yarn add react-event-timeline

Usage

The following snippet generates the timeline you see in the screenshot:

import {Timeline, TimelineEvent} from 'react-event-timeline'

ReactDOM.render(
    <Timeline>
            <TimelineEvent title="John Doe sent a SMS"
                           createdAt="2016-09-12 10:06 PM"
                           icon={<i className="material-icons md-18">textsms</i>}
            >
                I received the payment for $543. Should be shipping the item within a couple of hours.
            </TimelineEvent>
            <TimelineEvent
                title="You sent an email to John Doe"
                createdAt="2016-09-11 09:06 AM"
                icon={<i className="material-icons md-18">email</i>}
            >
                Like we talked, you said that you would share the shipment details? This is an urgent order and so I
                    am losing patience. Can you expedite the process and pls do share the details asap. Consider this a
                    gentle reminder if you are on track already!
            </TimelineEvent>
    </Timeline>,
      document.getElementById('container')
);

Please refer storybook to check code for all the examples in the storybook demo.

API Documentation

Timeline

This is the wrapper component that creates the infinite vertical timeline

Name Type Description
className string The css class name of timeline container
style object Override inline styles of timeline container
orientation string Display the timeline on right or left. Default: left
lineColor string CSS color code to override the line color
lineStyle string Override the appearance of line with custom css styling

TimelineEvent

Each event in the timeline will be represented by the TimelineEvent component. There can be multiple repeating instances of this component inside Timeline wrapper

Name Type Description
title node The title of the event. Can be string or any DOM element node(s)
createdAt node The time at which the event occurred. Can be datetime string or any DOM element node(s)
subtitle node If you prefer having the title at the top and some caption below, omit createdAt and specify title and subtitle
icon node The icon to show as event lable. Can be a SVG or font icon
iconStyle object Custom CSS styling for the icon
bubbleStyle object Custom CSS styling for the bubble containing the icon
buttons node Action buttons to display to the right of the event content
contentStyle node Override content style
container string Optional value card will render event as a Card
style object Override style for the entire event container. Can be used to modify card appearance if container is selected as card
titleStyle object Override style for the title content
subtitleStyle object Override style for the subtitle content
cardHeaderStyle object Override style for the card header if container is card
collapsible boolean Make the timeline event collapse body content
showContent boolean if collapsible is true, should content be shown by default. false is default value

TimelineBlip

Use this component if your event footprint is too small and can be described in a single line

Name Type Description
title node The title of the event. Can be string or any DOM element node(s)
icon node The icon to show as event label. Can be a SVG or font icon
iconColor string CSS color code for icon
iconStyle object Custom CSS styling for the icon
style object Override style for the entire event container

Refer to Condensed Timeline in Storybook for examples of using this component.

Development

This project recommends using react-storybook as a UI component development environment. Use the following scripts for your development workflow:

  1. npm run storybook: Start developing by using storybook
  2. npm run lint : Lint all js files
  3. npm run lintfix : fix linting errors of all js files
  4. npm run build: transpile all ES6 component files into ES5(commonjs) and put it in dist directory
  5. npm run docs: create static build of storybook in docs directory that can be used for github pages

The storybook artefacts can be found in stories folder. Run npm run storybook and you should see your code changes hot reloaded on the browser

Also use semantic-release to automate release to npm. Use npm run commit to commit your changes and raise a PR.

Acknowledgements

This project is graciously supported by IDE tools offered by JetBrains for development.

alt tag

License

MIT

react-event-timeline's People

Contributors

9renpoto avatar albinotonnina avatar dependabot-preview[bot] avatar dependabot-support avatar g4g1 avatar imgbotapp avatar rcdexta avatar sylchauf avatar varemenos 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-event-timeline's Issues

Icon in TimelineEvent can't be centered

First of all: Thanks for this great component!

I am facing a problem centering the icon of a TimelineEvent. (I am using Material-UI.)

It currently looks like this:
image

I found issues #7 after which you introduced iconStyle. I am using the following code:

import PhoneIcon from 'material-ui-icons/PermPhoneMsg';

[...]
            <TimelineEvent
              title={update.title}
              createdAt={moment(update.timestamp).format(DATE_TIME_FORMAT)}
              icon={<PhoneIcon />}
              iconStyle={{ marginLeft: 0, marginTop: 0 }}
              iconColor="#5C6BC0"
            >
              {update.description}
            </TimelineEvent>
[...]

It seems that iconStyle is changing the style of the complete Icon, but not the actual icon enclosed.

If I change the value to iconStyle={{ marginLeft: 20, marginTop: 20 }} it looks like this:
image
What I want to achieve is to move the phone icon within the TimelineEvent icon.

I am fairly new to React (Java developer here ;) therefore I hope I don't miss anything obvious.

Kind regards

Time on left side, but content on right

I'd like to have the time display on the left side of the line and the rest of the content on the right. It would be easier to read times going up and down. Is there an easy way to do this?

Add custom style to Icon

Would be nice if I could provide my own styles to the icon. I'm using FontAwesome, which has a different offset than the material-icons you're using. The Avatars i'm showing as Icon, don't need the 8px margin as well.

Need a way of styling the createdAt date string

I have a TimelineEvent which I'm using in a dark theme and so the default text colour for the createdAt date attribute is too dark against the dark theme background and doesn't show up very well!

I would like to restyle the createdAt date however none of the existing style props appear to affect the createdAt styling! I've tried all the various styles e.g. style, titleStyle, subtitleStyle etc and none of them can be used to modify the createdAt date styling.

The only way to override this it seems is to either just use my own css or perhaps render the createdAt attribute as a Dom node and attach my own custom styling to that, though I haven't tried that yet.

Am I missing something? Is there an easy declarative way of setting the styling on createdAt?

Thanks!

Collapsible not working

Want to use the neat collapse feature which I saw is pretty new, however it does not work as it seems the property is not recognized. Copying the code from your storybook:

https://rcdexta.me/react-event-timeline/?selectedKind=Timeline&selectedStory=TimelineEvent%20with%20collapsible%20content&full=0&down=0&left=1&panelRight=0

gives me error:

Warning: Received true for a non-boolean attribute collapsible.
If you want to write it to the DOM, pass a string instead: collapsible="true" or collapsible={value.toString()}.

Using version 1.5.4. I noticed that the merge of that feature to master gave a compile error so that's probably why?

Bubble size

Hello,
I want to reduce the bubble size to look something like that:
bubblesize

I used bubbleStyle to update the width and height but it then looks like that:
bug-bubble-size

The solution would be to change the 'left' property of the bubble but it's always overwritte here.

mergeNotificationStyle(iconColor, bubbleStyle, orientation) {
    const iconColorStyle = iconColor ? {...s.eventType, ...{color: iconColor, borderColor: iconColor}} : s.eventType
    const leftOrRight = (orientation === 'right') ? {...s['eventType--right']} : {...s['eventType--left']}
    return {...iconColorStyle, ...bubbleStyle, ...leftOrRight}
  }

the solution seems to be to switch ...bubleStyle and ...leftOrRight.

mergeNotificationStyle(iconColor, bubbleStyle, orientation) {
    const iconColorStyle = iconColor ? {...s.eventType, ...{color: iconColor, borderColor: iconColor}} : s.eventType
    const leftOrRight = (orientation === 'right') ? {...s['eventType--right']} : {...s['eventType--left']}
    return {...iconColorStyle, ...leftOrRight, ...bubbleStyle}
  }

what do you think?

'iconStyle' and 'style' properties not working for TimelineBlip

This is probably related to issue #13 and presumably has a similar fix.

I've found that iconStyle does indeed now work for TimelineEvents but the exact same property applied to TimelineBlips doesn't appear to append the css content to the icon styling.

Similarly, I've found that the 'style' property works for TimelineEvents but not for TimelineBlips.

docs does not match with prop typechecking

TimelineEvent.js#L48-L49

  title: React.PropTypes.string.isRequired,
  createdAt: React.PropTypes.string.isRequired,
Name Type Description
title node The title of the event. Can be string or any DOM element node(s)
createdAt node The time at which the event occurred. Can be datetime string or any DOM element node(s)

Thank you.

rtl

is it working properly for rtl apps?

Alternate Card

Hi,

Thanks for this awesome library, we have a use case where we need alternating the card, is it possible in the TimelineEvent component to pass an orientation like Timeline?

Ideally:

image

Add event listeners to `TimelineEvent` component

I am using your package to implement timeline in my project. Works great. Furthermore, I want to pass some event listeners to TimelineEvent component like:

<TimelineEvent
          createdAt="2016-09-11 09:06 AM"
          icon={<i className="uk-icon-envelope uk-icon-small" />}
          iconColor="#03a9f4"
          title="Added payment method."
          onClick={handleCollapse}
          onHover={handleHover}
 >

Currently, it does not seem to have these props, are you planning to add these or any way I can workaround? All I want is to fire some event, when user clicks on the TimelineEvent title or hovers over it. Thanks in advance.

Component showing html tag

Hello,

I'm trying to populate the component with variables, one of them returns the text entered by the user, however, the component is showing the html tag ... can anyone help?

image

Warning: Unknown prop `container` on <div> tag. Remove this prop from the element.

When using the timeline event like this:

      <TimelineEvent
      title={title}
      createdAt={moment(event.dateTime).format('MMMM Do, h:mm:ss a')}
      container="card"
      icon={icon}
      iconColor={iconColor}
      contentStyle={{display: show}}
      key={`event#${index}`}
      className={styles.incidentTimeLineEvent}
      >

I get this warning:

Warning: Unknown prop container on < div > tag. Remove this prop from the element.

Dynamically update createdAt after every cycle.

I want to display createdAt time in "time ago" format which is updated after every 5 seconds.
I've created function to display time in that format now
cc
how can I dynamically update the display.I change value of var which display 0 sec ago after every 10 sec but it's not updating the view.
ps:please excuse the content of feed ๐Ÿ˜†

Nice to have features

Hello,

I was going through this library and felt that these features would make it way more awesome:

  • Ability to Search Timeline Events with free text
  • Pagination/Infinite Scroll
  • Ability to separately define directions for each subtitle/title/event on either left or right of the timeline.
  • Expand/Collapse ( wrap long content) for a Timeline event #

lineColor

Nice to see ability to change line color by propType. In my opinion to have consistency, it should be lineStyle propType. then we could change other things (line width, left position)

Its only sugestion.

rename createdAt to subtitle

I think it's better to have a title and a subtitle to keep the terms more generic. This because there isn't anything special happening with the createdAt anyway. It's just a node, just like title, icon and children.

So, I guess it's better to rename title to subtitle and createdAt to title (because a subtitle should be standing below the title).

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.