forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add layout prop to Image component (vercel#18491)
This PR introduces a new `layout` property. This allows 3 possible values (`fixed`, `intrinsic`, or `responsive`) which solve many use cases we have seen since 10.0.0 and will hopefully avoid usage of `unsized`. Fixes vercel#18351 Co-authored-by: Joe Haddad <[email protected]>
- Loading branch information
Showing
9 changed files
with
316 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
test/integration/image-component/default/pages/layout-fixed.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react' | ||
import Image from 'next/image' | ||
|
||
const Page = () => { | ||
return ( | ||
<div> | ||
<p>Layout Fixed</p> | ||
<Image | ||
id="fixed1" | ||
src="/wide.png" | ||
width="1200" | ||
height="700" | ||
layout="fixed" | ||
></Image> | ||
<Image | ||
id="fixed2" | ||
src="/wide.png" | ||
width="1200" | ||
height="700" | ||
layout="fixed" | ||
></Image> | ||
<Image | ||
id="fixed3" | ||
src="/wide.png" | ||
width="1200" | ||
height="700" | ||
layout="fixed" | ||
></Image> | ||
<Image | ||
id="fixed4" | ||
src="/wide.png" | ||
width="1200" | ||
height="700" | ||
layout="fixed" | ||
></Image> | ||
<p>Layout Fixed</p> | ||
</div> | ||
) | ||
} | ||
|
||
export default Page |
41 changes: 41 additions & 0 deletions
41
test/integration/image-component/default/pages/layout-intrinsic.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react' | ||
import Image from 'next/image' | ||
|
||
const Page = () => { | ||
return ( | ||
<div> | ||
<p>Layout Intrinsic</p> | ||
<Image | ||
id="intrinsic1" | ||
src="/wide.png" | ||
width="1200" | ||
height="700" | ||
layout="intrinsic" | ||
></Image> | ||
<Image | ||
id="intrinsic2" | ||
src="/wide.png" | ||
width="1200" | ||
height="700" | ||
layout="intrinsic" | ||
></Image> | ||
<Image | ||
id="intrinsic3" | ||
src="/wide.png" | ||
width="1200" | ||
height="700" | ||
layout="intrinsic" | ||
></Image> | ||
<Image | ||
id="intrinsic4" | ||
src="/wide.png" | ||
width="1200" | ||
height="700" | ||
layout="intrinsic" | ||
></Image> | ||
<p>Layout Intrinsic</p> | ||
</div> | ||
) | ||
} | ||
|
||
export default Page |
41 changes: 41 additions & 0 deletions
41
test/integration/image-component/default/pages/layout-responsive.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react' | ||
import Image from 'next/image' | ||
|
||
const Page = () => { | ||
return ( | ||
<div> | ||
<p>Layout Responsive</p> | ||
<Image | ||
id="responsive1" | ||
src="/wide.png" | ||
width="1200" | ||
height="700" | ||
layout="responsive" | ||
></Image> | ||
<Image | ||
id="responsive2" | ||
src="/wide.png" | ||
width="1200" | ||
height="700" | ||
layout="responsive" | ||
></Image> | ||
<Image | ||
id="responsive3" | ||
src="/wide.png" | ||
width="1200" | ||
height="700" | ||
layout="responsive" | ||
></Image> | ||
<Image | ||
id="responsive4" | ||
src="/wide.png" | ||
width="1200" | ||
height="700" | ||
layout="responsive" | ||
></Image> | ||
<p>Layout Responsive</p> | ||
</div> | ||
) | ||
} | ||
|
||
export default Page |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.