Skip to content
This repository has been archived by the owner on Oct 20, 2021. It is now read-only.

Commit

Permalink
feat(input): add new input component (#77)
Browse files Browse the repository at this point in the history
* feat(input): add new input component

re #62

* add clearable to Input component

* optimize clearable codes

* improve input docs

* optimize remove icon

* add input test and optimize code

* remove uncontrolled input

* fix input test and optimize code

* update input docs

* add focus and moseEnter events to input

* fix state variable of icon to focus

* remove ClearableInput from src

* fix console log errors

* optimize Clear test of Input

* fix tests

* optimize tests, docs and lg icon style

* complete tests of input

* fix home page style issue

* add input public api

* remove redundant code in test
  • Loading branch information
Kimi-Gao committed Oct 10, 2019
1 parent 2712b67 commit 653de93
Show file tree
Hide file tree
Showing 18 changed files with 1,442 additions and 319 deletions.
16 changes: 10 additions & 6 deletions site/apps/apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,24 @@
"defaultOpen":false,
"components":[
{
"name":"Form",
"cn":"表单"
"name":"Switch",
"cn":"开关"
},
{
"name":"Menu",
"cn":"菜单"
"name":"Input",
"cn":"输入框"
},
{
"name":"Dropdown",
"cn":"下拉菜单"
},
{
"name":"Switch",
"cn":"开关"
"name":"Form",
"cn":"表单"
},
{
"name":"Menu",
"cn":"菜单"
},
{
"name":"DatePicker",
Expand Down
1 change: 1 addition & 0 deletions site/pages/Home/Section1/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
}
&-content {
padding-bottom: @ui-unit;
float: right;
h2 {
color: @theme;
margin-top: .5em;
Expand Down
104 changes: 56 additions & 48 deletions site/widgets/Doc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,29 @@ const Doc = props => {
<div className="doc">
<header className="doc__header">
<div className="doc__title">
{props.name.charCodeAt(0) < 97 ? '<' + props.name + ' />' : props.name}
{props.name.charCodeAt(0) < 97
? '<' + props.name + ' />'
: props.name}
</div>
</header>
{props.props && props.props.length ? (
<table>
<thead>
<tr>
<th>属性</th>
<th>类型</th>
<th>Property</th>
<th>Type</th>
{/* <th>默认</th> */}
<th>说明</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{props.props.map(prop => (
<tr key={prop.name}>
<td className={cx('doc__prop-name', {
'doc__prop-name--required': prop.required
})}>
<td
className={cx('doc__prop-name', {
'doc__prop-name--required': prop.required
})}
>
{prop.name}
</td>
<td className="doc__prop-type">{prop.type}</td>
Expand All @@ -40,47 +44,51 @@ const Doc = props => {
</tbody>
</table>
) : null}
{props.apis && props.apis.map(api => {
const { name, type, desc, params } = api
return (
<dl key={name}>
<dt>
{name}{type ? null : '( ' + (params || []).map(v => v.name).join(', ') + ' )'}
</dt>
{params && (
<dd>
<h2>参数</h2>
<ul>
{params.map(param => (
<li key={param.name}>
{param.name} {param.type}
<Markdown html={param.desc} />
</li>
))}
</ul>
</dd>
)}
{api['return'] && (
<dd>
<h2>返回</h2>
{api['return'].type + ' ' + api['return'].desc}
</dd>
)}
{type && (
<dd>
<h2>类型</h2>
{type}
</dd>
)}
{desc && (
<dd>
<h2>描述</h2>
<Markdown html={desc} />
</dd>
)}
</dl>
)
})}
{props.apis &&
props.apis.map(api => {
const { name, type, desc, params } = api
return (
<dl key={name}>
<dt>
{name}
{type
? null
: '( ' + (params || []).map(v => v.name).join(', ') + ' )'}
</dt>
{params && (
<dd>
<h2>Params</h2>
<ul>
{params.map(param => (
<li key={param.name}>
{param.name} {param.type}
<Markdown html={param.desc} />
</li>
))}
</ul>
</dd>
)}
{api.return && (
<dd>
<h2>Return</h2>
{api.return.type + ' ' + api.return.desc}
</dd>
)}
{type && (
<dd>
<h2>Type</h2>
{type}
</dd>
)}
{desc && (
<dd>
<h2>Description</h2>
<Markdown html={desc} />
</dd>
)}
</dl>
)
})}
</div>
)
}
Expand Down
26 changes: 0 additions & 26 deletions src/components/ClearableInput/docs/ClearableInput.dox

This file was deleted.

132 changes: 0 additions & 132 deletions src/components/ClearableInput/index.js

This file was deleted.

20 changes: 0 additions & 20 deletions src/components/ClearableInput/index.less

This file was deleted.

6 changes: 4 additions & 2 deletions src/components/Form/FormInput/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import cx from 'classnames'
import ClearableInput from '../../ClearableInput'
import Input from '../../Input'

const FormInput = (props, context) => {
const { children, className, onChange, ...other } = props
Expand All @@ -11,7 +11,9 @@ const FormInput = (props, context) => {
form.setItemValue(formItem, value)
onChange && onChange(value)
}
return <ClearableInput className={cx(`${prefixCls}-form__input`, className)} {...other} forbidClearable />
return (
<Input className={cx(`${prefixCls}-form__input`, className)} {...other} />
)
}

FormInput.propTypes = {
Expand Down
1 change: 1 addition & 0 deletions src/components/Icon/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ i {

.@{prefix-cls}-icon__close:before,
.@{prefix-cls}-icon__checked-alt:before,
.@{prefix-cls}-icon__remove:before,
.@{prefix-cls}-icon__industry:before {
top: -1px;
}
Expand Down

0 comments on commit 653de93

Please sign in to comment.