2017-05-12 00:23:56 +00:00
|
|
|
// @flow
|
2017-06-01 03:23:09 +00:00
|
|
|
import React, { Component } from 'react';
|
2017-05-17 07:11:13 +00:00
|
|
|
import { Link } from 'react-router-dom';
|
2017-06-28 05:15:29 +00:00
|
|
|
import Document from 'models/Document';
|
2017-05-25 07:07:41 +00:00
|
|
|
import styled from 'styled-components';
|
2017-05-26 04:59:35 +00:00
|
|
|
import { color } from 'styles/constants';
|
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,
|
2017-06-26 03:32:05 +00:00
|
|
|
highlight?: string,
|
2017-06-01 03:23:09 +00:00
|
|
|
innerRef?: Function,
|
2017-05-25 07:07:41 +00:00
|
|
|
};
|
|
|
|
|
2017-05-26 04:59:35 +00:00
|
|
|
const DocumentLink = styled(Link)`
|
|
|
|
display: block;
|
2017-06-26 03:32:05 +00:00
|
|
|
margin: 0 -16px;
|
2017-05-26 04:59:35 +00:00
|
|
|
padding: 16px;
|
|
|
|
border-radius: 8px;
|
2017-06-01 03:23:09 +00:00
|
|
|
border: 2px solid transparent;
|
|
|
|
max-height: 50vh;
|
2017-06-26 00:21:33 +00:00
|
|
|
min-width: 100%;
|
2017-06-01 03:23:09 +00:00
|
|
|
overflow: hidden;
|
2017-05-26 04:59:35 +00:00
|
|
|
|
2017-06-01 03:23:09 +00:00
|
|
|
&:hover,
|
|
|
|
&:active,
|
|
|
|
&:focus {
|
|
|
|
background: ${color.smokeLight};
|
|
|
|
border: 2px solid ${color.smoke};
|
|
|
|
outline: none;
|
2017-05-26 04:59:35 +00:00
|
|
|
}
|
|
|
|
|
2017-06-01 03:23:09 +00:00
|
|
|
&:focus {
|
|
|
|
border: 2px solid ${color.slateDark};
|
|
|
|
}
|
|
|
|
|
2017-06-26 03:32:05 +00:00
|
|
|
h3 {
|
2017-06-01 03:23:09 +00:00
|
|
|
margin-top: 0;
|
2017-05-26 04:59:35 +00:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2017-06-01 03:23:09 +00:00
|
|
|
class DocumentPreview extends Component {
|
|
|
|
props: Props;
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { document, innerRef, ...rest } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<DocumentLink to={document.url} innerRef={innerRef} {...rest}>
|
2017-06-26 03:32:05 +00:00
|
|
|
<h3>{document.title}</h3>
|
2017-05-26 04:59:35 +00:00
|
|
|
<PublishingInfo
|
|
|
|
createdAt={document.createdAt}
|
|
|
|
createdBy={document.createdBy}
|
|
|
|
updatedAt={document.updatedAt}
|
|
|
|
updatedBy={document.updatedBy}
|
|
|
|
/>
|
|
|
|
</DocumentLink>
|
2017-06-01 03:23:09 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2016-05-20 16:02:39 +00:00
|
|
|
|
2017-05-25 07:07:41 +00:00
|
|
|
export default DocumentPreview;
|