forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update example for Image Component (vercel#18762)
- Loading branch information
Showing
9 changed files
with
201 additions
and
9 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
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,47 @@ | ||
import Image from 'next/image' | ||
|
||
const Background = () => ( | ||
<div> | ||
<div className="container"> | ||
<Image | ||
alt="Mountains" | ||
src="/mountains.jpg" | ||
layout="fill" | ||
quality={100} | ||
className="cover" | ||
/> | ||
</div> | ||
<h1> | ||
Image Component | ||
<br /> | ||
as a Background | ||
</h1> | ||
<style jsx global>{` | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
background: black; | ||
color: white; | ||
} | ||
.container { | ||
position: fixed; | ||
height: 100vh; | ||
width: 100vw; | ||
overflow: hidden; | ||
z-index: -1; | ||
} | ||
.cover { | ||
object-fit: cover; | ||
} | ||
h1 { | ||
margin: 0; | ||
font-size: 2rem; | ||
line-height: 3rem; | ||
text-align: center; | ||
padding-top: 40vh; | ||
} | ||
`}</style> | ||
</div> | ||
) | ||
|
||
export default Background |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import Image from 'next/image' | ||
|
||
const Fill = () => ( | ||
<div> | ||
<h1>Image Component With Layout Fill</h1> | ||
<div style={{ position: 'relative', width: '300px', height: '500px' }}> | ||
<Image | ||
alt="Mountains" | ||
src="/mountains.jpg" | ||
layout="fill" | ||
className="cover" | ||
/> | ||
</div> | ||
<div style={{ position: 'relative', width: '300px', height: '500px' }}> | ||
<Image | ||
alt="Mountains" | ||
src="/mountains.jpg" | ||
layout="fill" | ||
className="contain" | ||
/> | ||
</div> | ||
<div style={{ position: 'relative', width: '300px', height: '500px' }}> | ||
<Image | ||
alt="Mountains" | ||
src="/mountains.jpg" | ||
layout="fill" | ||
className="none" | ||
quality={100} | ||
/> | ||
</div> | ||
<style jsx global>{` | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
background: black; | ||
color: white; | ||
} | ||
.contain { | ||
object-fit: contain; | ||
} | ||
.cover { | ||
object-fit: cover; | ||
} | ||
.none { | ||
object-fit: none; | ||
} | ||
`}</style> | ||
</div> | ||
) | ||
|
||
export default Fill |
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,24 @@ | ||
import Image from 'next/image' | ||
|
||
const Fixed = () => ( | ||
<div> | ||
<h1>Image Component With Layout Fixed</h1> | ||
<Image | ||
alt="Mountains" | ||
src="/mountains.jpg" | ||
layout="fixed" | ||
width={700} | ||
height={475} | ||
/> | ||
<style jsx global>{` | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
background: black; | ||
color: white; | ||
} | ||
`}</style> | ||
</div> | ||
) | ||
|
||
export default Fixed |
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,24 @@ | ||
import Image from 'next/image' | ||
|
||
const Intrinsic = () => ( | ||
<div> | ||
<h1>Image Component With Layout Intrinsic</h1> | ||
<Image | ||
alt="Mountains" | ||
src="/mountains.jpg" | ||
layout="intrinsic" | ||
width={700} | ||
height={475} | ||
/> | ||
<style jsx global>{` | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
background: black; | ||
color: white; | ||
} | ||
`}</style> | ||
</div> | ||
) | ||
|
||
export default Intrinsic |
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,24 @@ | ||
import Image from 'next/image' | ||
|
||
const Responsive = () => ( | ||
<div> | ||
<h1>Image Component With Layout Responsive</h1> | ||
<Image | ||
alt="Mountains" | ||
src="/mountains.jpg" | ||
layout="responsive" | ||
width={700} | ||
height={475} | ||
/> | ||
<style jsx global>{` | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
background: black; | ||
color: white; | ||
} | ||
`}</style> | ||
</div> | ||
) | ||
|
||
export default Responsive |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.