scratch-www/src/components/social-message/social-message.jsx

48 lines
1.5 KiB
React
Raw Normal View History

const classNames = require('classnames');
const PropTypes = require('prop-types');
const React = require('react');
const FlexRow = require('../flex-row/flex-row.jsx');
2023-01-06 15:55:16 -05:00
const RelativeTime = require('../relative-time/relative-time.jsx');
require('./social-message.scss');
const SocialMessage = props => (
<props.as className={classNames('social-message', props.className)}>
<FlexRow className="mod-social-message">
<div className="social-message-content">
{typeof props.iconSrc === 'undefined' ? [] : [
<img
alt={props.iconAlt}
className={classNames('social-message-icon', props.imgClassName)}
key="social-message-icon"
src={props.iconSrc}
/>
]}
<div>
{props.children}
</div>
</div>
<span className="social-message-date">
2023-01-06 15:55:16 -05:00
<RelativeTime value={new Date(props.datetime)} />
</span>
</FlexRow>
</props.as>
);
SocialMessage.propTypes = {
as: PropTypes.string, // eslint-disable-line react/no-unused-prop-types
children: PropTypes.node,
className: PropTypes.string,
datetime: PropTypes.string.isRequired,
iconAlt: PropTypes.string,
iconSrc: PropTypes.string,
imgClassName: PropTypes.string
};
SocialMessage.defaultProps = {
as: 'li'
};
module.exports = SocialMessage;