-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcard.js
45 lines (41 loc) · 1.2 KB
/
card.js
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
import React, { useEffect, useState } from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Card from '@material-ui/core/Card';
import CardActionArea from '@material-ui/core/CardActionArea';
import CardActions from '@material-ui/core/CardActions';
import CardMedia from '@material-ui/core/CardMedia';
import Button from '@material-ui/core/Button';
const useStyles = makeStyles({
root: {
maxWidth: 345,
},
});
export default function ImgCard() {
const classes = useStyles();
const [n1, setN1] = useState(100);
const [n2, setN2] = useState(100);
useEffect(()=>{
setN1(Math.floor(Math.random() * (800 - 100 + 1)) + 100);
setN2(Math.floor(Math.random() * (800 - 100 + 1)) + 100);
},[])
return (
<Card className={classes.root}>
<CardActionArea>
<CardMedia
component="img"
alt="Contemplative Reptile"
height="140"
image={"https://picsum.photos/" + n1 + "/" + n2}
/>
</CardActionArea>
<CardActions>
<Button size="small" color="primary">
Share
</Button>
<Button size="small" color="primary">
Learn More
</Button>
</CardActions>
</Card>
);
}