mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-13 04:53:11 +08:00
update form style for advanced-search-form demo
This commit is contained in:
parent
e5c8179189
commit
b3f519ac52
@ -7,29 +7,7 @@ function prefixClsFn(prefixCls, ...args) {
|
|||||||
}).join(' ');
|
}).join(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class FormItem extends React.Component {
|
class FormItem extends React.Component {
|
||||||
static defaultProps = {
|
|
||||||
hasFeedback: false,
|
|
||||||
prefixCls: 'ant-form',
|
|
||||||
}
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
prefixCls: React.PropTypes.string,
|
|
||||||
label: React.PropTypes.node,
|
|
||||||
labelCol: React.PropTypes.object,
|
|
||||||
help: React.PropTypes.oneOfType([React.PropTypes.node, React.PropTypes.bool]),
|
|
||||||
validateStatus: React.PropTypes.oneOf(['', 'success', 'warning', 'error', 'validating']),
|
|
||||||
hasFeedback: React.PropTypes.bool,
|
|
||||||
wrapperCol: React.PropTypes.object,
|
|
||||||
className: React.PropTypes.string,
|
|
||||||
id: React.PropTypes.string,
|
|
||||||
children: React.PropTypes.node,
|
|
||||||
}
|
|
||||||
|
|
||||||
static contextTypes = {
|
|
||||||
form: React.PropTypes.object,
|
|
||||||
}
|
|
||||||
|
|
||||||
_getLayoutClass(colDef) {
|
_getLayoutClass(colDef) {
|
||||||
if (!colDef) {
|
if (!colDef) {
|
||||||
return '';
|
return '';
|
||||||
@ -44,31 +22,18 @@ export default class FormItem extends React.Component {
|
|||||||
const context = this.context;
|
const context = this.context;
|
||||||
const props = this.props;
|
const props = this.props;
|
||||||
if (props.help === undefined && context.form) {
|
if (props.help === undefined && context.form) {
|
||||||
return this.getId() ? (context.form.getFieldError(this.getId()) || []).join(', ') : '';
|
return (context.form.getFieldError(this.getId()) || []).join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
return props.help;
|
return props.help;
|
||||||
}
|
}
|
||||||
|
|
||||||
getOnlyControl() {
|
|
||||||
const children = React.Children.toArray(this.props.children);
|
|
||||||
const child = children.filter((c) => {
|
|
||||||
return c.props && '__meta' in c.props;
|
|
||||||
})[0];
|
|
||||||
return child !== undefined ? child : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
getChildProp(prop) {
|
|
||||||
const child = this.getOnlyControl();
|
|
||||||
return child && child.props && child.props[prop];
|
|
||||||
}
|
|
||||||
|
|
||||||
getId() {
|
getId() {
|
||||||
return this.getChildProp('id');
|
return this.props.children.props && this.props.children.props.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
getMeta() {
|
getMeta() {
|
||||||
return this.getChildProp('__meta');
|
return this.props.children.props && this.props.children.props.__meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderHelp() {
|
renderHelp() {
|
||||||
@ -85,9 +50,7 @@ export default class FormItem extends React.Component {
|
|||||||
getValidateStatus() {
|
getValidateStatus() {
|
||||||
const { isFieldValidating, getFieldError, getFieldValue } = this.context.form;
|
const { isFieldValidating, getFieldError, getFieldValue } = this.context.form;
|
||||||
const field = this.getId();
|
const field = this.getId();
|
||||||
if (!field) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
if (isFieldValidating(field)) {
|
if (isFieldValidating(field)) {
|
||||||
return 'validating';
|
return 'validating';
|
||||||
} else if (!!getFieldError(field)) {
|
} else if (!!getFieldError(field)) {
|
||||||
@ -95,6 +58,7 @@ export default class FormItem extends React.Component {
|
|||||||
} else if (getFieldValue(field) !== undefined) {
|
} else if (getFieldValue(field) !== undefined) {
|
||||||
return 'success';
|
return 'success';
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,3 +170,27 @@ export default class FormItem extends React.Component {
|
|||||||
return this.renderFormItem(children);
|
return this.renderFormItem(children);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FormItem.propTypes = {
|
||||||
|
prefixCls: React.PropTypes.string,
|
||||||
|
label: React.PropTypes.node,
|
||||||
|
labelCol: React.PropTypes.object,
|
||||||
|
help: React.PropTypes.oneOfType([React.PropTypes.node, React.PropTypes.bool]),
|
||||||
|
validateStatus: React.PropTypes.oneOf(['', 'success', 'warning', 'error', 'validating']),
|
||||||
|
hasFeedback: React.PropTypes.bool,
|
||||||
|
wrapperCol: React.PropTypes.object,
|
||||||
|
className: React.PropTypes.string,
|
||||||
|
id: React.PropTypes.string,
|
||||||
|
children: React.PropTypes.node,
|
||||||
|
};
|
||||||
|
|
||||||
|
FormItem.defaultProps = {
|
||||||
|
hasFeedback: false,
|
||||||
|
prefixCls: 'ant-form',
|
||||||
|
};
|
||||||
|
|
||||||
|
FormItem.contextTypes = {
|
||||||
|
form: React.PropTypes.object,
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = FormItem;
|
||||||
|
@ -12,26 +12,26 @@ import { Form, Input, Row, Col, Button } from 'antd';
|
|||||||
const FormItem = Form.Item;
|
const FormItem = Form.Item;
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<Form horizontal className="advanced-search-form">
|
<Form horizontal className="ant-advanced-search-form">
|
||||||
<Row gutter={16}>
|
<Row gutter={16}>
|
||||||
<Col span="8">
|
<Col span="8">
|
||||||
<FormItem
|
<FormItem
|
||||||
label="搜索名称:"
|
label="搜索名称:"
|
||||||
labelCol={{ span: 10 }}
|
labelCol={{ span: 10 }}
|
||||||
wrapperCol={{ span: 14 }}>
|
wrapperCol={{ span: 14 }}>
|
||||||
<Input placeholder="请输入搜索名称" />
|
<Input placeholder="请输入搜索名称" size="default" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem
|
<FormItem
|
||||||
label="较长搜索名称:"
|
label="较长搜索名称:"
|
||||||
labelCol={{ span: 10 }}
|
labelCol={{ span: 10 }}
|
||||||
wrapperCol={{ span: 14 }}>
|
wrapperCol={{ span: 14 }}>
|
||||||
<Input placeholder="请输入搜索名称" />
|
<Input placeholder="请输入搜索名称" size="default" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem
|
<FormItem
|
||||||
label="搜索名称:"
|
label="搜索名称:"
|
||||||
labelCol={{ span: 10 }}
|
labelCol={{ span: 10 }}
|
||||||
wrapperCol={{ span: 14 }}>
|
wrapperCol={{ span: 14 }}>
|
||||||
<Input placeholder="请输入搜索名称" />
|
<Input placeholder="请输入搜索名称" size="default" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span="8">
|
<Col span="8">
|
||||||
@ -39,19 +39,19 @@ ReactDOM.render(
|
|||||||
label="搜索名称:"
|
label="搜索名称:"
|
||||||
labelCol={{ span: 10 }}
|
labelCol={{ span: 10 }}
|
||||||
wrapperCol={{ span: 14 }}>
|
wrapperCol={{ span: 14 }}>
|
||||||
<Input placeholder="请输入搜索名称" />
|
<Input placeholder="请输入搜索名称" size="default" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem
|
<FormItem
|
||||||
label="较长搜索名称:"
|
label="较长搜索名称:"
|
||||||
labelCol={{ span: 10 }}
|
labelCol={{ span: 10 }}
|
||||||
wrapperCol={{ span: 14 }}>
|
wrapperCol={{ span: 14 }}>
|
||||||
<Input placeholder="请输入搜索名称" />
|
<Input placeholder="请输入搜索名称" size="default" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem
|
<FormItem
|
||||||
label="搜索名称:"
|
label="搜索名称:"
|
||||||
labelCol={{ span: 10 }}
|
labelCol={{ span: 10 }}
|
||||||
wrapperCol={{ span: 14 }}>
|
wrapperCol={{ span: 14 }}>
|
||||||
<Input placeholder="请输入搜索名称" />
|
<Input placeholder="请输入搜索名称" size="default" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span="8">
|
<Col span="8">
|
||||||
@ -59,19 +59,19 @@ ReactDOM.render(
|
|||||||
label="搜索名称:"
|
label="搜索名称:"
|
||||||
labelCol={{ span: 10 }}
|
labelCol={{ span: 10 }}
|
||||||
wrapperCol={{ span: 14 }}>
|
wrapperCol={{ span: 14 }}>
|
||||||
<Input placeholder="请输入搜索名称" />
|
<Input placeholder="请输入搜索名称" size="default" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem
|
<FormItem
|
||||||
label="较长搜索名称:"
|
label="较长搜索名称:"
|
||||||
labelCol={{ span: 10 }}
|
labelCol={{ span: 10 }}
|
||||||
wrapperCol={{ span: 14 }}>
|
wrapperCol={{ span: 14 }}>
|
||||||
<Input placeholder="请输入搜索名称" />
|
<Input placeholder="请输入搜索名称" size="default" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem
|
<FormItem
|
||||||
label="搜索名称:"
|
label="搜索名称:"
|
||||||
labelCol={{ span: 10 }}
|
labelCol={{ span: 10 }}
|
||||||
wrapperCol={{ span: 14 }}>
|
wrapperCol={{ span: 14 }}>
|
||||||
<Input placeholder="请输入搜索名称" />
|
<Input placeholder="请输入搜索名称" size="default" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
@ -88,7 +88,7 @@ ReactDOM.render(
|
|||||||
````css
|
````css
|
||||||
/* 定制样式 */
|
/* 定制样式 */
|
||||||
|
|
||||||
.advanced-search-form {
|
.ant-advanced-search-form {
|
||||||
padding: 16px 8px;
|
padding: 16px 8px;
|
||||||
background: #f8f8f8;
|
background: #f8f8f8;
|
||||||
border: 1px solid #d9d9d9;
|
border: 1px solid #d9d9d9;
|
||||||
@ -96,16 +96,12 @@ ReactDOM.render(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 由于输入标签长度不确定,所以需要微调使之看上去居中 */
|
/* 由于输入标签长度不确定,所以需要微调使之看上去居中 */
|
||||||
.advanced-search-form > .row {
|
.ant-advanced-search-form > .row {
|
||||||
position: relative;
|
position: relative;
|
||||||
left: -6px;
|
left: -6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.advanced-search-form .ant-form-item {
|
.ant-advanced-search-form .ant-btn + .ant-btn {
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.advanced-search-form .ant-btn + .ant-btn {
|
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
@ -120,11 +120,6 @@ form {
|
|||||||
line-height: @input-height-lg;
|
line-height: @input-height-lg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.@{css-prefix}input,
|
|
||||||
.@{css-prefix}input-group .@{css-prefix}input,
|
|
||||||
.@{css-prefix}input-group .@{css-prefix}input-group-addon {
|
|
||||||
.input-lg();
|
|
||||||
}
|
|
||||||
|
|
||||||
textarea.@{css-prefix}input {
|
textarea.@{css-prefix}input {
|
||||||
height: auto;
|
height: auto;
|
||||||
@ -424,6 +419,10 @@ form {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ant-advanced-search-form .@{css-prefix}form-item {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
// need there different zoom animation
|
// need there different zoom animation
|
||||||
// otherwise won't trigger anim
|
// otherwise won't trigger anim
|
||||||
@keyframes diffZoomIn1 {
|
@keyframes diffZoomIn1 {
|
||||||
|
Loading…
Reference in New Issue
Block a user