Added multiple avatars to publishing info

This commit is contained in:
Jori Lallo
2016-08-15 15:50:13 +02:00
parent e06cac2344
commit 5673c383f5
3 changed files with 49 additions and 24 deletions

View File

@@ -1,4 +1,5 @@
import React, { PropTypes } from 'react';
import { toJS } from 'mobx';
import { observer } from 'mobx-react';
import PublishingInfo from 'components/PublishingInfo';
@@ -50,10 +51,11 @@ class Document extends React.Component {
return (
<div className={ styles.container }>
<PublishingInfo
name={ this.props.document.createdBy.name }
avatarUrl={ this.props.document.createdBy.avatarUrl }
createdAt={ this.props.document.createdAt }
createdBy={ this.props.document.createdBy }
updatedAt={ this.props.document.updatedAt }
updatedBy={ this.props.document.updatedBy }
collaborators={ toJS(this.props.document.collaborators) }
/>
<DocumentHtml html={ this.props.document.html } />
</div>

View File

@@ -1,4 +1,4 @@
import React from 'react';
import React, { PropTypes } from 'react';
import moment from 'moment';
import { Avatar } from 'rebass';
@@ -6,27 +6,45 @@ import { Flex } from 'reflexbox';
import styles from './PublishingInfo.scss';
const PublishingInfo = (props) => {
return (
<Flex align="center" className={ styles.user }>
<Avatar src={ props.avatarUrl } size={ 24 } />
<span className={ styles.userName }>
{ props.name } published { moment(props.createdAt).fromNow() }
{ props.createdAt !== props.updatedAt ? (
<span>
&nbsp;and modified { moment(props.updatedAt).fromNow() }
</span>
) : null }
</span>
</Flex>
);
};
class PublishingInfo extends React.Component {
static propTypes = {
collaborators: PropTypes.object.isRequired,
createdAt: PropTypes.string.isRequired,
createdBy: PropTypes.object.isRequired,
updatedAt: PropTypes.string.isRequired,
updatedBy: PropTypes.object.isRequired,
};
PublishingInfo.propTypes = {
avatarUrl: React.PropTypes.string.isRequired,
name: React.PropTypes.string.isRequired,
createdAt: React.PropTypes.string.isRequired,
updatedAt: React.PropTypes.string.isRequired,
};
render() {
return (
<Flex align="center" className={ styles.user }>
<Flex className={ styles.avatarLine }>
{ this.props.collaborators.reverse().map(user => (
<Avatar
src={ user.avatarUrl }
size={ 26 }
style={{
marginRight: '-12px',
border: '2px solid #FFFFFF',
}}
title={ user.name }
/>
)) }
</Flex>
<span className={ styles.userName }>
{ this.props.createdBy.name } published { moment(this.props.createdAt).fromNow() }
{ this.props.createdAt !== this.props.updatedAt ? (
<span>
&nbsp;and
{ this.props.createdBy.id !== this.props.updatedBy.id &&
` ${this.props.updatedBy.name} ` }
modified { moment(this.props.updatedAt).fromNow() }
</span>
) : null }
</span>
</Flex>
);
}
}
export default PublishingInfo;

View File

@@ -1,3 +1,8 @@
.avatarLine {
flex-direction: row-reverse;
margin-right: 10px;
}
.user {
margin-bottom: 30px;
color: #ccc;