Add image to messages page

This commit is contained in:
Jannis Mattheis 2018-03-30 19:51:31 +02:00 committed by Jannis Mattheis
parent a48204ea40
commit fd945af8fb
3 changed files with 30 additions and 16 deletions

View File

@ -13,12 +13,13 @@ class Container extends Component {
static propTypes = { static propTypes = {
classes: PropTypes.object.isRequired, classes: PropTypes.object.isRequired,
children: PropTypes.node, children: PropTypes.node,
style: PropTypes.object,
}; };
render() { render() {
const {classes, children} = this.props; const {classes, children, style} = this.props;
return ( return (
<Paper elevation={6} className={classes.paper}> <Paper elevation={6} className={classes.paper} style={style}>
{children} {children}
</Paper> </Paper>
); );

View File

@ -18,22 +18,36 @@ const styles = () => ({
marginTop: -15, marginTop: -15,
marginRight: -15, marginRight: -15,
}, },
messageContentWrapper: {
width: '100%',
},
image: {
marginRight: 15,
},
imageWrapper: {
display: 'flex',
},
}); });
class Message extends Component { class Message extends Component {
static propTypes = { static propTypes = {
classes: PropTypes.object.isRequired, classes: PropTypes.object.isRequired,
title: PropTypes.string.isRequired, title: PropTypes.string.isRequired,
image: PropTypes.string.isRequired,
date: PropTypes.string.isRequired, date: PropTypes.string.isRequired,
content: PropTypes.string.isRequired, content: PropTypes.string.isRequired,
fDelete: PropTypes.func.isRequired, fDelete: PropTypes.func.isRequired,
}; };
render() { render() {
const {fDelete, classes, title, date, content} = this.props; const {fDelete, classes, title, date, content, image} = this.props;
return ( return (
<Container> <Container style={{display: 'flex'}}>
<div className={classes.imageWrapper}>
<img src={image} alt="app logo" width="70" height="70" className={classes.image}/>
</div>
<div className={classes.messageContentWrapper}>
<div className={classes.header}> <div className={classes.header}>
<Typography className={classes.headerTitle} variant="headline"> <Typography className={classes.headerTitle} variant="headline">
{title} {title}
@ -43,9 +57,8 @@ class Message extends Component {
</Typography> </Typography>
<IconButton onClick={fDelete} className={classes.trash}><Delete/></IconButton> <IconButton onClick={fDelete} className={classes.trash}><Delete/></IconButton>
</div> </div>
<Typography component="p"> <Typography component="p">{content}</Typography>
{content} </div>
</Typography>
</Container> </Container>
); );
} }

View File

@ -59,7 +59,7 @@ class Messages extends Component {
return ( return (
<Grid item xs={12} key={message.id}> <Grid item xs={12} key={message.id}>
<Message fDelete={() => MessageAction.deleteMessage(message.id)} title={message.title} <Message fDelete={() => MessageAction.deleteMessage(message.id)} title={message.title}
date={message.date} content={message.message}/> date={message.date} content={message.message} image={message.image}/>
</Grid> </Grid>
); );
})} })}