Files
cinny/src/app/molecules/room-intro/RoomIntro.jsx
T

48 lines
1.3 KiB
React
Raw Normal View History

2021-07-28 18:45:52 +05:30
import React from 'react';
import PropTypes from 'prop-types';
2021-08-31 18:43:31 +05:30
import './RoomIntro.scss';
2021-07-28 18:45:52 +05:30
import Linkify from 'linkifyjs/react';
import colorMXID from '../../../util/colorMXID';
import Text from '../../atoms/text/Text';
import Avatar from '../../atoms/avatar/Avatar';
function linkifyContent(content) {
return <Linkify options={{ target: { url: '_blank' } }}>{content}</Linkify>;
}
2021-08-31 18:43:31 +05:30
function RoomIntro({
2021-08-17 17:04:21 +05:30
roomId, avatarSrc, name, heading, desc, time,
2021-07-28 18:45:52 +05:30
}) {
return (
2021-08-31 18:43:31 +05:30
<div className="room-intro">
2021-08-17 17:04:21 +05:30
<Avatar imageSrc={avatarSrc} text={name.slice(0, 1)} bgColor={colorMXID(roomId)} size="large" />
2021-08-31 18:43:31 +05:30
<div className="room-intro__content">
<Text className="room-intro__name" variant="h1">{heading}</Text>
<Text className="room-intro__desc" variant="b1">{linkifyContent(desc)}</Text>
{ time !== null && <Text className="room-intro__time" variant="b3">{time}</Text>}
2021-07-28 18:45:52 +05:30
</div>
</div>
);
}
2021-08-31 18:43:31 +05:30
RoomIntro.defaultProps = {
2021-07-28 18:45:52 +05:30
avatarSrc: false,
time: null,
};
2021-08-31 18:43:31 +05:30
RoomIntro.propTypes = {
2021-08-17 17:04:21 +05:30
roomId: PropTypes.string.isRequired,
2021-07-28 18:45:52 +05:30
avatarSrc: PropTypes.oneOfType([
PropTypes.string,
PropTypes.bool,
]),
name: PropTypes.string.isRequired,
heading: PropTypes.string.isRequired,
desc: PropTypes.string.isRequired,
time: PropTypes.string,
};
2021-08-31 18:43:31 +05:30
export default RoomIntro;