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
9ddc1d7b
Commit
9ddc1d7b
authored
Dec 10, 2018
by
Leon
Committed by
Tim Neutkens
Dec 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update styletron example (#5573)
parent
27c0b199
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
20 deletions
+28
-20
layout.js
examples/with-styletron/layout.js
+0
-8
package.json
examples/with-styletron/package.json
+3
-3
_app.js
examples/with-styletron/pages/_app.js
+19
-0
_document.js
examples/with-styletron/pages/_document.js
+1
-1
index.js
examples/with-styletron/pages/index.js
+2
-3
styletron.js
examples/with-styletron/styletron.js
+3
-5
No files found.
examples/with-styletron/layout.js
deleted
100644 → 0
View file @
27c0b199
import
{
StyletronProvider
}
from
'styletron-react'
import
getStyletron
from
'./styletron'
export
default
({
children
})
=>
(
<
StyletronProvider
styletron
=
{
getStyletron
()}
>
{
children
}
<
/StyletronProvider
>
)
examples/with-styletron/package.json
View file @
9ddc1d7b
...
@@ -10,8 +10,8 @@
...
@@ -10,8 +10,8 @@
"next"
:
"latest"
,
"next"
:
"latest"
,
"react"
:
"^16.0.0"
,
"react"
:
"^16.0.0"
,
"react-dom"
:
"^16.0.0"
,
"react-dom"
:
"^16.0.0"
,
"styletron
-client"
:
"^2.2.0
"
,
"styletron
"
:
"^3.0.4
"
,
"styletron-
react"
:
"^2.2.1
"
,
"styletron-
engine-atomic"
:
"^1.0.8
"
,
"styletron-
server"
:
"^2.2.0
"
"styletron-
react"
:
"^4.3.5
"
}
}
}
}
examples/with-styletron/pages/_app.js
0 → 100644
View file @
9ddc1d7b
import
App
,
{
Container
}
from
'next/app'
import
React
from
'react'
import
{
Provider
as
StyletronProvider
}
from
'styletron-react'
import
getStyletron
from
'../styletron'
class
MyApp
extends
App
{
render
()
{
const
{
Component
}
=
this
.
props
return
(
<
Container
>
<
StyletronProvider
value
=
{
getStyletron
()}
>
<
Component
/>
<
/StyletronProvider
>
<
/Container
>
)
}
}
export
default
MyApp
examples/with-styletron/pages/_document.js
View file @
9ddc1d7b
...
@@ -17,7 +17,7 @@ export default class MyDocument extends Document {
...
@@ -17,7 +17,7 @@ export default class MyDocument extends Document {
<
style
<
style
className
=
'_styletron_hydrate_'
className
=
'_styletron_hydrate_'
dangerouslySetInnerHTML
=
{{
__html
:
sheet
.
css
}}
dangerouslySetInnerHTML
=
{{
__html
:
sheet
.
css
}}
media
=
{
sheet
.
media
||
''
}
media
=
{
sheet
.
media
||
null
}
key
=
{
i
}
key
=
{
i
}
/
>
/
>
))}
))}
...
...
examples/with-styletron/pages/index.js
View file @
9ddc1d7b
import
{
styled
}
from
'styletron-react'
import
{
styled
}
from
'styletron-react'
import
Page
from
'../layout'
const
Title
=
styled
(
'div'
,
{
const
Title
=
styled
(
'div'
,
{
color
:
'red'
,
color
:
'red'
,
...
@@ -7,7 +6,7 @@ const Title = styled('div', {
...
@@ -7,7 +6,7 @@ const Title = styled('div', {
})
})
export
default
()
=>
(
export
default
()
=>
(
<
Page
>
<
div
>
<
Title
>
My
page
<
/Title
>
<
Title
>
My
page
<
/Title
>
<
/
Page
>
<
/
div
>
)
)
examples/with-styletron/styletron.js
View file @
9ddc1d7b
const
isServer
=
typeof
window
===
'undefined'
const
isServer
=
typeof
window
===
'undefined'
let
styletron
let
styletron
export
default
function
getStyletron
()
{
export
default
function
getStyletron
()
{
if
(
isServer
)
{
if
(
isServer
&&
!
styletron
)
{
const
Styletron
=
require
(
'styletron-
server'
)
const
Styletron
=
require
(
'styletron-
engine-atomic'
).
Server
styletron
=
new
Styletron
()
styletron
=
new
Styletron
()
}
else
if
(
!
styletron
)
{
}
else
if
(
!
styletron
)
{
const
Styletron
=
require
(
'styletron-
client'
)
const
Styletron
=
require
(
'styletron-
engine-atomic'
).
Client
const
styleElements
=
document
.
getElementsByClassName
(
'_styletron_hydrate_'
)
const
styleElements
=
document
.
getElementsByClassName
(
'_styletron_hydrate_'
)
styletron
=
new
Styletron
(
styleElements
)
styletron
=
new
Styletron
(
styleElements
)
}
}
return
styletron
return
styletron
}
}
...
...
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