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
b86bbb65
Commit
b86bbb65
authored
Jun 29, 2017
by
Colder Xihk
Committed by
Tim Neutkens
Jun 29, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update with-antd-mobile example (#2403)
add support custom svg remove expire tricks
parent
03cad7cb
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
122 additions
and
39 deletions
+122
-39
MenuBar.js
examples/with-antd-mobile/components/MenuBar.js
+7
-1
next.config.js
examples/with-antd-mobile/next.config.js
+22
-5
package.json
examples/with-antd-mobile/package.json
+6
-6
icon.js
examples/with-antd-mobile/pages/icon.js
+81
-0
trick.js
examples/with-antd-mobile/pages/trick.js
+5
-27
reload.svg
examples/with-antd-mobile/static/reload.svg
+1
-0
No files found.
examples/with-antd-mobile/components/MenuBar.js
View file @
b86bbb65
...
...
@@ -36,9 +36,15 @@ const tabBarData = [
link
:
'/home'
},
{
title
:
'
Trick
'
,
title
:
'
Icon
'
,
icon
:
'check-circle-o'
,
selectedIcon
:
'check-circle'
,
link
:
'/icon'
},
{
title
:
'Trick'
,
icon
:
'cross-circle-o'
,
selectedIcon
:
'cross-circle'
,
link
:
'/trick'
}
]
examples/with-antd-mobile/next.config.js
View file @
b86bbb65
...
...
@@ -10,10 +10,16 @@ function setupRequireHacker () {
})
requireHacker
.
hook
(
'js'
,
filename
=>
{
if
(
filename
.
endsWith
(
'/node_modules/hammerjs/hammer.js'
))
{
return
`
module.exports = {}
`
}
if
(
filename
.
endsWith
(
'.web.js'
)
||
!
filename
.
includes
(
'/node_modules/'
)
||
[
'antd-mobile'
,
'r
c-swipeout'
,
'r
mc-picker'
].
every
(
p
=>
!
filename
.
includes
(
p
))
[
'antd-mobile'
,
'rmc-picker'
].
every
(
p
=>
!
filename
.
includes
(
p
))
)
return
const
webjs
=
filename
.
replace
(
/
\.
js$/
,
'.web.js'
)
...
...
@@ -22,10 +28,9 @@ function setupRequireHacker () {
return
fs
.
readFileSync
(
webjs
,
{
encoding
:
'utf8'
})
})
requireHacker
.
hook
(
'css'
,
()
=>
''
)
requireHacker
.
hook
(
'svg'
,
filename
=>
{
return
requireHacker
.
to_javascript_module_source
(
fs
.
readFileSync
(
filename
,
{
encoding
:
'utf8'
}))
const
id
=
path
.
basename
(
filename
).
replace
(
/
\.
svg$/
,
''
)
return
requireHacker
.
to_javascript_module_source
(
`#
${
id
}
`
)
})
}
...
...
@@ -40,11 +45,23 @@ module.exports = {
config
.
resolve
.
extensions
=
[
'.web.js'
,
'.js'
,
'.json'
]
config
.
module
.
rules
.
push
(
{
test
:
/
\.(
svg
)
$/i
,
loader
:
'emit-file-loader'
,
options
:
{
name
:
'dist/[path][name].[ext]'
},
include
:
[
moduleDir
(
'antd-mobile'
),
__dirname
]
},
{
test
:
/
\.(
svg
)
$/i
,
loader
:
'svg-sprite-loader'
,
include
:
[
moduleDir
(
'antd-mobile'
)
moduleDir
(
'antd-mobile'
),
__dirname
]
}
)
...
...
examples/with-antd-mobile/package.json
View file @
b86bbb65
{
"name"
:
"with-antd-mobile"
,
"version"
:
"1.
0
.0"
,
"version"
:
"1.
1
.0"
,
"dependencies"
:
{
"antd-mobile"
:
"
^1.1.2
"
,
"babel-plugin-import"
:
"^1.
1
.1"
,
"antd-mobile"
:
"
1.4.0
"
,
"babel-plugin-import"
:
"^1.
2
.1"
,
"next"
:
"latest"
,
"react"
:
"^15.
5.4
"
,
"react-dom"
:
"^15.
5.4
"
,
"react"
:
"^15.
6.1
"
,
"react-dom"
:
"^15.
6.1
"
,
"require-hacker"
:
"^3.0.0"
,
"svg-sprite-loader"
:
"
~0.3.0
"
"svg-sprite-loader"
:
"
0.3.1
"
},
"scripts"
:
{
"dev"
:
"next"
,
...
...
examples/with-antd-mobile/pages/icon.js
0 → 100644
View file @
b86bbb65
import
React
,
{
Component
}
from
'react'
import
{
WhiteSpace
,
WingBlank
,
Card
,
Icon
}
from
'antd-mobile'
import
Layout
from
'../components/Layout'
import
MenuBar
from
'../components/MenuBar'
export
default
class
Home
extends
Component
{
static
getInitialProps
({
req
})
{
const
language
=
req
?
req
.
headers
[
'accept-language'
]
:
navigator
.
language
return
{
language
}
}
render
()
{
const
{
language
,
url
:
{
pathname
}
}
=
this
.
props
return
(
<
Layout
language
=
{
language
}
>
<
MenuBar
pathname
=
{
pathname
}
>
<
WingBlank
>
<
WhiteSpace
/>
<
Card
>
<
Card
.
Header
extra
=
'Internal svg'
thumb
=
{
<
Icon
type
=
'check'
/>
}
/
>
<
Card
.
Body
>
<
code
>
{
`<Icon type='check' />`
}
<
/code
>
<
/Card.Body
>
<
/Card
>
<
WhiteSpace
/>
<
Card
>
<
Card
.
Header
extra
=
'Custom svg'
thumb
=
{
<
Icon
type
=
{
require
(
'../static/reload.svg'
)}
/>
}
/>
<
Card
.
Body
>
<
code
>
{
`<Icon type={require('../static/reload.svg')} />`
}
<
/code
>
<
/Card.Body
>
<
/Card
>
<
WhiteSpace
/>
<
Card
>
<
Card
.
Header
extra
=
'Fill color'
thumb
=
{
<
Icon
type
=
{
require
(
'../static/reload.svg'
)}
style
=
{{
fill
:
'#108ee9'
}}
/
>
}
/
>
<
Card
.
Body
>
<
code
>
{
`
<Icon
type={require('../static/reload.svg')}
style={{ fill: '#108ee9' }}
/>
`
}
<
/code
>
<
/Card.Body
>
<
/Card
>
<
style
jsx
>
{
`
code {
color: gray;
}
`
}
<
/style
>
<
/WingBlank
>
<
/MenuBar
>
<
/Layout
>
)
}
}
examples/with-antd-mobile/pages/trick.js
View file @
b86bbb65
import
React
,
{
Component
}
from
'react'
import
{
WhiteSpace
,
List
,
Switch
,
Modal
,
Button
,
Menu
}
from
'antd-mobile'
import
{
WhiteSpace
,
List
,
Switch
,
Menu
}
from
'antd-mobile'
import
Layout
from
'../components/Layout'
import
MenuBar
from
'../components/MenuBar'
...
...
@@ -19,9 +16,7 @@ export default class Trick extends Component {
}
}
constructor
(
props
)
{
super
(
props
)
componentWillMount
()
{
this
.
menuData
=
[
{
label
:
'Menu 1'
,
...
...
@@ -58,8 +53,7 @@ export default class Trick extends Component {
]
this
.
state
=
{
switchChecked
:
true
,
modalOpened
:
false
switchChecked
:
true
}
}
...
...
@@ -71,8 +65,7 @@ export default class Trick extends Component {
}
=
this
.
props
const
{
switchChecked
,
modalOpened
switchChecked
}
=
this
.
state
return
(
...
...
@@ -81,7 +74,7 @@ export default class Trick extends Component {
pathname
=
{
pathname
}
>
<
WhiteSpace
/>
<
List
renderHeader
=
{()
=>
'Switch
and Modal
platform prop is required in SSR mode'
}
>
<
List
renderHeader
=
{()
=>
'Switch platform prop is required in SSR mode'
}
>
<
List
.
Item
extra
=
{
<
Switch
...
...
@@ -93,22 +86,7 @@ export default class Trick extends Component {
>
Switch
{
platform
}
<
/List.Item
>
<
Button
onClick
=
{()
=>
this
.
setState
({
modalOpened
:
true
})}
>
Open
{
platform
}
modal
<
/Button
>
<
/List
>
<
Modal
title
=
'Modal'
platform
=
{
platform
}
visible
=
{
modalOpened
}
transparent
closable
footer
=
{[{
text
:
'OK'
,
onPress
:
()
=>
this
.
setState
({
modalOpened
:
false
})
}]}
onClose
=
{()
=>
this
.
setState
({
modalOpened
:
false
})}
>
I
am
a
modal
.
<
br
/>
Must
set
platform
prop
<
/Modal
>
<
List
renderHeader
=
{()
=>
'Menu height prop is required in SSR mode'
}
>
<
Menu
height
=
{
500
}
...
...
examples/with-antd-mobile/static/reload.svg
0 → 100644
View file @
b86bbb65
<svg
width=
"64"
height=
"64"
viewBox=
"0 0 64 64"
xmlns=
"http://www.w3.org/2000/svg"
><title>
Share Icons Copy
</title><path
d=
"M59.177 29.5s-1.25 0-1.25 2.5c0 14.471-11.786 26.244-26.253 26.244C17.206 58.244 5.417 46.47 5.417 32c0-13.837 11.414-25.29 25.005-26.26v6.252c0 .622-.318 1.635.198 1.985a1.88 1.88 0 0 0 1.75.19l21.37-8.545c.837-.334 1.687-1.133 1.687-2.384C55.425 1.99 53.944 2 53.044 2h-21.37C15.134 2 1.667 15.46 1.667 32c0 16.543 13.467 30 30.007 30 16.538 0 29.918-13.458 29.993-30 .01-2.5-1.24-2.5-1.24-2.5h-1.25"
fill-rule=
"evenodd"
/></svg>
\ No newline at end of file
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