Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | 1x 5x 5x 5x 5x 1x 1x | import React, { useState } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { useInView } from 'react-intersection-observer';
const VerticalTimelineElement = ({
children,
className,
contentArrowStyle,
contentStyle,
date,
dateClassName,
icon,
iconClassName,
iconOnClick,
onTimelineElementClick,
iconStyle,
id,
position,
style,
textClassName,
intersectionObserverProps,
}) => {
const [visible, setVisible] = useState(false);
const [ref, inView] = useInView(intersectionObserverProps);
Iif (!visible && inView) {
setVisible(true);
}
return (
<div
ref={ref}
id={id}
className={classNames(className, 'vertical-timeline-element', {
'vertical-timeline-element--left': position === 'left',
'vertical-timeline-element--right': position === 'right',
'vertical-timeline-element--no-children': children === '',
})}
style={style}
>
<React.Fragment>
<span // eslint-disable-line jsx-a11y/no-static-element-interactions
style={iconStyle}
onClick={iconOnClick}
className={classNames(
iconClassName,
'vertical-timeline-element-icon',
{
'bounce-in': visible,
'is-hidden': !visible,
}
)}
>
{icon}
</span>
<div
style={contentStyle}
onClick={onTimelineElementClick}
className={classNames(
textClassName,
'vertical-timeline-element-content',
{
'bounce-in': visible,
'is-hidden': !visible,
}
)}
>
<div
style={contentArrowStyle}
className="vertical-timeline-element-content-arrow"
/>
{children}
<span
className={classNames(
dateClassName,
'vertical-timeline-element-date'
)}
>
{date}
</span>
</div>
</React.Fragment>
</div>
);
};
VerticalTimelineElement.propTypes = {
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node,
]),
className: PropTypes.string,
contentArrowStyle: PropTypes.shape({}),
contentStyle: PropTypes.shape({}),
date: PropTypes.node,
dateClassName: PropTypes.string,
icon: PropTypes.element,
iconClassName: PropTypes.string,
iconStyle: PropTypes.shape({}),
iconOnClick: PropTypes.func,
onTimelineElementClick: PropTypes.func,
id: PropTypes.string,
position: PropTypes.string,
style: PropTypes.shape({}),
textClassName: PropTypes.string,
intersectionObserverProps: PropTypes.shape({
root: PropTypes.object,
rootMargin: PropTypes.string,
threshold: PropTypes.number,
triggerOnce: PropTypes.bool,
}),
};
VerticalTimelineElement.defaultProps = {
children: '',
className: '',
contentArrowStyle: null,
contentStyle: null,
icon: null,
iconClassName: '',
iconOnClick: null,
onTimelineElementClick: null,
iconStyle: null,
id: '',
style: null,
date: '',
dateClassName: '',
position: '',
textClassName: '',
intersectionObserverProps: { rootMargin: '0px 0px -40px 0px' },
};
export default VerticalTimelineElement;
|