Skip to content

Commit

Permalink
Add component wrapper in sizes documentation code snippet (#39437)
Browse files Browse the repository at this point in the history
* Wrap sizes code snippets in component

* Don't remove docs import statement
  • Loading branch information
atcastle committed Aug 9, 2022
1 parent 997e3c0 commit e2119c0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
20 changes: 11 additions & 9 deletions docs/api-reference/next/future/image.md
Expand Up @@ -263,15 +263,17 @@ For example, if you know your styling will cause an image to be full-width on mo

```js
import Image from 'next/image'
;<div className="grid-element">
<Image
src="/example.png"
layout="fill"
sizes="(min-width: 75em) 33vw,
(min-width: 48em) 50vw,
100vw"
/>
</div>
const Example = () => (
<div className="grid-element">
<Image
src="/example.png"
layout="fill"
sizes="(min-width: 75em) 33vw,
(min-width: 48em) 50vw,
100vw"
/>
</div>
)
```

This example `sizes` could have a dramatic effect on performance metrics. Without the `33vw` sizes, the image selected from the server would be 3 times as wide as it needs to be. Because file size is proportional to the square of the width, without `sizes` the user would download an image that's 9 times larger than necessary.
Expand Down
20 changes: 11 additions & 9 deletions docs/api-reference/next/image.md
Expand Up @@ -143,15 +143,17 @@ For example, if you know your styling will cause an image to be full-width on mo

```js
import Image from 'next/image'
;<div className="grid-element">
<Image
src="/example.png"
layout="fill"
sizes="(min-width: 75em) 33vw,
(min-width: 48em) 50vw,
100vw"
/>
</div>
const Example = () => (
<div className="grid-element">
<Image
src="/example.png"
layout="fill"
sizes="(min-width: 75em) 33vw,
(min-width: 48em) 50vw,
100vw"
/>
</div>
)
```

This example `sizes` could have a dramatic effect on performance metrics. Without the `33vw` sizes, the image selected from the server would be 3 times as wide as it needs to be. Because file size is proportional to the square of the width, without `sizes` the user would download an image that's 9 times larger than necessary.
Expand Down

0 comments on commit e2119c0

Please sign in to comment.