Skip to content
This repository was archived by the owner on Jul 12, 2023. It is now read-only.

Commit df67449

Browse files
authored
Merge pull request #26 from aaron9000/improve-readme
[WIP] Improve Readme
2 parents 600a785 + 751ab1a commit df67449

File tree

5 files changed

+2771
-3131
lines changed

5 files changed

+2771
-3131
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
parallelism: 1
77
shell: /bin/bash --login
88
docker:
9-
- image: circleci/node:8.10
9+
- image: circleci/node:10.20
1010
steps:
1111
- checkout
1212
- run: yarn

README.md

Lines changed: 107 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,75 @@ import ReactDOM from 'react-dom';
2727
import Timeline from 'react-image-timeline';
2828
require('react-image-timeline/dist/timeline.css'); // .scss also available
2929

30+
const events = [
31+
{
32+
date: new Date(2013, 9, 27),
33+
text: "Sed leo elit, pellentesque sit amet congue quis, ornare nec lorem.",
34+
title: "Cairo, Egypt",
35+
buttonText: 'Click Me',
36+
imageUrl: "http://github.com/aaron9000/react-image-timeline/blob/master/src/assets/cairo.jpg?raw=true",
37+
onClick: console.log,
38+
}
39+
];
40+
3041
ReactDOM.render(<Timeline events={events} />, document.getElementById('root'));
3142
```
3243

33-
##### Sample TimelineEvent
44+
## Customization
45+
46+
#### Custom Styles
47+
To customize the timeline, add your own CSS to override the [default styles](https://github.com/aaron9000/react-image-timeline/blob/master/src/lib/timeline.scss/).
48+
49+
#### Event Metadata
50+
To pass extra data into custom components, use `extras` on `TimelineEvent`.
51+
52+
#### Custom Dot Pattern
53+
The dots are defined in CSS using a [base64-encoded image](https://www.base64-image.de/). Encode a new image and override the corresponding CSS class.
54+
55+
#### Custom Components
56+
For more advanced customization, you can pass in custom components to replace the defaults. Custom components will be passed a `TimelineEvent` model in props.
3457
```js
35-
{
36-
date: new Date(2013, 9, 27),
37-
text: "Sed leo elit, pellentesque sit amet congue quis, ornare nec lorem.",
38-
title: "Cairo, Egypt",
39-
buttonText: 'Click Me',
40-
imageUrl: "http://github.com/aaron9000/react-image-timeline/blob/master/src/assets/cairo.jpg?raw=true",
41-
onClick: () => {
42-
console.log('hello');
43-
}
44-
}
58+
59+
const CustomHeader = (props) => {
60+
61+
const {title, extras} = props.event;
62+
const {customField} = extras;
63+
64+
return <div className="custom-header">
65+
<h1>{title}</h1>
66+
<p>{customField}</p>
67+
</div>;
68+
};
69+
70+
ReactDOM.render(<Timeline events={events} customComponents={{header: CustomHeader}}/>, document.getElementById('root'));
71+
```
72+
73+
---
74+
75+
#### Run Example Project (you will need `create-react-app` to run)
76+
```
77+
*install create-react-app*
78+
*clone repository*
79+
yarn
80+
yarn --debug
81+
yarn start
82+
```
83+
84+
#### Run Tests
85+
```
86+
*clone repository*
87+
yarn test
4588
```
4689

4790

48-
## Types
4991

50-
Typescript definitions are available
92+
## TypeScript & Models
93+
94+
Typescript definitions are included in the library.
95+
96+
---
97+
98+
#### Importing TypeScript Definitions
5199

52100
```js
53101
import {
@@ -58,17 +106,41 @@ import {
58106
} from 'react-image-timeline';
59107
```
60108

109+
---
110+
61111
#### TimelineProps
62112

113+
```js
114+
export interface TimelineProps {
115+
customComponents?: TimelineCustomComponents | null;
116+
events: Array<TimelineEvent>;
117+
reverseOrder?: boolean;
118+
denseLayout?: boolean;
119+
}
120+
```
121+
63122
| Key | Type | Required?
64123
|--------------------------|--------------------------|--------------------------|
65124
| events | Array<TimelineEvent> | Yes |
66125
| customComponents |TimelineCustomComponents | |
67126
| reverseOrder | boolean | |
68127
| denseLayout | boolean | |
69128

129+
---
130+
70131
#### TimelineCustomComponents
71132

133+
```js
134+
export interface TimelineCustomComponents {
135+
topLabel?: React.PureComponent<TimelineEventProps> | React.ReactNode | null;
136+
bottomLabel?: React.PureComponent<TimelineEventProps> | React.ReactNode | null;
137+
header?: React.PureComponent<TimelineEventProps> | React.ReactNode | null;
138+
imageBody?: React.PureComponent<TimelineEventProps> | React.ReactNode | null;
139+
textBody?: React.PureComponent<TimelineEventProps> | React.ReactNode | null;
140+
footer?: React.PureComponent<TimelineEventProps> | React.ReactNode | null;
141+
}
142+
```
143+
72144
| Key | Type | Required?
73145
|--------------------------|--------------------------|--------------------------|
74146
| topLabel | component | |
@@ -78,14 +150,36 @@ import {
78150
| textBody | component | |
79151
| footer | component | |
80152

153+
---
154+
81155
#### TimelineEventProps
82156

157+
```js
158+
export interface TimelineEventProps {
159+
event: TimelineEvent;
160+
}
161+
```
162+
83163
| Key | Type | Required?
84164
|--------------------------|--------------------------|--------------------------|
85165
| event | TimelineEvent | Yes |
86166

167+
---
168+
87169
#### TimelineEvent
88170

171+
```js
172+
export interface TimelineEvent {
173+
date: Date;
174+
title: string;
175+
imageUrl: string;
176+
text: string;
177+
onClick?: TimelineEventClickHandler | null;
178+
buttonText?: string | null;
179+
extras?: object | null;
180+
}
181+
```
182+
89183
| Key | Type | Required?
90184
|--------------------------|--------------------------|--------------------------|
91185
| date | date | Yes |
@@ -97,46 +191,3 @@ import {
97191
| extras | object | |
98192

99193

100-
## Customization
101-
102-
#### Custom Styles
103-
To customize the timeline, add your own CSS to override the [default styles](https://github.com/aaron9000/react-image-timeline/blob/master/src/lib/timeline.scss/).
104-
105-
#### Event Metadata
106-
To pass extra data into custom components, use `extras` on `TimelineEvent`.
107-
108-
#### Custom Dot Pattern
109-
The dots are defined in CSS using a [base64-encoded image](https://www.base64-image.de/). Encode a new image and override the corresponding CSS class.
110-
111-
#### Custom Components
112-
For more advanced customization, you can pass in custom components to replace the defaults. Custom components will be passed a `TimelineEvent` model in props.
113-
```js
114-
115-
const CustomHeader = (props) => {
116-
117-
const {title, extras} = props.event;
118-
const {customField} = extras;
119-
120-
return <div className="custom-header">
121-
<h1>{title}</h1>
122-
<p>{customField}</p>
123-
</div>;
124-
};
125-
126-
ReactDOM.render(<Timeline events={events} customComponents={{header: CustomHeader}}/>, document.getElementById('root'));
127-
```
128-
129-
---
130-
131-
#### Run Example Project
132-
```
133-
*clone repository*
134-
npm install
135-
npm run start
136-
```
137-
138-
#### Run Tests
139-
```
140-
*clone repository*
141-
npm run test
142-
```

0 commit comments

Comments
 (0)