Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mr-julyedu
Overview
Overview
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
baiguangyao
mr-julyedu
Commits
a5c96251
Commit
a5c96251
authored
Aug 13, 2020
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storybook
parent
4d4316e7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
156 additions
and
13 deletions
+156
-13
.storybook/preview.js
+4
-2
src/common/address/address.stories.tsx
+43
-0
src/common/address/index.scss
+66
-0
src/common/address/index.tsx
+43
-11
No files found.
.storybook/preview.js
View file @
a5c96251
import
'./style.scss'
\ No newline at end of file
import
'./style.scss'
import
'../src/assets/font/iconfont.css'
import
'@csstools/normalize.css/normalize.css'
\ No newline at end of file
src/common/address/address.stories.tsx
0 → 100644
View file @
a5c96251
import
React
from
'react'
import
Address
from
"./index"
;
import
{
text
,
boolean
,
withKnobs
}
from
'@storybook/addon-knobs'
import
{
action
}
from
'@storybook/addon-actions'
export
default
{
title
:
'address'
,
component
:
Address
,
decorators
:
[
withKnobs
]
}
let
visible
=
true
,
title
=
'收货地址'
,
subtitle
=
'获奖用户(以最终榜单为准)请及时填写收货信息'
,
address
=
'金域国际中心'
,
phone
=
'1331234123'
,
name
=
'某某某'
export
const
Default
=
()
=>
{
visible
=
boolean
(
'visible'
,
visible
)
name
=
text
(
'name'
,
name
)
phone
=
text
(
'phone'
,
phone
)
address
=
text
(
'address'
,
address
)
title
=
text
(
'title(optional)'
,
title
)
subtitle
=
text
(
'subtitle(optional)'
,
subtitle
)
return
<
Address
visible=
{
visible
}
subtitle=
{
subtitle
}
title=
{
title
}
name=
{
name
}
phone=
{
phone
}
address=
{
address
}
onClose=
{
action
(
'onClose'
)
}
validate=
{
()
=>
({
name
:
'姓名'
})
}
onError=
{
(
errors
)
=>
{
console
.
log
(
errors
);}
}
onSubmit=
{
(
values
,
formikHelpers
)
=>
{
console
.
log
(
formikHelpers
);
}
}
/>
}
\ No newline at end of file
src/common/address/index.scss
View file @
a5c96251
.common-address-container
{
position
:
absolute
;
left
:
50%
;
top
:
50%
;
transform
:
translate
(
-50%
,
-50%
);
width
:
300px
;
padding
:
20px
25px
;
background
:
#fff
;
border-radius
:
10px
;
box-sizing
:
border-box
;
text-align
:
center
;
.title
{
margin-bottom
:
8px
;
color
:
#525C65
;
font-size
:
16px
;
}
.subtitle
{
margin-bottom
:
15px
;
font-size
:
13px
;
color
:
#ED6A1D
;
text-align
:
left
;
}
input
{
width
:
250px
;
height
:
40px
;
line-height
:
40px
;
border
:
1px
solid
#DDD
;
font-size
:
13px
;
color
:
#999
;
outline
:
0
;
-webkit-appearance
:
none
;
&
:nth-child
(
n
+
2
)
{
margin-top
:
10px
;
}
&
:
:
placeholder
{
color
:
#999
;
}
}
.submit
{
margin-top
:
18px
;
width
:
121px
;
height
:
33px
;
background
:
#09f
;
border-radius
:
17px
;
font-size
:
15px
;
color
:
#fff
;
-webkit-appearance
:
none
;
outline
:
0
;
border
:
0
;
}
.close
{
position
:
absolute
;
left
:
50%
;
bottom
:
-56px
;
transform
:
translateX
(
-50%
);
font-size
:
26px
;
color
:
#fff
;
}
}
\ No newline at end of file
src/common/address/index.tsx
View file @
a5c96251
import
React
,
{
Component
}
from
'react'
import
'./index.scss'
import
MaskCover
from
"../cover"
;
import
{
Formik
,
Form
,
Field
,
FormikHelpers
,
FormikErrors
}
from
"formik"
;
interface
PersonalInfo
{
name
:
string
...
...
@@ -9,20 +10,51 @@ interface PersonalInfo {
}
interface
Props
extends
PersonalInfo
{
subtitle
:
string
subtitle
?
:
string
title
?:
string
onSubmit
?:
()
=>
PersonalInfo
onClose
:
()
=>
void
visible
:
boolean
validate
:
()
=>
void
onSubmit
:
(
values
:
PersonalInfo
,
formikHelpers
:
FormikHelpers
<
PersonalInfo
>
)
=>
void
onError
:
(
errors
:
FormikErrors
<
PersonalInfo
>
)
=>
void
}
class
Address
extends
Component
<
Props
>
{
render
()
{
return
<
MaskCover
>
<
div
className=
"address-container"
>
<
div
className=
"title"
></
div
>
<
div
className=
"subtitle"
></
div
>
</
div
>
</
MaskCover
>
}
const
Address
:
React
.
FC
<
Props
>
=
({
name
,
phone
,
address
,
title
,
subtitle
,
visible
,
onClose
,
validate
,
onSubmit
,
onError
})
=>
{
return
(
visible
?
<
MaskCover
>
<
div
className=
"common-address-container"
>
<
div
className=
"title"
>
{
title
}
</
div
>
<
div
className=
"subtitle"
>
{
subtitle
}
</
div
>
<
Formik
initialValues=
{
{
name
,
phone
,
address
}
}
enableReinitialize=
{
true
}
onSubmit=
{
onSubmit
}
validate=
{
validate
}
>
{
(
props
)
=>
{
if
(
props
.
errors
)
{
onError
(
props
.
errors
)
}
return
<
Form
className=
{
'form'
}
>
<
Field
placeholder=
{
'姓名'
}
name=
'name'
></
Field
>
<
Field
placeholder=
{
'手机号'
}
name=
'phone'
></
Field
>
<
Field
placeholder=
{
'地址'
}
name=
'address'
></
Field
>
<
button
type=
{
'submit'
}
className=
{
'submit'
}
>
提交
</
button
>
</
Form
>
}
}
</
Formik
>
<
i
className=
{
'iconfont iconiconfront-2 close'
}
onClick=
{
onClose
}
></
i
>
</
div
>
</
MaskCover
>
:
null
)
}
Address
.
defaultProps
=
{
title
:
'收货信息'
,
subtitle
:
'获奖用户(以最终榜单为准)请及时填写收货信息'
}
export
default
Address
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