File tree Expand file tree Collapse file tree 6 files changed +1322
-479
lines changed Expand file tree Collapse file tree 6 files changed +1322
-479
lines changed Original file line number Diff line number Diff line change 1
- import React from 'react' ;
2
1
import styled , { keyframes } from 'styled-components' ;
3
2
4
3
/**
5
- * Loading spinner, shows while loading products or categories.
4
+ * Loading spinner, shows while loading products or categories.
6
5
* Uses Styled-Components
7
6
*/
8
7
const LoadingSpinner = ( ) => {
Original file line number Diff line number Diff line change 1
1
import Link from 'next/link' ;
2
+ import Image from 'next/image' ;
2
3
import { v4 as uuidv4 } from 'uuid' ;
3
4
4
5
import WOO_CONFIG from 'utils/config/nextConfig' ;
@@ -16,7 +17,6 @@ const IndexProducts = ({ products }) => {
16
17
{ products ? (
17
18
products . map (
18
19
( {
19
- id,
20
20
databaseId,
21
21
name,
22
22
price,
@@ -30,26 +30,42 @@ const IndexProducts = ({ products }) => {
30
30
key = { uuidv4 ( ) }
31
31
className = "flex flex-col p-6 md:w-1/2 xl:w-1/4"
32
32
>
33
- < Link href = "/produkt/[post]" as = { `/produkt/${ slug } ?id=${ databaseId } ` } >
33
+ < Link
34
+ href = "/produkt/[post]"
35
+ as = { `/produkt/${ slug } ?id=${ databaseId } ` }
36
+ >
34
37
< a >
35
38
{ image ? (
36
- < img
39
+ < Image
37
40
id = "product-image"
38
41
className = "transition duration-500 ease-in-out transform cursor-pointer hover:grow hover:shadow-lg hover:scale-105"
39
42
alt = { name }
43
+ loading = "lazy"
44
+ quality = "60"
40
45
src = { image . sourceUrl }
46
+ sizes = "(max-width: 900px) 1366px, (min-width: 901px) 272px"
47
+ width = { 366 }
48
+ height = { 366 }
41
49
/>
42
50
) : (
43
- < img
51
+ < Image
44
52
id = "product-image"
45
53
className = "transition duration-500 ease-in-out transform cursor-pointer hover:grow hover:shadow-lg hover:scale-105"
46
54
alt = { name }
55
+ loading = "lazy"
56
+ quality = "60"
47
57
src = { WOO_CONFIG . PLACEHOLDER_SMALL_IMAGE_URL }
58
+ sizes = "(max-width: 900px) 1366px, (min-width: 901px) 272px"
59
+ width = { 366 }
60
+ height = { 366 }
48
61
/>
49
62
) }
50
63
</ a >
51
64
</ Link >
52
- < Link href = "/produkt/[post]" as = { `/produkt/${ slug } ?id=${ databaseId } ` } >
65
+ < Link
66
+ href = "/produkt/[post]"
67
+ as = { `/produkt/${ slug } ?id=${ databaseId } ` }
68
+ >
53
69
< a >
54
70
< div className = "flex justify-center pt-3" >
55
71
< p className = "font-bold text-center cursor-pointer" >
Original file line number Diff line number Diff line change 1
1
import { useState , useEffect } from 'react' ;
2
+ import Image from 'next/image' ;
2
3
3
4
import AddToCartButton from 'components/Cart/AddToCartButton.component' ;
4
5
import LoadingSpinner from 'components/LoadingSpinner/LoadingSpinner.component' ;
5
6
6
- import WOO_CONFIG from 'utils/config/nextConfig' ;
7
+ import WOO_CONFIG from 'utils/config/nextConfig' ;
7
8
8
9
/**
9
10
* Shows a single product with an Add To Cart button.
@@ -44,18 +45,26 @@ const SingleProduct = ({ product }) => {
44
45
< div className = "container flex flex-wrap items-center pt-4 pb-12 mx-auto " >
45
46
< div className = "grid grid-cols-1 gap-4 mt-16 lg:grid-cols-2 xl:grid-cols-2 md:grid-cols-2 sm:grid-cols-2" >
46
47
{ image ? (
47
- < img
48
+ < Image
48
49
id = "product-image"
49
50
className = "h-auto p-8 transition duration-500 ease-in-out transform xl:p-2 md:p-2 lg:p-2 hover:grow hover:shadow-lg hover:scale-105"
50
51
alt = { name }
51
52
src = { image . sourceUrl }
53
+ loading = "lazy"
54
+ quality = "60"
55
+ width = { 600 }
56
+ height = { 600 }
52
57
/>
53
58
) : (
54
- < img
59
+ < Image
55
60
id = "product-image"
56
61
className = "h-auto p-8 transition duration-500 ease-in-out transform xl:p-2 md:p-2 lg:p-2 hover:grow hover:shadow-lg hover:scale-105"
57
62
alt = { name }
58
63
src = { WOO_CONFIG . PLACEHOLDER_LARGE_IMAGE_URL }
64
+ loading = "lazy"
65
+ quality = "60"
66
+ width = { 600 }
67
+ height = { 600 }
59
68
/>
60
69
) }
61
70
You can’t perform that action at this time.
0 commit comments