Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CoCo_Code_Op2
next.js
提交
974cae68
N
next.js
项目概览
CoCo_Code_Op2
/
next.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
next.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
974cae68
编写于
7月 07, 2020
作者:
C
Christian Alfoni
提交者:
GitHub
7月 07, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update example: update to new stitches version and api (#14876)
上级
75b25901
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
42 addition
and
91 deletion
+42
-91
examples/with-stitches-styled/css/index.js
examples/with-stitches-styled/css/index.js
+3
-8
examples/with-stitches-styled/package.json
examples/with-stitches-styled/package.json
+2
-2
examples/with-stitches-styled/pages/_app.js
examples/with-stitches-styled/pages/_app.js
+0
-18
examples/with-stitches-styled/pages/_document.js
examples/with-stitches-styled/pages/_document.js
+11
-8
examples/with-stitches-styled/pages/index.js
examples/with-stitches-styled/pages/index.js
+3
-1
examples/with-stitches/css/index.js
examples/with-stitches/css/index.js
+2
-23
examples/with-stitches/package.json
examples/with-stitches/package.json
+1
-1
examples/with-stitches/pages/_app.js
examples/with-stitches/pages/_app.js
+0
-18
examples/with-stitches/pages/_document.js
examples/with-stitches/pages/_document.js
+10
-9
examples/with-stitches/pages/index.js
examples/with-stitches/pages/index.js
+10
-3
未找到文件。
examples/with-stitches-styled/css/index.js
浏览文件 @
974cae68
import
{
createC
onfig
}
from
'
@stitches/css
'
import
{
createC
ss
}
from
'
@stitches/css
'
import
{
createStyled
}
from
'
@stitches/styled
'
const
config
=
createConfig
({
export
const
css
=
createCss
({
tokens
:
{
colors
:
{
RED
:
'
tomato
'
,
},
},
})
/*
With Typescript:
const { Provider, styled, useCss } = createStyled<typeof config>()
*/
const
{
Provider
,
styled
,
useCss
}
=
createStyled
()
export
{
config
,
Provider
,
styled
,
useCss
}
export
const
styled
=
createStyled
(
css
)
examples/with-stitches-styled/package.json
浏览文件 @
974cae68
...
...
@@ -8,8 +8,8 @@
"start"
:
"next start"
},
"dependencies"
:
{
"@stitches/css"
:
"
2.0.6
"
,
"@stitches/styled"
:
"
2.0.6
"
,
"@stitches/css"
:
"
3.0.0
"
,
"@stitches/styled"
:
"
3.0.0
"
,
"next"
:
"9.3.5"
,
"react"
:
"16.13.1"
,
"react-dom"
:
"16.13.1"
...
...
examples/with-stitches-styled/pages/_app.js
已删除
100644 → 0
浏览文件 @
75b25901
import
App
from
'
next/app
'
import
{
createCss
}
from
'
@stitches/css
'
import
{
Provider
,
config
}
from
'
../css
'
/*
With Typescript:
export default class MyApp extends App<{ serverCss: TCss<typeof config> }> {
*/
export
default
class
MyApp
extends
App
{
render
()
{
const
{
Component
,
pageProps
,
serverCss
}
=
this
.
props
return
(
<
Provider
css
=
{
serverCss
||
createCss
(
config
)}
>
<
Component
{...
pageProps
}
/
>
<
/Provider
>
)
}
}
examples/with-stitches-styled/pages/_document.js
浏览文件 @
974cae68
import
Document
from
'
next/document
'
import
{
createCss
}
from
'
@stitches/css
'
import
{
config
}
from
'
../css
'
import
{
css
}
from
'
../css
'
export
default
class
MyDocument
extends
Document
{
static
async
getInitialProps
(
ctx
)
{
const
css
=
createCss
(
config
)
const
originalRenderPage
=
ctx
.
renderPage
try
{
ctx
.
renderPage
=
()
=>
originalRenderPage
({
enhanceApp
:
(
App
)
=>
(
props
)
=>
<
App
{...
props
}
serverCss
=
{
css
}
/>
,
})
let
extractedStyles
ctx
.
renderPage
=
()
=>
{
const
{
styles
,
result
}
=
css
.
getStyles
(
originalRenderPage
)
extractedStyles
=
styles
return
result
}
const
initialProps
=
await
Document
.
getInitialProps
(
ctx
)
return
{
...
initialProps
,
styles
:
(
<>
{
initialProps
.
styles
}
<
style
>
{
css
.
getStyles
()}
<
/style
>
{
extractedStyles
.
map
((
content
)
=>
(
<
style
>
{
content
}
<
/style
>
))}
<
/
>
),
}
...
...
examples/with-stitches-styled/pages/index.js
浏览文件 @
974cae68
import
{
styled
}
from
'
../css
'
const
Header
=
styled
.
h1
((
css
)
=>
css
.
color
(
'
RED
'
))
const
Header
=
styled
.
h1
({
color
:
'
RED
'
,
})
export
default
function
Home
()
{
return
<
Header
>
Hello
world
<
/Header
>
...
...
examples/with-stitches/css/index.js
浏览文件 @
974cae68
import
{
createConfig
}
from
'
@stitches/css
'
import
*
as
React
from
'
react
'
import
{
createCss
}
from
'
@stitches/css
'
const
config
=
createConfig
({
export
const
css
=
createCss
({
tokens
:
{
colors
:
{
RED
:
'
tomato
'
,
},
},
})
/*
With Typescript:
const context = React.createContext<TCss<typeof config>>(null)
*/
const
context
=
React
.
createContext
(
null
)
/*
With Typescript:
const Provider = ({ css, children }: { css: TCss<typeof config>, children?: React.ReactNode }) => {
return <context.Provider value={css}>{children}</context.Provider>
}
*/
const
Provider
=
({
css
,
children
})
=>
{
return
<
context
.
Provider
value
=
{
css
}
>
{
children
}
<
/context.Provider
>
}
const
useCss
=
()
=>
React
.
useContext
(
context
)
export
{
config
,
Provider
,
useCss
}
examples/with-stitches/package.json
浏览文件 @
974cae68
...
...
@@ -8,7 +8,7 @@
"start"
:
"next start"
},
"dependencies"
:
{
"@stitches/css"
:
"
2.0.6
"
,
"@stitches/css"
:
"
3.0.0
"
,
"next"
:
"9.3.5"
,
"react"
:
"16.13.1"
,
"react-dom"
:
"16.13.1"
...
...
examples/with-stitches/pages/_app.js
已删除
100644 → 0
浏览文件 @
75b25901
import
{
createCss
}
from
'
@stitches/css
'
import
App
from
'
next/app
'
import
{
config
,
Provider
}
from
'
../css
'
/*
With Typescript:
export default class MyApp extends App<{ serverCss: TCss<typeof config> }> {
*/
export
default
class
MyApp
extends
App
{
render
()
{
const
{
Component
,
pageProps
,
serverCss
}
=
this
.
props
return
(
<
Provider
css
=
{
serverCss
||
createCss
(
config
)}
>
<
Component
{...
pageProps
}
/
>
<
/Provider
>
)
}
}
examples/with-stitches/pages/_document.js
浏览文件 @
974cae68
import
{
createCss
}
from
'
@stitches/css
'
import
Document
from
'
next/document
'
import
{
c
onfig
}
from
'
../css
'
import
{
c
ss
}
from
'
../css
'
export
default
class
MyDocument
extends
Document
{
static
async
getInitialProps
(
ctx
)
{
const
css
=
createCss
(
config
)
const
originalRenderPage
=
ctx
.
renderPage
try
{
ctx
.
renderPage
=
()
=>
originalRenderPage
({
enhanceApp
:
(
App
)
=>
(
props
)
=>
<
App
{...
props
}
serverCss
=
{
css
}
/>
,
})
let
extractedStyles
ctx
.
renderPage
=
()
=>
{
const
{
styles
,
result
}
=
css
.
getStyles
(
originalRenderPage
)
extractedStyles
=
styles
return
result
}
const
initialProps
=
await
Document
.
getInitialProps
(
ctx
)
return
{
...
initialProps
,
styles
:
(
<>
{
initialProps
.
styles
}
{
css
.
getStyles
().
map
((
css
,
index
)
=>
(
<
style
key
=
{
index
}
>
{
css
}
<
/style
>
{
extractedStyles
.
map
((
content
)
=>
(
<
style
>
{
content
}
<
/style
>
))}
<
/
>
),
...
...
examples/with-stitches/pages/index.js
浏览文件 @
974cae68
import
{
useC
ss
}
from
'
../css
'
import
{
c
ss
}
from
'
../css
'
export
default
function
Home
()
{
const
css
=
useCss
()
return
<
h1
className
=
{
css
.
color
(
'
RED
'
)}
>
Hello
world
<
/h1
>
return
(
<
h1
className
=
{
css
({
color
:
'
RED
'
,
})}
>
Hello
world
<
/h1
>
)
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录