From d6386bbb6bdd30c6fc968b18368305e9f7c9288a Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 13 Oct 2017 17:35:33 +0800 Subject: [PATCH] update components API and demo --- src/components/FooterToolbar/demo/basic.md | 29 ++++++++++++++++++ src/components/FooterToolbar/index.md | 11 +++++++ src/components/GlobalFooter/demo/basic.md | 3 +- src/components/GlobalFooter/index.md | 8 ++--- src/components/HeaderSearch/demo/basic.md | 35 ++++++++++++++++++++++ src/components/HeaderSearch/index.js | 18 ++++++++++- src/components/HeaderSearch/index.md | 19 ++++++++++++ 7 files changed, 117 insertions(+), 6 deletions(-) create mode 100644 src/components/FooterToolbar/demo/basic.md create mode 100644 src/components/HeaderSearch/demo/basic.md create mode 100644 src/components/HeaderSearch/index.md diff --git a/src/components/FooterToolbar/demo/basic.md b/src/components/FooterToolbar/demo/basic.md new file mode 100644 index 00000000..4d90efe0 --- /dev/null +++ b/src/components/FooterToolbar/demo/basic.md @@ -0,0 +1,29 @@ +--- +order: 0 +title: 演示 +iframe: 600 +--- + +浮动固定页脚。 + +````jsx +import FooterToolbar from 'ant-design-pro/lib/FooterToolbar'; +import { Icon } from 'antd'; + +ReactDOM.render( +
+

页面内容 页面内容 页面内容 页面内容

+

页面内容 页面内容 页面内容 页面内容

+

页面内容 页面内容 页面内容 页面内容

+

页面内容 页面内容 页面内容 页面内容

+

页面内容 页面内容 页面内容 页面内容

+

页面内容 页面内容 页面内容 页面内容

+

页面内容 页面内容 页面内容 页面内容

+

页面内容 页面内容 页面内容 页面内容

+ + + + +
+, mountNode); +```` diff --git a/src/components/FooterToolbar/index.md b/src/components/FooterToolbar/index.md index b202bd1e..acdb62ad 100644 --- a/src/components/FooterToolbar/index.md +++ b/src/components/FooterToolbar/index.md @@ -6,4 +6,15 @@ subtitle: 底部固定工具栏 cols: 1 --- +固定在底部的工具栏。 + +## 何时使用 + +固定在内容区域的底部,不随滚动条移动,常用于长页面的数据搜集和提交工作。 + ## API + +参数 | 说明 | 类型 | 默认值 +----|------|-----|------ +children | 工具栏内容,向右对齐 | ReactNode | - +extra | 额外信息,向左对齐 | ReactNode | - diff --git a/src/components/GlobalFooter/demo/basic.md b/src/components/GlobalFooter/demo/basic.md index eb47d0e4..53e5caba 100644 --- a/src/components/GlobalFooter/demo/basic.md +++ b/src/components/GlobalFooter/demo/basic.md @@ -1,6 +1,7 @@ --- order: 0 -title: Basic +title: 演示 +iframe: 600 --- 基本页脚。 diff --git a/src/components/GlobalFooter/index.md b/src/components/GlobalFooter/index.md index 6f3e43a1..c1816293 100644 --- a/src/components/GlobalFooter/index.md +++ b/src/components/GlobalFooter/index.md @@ -10,7 +10,7 @@ cols: 1 ## API -| 参数 | 说明 | 类型 | 默认值 | -|----------|------------------------------------------|-------------|-------| -| links | 链接数据 | array<{ title: ReactNode, href: string, blankTarget?: boolean }> | - | -| copyright | 版权信息 | ReactNode | - | +参数 | 说明 | 类型 | 默认值 +----|------|-----|------ +links | 链接数据 | array<{ title: ReactNode, href: string, blankTarget?: boolean }> | - +copyright | 版权信息 | ReactNode | - diff --git a/src/components/HeaderSearch/demo/basic.md b/src/components/HeaderSearch/demo/basic.md new file mode 100644 index 00000000..733e5555 --- /dev/null +++ b/src/components/HeaderSearch/demo/basic.md @@ -0,0 +1,35 @@ +--- +order: 0 +title: 全局搜索 +--- + +通常放在全局导航条右侧。 + +````jsx +import HeaderSearch from 'ant-design-pro/lib/HeaderSearch'; +import { Icon } from 'antd'; + +ReactDOM.render( +
+ { + console.log('input', value); // eslint-disable-line + }} + onPressEnter={(value) => { + console.log('enter', value); // eslint-disable-line + }} + /> +
+, mountNode); +```` diff --git a/src/components/HeaderSearch/index.js b/src/components/HeaderSearch/index.js index 06ad10b2..e96986ee 100644 --- a/src/components/HeaderSearch/index.js +++ b/src/components/HeaderSearch/index.js @@ -1,4 +1,5 @@ import React, { PureComponent } from 'react'; +import PropTypes from 'prop-types'; import { Input, Icon, AutoComplete } from 'antd'; import classNames from 'classnames'; import styles from './index.less'; @@ -6,6 +7,21 @@ import styles from './index.less'; export default class HeaderSearch extends PureComponent { static defaultProps = { defaultActiveFirstOption: false, + onPressEnter: () => {}, + onChange: () => {}, + onSearch: () => {}, + className: '', + placeholder: '', + dataSource: [], + }; + static propTypes = { + className: PropTypes.string, + placeholder: PropTypes.string, + onSearch: PropTypes.func, + onPressEnter: PropTypes.func, + onChange: PropTypes.func, + defaultActiveFirstOption: PropTypes.bool, + dataSource: PropTypes.array, }; state = { searchMode: false, @@ -23,6 +39,7 @@ export default class HeaderSearch extends PureComponent { } onChange = (value) => { this.setState({ value }); + this.props.onChange(); } enterSearchMode = () => { this.setState({ searchMode: true }, () => { @@ -49,7 +66,6 @@ export default class HeaderSearch extends PureComponent { className={inputClass} value={this.state.value} onChange={this.onChange} - onSelect={this.onSelect} {...restProps} >