2017-05-12 00:23:56 +00:00
|
|
|
// @flow
|
2016-05-20 16:02:39 +00:00
|
|
|
import React from 'react';
|
2016-08-15 19:41:41 +00:00
|
|
|
import { toJS } from 'mobx';
|
2017-05-17 07:11:13 +00:00
|
|
|
import { Link } from 'react-router-dom';
|
2017-05-25 07:07:41 +00:00
|
|
|
import type { Document } from 'types';
|
|
|
|
import styled from 'styled-components';
|
2017-05-26 04:59:35 +00:00
|
|
|
import { color } from 'styles/constants';
|
2017-05-25 07:07:41 +00:00
|
|
|
import Markdown from 'components/Markdown';
|
2017-05-26 07:04:13 +00:00
|
|
|
import PublishingInfo from 'components/PublishingInfo';
|
2017-05-25 07:07:41 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
document: Document,
|
|
|
|
};
|
|
|
|
|
|
|
|
const Container = styled.div`
|
|
|
|
width: 100%;
|
|
|
|
padding: 20px 0;
|
|
|
|
`;
|
|
|
|
|
2017-05-26 04:59:35 +00:00
|
|
|
const DocumentLink = styled(Link)`
|
|
|
|
display: block;
|
|
|
|
margin: -16px;
|
|
|
|
padding: 16px;
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
|
|
h1 {
|
|
|
|
margin-top: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
background: ${color.smokeLight};
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2017-05-30 01:22:10 +00:00
|
|
|
// $FlowIssue
|
2017-05-26 07:04:13 +00:00
|
|
|
const TruncatedMarkdown = styled(Markdown)`
|
2017-05-26 04:59:35 +00:00
|
|
|
pointer-events: none;
|
|
|
|
`;
|
|
|
|
|
2017-05-25 07:07:41 +00:00
|
|
|
const DocumentPreview = ({ document }: Props) => {
|
|
|
|
return (
|
|
|
|
<Container>
|
2017-05-26 04:59:35 +00:00
|
|
|
<DocumentLink to={document.url}>
|
|
|
|
<PublishingInfo
|
|
|
|
createdAt={document.createdAt}
|
|
|
|
createdBy={document.createdBy}
|
|
|
|
updatedAt={document.updatedAt}
|
|
|
|
updatedBy={document.updatedBy}
|
|
|
|
collaborators={toJS(document.collaborators)}
|
|
|
|
/>
|
2017-05-26 07:04:13 +00:00
|
|
|
<TruncatedMarkdown text={document.text} limit={150} />
|
2017-05-26 04:59:35 +00:00
|
|
|
</DocumentLink>
|
2017-05-25 07:07:41 +00:00
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
};
|
2016-05-20 16:02:39 +00:00
|
|
|
|
2017-05-25 07:07:41 +00:00
|
|
|
export default DocumentPreview;
|