Bug.js

  1import { withStyles } from '@material-ui/core/styles';
  2import Typography from '@material-ui/core/Typography/Typography';
  3import gql from 'graphql-tag';
  4import React from 'react';
  5import Author from '../Author';
  6import Date from '../Date';
  7import TimelineQuery from './TimelineQuery';
  8import Label from '../Label';
  9
 10const styles = theme => ({
 11  main: {
 12    maxWidth: 800,
 13    margin: 'auto',
 14    marginTop: theme.spacing.unit * 4,
 15  },
 16  header: {
 17    marginLeft: theme.spacing.unit + 40,
 18  },
 19  title: {
 20    ...theme.typography.headline,
 21  },
 22  id: {
 23    ...theme.typography.subheading,
 24    marginLeft: theme.spacing.unit,
 25  },
 26  container: {
 27    display: 'flex',
 28    marginBottom: theme.spacing.unit,
 29  },
 30  timeline: {
 31    flex: 1,
 32    marginTop: theme.spacing.unit * 2,
 33    marginRight: theme.spacing.unit * 2,
 34  },
 35  sidebar: {
 36    marginTop: theme.spacing.unit * 2,
 37    flex: '0 0 200px',
 38  },
 39  labelList: {
 40    listStyle: 'none',
 41    padding: 0,
 42    margin: 0,
 43  },
 44  label: {
 45    marginTop: theme.spacing.unit,
 46    marginBottom: theme.spacing.unit,
 47    '& > *': {
 48      display: 'block',
 49    },
 50  },
 51});
 52
 53const Bug = ({ bug, classes }) => (
 54  <main className={classes.main}>
 55    <div className={classes.header}>
 56      <span className={classes.title}>{bug.title}</span>
 57      <span className={classes.id}>{bug.humanId}</span>
 58
 59      <Typography color={'textSecondary'}>
 60        <Author author={bug.author} />
 61        {' opened this bug '}
 62        <Date date={bug.createdAt} />
 63      </Typography>
 64    </div>
 65
 66    <div className={classes.container}>
 67      <div className={classes.timeline}>
 68        <TimelineQuery id={bug.id} />
 69      </div>
 70      <div className={classes.sidebar}>
 71        <Typography variant={'subheading'}>Labels</Typography>
 72        <ul className={classes.labelList}>
 73          {bug.labels.map(l => (
 74            <li className={classes.label}>
 75              <Label label={l} key={l} />
 76            </li>
 77          ))}
 78        </ul>
 79      </div>
 80    </div>
 81  </main>
 82);
 83
 84Bug.fragment = gql`
 85  fragment Bug on Bug {
 86    id
 87    humanId
 88    status
 89    title
 90    labels
 91    createdAt
 92    author {
 93      email
 94      name
 95      displayName
 96    }
 97  }
 98`;
 99
100export default withStyles(styles)(Bug);