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
523b6156
Commit
523b6156
authored
Feb 16, 2018
by
Kye Hohenberger
Committed by
Tim Neutkens
Feb 16, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
with emotion example - hoist styles out of the index page component (#3821)
parent
7a1d9c18
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
56 deletions
+56
-56
index.js
examples/with-emotion/pages/index.js
+56
-56
No files found.
examples/with-emotion/pages/index.js
View file @
523b6156
...
@@ -7,8 +7,7 @@ if (typeof window !== 'undefined') {
...
@@ -7,8 +7,7 @@ if (typeof window !== 'undefined') {
hydrate
(
window
.
__NEXT_DATA__
.
ids
)
hydrate
(
window
.
__NEXT_DATA__
.
ids
)
}
}
export
default
()
=>
{
injectGlobal
`
injectGlobal
`
html, body {
html, body {
padding: 3rem 1rem;
padding: 3rem 1rem;
margin: 0;
margin: 0;
...
@@ -17,9 +16,9 @@ export default () => {
...
@@ -17,9 +16,9 @@ export default () => {
font-family: Helvetica, Arial, sans-serif;
font-family: Helvetica, Arial, sans-serif;
font-size: 24px;
font-size: 24px;
}
}
`
`
const
basicStyles
=
css
`
const
basicStyles
=
css
`
background-color: white;
background-color: white;
color: cornflowerblue;
color: cornflowerblue;
border: 1px solid lightgreen;
border: 1px solid lightgreen;
...
@@ -29,44 +28,45 @@ export default () => {
...
@@ -29,44 +28,45 @@ export default () => {
transition: all 0.1s linear;
transition: all 0.1s linear;
margin: 3rem 0;
margin: 3rem 0;
padding: 1rem 0.5rem;
padding: 1rem 0.5rem;
`
`
const
hoverStyles
=
css
`
const
hoverStyles
=
css
`
&:hover {
&:hover {
color: white;
color: white;
background-color: lightgray;
background-color: lightgray;
border-color: aqua;
border-color: aqua;
box-shadow: -15px -15px 0 0 aqua, -30px -30px 0 0 cornflowerblue;
box-shadow: -15px -15px 0 0 aqua, -30px -30px 0 0 cornflowerblue;
}
}
`
`
const
bounce
=
keyframes
`
const
bounce
=
keyframes
`
from {
from {
transform: scale(1.01);
transform: scale(1.01);
}
}
to {
to {
transform: scale(0.99);
transform: scale(0.99);
}
}
`
`
const
Basic
=
styled
.
div
`
const
Basic
=
styled
.
div
`
${
basicStyles
}
;
${
basicStyles
}
;
`
`
const
Combined
=
styled
.
div
`
const
Combined
=
styled
.
div
`
${
basicStyles
}
;
${
basicStyles
}
;
${
hoverStyles
}
;
${
hoverStyles
}
;
& code {
& code {
background-color: linen;
background-color: linen;
}
}
`
`
const
Animated
=
styled
.
div
`
const
Animated
=
styled
.
div
`
${
basicStyles
}
;
${
basicStyles
}
;
${
hoverStyles
}
;
${
hoverStyles
}
;
& code {
& code {
background-color: linen;
background-color: linen;
}
}
animation:
${
props
=>
props
.
animation
}
0.2s infinite ease-in-out alternate;
animation:
${
props
=>
props
.
animation
}
0.2s infinite ease-in-out alternate;
`
`
export
default
()
=>
{
return
(
return
(
<
div
>
<
div
>
<
Basic
>
Cool
Styles
<
/Basic
>
<
Basic
>
Cool
Styles
<
/Basic
>
...
...
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