Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions using-pagination/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ const limit = 1;
const singleProductStyle = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to improve styling for all our examples. I'm happy if you want to add these here, but FYI, these may get removed with an updated design when we get some design resources to help here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's definitely a thing! Do you already have basic styling from other example that I could use here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these may get removed with an updated design when we get some design resources to help here

display: 'flex',
flexDirection: 'column',
width: '300px',
width: '200px',
margin: '10px',
};

function SingleProduct({product, index}) {
const { image } = product;
return (
<div style={singleProductStyle}>
<img src={`https://via.placeholder.com/300x200?text=${product.name}`} width={300} height={200} alt={product.name} title={product.name} />
<img src={image.url} width={200} height={200} alt={product.name} title={product.name} />
<Link href={`/products/${index+1}`}>
<a>{product.name}</a>
</Link>
Expand Down Expand Up @@ -45,6 +46,17 @@ export async function getStaticProps() {
node {
id
name
image {
id
url(transformation: {
image: {
resize: {
width: 200,
height: 200
}
}
})
}
}
}
pageInfo {
Expand Down
16 changes: 14 additions & 2 deletions using-pagination/src/pages/products/[page].js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ const limit = 1;
const singleProductStyle = {
display: 'flex',
flexDirection: 'column',
width: '300px',
width: '200px',
margin: '10px',
color: '#000',
};

function SingleProduct({product}) {
const { image } = product;
return (
<div style={singleProductStyle} key={product.id}>
<img src={`https://via.placeholder.com/300x200?text=${product.name}`} width={300} height={200} alt={product.name} title={product.name} />
<img src={image.url} width={200} height={200} alt={product.name} title={product.name} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not recommended you use <img /> if you know the width/height but instead use Next.js Image.

However, I would not show an image at all here. We have an example for that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@notrab we're using Next.js 9 on this project and next/image was introduced in v10. Unless we upgrade it, it's not possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not really relevant though. We should aim to keep these updated regardless.

<h3>{product.name}</h3>
</div>
)
Expand Down Expand Up @@ -105,6 +106,17 @@ export async function getStaticProps({ params }) {
node {
id
name
image {
id
url(transformation: {
image: {
resize: {
width: 200,
height: 200
}
}
})
}
}
}
pageInfo {
Expand Down