-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React, { useEffect } from 'react'; | ||
import { Timeline as TL } from '@knight-lab/timelinejs'; | ||
import '@knight-lab/timelinejs/dist/css/timeline.css'; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
matthewsmawfield
Author
Collaborator
|
||
import './Timeline.css'; | ||
|
||
export interface Props { | ||
data: { | ||
Date: string; | ||
Category: string; | ||
Details: string; | ||
Source: string; | ||
Link: string; | ||
}[], | ||
} | ||
|
||
function Timeline({ data }: Props) { | ||
const timelineoptions = { | ||
// initial_zoom: 2, | ||
scale_factor: 1.4, | ||
timenav_position: 'top', | ||
height: '500', | ||
width: '100%', | ||
lang: 'en', | ||
start_at_end: true, | ||
font: 'Roboto Slab', | ||
}; | ||
|
||
// eslint-disable-next-line | ||
const evt = data.map((d:any) => ( | ||
{ | ||
start_date: new Date(d.Date), | ||
display_date: (new Date(d.Date)).toDateString(), | ||
group: d.Category, | ||
text: { | ||
headline: d['Main events'], | ||
text: d.Details, | ||
}, | ||
} | ||
)); | ||
|
||
const events = { events: evt }; | ||
|
||
useEffect(() => { | ||
// eslint-disable-next-line | ||
const timeline = new TL( | ||
'timeline-embed', | ||
events, | ||
timelineoptions, | ||
); | ||
}); | ||
|
||
return ( | ||
<div id="timeline-embed" className="container" style={{ height: 500 }} /> | ||
); | ||
} | ||
|
||
export default Timeline; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module '@knight-lab/timelinejs'; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
matthewsmawfield
Author
Collaborator
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,5 +30,5 @@ | |
"sourceMap": true, | ||
"baseUrl": "." | ||
}, | ||
"include": ["./src/index.ts", "./src/declarations"] | ||
"include": ["./src/index.ts", "./src/declarations", "src/Timeline/timelinejs.d.ts"] | ||
This comment has been minimized.
Sorry, something went wrong.
tnagorra
Member
|
||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,5 +22,5 @@ | |
}, | ||
"include": [ | ||
"src" | ||
] | ||
, "../lib/src/Timeline" ] | ||
This comment has been minimized.
Sorry, something went wrong.
tnagorra
Member
|
||
} |
Instead of importing the CSS file here. We should import the CSS in
storybook/src/App.jsx
We can even make
@knight-lab/timelinejs
a peer dependency.