PostCard.js
1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React from "react";
import { Card, Image, Button, Label, Icon } from "semantic-ui-react";
import moment from "moment";
import { Link } from "react-router-dom";
const PostCard = ({
post: { username, body, id, createdAt, likeCount, commentCount, likes }
}) => {
const likePost = () => {};
return (
<Card fluid>
<Card.Content>
<Image
floated="right"
size="mini"
src="https://react.semantic-ui.com/images/avatar/large/steve.jpg"
/>
<Card.Header>{username} </Card.Header>
<Card.Meta as={Link} to={`/posts/${id}`}>
{moment(createdAt).fromNow(true)}
</Card.Meta>
<Card.Description>{body}</Card.Description>
</Card.Content>
<Card.Content extra>
<Button as="div" labelPosition="right" onClick={likePost}>
<Button color="teal" basic>
<Icon name="heart" />
</Button>
<Label basic color="teal" pointing="left">
{likeCount}
</Label>
</Button>
<Button as="div" labelPosition="right">
<Button color="blue" basic>
<Icon name="comment" />
</Button>
<Label basic color="blue" pointing="left">
{commentCount}
</Label>
</Button>
</Card.Content>
</Card>
);
};
export default PostCard;