Skip to content

Commit 37b1ded

Browse files
authored
Merge pull request #45 from Proskynete/add-typescript
Add typescript
2 parents b31311a + e280e13 commit 37b1ded

File tree

96 files changed

+9815
-9149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+9815
-9149
lines changed

.babelrc

Lines changed: 0 additions & 19 deletions
This file was deleted.

README.md

Lines changed: 110 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,54 @@
1-
# vertical-timeline-component-react
1+
<div id="top">
2+
<h1>vertical-timeline-component-react
3+
<img src="https://cdn.iconscout.com/icon/free/png-256/typescript-1174965.png" width="25" height="25" />
4+
</h1>
5+
6+
<p>A simple component to generate a responsive vertical timeline</p>
7+
</div>
28

3-
A simple component to generate a responsive vertical timeline
49
![Vertical Timeline Component React](https://i.imgur.com/KBqLIlK.png 'How to see vertical-timeline-component-react')
510

611
## Status
712

8-
[![Coverage Status](https://coveralls.io/repos/github/Proskynete/vertical-timeline-component-react/badge.svg?branch=unit-tests)](https://coveralls.io/github/Proskynete/vertical-timeline-component-react?branch=unit-tests) [![Version](https://img.shields.io/npm/v/vertical-timeline-component-react.svg)](https://www.npmjs.com/package/vertical-timeline-component-react) [![Build Status](https://travis-ci.org/Proskynete/vertical-timeline-component-react.svg?branch=master)](https://travis-ci.org/Proskynete/vertical-timeline-component-react) [![Dependencies](https://david-dm.org/proskynete/vertical-timeline-component-react.svg)](https://david-dm.org/proskynete/vertical-timeline-component-react) [![devDependencies Status](https://david-dm.org/proskynete/vertical-timeline-component-react/dev-status.svg)](https://david-dm.org/proskynete/vertical-timeline-component-react?type=dev) [![peerDependencies Status](https://david-dm.org/proskynete/vertical-timeline-component-react/peer-status.svg)](https://david-dm.org/proskynete/vertical-timeline-component-react?type=peer)
9-
10-
## Getting started
11-
13+
![PRs welcome](https://img.shields.io/badge/PRs-welcome-green) [![Coverage Status](https://coveralls.io/repos/github/Proskynete/vertical-timeline-component-react/badge.svg?branch=unit-tests)](https://coveralls.io/github/Proskynete/vertical-timeline-component-react?branch=unit-tests) [![Version](https://img.shields.io/npm/v/vertical-timeline-component-react.svg)](https://www.npmjs.com/package/vertical-timeline-component-react) [![Build Status](https://travis-ci.org/Proskynete/vertical-timeline-component-react.svg?branch=master)](https://travis-ci.org/Proskynete/vertical-timeline-component-react) [![Package Quality](https://packagequality.com/shield/vertical-timeline-component-react.svg)](https://packagequality.com/#?package=vertical-timeline-component-react)
14+
15+
<br />
16+
<br />
17+
18+
<details>
19+
<summary>Table of contents</summary>
20+
<ol>
21+
<li>
22+
<a href="#getting-started">Getting started</a>
23+
</li>
24+
<li>
25+
<a href="#api-documentation">API Documentation</a>
26+
<ul>
27+
<li><a href="#timeline">Timeline</a></li>
28+
<li><a href="#container">Container</a></li>
29+
<li><a href="#year-content">YearContent</a></li>
30+
<li><a href="#body-content">BodyContent</a></li>
31+
<li><a href="#section">Section</a></li>
32+
<li><a href="#description">Description</a></li>
33+
</ul>
34+
</li>
35+
<li><a href="#how-to-use">How to use it</a></li>
36+
<li><a href="#contributors">Contributors</a></li>
37+
</ol>
38+
</details>
39+
40+
<h2 id="getting-started">Getting started</h2>
1241
To install as npm dependency
1342

1443
```sh
1544
npm install --save vertical-timeline-component-react
1645
```
1746

18-
## API Documentation
47+
<p align="right"><a href="#top">🔝</a></p>
48+
49+
<h2 id="api-documentation">API Documentation</h2>
1950

20-
### Timeline
51+
<h3 id="timeline">Timeline</h3>
2152

2253
This is the wrapper component that creates the vertical timeline.
2354

@@ -29,22 +60,23 @@ This is the wrapper component that creates the vertical timeline.
2960

3061
- Props
3162

32-
| name | Type | Required | Values Allowed | default values | Description |
33-
| ---------- | ------ | -------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
34-
| theme | object | false | colors | { yearColor: "#888888", lineColor: "#c5c5c5", dotColor: "#c5c5c5", borderDotColor: "#ffffff", titleColor: "#cccccc", subtitleColor: "#888888", textColor: "#cccccc" } | Set colors in all components |
35-
| lang | node | false | `en`, `es`, `de` or `zh_CN` | `en` | Change the language `from` and `to` texts and change the format in the dates |
36-
| dateFormat | string | false | `L`, `l` or `ll` | `L` | Change the presentation format of dates |
63+
| name | Type | Required | Values Allowed | default values | Description |
64+
| ---------- | ------ | -------- | ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
65+
| theme | object | false | colors | { yearColor: "#888888", lineColor: "#c5c5c5", dotColor: "#c5c5c5", borderDotColor: "#ffffff", titleColor: "#cccccc", subtitleColor: "#888888", textColor: "#cccccc" } | Set colors in all components |
66+
| lang | string | false | `en`, `es`, `de`, `tr` or `zh_CN` | `en` | Change the language `from` and `to` texts and change the format in the dates |
67+
| dateFormat | string | false | `only-number`, `short`, `with-weekday` or `full` | `only-number` | Change the presentation format of dates |
3768

38-
`dateFormat`: Receive only one of three options. (The options are same the [moment.js](https://momentjs.com/) using).
69+
`dateFormat`: Receive only one of four options (The options are same the [moment.js](https://momentjs.com/) using)
3970

40-
| | `L` | `l` | `ll` |
41-
|:---:|---|---|---|
42-
|English(`en`)| `MM/DD/YYYY` | `M/D/YYYY` | `MMM DD, YYYY` |
43-
|Spanish(`es`)| `DD/MM/YYYY` | `D/M/YYYY` | `DD de MMM, YYYY` |
44-
|German(`de`) | `DD.MM.YYYY` | `D.M.YYYY` | `DD. MMM YYYY` |
45-
|Simplified Chinese(`zh_CN`)| `YYYY 年 MM 月 DD 日` | `YYYY 年 M 月 D 日` | `YYYY 年MMM DD 日` |
71+
| | `only-number` | `short` | `with-weekday` | `full` |
72+
| :--------------------------: | ------------- | ---------------- | ----------------------- | ------------------------------ |
73+
| English (`en`) | `MM/D/YYYY` | `MMM DD, YYYY` | `ddd, MMM DD, YYYY` | `dddd, MMMM DD, YYYY` |
74+
| Spanish (`es`) | `D/MM/YYYY` | `DD MMM YYYY` | `ddd, DD [de] MMM YYYY` | `dddd, DD [de] MMMM [de] YYYY` |
75+
| German (`de`) | `D.MM.YYYY` | `DD.MMM.YYYY` | `ddd., DD. MMM. YYYY` | `dddd, DD. MMMM YYYY` |
76+
| Turk (`tr`) | `DD.MM.YYYY` | `DD MMM YYYY` | `DD MMM YYYY ddd` | `DD MMMM YYYY dddd` |
77+
| Simplified Chinese (`zh_CN`) | `YYYY/MM/D` | `YYYY年MM月DD日` | `YYYY年MMM月DD日` | `YYYY年MM月DD日dddd` |
4678

47-
### Container
79+
<h3 id="container">Container</h3>
4880

4981
Each event in the timeline will be represented by the `Content` component. This component receive only two children's, the first is `YearContent` and the second is `BodyContent`. There can be multiple repeating instances of this component inside `Timeline` wrapper.
5082

@@ -54,9 +86,9 @@ Each event in the timeline will be represented by the `Content` component. This
5486
| ------------------ | -------- | ------------------------------- |
5587
| 2 | true | `YearContent` and `BodyContent` |
5688

57-
### YearContent
89+
<h3 id="year-content">YearContent</h3>
5890

59-
For each `Container` you need `YearContent` (like firts children) since with this component you mark the events in the given year.
91+
For each `Container` you need `YearContent` (like first children) since with this component you mark the events in the given year.
6092

6193
- Props
6294

@@ -66,7 +98,7 @@ For each `Container` you need `YearContent` (like firts children) since with thi
6698
| endDate | string | false | `YYYY/MM/DD` - `YYYY/MM` - `YYYY` | does not apply | The date of the end of the content or contents |
6799
| currentYear | boolean | false | `true` or `false` | current year | The value is the current year, it is recommended to use it in the last Container |
68100

69-
### BodyContent
101+
<h3 id="body-content">BodyContent</h3>
70102

71103
For each `Container` you need `ContentBody` (like second children). This component will be the container of the one or more `Sections`.
72104

@@ -76,7 +108,7 @@ For each `Container` you need `ContentBody` (like second children). This compone
76108
| ------------------ | -------------------------------------------------- | ------------------------- |
77109
| Many | At least the first `Section` component is required | Only `Section` components |
78110

79-
### Section
111+
<h3 id="section">Section</h3>
80112

81113
This component is the container for one or more `Description`.
82114

@@ -92,7 +124,7 @@ This component is the container for one or more `Description`.
92124
| ----- | ------ | -------- | ----------------------------- |
93125
| title | string | true | It's the title of any section |
94126

95-
### Description
127+
<h3 id="description">Description</h3>
96128

97129
This component can be the text of the description or a subtitle
98130

@@ -103,7 +135,9 @@ This component can be the text of the description or a subtitle
103135
| variant | string | false | `subtitle` or `description` | `description` | Transform the format of the text |
104136
| text | string | true | Any text | does not apply | Show the description of the `Section` |
105137

106-
## How to use it
138+
<p align="right"><a href="#top">🔝</a></p>
139+
140+
<h2 id="how-to-use">How to use it</h2>
107141

108142
The following snippet will show you how to use the library:
109143

@@ -132,7 +166,7 @@ const customTheme = {
132166
class Main extends Component {
133167
render() {
134168
return(
135-
<Timeline theme={customTheme} dateFormat='ll'>
169+
<Timeline theme={customTheme} dateFormat='full'>
136170
<Container>
137171
<YearContent startDate='2020/07/01' currentYear />
138172
<BodyContent>
@@ -158,47 +192,59 @@ class Main extends Component {
158192

159193
```js
160194
import {
161-
Timeline,
162-
Container,
163-
YearContent,
164-
BodyContent,
165-
Section,
166-
Description,
195+
Timeline,
196+
Container,
197+
YearContent,
198+
BodyContent,
199+
Section,
200+
Description,
167201
} from 'vertical-timeline-component-react';
168202

169203
const Main = () => {
170-
const customTheme = {
171-
yearColor: '#405b73',
172-
lineColor: '#d0cdc4',
173-
dotColor: '#262626',
174-
borderDotColor: '#d0cdc4',
175-
titleColor: '#405b73',
176-
subtitleColor: '#bf9765',
177-
textColor: '#262626',
178-
};
179-
180-
return (
181-
<Timeline theme={customTheme} dateFormat='ll'>
182-
<Container>
183-
<YearContent startDate='2020/07/01' currentYear />
184-
<BodyContent>
185-
<Section title='Title'>
186-
<Description variant='subtitle' text='Subtitle' />
187-
<Description text='Description' />
188-
<Description text='Another description' />
189-
</Section>
190-
191-
<Section title='Another title'>
192-
<Description text='Description' />
193-
<Description text='Another description' />
194-
</Section>
195-
</BodyContent>
196-
</Container>
197-
</Timeline>
198-
);
204+
const customTheme = {
205+
yearColor: '#405b73',
206+
lineColor: '#d0cdc4',
207+
dotColor: '#262626',
208+
borderDotColor: '#d0cdc4',
209+
titleColor: '#405b73',
210+
subtitleColor: '#bf9765',
211+
textColor: '#262626',
212+
};
213+
214+
return (
215+
<Timeline theme={customTheme} dateFormat='full'>
216+
<Container>
217+
<YearContent startDate='2020/07/01' currentYear />
218+
<BodyContent>
219+
<Section title='Title'>
220+
<Description variant='subtitle' text='Subtitle' />
221+
<Description text='Description' />
222+
<Description text='Another description' />
223+
</Section>
224+
225+
<Section title='Another title'>
226+
<Description text='Description' />
227+
<Description text='Another description' />
228+
</Section>
229+
</BodyContent>
230+
</Container>
231+
</Timeline>
232+
);
199233
};
200234
```
201235

202-
## License
236+
<p align="right"><a href="#top">🔝</a></p>
237+
238+
<h2 id="contributors">Contributors</h2>
239+
240+
<a href="https://github.com/Proskynete/vertical-timeline-component-react/graphs/contributors">
241+
<img src="https://contrib.rocks/image?repo=Proskynete/vertical-timeline-component-react"/>
242+
</a>
243+
244+
<p align="right"><a href="#top">🔝</a></p>
245+
246+
<h2 id="license">License</h2>
203247

204248
MIT
249+
250+
<p align="right"><a href="#top">🔝</a></p>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { FC } from 'react';
2+
declare const BodyContent: FC;
3+
export default BodyContent;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
var react_1 = __importDefault(require("react"));
7+
var BodyContent = function (_a) {
8+
var children = _a.children;
9+
return react_1.default.createElement(react_1.default.Fragment, null, children);
10+
};
11+
exports.default = BodyContent;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { FC } from 'react';
2+
declare const Container: FC;
3+
export default Container;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
var react_1 = __importDefault(require("react"));
7+
var main_1 = require("../../styles/main");
8+
var Container = function (_a) {
9+
var children = _a.children;
10+
return children ? (react_1.default.createElement(main_1.ContainerWrapper, null,
11+
children[0],
12+
react_1.default.createElement(main_1.BodyContent, null, children[1]))) : (react_1.default.createElement(react_1.default.Fragment, null));
13+
};
14+
exports.default = Container;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
interface DescriptionProps {
2+
text: string;
3+
variant?: 'description' | 'subtitle' | 'descriptionSubtitle';
4+
}
5+
declare const Description: ({ text, variant }: DescriptionProps) => JSX.Element;
6+
export default Description;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
var react_1 = __importDefault(require("react"));
7+
var main_1 = require("../../styles/main");
8+
var Description = function (_a) {
9+
var text = _a.text, _b = _a.variant, variant = _b === void 0 ? 'description' : _b;
10+
switch (variant) {
11+
case 'subtitle':
12+
return react_1.default.createElement(main_1.Subtitle, null, text);
13+
case 'descriptionSubtitle':
14+
return react_1.default.createElement(main_1.DescriptionSubtitle, null, text);
15+
default:
16+
return react_1.default.createElement(main_1.DescriptionText, null, text);
17+
}
18+
};
19+
exports.default = Description;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { PropsWithChildren } from 'react';
2+
interface SectionProps {
3+
title: string;
4+
}
5+
declare const Section: ({ title, children }: PropsWithChildren<SectionProps>) => JSX.Element;
6+
export default Section;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
var react_1 = __importDefault(require("react"));
7+
var main_1 = require("../../styles/main");
8+
var Section = function (_a) {
9+
var title = _a.title, children = _a.children;
10+
return (react_1.default.createElement(main_1.BodyWrapper, null,
11+
react_1.default.createElement(main_1.Title, null, title),
12+
react_1.default.createElement(main_1.BodyInner, null, children)));
13+
};
14+
exports.default = Section;

0 commit comments

Comments
 (0)