rpocklin / angular-timeline

An Angular.JS directive that generates a responsive, data-driven vertical timeline to tell a story, show history or describe a sequence of events.
Other
416 stars 108 forks source link

Angular Timeline

An Angular.js directive that generates a responsive, data-driven vertical timeline to tell a story, show history or describe a sequence of events.

Build Status

Demo

Demo

Demo without bootstrap

Original Implementation (HTML / Javascript)

NG Docs

link

Inspiration

1 2 3 4 5 6

Installation

  1. Install the plugin into your Angular.js project, manually or via

    bower install angular-timeline --save

  2. Include angular-timeline.css in your app:

    <link rel="stylesheet" href="https://github.com/rpocklin/angular-timeline/blob/master/bower_components/angular-timeline/dist/angular-timeline.css"/>

  3. Include angular-timeline.js in your app:

    <script src="https://github.com/rpocklin/angular-timeline/raw/master/bower_components/angular-timeline/dist/angular-timeline.js"></script>

  4. Add angular-timeline as a new module dependency in your angular app.

    var myapp = angular.module('myapp', ['angular-timeline']);

  5. To define a timeline, do the following (either manually or using ng-repeat on a dataset):

    
    // in controller
    $scope.events = [{
      badgeClass: 'info',
      badgeIconClass: 'glyphicon-check',
      title: 'First heading',
      content: 'Some awesome content.'
    }, {
      badgeClass: 'warning',
      badgeIconClass: 'glyphicon-credit-card',
      title: 'Second heading',
      content: 'More awesome content.'
    }];
    
    <!-- view -->
    <timeline>
      <timeline-event ng-repeat="event in events" side="right">
        <timeline-badge class="{{event.badgeClass}}">
          <i class="glyphicon {{event.badgeIconClass}}"></i>
        </timeline-badge>
        <timeline-panel class="{{event.badgeClass}}">
          <timeline-heading>
            <h4>{{event.title}}</h4>
          </timeline-heading>
          <p>{{event.content}}</p>
        </timeline-panel>
      </timeline-event>
    </timeline>

There is a bit of markup here but <timeline-heading> is optional. <timeline-badge> is for the centre line between the two sides, and should represent the event type that occured.

Notes

  <link rel="stylesheet" href="https://github.com/rpocklin/angular-timeline/blob/master/bower_components/bootstrap/dist/css/bootstrap.css" />
  <link rel="stylesheet" href="https://github.com/rpocklin/angular-timeline/blob/master/bower_components/angular-timeline/dist/angular-timeline-bootstrap.css" />
  <script src="https://github.com/rpocklin/angular-timeline/raw/master/bower_components/angular-timeline/dist/angular-timeline.js"></script>

Running Locally

  1. Checkout git repository locally: git clone git@github.com:rpocklin/angular-timeline.git
  2. npm install
  3. bower install
  4. grunt serve
  5. View http://localhost:9000/example/ in your browser to see the example.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Beautify (grunt beautify)
  4. Ensure it passes code-checks / tests (grunt)
  5. Commit your changes (git commit -am 'Added some feature')
  6. Push to the branch (git push origin my-new-feature)
  7. Create a new Pull Request

History

TODO

Thanks

luisrudge for the original vanilla JS implementation on Bootsnipp

License

Released under the MIT License. See the LICENSE file for further details.