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
278f58b5
Commit
278f58b5
authored
Dec 06, 2017
by
Thomas Greco
Committed by
Tim Neutkens
Dec 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pushing updated emotion example (#3344)
* pushing updated emotion example * Fix linting
parent
732696e8
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
152 additions
and
0 deletions
+152
-0
home.component.js
examples/with-emotion-fiber/features/home.component.js
+12
-0
withEmotion.component.js
examples/with-emotion-fiber/hoc/withEmotion.component.js
+22
-0
package.json
examples/with-emotion-fiber/package.json
+20
-0
_document.js
examples/with-emotion-fiber/pages/_document.js
+33
-0
index.js
examples/with-emotion-fiber/pages/index.js
+4
-0
styles.js
examples/with-emotion-fiber/shared/styles.js
+61
-0
No files found.
examples/with-emotion-fiber/features/home.component.js
0 → 100644
View file @
278f58b5
import
{
Basic
,
Combined
,
Animated
,
bounce
}
from
'../shared/styles'
const
Home
=
()
=>
(
<
div
>
<
Basic
>
Cool
Styles
<
/Basic
>
<
Combined
>
With
<
code
>
:
hover
<
/code>
.
<
/Combined
>
<
Animated
animation
=
{
bounce
}
>
Let
's bounce.</Animated>
</div>
)
export default Home
examples/with-emotion-fiber/hoc/withEmotion.component.js
0 → 100644
View file @
278f58b5
import
React
,
{
Component
}
from
'react'
import
{
hydrate
}
from
'react-emotion'
import
{
injectGlobalStyles
}
from
'../shared/styles'
const
withEmotion
=
ComposedComponent
=>
{
class
HOC
extends
Component
{
componentWillMount
()
{
if
(
typeof
window
!==
'undefined'
)
{
hydrate
(
window
.
__NEXT_DATA__
.
ids
)
}
injectGlobalStyles
()
}
render
()
{
return
<
ComposedComponent
/>
}
};
return
HOC
}
export
default
withEmotion
examples/with-emotion-fiber/package.json
0 → 100644
View file @
278f58b5
{
"name"
:
"with-emotion-fiber"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"dev"
:
"next"
},
"keywords"
:
[],
"author"
:
"Thomas Greco"
,
"license"
:
"ISC"
,
"dependencies"
:
{
"emotion"
:
"^8.0.11"
,
"emotion-server"
:
"^8.0.11"
,
"next"
:
"^4.1.4"
,
"react"
:
"^16.1.1"
,
"react-dom"
:
"^16.1.1"
,
"react-emotion"
:
"^8.0.11"
}
}
examples/with-emotion-fiber/pages/_document.js
0 → 100644
View file @
278f58b5
import
Document
,
{
Head
,
Main
,
NextScript
}
from
'next/document'
import
{
extractCritical
}
from
'emotion-server'
export
default
class
MyDocument
extends
Document
{
static
getInitialProps
({
renderPage
})
{
const
page
=
renderPage
()
const
styles
=
extractCritical
(
page
.
html
)
return
{
...
page
,
...
styles
}
}
constructor
(
props
)
{
super
(
props
)
const
{
__NEXT_DATA__
,
ids
}
=
props
if
(
ids
)
{
__NEXT_DATA__
.
ids
=
ids
}
}
render
()
{
return
(
<
html
>
<
Head
>
<
title
>
With
Emotion
<
/title
>
<
style
dangerouslySetInnerHTML
=
{{
__html
:
this
.
props
.
css
}}
/
>
<
/Head
>
<
body
>
<
Main
/>
<
NextScript
/>
<
/body
>
<
/html
>
)
}
}
examples/with-emotion-fiber/pages/index.js
0 → 100644
View file @
278f58b5
import
withEmotion
from
'../hoc/withEmotion.component'
import
home
from
'../features/home.component'
export
default
withEmotion
(
home
)
examples/with-emotion-fiber/shared/styles.js
0 → 100644
View file @
278f58b5
import
styled
,
{
keyframes
,
css
,
injectGlobal
}
from
'react-emotion'
export
const
injectGlobalStyles
=
()
=>
injectGlobal
`
html, body {
padding: 3rem 1rem;
margin: 0;
background: papayawhip;
min-height: 100%;
font-family: Helvetica, Arial, sans-serif;
font-size: 24px;
}
`
export
const
basicStyles
=
css
`
background-color: white;
color: cornflowerblue;
border: 1px solid lightgreen;
border-right: none;
border-bottom: none;
box-shadow: 5px 5px 0 0 lightgreen, 10px 10px 0 0 lightyellow;
transition: all 0.1s linear;
margin: 3rem 0;
padding: 1rem 0.5rem;
`
export
const
hoverStyles
=
css
`
&:hover {
color: white;
background-color: lightgray;
border-color: aqua;
box-shadow: -15px -15px 0 0 aqua, -30px -30px 0 0 cornflowerblue;
}
`
export
const
bounce
=
keyframes
`
from {
transform: scale(1.01);
}
to {
transform: scale(0.99);
}
`
export
const
Basic
=
styled
(
'div'
)
`
${
basicStyles
}
;
`
export
const
Combined
=
styled
(
'div'
)
`
${
basicStyles
}
;
${
hoverStyles
}
;
& code {
background-color: linen;
}
`
export
const
Animated
=
styled
(
'div'
)
`
${
basicStyles
}
;
${
hoverStyles
}
;
& code {
background-color: linen;
}
animation:
${
props
=>
props
.
animation
}
0.2s infinite ease-in-out alternate;
`
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