Skip to content

Commit

Permalink
Merge pull request #92 from avgupta456/master
Browse files Browse the repository at this point in the history
lineColor prop
  • Loading branch information
stephane-monnot authored Oct 2, 2021
2 parents f557eae + 5854503 commit bf3fb02
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ Add extra class name to root div element.

Choose if you want `'1-column-left'` or `'1-column-right'` or `'2-columns'` (default: `'2-columns'`).

### `lineColor={ String }`

Choose a color for the timeline (default: `'white'`).

## VerticalTimelineElement Props

Expand Down
2 changes: 1 addition & 1 deletion src/VerticalTimeline.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
left: 18px;
height: 100%;
width: 4px;
background: white;
background: var(--line-color);
}

.vertical-timeline.vertical-timeline--one-column-right::before {
Expand Down
37 changes: 24 additions & 13 deletions src/VerticalTimeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,28 @@ import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';

const VerticalTimeline = ({ animate, className, layout, children }) => (
<div
className={classNames(className, 'vertical-timeline', {
'vertical-timeline--animate': animate,
'vertical-timeline--two-columns': layout === '2-columns',
'vertical-timeline--one-column-left':
layout === '1-column' || layout === '1-column-left',
'vertical-timeline--one-column-right': layout === '1-column-right',
})}
>
{children}
</div>
);
const VerticalTimeline = ({
animate,
className,
layout,
lineColor,
children,
}) => {
document.documentElement.style.setProperty('--line-color', lineColor);
return (
<div
className={classNames(className, 'vertical-timeline', {
'vertical-timeline--animate': animate,
'vertical-timeline--two-columns': layout === '2-columns',
'vertical-timeline--one-column-left':
layout === '1-column' || layout === '1-column-left',
'vertical-timeline--one-column-right': layout === '1-column-right',
})}
>
{children}
</div>
);
};

VerticalTimeline.propTypes = {
children: PropTypes.oneOfType([
Expand All @@ -29,12 +38,14 @@ VerticalTimeline.propTypes = {
'2-columns',
'1-column-right',
]),
lineColor: PropTypes.string,
};

VerticalTimeline.defaultProps = {
animate: true,
className: '',
layout: '2-columns',
lineColor: '#FFF',
};

export default VerticalTimeline;

0 comments on commit bf3fb02

Please sign in to comment.