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
2dcd4e95
Unverified
Commit
2dcd4e95
authored
May 02, 2020
by
mit123suki
Committed by
GitHub
May 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
example: antd-4 with built-in css support (#11837)
parent
e19023d6
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
373 additions
and
60 deletions
+373
-60
.babelrc
examples/with-ant-design/.babelrc
+22
-0
next.config.js
examples/with-ant-design/next.config.js
+51
-0
package.json
examples/with-ant-design/package.json
+15
-7
_app.js
examples/with-ant-design/pages/_app.js
+3
-0
index.js
examples/with-ant-design/pages/index.js
+84
-53
global.css
examples/with-ant-design/styles/global.css
+193
-0
vars.css
examples/with-ant-design/styles/vars.css
+5
-0
No files found.
examples/with-ant-design/.babelrc
0 → 100644
View file @
2dcd4e95
{
"presets": ["next/babel"],
"plugins": [
[
"import",
{
"libraryName": "antd",
"libraryDirectory": "es",
"style": "index.css"
}
],
[
"import",
{
"libraryName": "@ant-design/icons",
"libraryDirectory": "es/icons",
"camel2DashComponentName": false
},
"@ant-design/icons"
]
]
}
examples/with-ant-design/next.config.js
0 → 100644
View file @
2dcd4e95
const
compose
=
plugins
=>
({
webpack
(
config
,
options
)
{
return
plugins
.
reduce
((
config
,
plugin
)
=>
{
if
(
plugin
instanceof
Array
)
{
const
[
_plugin
,
...
args
]
=
plugin
plugin
=
_plugin
(...
args
)
}
if
(
plugin
instanceof
Function
)
{
plugin
=
plugin
()
}
if
(
plugin
&&
plugin
.
webpack
instanceof
Function
)
{
return
plugin
.
webpack
(
config
,
options
)
}
return
config
},
config
)
},
webpackDevMiddleware
(
config
)
{
return
plugins
.
reduce
((
config
,
plugin
)
=>
{
if
(
plugin
instanceof
Array
)
{
const
[
_plugin
,
...
args
]
=
plugin
plugin
=
_plugin
(...
args
)
}
if
(
plugin
instanceof
Function
)
{
plugin
=
plugin
()
}
if
(
plugin
&&
plugin
.
webpackDevMiddleware
instanceof
Function
)
{
return
plugin
.
webpackDevMiddleware
(
config
)
}
return
config
},
config
)
},
})
const
withBundleAnalyzer
=
require
(
'@next/bundle-analyzer'
)
const
AntdDayjsWebpackPlugin
=
require
(
'antd-dayjs-webpack-plugin'
)
module
.
exports
=
compose
([
{
webpack
(
config
,
{
buildId
,
dev
,
isServer
,
defaultLoaders
,
webpack
})
{
config
.
plugins
.
push
(
new
AntdDayjsWebpackPlugin
())
return
config
},
},
[
withBundleAnalyzer
,
{
enabled
:
process
.
env
.
ANALYZE
===
'true'
,
},
],
])
examples/with-ant-design/package.json
View file @
2dcd4e95
...
@@ -2,16 +2,24 @@
...
@@ -2,16 +2,24 @@
"name"
:
"with-ant-design"
,
"name"
:
"with-ant-design"
,
"version"
:
"1.0.0"
,
"version"
:
"1.0.0"
,
"scripts"
:
{
"scripts"
:
{
"dev"
:
"next"
,
"dev"
:
"cross-env NODE_OPTIONS=
\"
-r esm
\"
next"
,
"build"
:
"next build"
,
"build"
:
"cross-env NODE_OPTIONS=
\"
-r esm
\"
next build"
,
"analyze"
:
"cross-env-shell NODE_OPTIONS=
\"
-r esm
\"
ANALYZE=true next build"
,
"start"
:
"next start"
"start"
:
"next start"
},
},
"dependencies"
:
{
"dependencies"
:
{
"@zeit/next-css"
:
"^1.0.1"
,
"@ant-design/icons"
:
"^4.0.6"
,
"antd"
:
"^4.0.1"
,
"@next/bundle-analyzer"
:
"^9.1.4"
,
"next"
:
"latest"
,
"antd"
:
"4.1.2"
,
"react"
:
"^16.7.0"
,
"antd-dayjs-webpack-plugin"
:
"1.0.0"
,
"react-dom"
:
"^16.7.0"
"babel-plugin-import"
:
"1.13.0"
,
"cross-env"
:
"^7.0.2"
,
"dayjs"
:
"1.8.24"
,
"esm"
:
"^3.2.25"
,
"next"
:
"9.3.4"
,
"postcss-preset-env"
:
"^6.7.0"
,
"react"
:
"16.13.1"
,
"react-dom"
:
"16.13.1"
},
},
"license"
:
"ISC"
"license"
:
"ISC"
}
}
examples/with-ant-design/pages/_app.js
View file @
2dcd4e95
import
React
from
'react'
import
'antd/dist/antd.css'
import
'antd/dist/antd.css'
import
'../styles/vars.css'
import
'../styles/global.css'
export
default
function
MyApp
({
Component
,
pageProps
})
{
export
default
function
MyApp
({
Component
,
pageProps
})
{
return
<
Component
{...
pageProps
}
/
>
return
<
Component
{...
pageProps
}
/
>
...
...
examples/with-ant-design/pages/index.js
View file @
2dcd4e95
import
React
from
'react'
import
{
import
{
Form
,
Form
,
Select
,
Select
,
...
@@ -8,67 +9,97 @@ import {
...
@@ -8,67 +9,97 @@ import {
Button
,
Button
,
}
from
'antd'
}
from
'antd'
import
{
SmileFilled
}
from
'@ant-design/icons'
import
Link
from
'next/link'
const
FormItem
=
Form
.
Item
const
FormItem
=
Form
.
Item
const
Option
=
Select
.
Option
const
Option
=
Select
.
Option
const
content
=
{
marginTop
:
'100px'
,
}
export
default
()
=>
(
export
default
()
=>
(
<
div
style
=
{{
marginTop
:
100
}}
>
<
div
style
=
{
content
}
>
<
Form
layout
=
"horizontal"
>
<
div
className
=
"text-center mb-5"
>
<
FormItem
<
Link
href
=
"#"
>
label
=
"Input Number"
<
a
className
=
"logo mr-0"
>
labelCol
=
{{
span
:
8
}}
<
SmileFilled
size
=
{
48
}
strokeWidth
=
{
1
}
/
>
wrapperCol
=
{{
span
:
8
}}
<
/a
>
>
<
/Link
>
<
InputNumber
size
=
"large"
<
p
className
=
"mb-0 mt-3 text-disabled"
>
Welcome
to
the
world
!<
/p
>
min
=
{
1
}
<
/div
>
max
=
{
10
}
<
div
>
style
=
{{
width
:
100
}}
<
Form
layout
=
"horizontal"
>
defaultValue
=
{
3
}
<
FormItem
name
=
"inputNumber"
label
=
"Input Number"
/>
labelCol
=
{{
span
:
8
}}
<
a
href
=
"#"
>
Link
<
/a
>
wrapperCol
=
{{
span
:
8
}}
<
/FormItem
>
>
<
InputNumber
size
=
"large"
min
=
{
1
}
max
=
{
10
}
style
=
{{
width
:
100
}}
defaultValue
=
{
3
}
name
=
"inputNumber"
/>
<
/FormItem
>
<
FormItem
label
=
"Switch"
labelCol
=
{{
span
:
8
}}
wrapperCol
=
{{
span
:
8
}}
>
<
FormItem
<
Switch
defaultChecked
name
=
"switch"
/>
label
=
"Switch"
<
/FormItem
>
labelCol
=
{{
span
:
8
}}
wrapperCol
=
{{
span
:
8
}}
>
<
Switch
defaultChecked
name
=
"switch"
/>
<
/FormItem
>
<
FormItem
label
=
"Slider"
labelCol
=
{{
span
:
8
}}
wrapperCol
=
{{
span
:
8
}}
>
<
FormItem
<
Slider
defaultValue
=
{
70
}
/
>
label
=
"Slider"
<
/FormItem
>
labelCol
=
{{
span
:
8
}}
wrapperCol
=
{{
span
:
8
}}
>
<
Slider
defaultValue
=
{
70
}
/
>
<
/FormItem
>
<
FormItem
label
=
"Select"
labelCol
=
{{
span
:
8
}}
wrapperCol
=
{{
span
:
8
}}
>
<
FormItem
<
Select
label
=
"Select"
size
=
"large"
labelCol
=
{{
span
:
8
}}
defaultValue
=
"lucy"
wrapperCol
=
{{
span
:
8
}}
style
=
{{
width
:
192
}}
name
=
"select"
>
>
<
Option
value
=
"jack"
>
jack
<
/Option
>
<
Select
<
Option
value
=
"lucy"
>
lucy
<
/Option
>
size
=
"large"
<
Option
value
=
"disabled"
disabled
>
defaultValue
=
"lucy"
disabled
style
=
{{
width
:
192
}}
<
/Option
>
name
=
"select"
<
Option
value
=
"yiminghe"
>
yiminghe
<
/Option
>
>
<
/Select
>
<
Option
value
=
"jack"
>
jack
<
/Option
>
<
/FormItem
>
<
Option
value
=
"lucy"
>
lucy
<
/Option
>
<
Option
value
=
"disabled"
disabled
>
disabled
<
/Option
>
<
Option
value
=
"yiminghe"
>
yiminghe
<
/Option
>
<
/Select
>
<
/FormItem
>
<
FormItem
<
FormItem
label
=
"DatePicker"
label
=
"DatePicker"
labelCol
=
{{
span
:
8
}}
labelCol
=
{{
span
:
8
}}
wrapperCol
=
{{
span
:
8
}}
wrapperCol
=
{{
span
:
8
}}
>
>
<
DatePicker
name
=
"startDate"
/>
<
DatePicker
name
=
"startDate"
/>
<
/FormItem
>
<
/FormItem
>
<
FormItem
style
=
{{
marginTop
:
48
}}
wrapperCol
=
{{
span
:
8
,
offset
:
8
}}
>
<
FormItem
style
=
{{
marginTop
:
48
}}
wrapperCol
=
{{
span
:
8
,
offset
:
8
}}
>
<
Button
size
=
"large"
type
=
"primary"
htmlType
=
"submit"
>
<
Button
size
=
"large"
type
=
"primary"
htmlType
=
"submit"
>
OK
OK
<
/Button
>
<
/Button
>
<
Button
size
=
"large"
style
=
{{
marginLeft
:
8
}}
>
<
Button
size
=
"large"
style
=
{{
marginLeft
:
8
}}
>
Cancel
Cancel
<
/Button
>
<
/Button
>
<
/FormItem
>
<
/FormItem
>
<
/Form
>
<
/Form
>
<
/div
>
<
/div
>
<
/div
>
)
)
examples/with-ant-design/styles/global.css
0 → 100644
View file @
2dcd4e95
*,
*
:before
,
*
:after
{
box-sizing
:
inherit
;
}
html
{
box-sizing
:
border-box
;
font-size
:
14px
;
-ms-overflow-style
:
-ms-autohiding-scrollbar
;
}
body
{
background-color
:
var
(
--backgroundColor
);
-ms-text-size-adjust
:
100%
;
-webkit-font-smoothing
:
antialiased
;
-moz-osx-font-smoothing
:
grayscale
;
text-rendering
:
optimizeLegibility
;
}
.text-left
{
text-align
:
left
!important
;
}
.text-right
{
text-align
:
right
!important
;
}
.text-center
{
text-align
:
center
!important
;
}
.m-0
{
margin
:
0
!important
;
}
.mt-0
,
.my-0
{
margin-top
:
0
!important
;
}
.mr-0
,
.mx-0
{
margin-right
:
0
!important
;
}
.mb-0
,
.my-0
{
margin-bottom
:
0
!important
;
}
.ml-0
,
.mx-0
{
margin-left
:
0
!important
;
}
.m-1
{
margin
:
0.25rem
!important
;
}
.mt-1
,
.my-1
{
margin-top
:
0.25rem
!important
;
}
.mr-1
,
.mx-1
{
margin-right
:
0.25rem
!important
;
}
.mb-1
,
.my-1
{
margin-bottom
:
0.25rem
!important
;
}
.ml-1
,
.mx-1
{
margin-left
:
0.25rem
!important
;
}
.m-2
{
margin
:
0.5rem
!important
;
}
.mt-2
,
.my-2
{
margin-top
:
0.5rem
!important
;
}
.mr-2
,
.mx-2
{
margin-right
:
0.5rem
!important
;
}
.mb-2
,
.my-2
{
margin-bottom
:
0.5rem
!important
;
}
.ml-2
,
.mx-2
{
margin-left
:
0.5rem
!important
;
}
.m-3
{
margin
:
1rem
!important
;
}
.mt-3
,
.my-3
{
margin-top
:
1rem
!important
;
}
.mr-3
,
.mx-3
{
margin-right
:
1rem
!important
;
}
.mb-3
,
.my-3
{
margin-bottom
:
1rem
!important
;
}
.ml-3
,
.mx-3
{
margin-left
:
1rem
!important
;
}
.m-4
{
margin
:
1.5rem
!important
;
}
.mt-4
,
.my-4
{
margin-top
:
1.5rem
!important
;
}
.mr-4
,
.mx-4
{
margin-right
:
1.5rem
!important
;
}
.mb-4
,
.my-4
{
margin-bottom
:
1.5rem
!important
;
}
.ml-4
,
.mx-4
{
margin-left
:
1.5rem
!important
;
}
.m-5
{
margin
:
3rem
!important
;
}
.mt-5
,
.my-5
{
margin-top
:
3rem
!important
;
}
.mr-5
,
.mx-5
{
margin-right
:
3rem
!important
;
}
.mb-5
,
.my-5
{
margin-bottom
:
3rem
!important
;
}
.ml-5
,
.mx-5
{
margin-left
:
3rem
!important
;
}
.logo
{
display
:
flex
;
align-items
:
center
;
margin-right
:
1rem
;
font-size
:
1.25rem
;
white-space
:
nowrap
;
color
:
var
(
--primaryColor
);
justify-content
:
center
;
}
.logo
>
svg
{
fill
:
var
(
--primaryColor
);
}
.text-disabled
{
color
:
var
(
--textColorSecondary
)
!important
;
}
examples/with-ant-design/styles/vars.css
0 → 100644
View file @
2dcd4e95
:root
{
--backgroundColor
:
#f7f7f7
;
--primaryColor
:
#191a1b
;
--textColorSecondary
:
rgba
(
0
,
0
,
0
,
0.45
);
}
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