Nicer document previews

This commit is contained in:
Jori Lallo
2016-05-20 00:34:46 -07:00
parent 90310703ec
commit 01bd07bf9b
3 changed files with 35 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import moment from 'moment';
import Link from 'react-router/lib/Link'; import Link from 'react-router/lib/Link';
import styles from './AtlasPreview.scss'; import styles from './AtlasPreview.scss';
@ -16,7 +17,17 @@ class AtlasPreview extends React.Component {
return ( return (
<div className={ styles.container }> <div className={ styles.container }>
<h2><Link to={ `/atlas/${data.id}` } className={ styles.atlasLink }>{ data.name }</Link></h2> <h2><Link to={ `/atlas/${data.id}` } className={ styles.atlasLink }>{ data.name }</Link></h2>
<div className={ styles.description }>No documents. Why not <Link to={ `/atlas/${data.id}/new` }>create one</Link>?</div> { data.recentDocuments.length > 0 ?
data.recentDocuments.map(document => {
return (
<Link to={ `/documents/${document.id}` } className={ styles.documentPreview }>
<h3>{ document.title }</h3>
<span>{ moment(document.updatedAt).fromNow() }</span>
</Link>)
})
: (
<div className={ styles.description }>No documents. Why not <Link to={ `/atlas/${data.id}/new` }>create one</Link>?</div>
) }
</div> </div>
); );
} }

View File

@ -16,4 +16,26 @@
.description { .description {
color: #aaa; color: #aaa;
}
.documentPreview {
display: flex;
flex: 1;
justify-content: space-between;
margin-bottom: 20px;
text-decoration: none;
h3 {
font-weight: normal;
font-size: 15px;
color: $textColor;
margin: 0;
}
span {
font-size: 13px;
color: #ccc;
}
} }

View File

@ -27,7 +27,7 @@ class Dashboard extends React.Component {
{ this.props.isLoading ? ( { this.props.isLoading ? (
<AtlasPreviewLoading /> <AtlasPreviewLoading />
) : this.props.items.map((item) => { ) : this.props.items.map((item) => {
return (<AtlasPreview data={ item } />); return (<AtlasPreview key={ item.id } data={ item } />);
}) } }) }
</Flex> </Flex>
</CenteredContent> </CenteredContent>