Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify image component examples app for static image #25956

Merged
merged 1 commit into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion examples/image-component/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import styles from '../styles.module.css'
import Image from 'next/image'
import Link from 'next/link'
import ViewSource from '../components/view-source'
import vercel from '../public/vercel.png'

const Code = (p) => <code className={styles.inlineCode} {...p} />

Expand Down Expand Up @@ -62,6 +63,17 @@ const Index = () => (
</li>
</ul>
<hr className={styles.hr} />
<h2 id="placeholder">Placeholder</h2>
<p>
Adding <Code>placeholder="blur"</Code> to an image enables a blurry
placeholder effect while that image loads.
</p>
<p>
<Link href="/background">
<a>See an example of the blurry placeholder.</a>
</Link>
</p>
<hr className={styles.hr} />
<h2 id="internal">Internal Image</h2>
<p>
The following is an example of a reference to an interal image from the{' '}
Expand All @@ -71,7 +83,7 @@ const Index = () => (
This image is intentionally large so you have to scroll down to the next
image.
</p>
<Image alt="Vercel logo" src="/vercel.png" width={1000} height={1000} />
<Image alt="Vercel logo" src={vercel} width={1000} height={1000} />
<hr className={styles.hr} />
<h2 id="external">External Image</h2>
<p>
Expand Down
12 changes: 4 additions & 8 deletions examples/image-component/pages/layout-fill.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
import Image from 'next/image'
import ViewSource from '../components/view-source'
import mountains from '../public/mountains.jpg'
Copy link
Member

@styfle styfle Jun 9, 2021

Choose a reason for hiding this comment

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

Do we want to use lowercase or should we use uppercase to match other imports?

Copy link
Member

Choose a reason for hiding this comment

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

Lowercase is correct, uppercase is for React components


const Fill = () => (
<div>
<ViewSource pathname="pages/layout-fill.js" />
<h1>Image Component With Layout Fill</h1>
<div style={{ position: 'relative', width: '300px', height: '500px' }}>
<Image
alt="Mountains"
src="/mountains.jpg"
layout="fill"
objectFit="cover"
/>
<Image alt="Mountains" src={mountains} layout="fill" objectFit="cover" />
</div>
<div style={{ position: 'relative', width: '300px', height: '500px' }}>
<Image
alt="Mountains"
src="/mountains.jpg"
src={mountains}
layout="fill"
objectFit="contain"
/>
</div>
<div style={{ position: 'relative', width: '300px', height: '500px' }}>
<Image
alt="Mountains"
src="/mountains.jpg"
src={mountains}
layout="fill"
objectFit="none"
quality={100}
Expand Down
3 changes: 2 additions & 1 deletion examples/image-component/pages/layout-fixed.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import Image from 'next/image'
import ViewSource from '../components/view-source'
import mountains from '../public/mountains.jpg'

const Fixed = () => (
<div>
<ViewSource pathname="pages/layout-fixed.js" />
<h1>Image Component With Layout Fixed</h1>
<Image
alt="Mountains"
src="/mountains.jpg"
src={mountains}
layout="fixed"
width={700}
height={475}
Expand Down
3 changes: 2 additions & 1 deletion examples/image-component/pages/layout-intrinsic.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import Image from 'next/image'
import ViewSource from '../components/view-source'
import mountains from '../public/mountains.jpg'

const Intrinsic = () => (
<div>
<ViewSource pathname="pages/layout-intrinsic.js" />
<h1>Image Component With Layout Intrinsic</h1>
<Image
alt="Mountains"
src="/mountains.jpg"
src={mountains}
layout="intrinsic"
width={700}
height={475}
Expand Down
3 changes: 2 additions & 1 deletion examples/image-component/pages/layout-responsive.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import Image from 'next/image'
import ViewSource from '../components/view-source'
import mountains from '../public/mountains.jpg'

const Responsive = () => (
<div>
<ViewSource pathname="pages/layout-responsive.js" />
<h1>Image Component With Layout Responsive</h1>
<Image
alt="Mountains"
src="/mountains.jpg"
src={mountains}
layout="responsive"
width={700}
height={475}
Expand Down
20 changes: 20 additions & 0 deletions examples/image-component/pages/placeholder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Image from 'next/image'
import ViewSource from '../components/view-source'
import mountains from '../public/mountains.jpg'

const Responsive = () => (
<div>
<ViewSource pathname="pages/layout-responsive.js" />
<h1>Image Component With Layout Responsive</h1>
<Image
alt="Mountains"
src={mountains}
layout="responsive"
placeholder="blur"
width={700}
height={475}
/>
</div>
)

export default Responsive