https://lukistuki.github.io/vue_timeline/
- Vue 2
- Momentjs
- Font Awesome
- Normalize.css
Clone the master repository: git clone https://github.com/lukistuki/vue_timeline.git myapp
Go to root directory: cd myapp
Install dependencies: npm install --production
Open the: public/index.html
Install dependencies: npm install
Run the build: npm run start
The: src/*
build will fill the public/*
directory
Data of the timelines and events is stored in the file as a object (in the future it could be for example a database). Next, the data file is bundled with other scripts (that's why Vue has an access to the data). Vue components processes information with the Moment.js library and sends output to HTML file.
Before we start - ALL DATES SHOULD BE JAVASCRIPT OBJECTS - new Date("...")
For name of the icons check the list: http://fontawesome.io/icons/
The events
array consist of 3 element arrays.
The single event array should consist of : [Javascript Date Object, Event title, Font Awesome icon name]
Event Javascript Date Object
should be between startDate and endDate or equal startDate/endDate
The settings
object got 3 properties:
startDate
should be the earliest dateendDate
should be the latest datecurrentDate
should be between startDate and endDate or equal startDate/endDate
Note: If you can't see the timeline or events, you probably passed the wrong date and the application will not display it (e.g. event's date isn't between settings dates, starting date is later then ending date of axis).
Go to src/data.js
script and pass the new object
myFooTimeline : {
events : [
[new Date("2017-06-01"), 'Suspendisse rhoncus ege', 'globe'], // [Javascript Object Date, Title of the event, Font Awesome icon name]
[new Date("2017-06-02"), 'Sed accumsan sit', 'leaf'],
[new Date("2017-06-15"), 'Mauris a dictum ut', 'gear'],
//(...)
],
settings : {
startDate: new Date("2017-06-01"), // here axis starts
endDate: new Date("2017-06-30"), // here it's end
currentDate: Date.now() // you can pass Date.now() to get present day
}
}
Go to src/index.html
and add the following syntax
<si-timeline source="myFooTimeline"></si-timeline> <!-- the source indicates name of the timeline object in src/data.js -->
Build the timeline: npm run start
That's all
Łukasz Stukan