This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
outline/frontend/components/PublishingInfo/PublishingInfo.js
2017-05-11 17:23:56 -07:00

63 lines
1.6 KiB
JavaScript

// @flow
import React, { PropTypes } from 'react';
import moment from 'moment';
import styled from 'styled-components';
import { Flex } from 'reflexbox';
import styles from './PublishingInfo.scss';
class PublishingInfo extends React.Component {
static propTypes = {
collaborators: PropTypes.array.isRequired,
createdAt: PropTypes.string.isRequired,
createdBy: PropTypes.object.isRequired,
updatedAt: PropTypes.string.isRequired,
updatedBy: PropTypes.object.isRequired,
};
render() {
return (
<Flex align="center" className={styles.user}>
<Flex className={styles.avatarLine}>
{this.props.collaborators
.reverse()
.map(user => (
<Avatar
key={`avatar-${user.id}`}
src={user.avatarUrl}
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&nbsp;
{this.props.createdBy.id !== this.props.updatedBy.id &&
` ${this.props.updatedBy.name} `}
modified {moment(this.props.updatedAt).fromNow()}
</span>
: null}
</span>
</Flex>
);
}
}
const Avatar = styled.img`
width: 26px;
height: 26px;
marginRight: '-12px',
border-radius: 50%;
border: '2px solid #FFFFFF';
`;
export default PublishingInfo;