summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-11-12 19:33:57 +0900
committerJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-11-12 19:33:57 +0900
commit0eca7a9986cb5730cc64c858803a1a8040a7bc72 (patch)
tree03dc0018e1e9d899efef9a98a8ba7da2d3f4e68c
parent5c8387ac7e7b268a7257ad6671b5dc9eb34cc90b (diff)
lazy-load card images
-rw-r--r--public/index.html1
-rw-r--r--public/loading.pngbin0 -> 25334 bytes
-rw-r--r--src/App.js16
3 files changed, 11 insertions, 6 deletions
diff --git a/public/index.html b/public/index.html
index 71c2c1f..2a6a775 100644
--- a/public/index.html
+++ b/public/index.html
@@ -15,6 +15,7 @@
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
+ <img src="%PUBLIC_URL%/loading.png" style='display:none'/>
<div id="root"></div>
</body>
</html>
diff --git a/public/loading.png b/public/loading.png
new file mode 100644
index 0000000..7f4571b
--- /dev/null
+++ b/public/loading.png
Binary files differ
diff --git a/src/App.js b/src/App.js
index ef78070..96f3aa9 100644
--- a/src/App.js
+++ b/src/App.js
@@ -172,14 +172,18 @@ function StoreItem(props) {
subheader={props.data.author}
subheaderTypographyProps={{className: classes.text}}
/>
- <CardMedia className={classes.media}
- image={props.data.img}
- title={props.data.title}
- >
+ <div className={classes.media}>
+ <CardMedia
+ component='img'
+ loading='lazy'
+ image={props.data.img}
+ title={props.data.title}
+ style={{height: '100%', backgroundImage:'url(/loading.png)'}}
+ />
<Chip label={props.data.price} className={classes.price}/>
<Chip label={t(props.data.cat)} className={classes.cat}/>
- <Rating name="size-small" size="small" className={classes.rating} readOnly defaultValue={props.data.rating} precision={0.5}/>
- </CardMedia>
+ <Rating size="small" className={classes.rating} readOnly defaultValue={props.data.rating} precision={0.5}/>
+ </div>
</CardActionArea>
</Card>
</Grow>