Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
37fb0ad2
Unverified
Commit
37fb0ad2
authored
Nov 06, 2020
by
Steven
Committed by
GitHub
Nov 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update image example with link back to source code (#18909)
Fixes #18908
parent
39453bba
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
88 additions
and
2 deletions
+88
-2
view-source.js
examples/image-component/components/view-source.js
+26
-0
view-source.module.css
examples/image-component/components/view-source.module.css
+48
-0
package.json
examples/image-component/package.json
+2
-2
background.js
examples/image-component/pages/background.js
+2
-0
index.js
examples/image-component/pages/index.js
+2
-0
layout-fill.js
examples/image-component/pages/layout-fill.js
+2
-0
layout-fixed.js
examples/image-component/pages/layout-fixed.js
+2
-0
layout-intrinsic.js
examples/image-component/pages/layout-intrinsic.js
+2
-0
layout-responsive.js
examples/image-component/pages/layout-responsive.js
+2
-0
No files found.
examples/image-component/components/view-source.js
0 → 100644
View file @
37fb0ad2
import
{
svg
,
arm
}
from
'./view-source.module.css'
const
ViewSource
=
({
pathname
})
=>
(
<
a
title
=
"View Source"
href
=
{
`https://github.com/vercel/next.js/tree/canary/examples/image-component/
${
pathname
}
`
}
>
<
svg
xmlns
=
"http://www.w3.org/2000/svg"
width
=
"80"
height
=
"80"
viewBox
=
"0 0 250 250"
fill
=
"#151513"
className
=
{
svg
}
>
<
path
d
=
"M0 0l115 115h15l12 27 108 108V0z"
fill
=
"#fff"
/>
<
path
className
=
{
arm
}
d
=
"M128 109c-15-9-9-19-9-19 3-7 2-11 2-11-1-7 3-2 3-2 4 5 2 11 2 11-3 10 5 15 9 16"
/>
<
path
d
=
"M115 115s4 2 5 0l14-14c3-2 6-3 8-3-8-11-15-24 2-41 5-5 10-7 16-7 1-2 3-7 12-11 0 0 5 3 7 16 4 2 8 5 12 9s7 8 9 12c14 3 17 7 17 7-4 8-9 11-11 11 0 6-2 11-7 16-16 16-30 10-41 2 0 3-1 7-5 11l-12 11c-1 1 1 5 1 5z"
/>
<
/svg
>
<
/a
>
)
export
default
ViewSource
examples/image-component/components/view-source.module.css
0 → 100644
View file @
37fb0ad2
.svg
{
position
:
absolute
;
top
:
0
;
right
:
0
;
}
.arm
{
transform-origin
:
130px
106px
;
}
.svg
:hover
.arm
{
animation
:
wave
560ms
ease-in-out
;
}
@keyframes
wave
{
0
%
{
transform
:
rotate
(
0deg
);
}
20
%
{
transform
:
rotate
(
-25deg
);
}
40
%
{
transform
:
rotate
(
10deg
);
}
60
%
{
transform
:
rotate
(
-25deg
);
}
80
%
{
transform
:
rotate
(
10deg
);
}
100
%
{
transform
:
rotate
(
0deg
);
}
}
@media
(
max-width
:
500px
)
{
.svg
:hover
.arm
{
animation
:
none
;
}
.svg
:hover
.arm
{
animation
:
wave
560ms
ease-in-out
;
}
}
examples/image-component/package.json
View file @
37fb0ad2
{
{
"name"
:
"
rewrites
"
,
"name"
:
"
image-component
"
,
"version"
:
"1.0.0"
,
"version"
:
"1.0.0"
,
"scripts"
:
{
"scripts"
:
{
"dev"
:
"next dev"
,
"dev"
:
"next dev"
,
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
"start"
:
"next start"
"start"
:
"next start"
},
},
"dependencies"
:
{
"dependencies"
:
{
"next"
:
"
latest
"
,
"next"
:
"
canary
"
,
"react"
:
"^16.13.1"
,
"react"
:
"^16.13.1"
,
"react-dom"
:
"^16.13.1"
"react-dom"
:
"^16.13.1"
},
},
...
...
examples/image-component/pages/background.js
View file @
37fb0ad2
import
Image
from
'next/image'
import
Image
from
'next/image'
import
ViewSource
from
'../components/view-source'
import
{
bgWrap
,
bgText
}
from
'../styles.module.css'
import
{
bgWrap
,
bgText
}
from
'../styles.module.css'
const
Background
=
()
=>
(
const
Background
=
()
=>
(
<
div
>
<
div
>
<
ViewSource
pathname
=
"pages/background.js"
/>
<
div
className
=
{
bgWrap
}
>
<
div
className
=
{
bgWrap
}
>
<
Image
<
Image
alt
=
"Mountains"
alt
=
"Mountains"
...
...
examples/image-component/pages/index.js
View file @
37fb0ad2
import
styles
from
'../styles.module.css'
import
styles
from
'../styles.module.css'
import
Image
from
'next/image'
import
Image
from
'next/image'
import
Link
from
'next/link'
import
Link
from
'next/link'
import
ViewSource
from
'../components/view-source'
const
Code
=
(
p
)
=>
<
code
className
=
{
styles
.
inlineCode
}
{...
p
}
/
>
const
Code
=
(
p
)
=>
<
code
className
=
{
styles
.
inlineCode
}
{...
p
}
/
>
const
Index
=
()
=>
(
const
Index
=
()
=>
(
<
div
className
=
{
styles
.
container
}
>
<
div
className
=
{
styles
.
container
}
>
<
ViewSource
pathname
=
"pages/index.js"
/>
<
div
className
=
{
styles
.
card
}
>
<
div
className
=
{
styles
.
card
}
>
<
h1
>
Image
Component
with
Next
.
js
<
/h1
>
<
h1
>
Image
Component
with
Next
.
js
<
/h1
>
<
p
>
<
p
>
...
...
examples/image-component/pages/layout-fill.js
View file @
37fb0ad2
import
Image
from
'next/image'
import
Image
from
'next/image'
import
ViewSource
from
'../components/view-source'
const
Fill
=
()
=>
(
const
Fill
=
()
=>
(
<
div
>
<
div
>
<
ViewSource
pathname
=
"pages/layout-fill.js"
/>
<
h1
>
Image
Component
With
Layout
Fill
<
/h1
>
<
h1
>
Image
Component
With
Layout
Fill
<
/h1
>
<
div
style
=
{{
position
:
'relative'
,
width
:
'300px'
,
height
:
'500px'
}}
>
<
div
style
=
{{
position
:
'relative'
,
width
:
'300px'
,
height
:
'500px'
}}
>
<
Image
<
Image
...
...
examples/image-component/pages/layout-fixed.js
View file @
37fb0ad2
import
Image
from
'next/image'
import
Image
from
'next/image'
import
ViewSource
from
'../components/view-source'
const
Fixed
=
()
=>
(
const
Fixed
=
()
=>
(
<
div
>
<
div
>
<
ViewSource
pathname
=
"pages/layout-fixed.js"
/>
<
h1
>
Image
Component
With
Layout
Fixed
<
/h1
>
<
h1
>
Image
Component
With
Layout
Fixed
<
/h1
>
<
Image
<
Image
alt
=
"Mountains"
alt
=
"Mountains"
...
...
examples/image-component/pages/layout-intrinsic.js
View file @
37fb0ad2
import
Image
from
'next/image'
import
Image
from
'next/image'
import
ViewSource
from
'../components/view-source'
const
Intrinsic
=
()
=>
(
const
Intrinsic
=
()
=>
(
<
div
>
<
div
>
<
ViewSource
pathname
=
"pages/layout-intrinsic.js"
/>
<
h1
>
Image
Component
With
Layout
Intrinsic
<
/h1
>
<
h1
>
Image
Component
With
Layout
Intrinsic
<
/h1
>
<
Image
<
Image
alt
=
"Mountains"
alt
=
"Mountains"
...
...
examples/image-component/pages/layout-responsive.js
View file @
37fb0ad2
import
Image
from
'next/image'
import
Image
from
'next/image'
import
ViewSource
from
'../components/view-source'
const
Responsive
=
()
=>
(
const
Responsive
=
()
=>
(
<
div
>
<
div
>
<
ViewSource
pathname
=
"pages/layout-responsive.js"
/>
<
h1
>
Image
Component
With
Layout
Responsive
<
/h1
>
<
h1
>
Image
Component
With
Layout
Responsive
<
/h1
>
<
Image
<
Image
alt
=
"Mountains"
alt
=
"Mountains"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment