Giter Site home page Giter Site logo

steven-mercatante / react-timeline Goto Github PK

View Code? Open in Web Editor NEW
75.0 2.0 1.0 11.79 MB

The easiest way to add a responsive and customizable timeline to React apps

Home Page: https://react-timeline.com

JavaScript 99.92% CSS 0.08%
react reactjs timeline timeline-component responsive responsive-layout responsive-grid

react-timeline's Introduction

React Timeline

npm badge travis badge

The easiest way to add responsive and customizable timelines to React apps.

View the documentation for detailed instructions and demos.

Installation

npm install @merc/react-timeline
# or
yarn add @merc/react-timeline

Usage

import React from 'react';
import {
  Timeline,
  Events,
  UrlButton,
  ImageEvent,
  TextEvent,
  YouTubeEvent,
} from '@merc/react-timeline';

export default function App() {
  return (
    <Timeline>
      <Events>
        <TextEvent date="1/1/19" text="**Markdown** is *supported*" />

        <ImageEvent
          date="4/13/19"
          text="You can embed images..."
          src="https://res.cloudinary.com/dovoq8jou/image/upload/v1564772194/jellyfish.jpg"
          alt="jellyfish swimming"
          credit="Photo by [@tavi004](https://unsplash.com/@tavi004)"
        >
          <div>
            <UrlButton href="https://unsplash.com/search/photos/undersea">
              View more undersea photos
            </UrlButton>
          </div>
        </ImageEvent>

        <YouTubeEvent
          date="6/18/19"
          id="6UnRHtwHGSE"
          name="General Tso's Chicken recipe"
          text="... and YouTube videos!"
        />
      </Events>
    </Timeline>
  );
}

react-timeline's People

Contributors

steven-mercatante 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

Watchers

 avatar  avatar

react-timeline's Issues

Marker alignment differences

The alignment of the event marker relative to the line is slightly off, layout styles affected:

  • alt-evts
  • alt-evts-inline-date
  • inline-evts

offset

When switching through the different layout styles available, the issue does not seem to occur when using the inline-evts-inline-date-layout :

normal

Forward ref to Event

When developing a library it's a good practice to expose a reference of a component.
It can be achieved with forwardRef.

Working with this library I couldn't obtain Event reference in order to animate it.

A straight forward implementation can be something like this:

const Event = forwardRef(({ date, marker, children, className, card }, ref) => {
...
return <Container ref={ref}>...</Container>
});

The user then can use the reference for his care, like reveal animation:

const Timeline = () => {
  const revealEvents = useRef([]);

  useEffect(() => {
    revealEvents.current.forEach((ref, i) => sr.reveal(ref, srConfig(i * 100)));
  }, []);

  const events = useTimeline();

  return (
    <ThemedTimeline>
      <Events>
        {events.map(({ ... }, i) => {
          const MyCustomCard = () => (... );
          const date = () => (... );

          return <Event key={i} date={date} card={MyCustomCard} ref={el => (revealEvents.current[i] = el)}/>;
        })}
      </Events>
    </ThemedTimeline>
  );
};

I hope I'll able to add a merge request in a few days.

On custom card wrong media-queries

On providing a custom card, 768px is a "Golden Number" which may brake the component, in this case, the user should control the query and the default one need to be disabled.

localhost_8000_ (9)

Possible user's fix example:

const EventDetails = styled.div`
  ${mixins.boxShadowSmall}
  background-color: ${colors.backgroundDark};
  padding: 15px;
  @media (max-width: 768px) {
    display: none;
  }
`;

The user may not catch the bug on smaller devices, therefore, it is not expected behavior.

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.