cinny/src/app/molecules/message/TimelineChange.jsx

82 lines
2.2 KiB
React
Raw Normal View History

2021-07-28 16:15:52 +03:00
import React from 'react';
import PropTypes from 'prop-types';
import './TimelineChange.scss';
// import Linkify from 'linkifyjs/react';
import Text from '../../atoms/text/Text';
import RawIcon from '../../atoms/system-icons/RawIcon';
import JoinArraowIC from '../../../../public/res/ic/outlined/join-arrow.svg';
import LeaveArraowIC from '../../../../public/res/ic/outlined/leave-arrow.svg';
import InviteArraowIC from '../../../../public/res/ic/outlined/invite-arrow.svg';
import InviteCancelArraowIC from '../../../../public/res/ic/outlined/invite-cancel-arrow.svg';
import UserIC from '../../../../public/res/ic/outlined/user.svg';
import TickMarkIC from '../../../../public/res/ic/outlined/tick-mark.svg';
2021-08-16 15:21:23 +03:00
function TimelineChange({ variant, content, time, onClick }) {
2021-07-28 16:15:52 +03:00
let iconSrc;
switch (variant) {
case 'join':
iconSrc = JoinArraowIC;
break;
case 'leave':
iconSrc = LeaveArraowIC;
break;
case 'invite':
iconSrc = InviteArraowIC;
break;
case 'invite-cancel':
iconSrc = InviteCancelArraowIC;
break;
case 'avatar':
iconSrc = UserIC;
break;
case 'follow':
iconSrc = TickMarkIC;
break;
default:
iconSrc = JoinArraowIC;
break;
}
return (
2021-08-16 15:21:23 +03:00
<button style={{ cursor: onClick === null ? 'default' : 'pointer' }} onClick={onClick} type="button" className="timeline-change">
2021-07-28 16:15:52 +03:00
<div className="timeline-change__avatar-container">
<RawIcon src={iconSrc} size="extra-small" />
</div>
<div className="timeline-change__content">
<Text variant="b2">
{content}
{/* <Linkify options={{ target: { url: '_blank' } }}>{content}</Linkify> */}
</Text>
</div>
<div className="timeline-change__time">
<Text variant="b3">{time}</Text>
</div>
2021-08-16 15:21:23 +03:00
</button>
2021-07-28 16:15:52 +03:00
);
}
TimelineChange.defaultProps = {
variant: 'other',
2021-08-16 15:21:23 +03:00
onClick: null,
2021-07-28 16:15:52 +03:00
};
TimelineChange.propTypes = {
variant: PropTypes.oneOf([
'join', 'leave', 'invite',
'invite-cancel', 'avatar', 'other',
'follow',
]),
content: PropTypes.oneOfType([
PropTypes.string,
PropTypes.node,
]).isRequired,
time: PropTypes.string.isRequired,
2021-08-16 15:21:23 +03:00
onClick: PropTypes.func,
2021-07-28 16:15:52 +03:00
};
export default TimelineChange;