Browse Source

Popover prop content => overlay, ref #978

pull/1319/head
afc163 9 years ago
parent
commit
be8d19628b
  1. 2
      components/popover/demo/basic.md
  2. 2
      components/popover/demo/control.md
  3. 24
      components/popover/demo/placement.md
  4. 6
      components/popover/demo/triggerType.md
  5. 14
      components/popover/index.jsx
  6. 2
      components/popover/index.md

2
components/popover/demo/basic.md

@ -16,7 +16,7 @@ const content = (
);
ReactDOM.render(
<Popover overlay={content} title="标题">
<Popover content={content} title="标题">
<Button type="primary">弹出卡片</Button>
</Popover>
, mountNode);

2
components/popover/demo/control.md

@ -29,7 +29,7 @@ const App = React.createClass({
</div>
);
return (
<Popover overlay={content} title="标题" trigger="click"
<Popover content={content} title="标题" trigger="click"
visible={this.state.visible} onVisibleChange={this.handleVisibleChange}>
<Button type="primary">点击弹出卡片</Button>
</Popover>

24
components/popover/demo/placement.md

@ -19,46 +19,46 @@ const content = (
ReactDOM.render(
<div>
<div style={{ marginLeft: 60 }}>
<Popover placement="topLeft" title={text} overlay={content} trigger="click">
<Popover placement="topLeft" title={text} content={content} trigger="click">
<Button>上左</Button>
</Popover>
<Popover placement="top" title={text} overlay={content} trigger="click">
<Popover placement="top" title={text} content={content} trigger="click">
<Button>上边</Button>
</Popover>
<Popover placement="topRight" title={text} overlay={content} trigger="click">
<Popover placement="topRight" title={text} content={content} trigger="click">
<Button>上右</Button>
</Popover>
</div>
<div style={{ width: 60, float: 'left' }}>
<Popover placement="leftTop" title={text} overlay={content} trigger="click">
<Popover placement="leftTop" title={text} content={content} trigger="click">
<Button>左上</Button>
</Popover>
<Popover placement="left" title={text} overlay={content} trigger="click">
<Popover placement="left" title={text} content={content} trigger="click">
<Button>左边</Button>
</Popover>
<Popover placement="leftBottom" title={text} overlay={content} trigger="click">
<Popover placement="leftBottom" title={text} content={content} trigger="click">
<Button>左下</Button>
</Popover>
</div>
<div style={{ width: 60, marginLeft: 270 }}>
<Popover placement="rightTop" title={text} overlay={content} trigger="click">
<Popover placement="rightTop" title={text} content={content} trigger="click">
<Button>右上</Button>
</Popover>
<Popover placement="right" title={text} overlay={content} trigger="click">
<Popover placement="right" title={text} content={content} trigger="click">
<Button>右边</Button>
</Popover>
<Popover placement="rightBottom" title={text} overlay={content} trigger="click">
<Popover placement="rightBottom" title={text} content={content} trigger="click">
<Button>右下</Button>
</Popover>
</div>
<div style={{ marginLeft: 60, clear: 'both' }}>
<Popover placement="bottomLeft" title={text} overlay={content} trigger="click">
<Popover placement="bottomLeft" title={text} content={content} trigger="click">
<Button>下左</Button>
</Popover>
<Popover placement="bottom" title={text} overlay={content} trigger="click">
<Popover placement="bottom" title={text} content={content} trigger="click">
<Button>下边</Button>
</Popover>
<Popover placement="bottomRight" title={text} overlay={content} trigger="click">
<Popover placement="bottomRight" title={text} content={content} trigger="click">
<Button>下右</Button>
</Popover>
</div>

6
components/popover/demo/triggerType.md

@ -17,13 +17,13 @@ const content = (
ReactDOM.render(
<div>
<Popover overlay={content} title="标题" trigger="hover">
<Popover content={content} title="标题" trigger="hover">
<Button>移入</Button>
</Popover>
<Popover overlay={content} title="标题" trigger="focus">
<Popover content={content} title="标题" trigger="focus">
<Button>聚焦</Button>
</Popover>
<Popover overlay={content} title="标题" trigger="click">
<Popover content={content} title="标题" trigger="click">
<Button>点击</Button>
</Popover>
</div>

14
components/popover/index.jsx

@ -1,6 +1,7 @@
import React from 'react';
import Tooltip from 'rc-tooltip';
import getPlacements from './placements';
import warning from 'warning';
const placements = getPlacements();
@ -45,13 +46,22 @@ export default class Popover extends React.Component {
return this.refs.tooltip.getPopupDomNode();
}
componentDidMount() {
if ('overlay' in this.props) {
warning(false, '`overlay` prop of Popover is deperated, use `content` instead.');
}
}
getOverlay() {
const { title, prefixCls, overlay } = this.props;
// use content replace overlay
// keep overlay for compatibility
const { title, prefixCls, overlay, content } = this.props;
return (
<div>
{title && <div className={`${prefixCls}-title`}>{title}</div>}
<div className={`${prefixCls}-inner-content`}>
{overlay}
{content || overlay}
</div>
</div>
);

2
components/popover/index.md

@ -20,7 +20,7 @@ english: Popover
| trigger | 触发行为,可选 `hover/focus/click` | string | hover |
| placement | 气泡框位置,可选 `top/left/right/bottom` `topLeft/topRight/bottomLeft/bottomRight` `leftTop/leftBottom/rightTop/rightBottom` | string | top |
| title | 卡片标题 | React.Element | 无 |
| overlay | 卡片内容 | React.Element | 无 |
| content | 卡片内容 | React.Element | 无 |
| overlayClassName | 卡片类名 | string | 无 |
| overlayStyle | 卡片样式 | object | 无 |
| visible | 用于手动控制浮层显隐 | boolean | false |

Loading…
Cancel
Save