2019-06-27 01:59:27 +02:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
|
|
|
import relativeDate from 'tiny-relative-date';
|
2019-07-21 22:46:30 +02:00
|
|
|
import Button from 'component/button';
|
2019-07-24 23:02:35 +02:00
|
|
|
import Expandable from 'component/expandable';
|
2019-10-13 06:04:16 +02:00
|
|
|
import MarkdownPreview from 'component/common/markdown-preview';
|
2019-06-27 01:59:27 +02:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
author: string,
|
2019-07-17 22:56:36 +02:00
|
|
|
authorUri: string,
|
2019-06-27 01:59:27 +02:00
|
|
|
message: string,
|
|
|
|
timePosted: number,
|
|
|
|
};
|
|
|
|
|
|
|
|
function Comment(props: Props) {
|
2019-07-17 22:56:36 +02:00
|
|
|
const { author, authorUri, timePosted, message } = props;
|
2019-06-27 01:59:27 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<li className="comment">
|
2019-07-17 22:56:36 +02:00
|
|
|
<div className="comment__meta">
|
2019-11-22 22:13:00 +01:00
|
|
|
{!author ? (
|
|
|
|
<span className="comment__author">{__('Anonymous')}</span>
|
|
|
|
) : (
|
|
|
|
<Button
|
|
|
|
className="button--uri-indicator truncated-text comment__author"
|
|
|
|
navigate={authorUri}
|
|
|
|
label={author}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
2019-07-17 22:56:36 +02:00
|
|
|
<time className="comment__time" dateTime={timePosted}>
|
|
|
|
{relativeDate(timePosted)}
|
|
|
|
</time>
|
2019-06-27 01:59:27 +02:00
|
|
|
</div>
|
2019-07-24 23:02:35 +02:00
|
|
|
<div>
|
|
|
|
<Expandable>
|
2019-10-13 06:04:16 +02:00
|
|
|
<div className={'comment__message'}>
|
|
|
|
<MarkdownPreview content={message} promptLinks />
|
|
|
|
</div>
|
2019-07-24 23:02:35 +02:00
|
|
|
</Expandable>
|
|
|
|
</div>
|
2019-06-27 01:59:27 +02:00
|
|
|
</li>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Comment;
|