Author.js

 1import { withStyles } from '@material-ui/core/styles';
 2import Tooltip from '@material-ui/core/Tooltip/Tooltip';
 3import React from 'react';
 4
 5const styles = theme => ({
 6  author: {
 7    ...theme.typography.body2,
 8  },
 9  bold: {
10    fontWeight: 'bold',
11  },
12});
13
14const Author = ({ author, bold, classes }) => {
15  const klass = bold ? [classes.author, classes.bold] : [classes.author];
16
17  if (!author.email) {
18    return <span className={klass.join(' ')}>{author.displayName}</span>;
19  }
20
21  return (
22    <Tooltip title={author.email}>
23      <span className={klass.join(' ')}>{author.displayName}</span>
24    </Tooltip>
25  );
26};
27
28export default withStyles(styles)(Author);