Added multiple avatars to publishing info
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
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>
|
||||
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;
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
.avatarLine {
|
||||
flex-direction: row-reverse;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.user {
|
||||
margin-bottom: 30px;
|
||||
color: #ccc;
|
||||
|
||||
Reference in New Issue
Block a user