Skip to content

Commit 2073d34

Browse files
authored
Upgrade project to Next.js 10
Upgrade project to Next.js 10
2 parents ef44c00 + 43e1be3 commit 2073d34

File tree

6 files changed

+1322
-479
lines changed

6 files changed

+1322
-479
lines changed

components/LoadingSpinner/LoadingSpinner.component.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import React from 'react';
21
import styled, { keyframes } from 'styled-components';
32

43
/**
5-
* Loading spinner, shows while loading products or categories.
4+
* Loading spinner, shows while loading products or categories.
65
* Uses Styled-Components
76
*/
87
const LoadingSpinner = () => {

components/Product/IndexProducts.component.jsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Link from 'next/link';
2+
import Image from 'next/image';
23
import { v4 as uuidv4 } from 'uuid';
34

45
import WOO_CONFIG from 'utils/config/nextConfig';
@@ -16,7 +17,6 @@ const IndexProducts = ({ products }) => {
1617
{products ? (
1718
products.map(
1819
({
19-
id,
2020
databaseId,
2121
name,
2222
price,
@@ -30,26 +30,42 @@ const IndexProducts = ({ products }) => {
3030
key={uuidv4()}
3131
className="flex flex-col p-6 md:w-1/2 xl:w-1/4"
3232
>
33-
<Link href="/produkt/[post]" as={`/produkt/${slug}?id=${databaseId}`}>
33+
<Link
34+
href="/produkt/[post]"
35+
as={`/produkt/${slug}?id=${databaseId}`}
36+
>
3437
<a>
3538
{image ? (
36-
<img
39+
<Image
3740
id="product-image"
3841
className="transition duration-500 ease-in-out transform cursor-pointer hover:grow hover:shadow-lg hover:scale-105"
3942
alt={name}
43+
loading="lazy"
44+
quality="60"
4045
src={image.sourceUrl}
46+
sizes="(max-width: 900px) 1366px, (min-width: 901px) 272px"
47+
width={366}
48+
height={366}
4149
/>
4250
) : (
43-
<img
51+
<Image
4452
id="product-image"
4553
className="transition duration-500 ease-in-out transform cursor-pointer hover:grow hover:shadow-lg hover:scale-105"
4654
alt={name}
55+
loading="lazy"
56+
quality="60"
4757
src={WOO_CONFIG.PLACEHOLDER_SMALL_IMAGE_URL}
58+
sizes="(max-width: 900px) 1366px, (min-width: 901px) 272px"
59+
width={366}
60+
height={366}
4861
/>
4962
)}
5063
</a>
5164
</Link>
52-
<Link href="/produkt/[post]" as={`/produkt/${slug}?id=${databaseId}`}>
65+
<Link
66+
href="/produkt/[post]"
67+
as={`/produkt/${slug}?id=${databaseId}`}
68+
>
5369
<a>
5470
<div className="flex justify-center pt-3">
5571
<p className="font-bold text-center cursor-pointer">

components/Product/SingleProduct.component.jsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { useState, useEffect } from 'react';
2+
import Image from 'next/image';
23

34
import AddToCartButton from 'components/Cart/AddToCartButton.component';
45
import LoadingSpinner from 'components/LoadingSpinner/LoadingSpinner.component';
56

6-
import WOO_CONFIG from 'utils/config/nextConfig';
7+
import WOO_CONFIG from 'utils/config/nextConfig';
78

89
/**
910
* Shows a single product with an Add To Cart button.
@@ -44,18 +45,26 @@ const SingleProduct = ({ product }) => {
4445
<div className="container flex flex-wrap items-center pt-4 pb-12 mx-auto ">
4546
<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">
4647
{image ? (
47-
<img
48+
<Image
4849
id="product-image"
4950
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"
5051
alt={name}
5152
src={image.sourceUrl}
53+
loading="lazy"
54+
quality="60"
55+
width={600}
56+
height={600}
5257
/>
5358
) : (
54-
<img
59+
<Image
5560
id="product-image"
5661
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"
5762
alt={name}
5863
src={WOO_CONFIG.PLACEHOLDER_LARGE_IMAGE_URL}
64+
loading="lazy"
65+
quality="60"
66+
width={600}
67+
height={600}
5968
/>
6069
)}
6170

0 commit comments

Comments
 (0)