-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathProfileCard.component.jsx
More file actions
87 lines (81 loc) · 1.88 KB
/
Copy pathProfileCard.component.jsx
File metadata and controls
87 lines (81 loc) · 1.88 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import React from "react";
import PropTypes from "prop-types";
import makeStyles from "@material-ui/core/styles/makeStyles";
import {
Card,
CardMedia,
CardContent,
CardHeader,
Typography
} from "@material-ui/core";
import Divider from "@material-ui/core/Divider";
const useStyles = makeStyles((theme) => ({
root: {
width: theme.spacing(32),
height: theme.spacing(56),
margin: theme.spacing(1),
position: "relative"
},
cardMedia: {
minHeight: 240
},
cardContent: {
marginBottom: theme.spacing(1),
borderRadius: theme.shape.borderRadius,
padding: theme.spacing(0.5)
}
}));
function ProfileCard({
avatarUrl,
username,
submissionCount,
langCount,
avgRating,
...props
}) {
const classes = useStyles();
const imageUrl = avatarUrl || `https://robohash.org/${username}`;
return (
<Card className={classes.root}>
<CardHeader title={username} />
<Divider />
<div className={classes.imgContainer}>
<CardMedia
className={classes.cardMedia}
onError={(e) => {
e.target.src = `https://robohash.org/${username}`;
}}
image={imageUrl}
height={80}
component="img"
/>
</div>
<Divider />
<CardContent>
<div className={classes.cardContent}>
<Typography variant="body1">
Total Submissions : {submissionCount}
</Typography>
</div>
<div className={classes.cardContent}>
<Typography variant="body1">
Languages used : {langCount}
</Typography>
</div>
<div className={classes.cardContent}>
<Typography variant="body1">
Average Rating : {avgRating}
</Typography>
</div>
</CardContent>
</Card>
);
}
ProfileCard.propTypes = {
username: PropTypes.string.isRequired,
avatarUrl: PropTypes.string,
submissionCount: PropTypes.number.isRequired,
langCount: PropTypes.number.isRequired,
avgRating: PropTypes.number.isRequired
};
export default React.memo(ProfileCard);