diff --git a/components/popconfirm/index.jsx b/components/popconfirm/index.jsx index 45d81f300b..8102fd3d49 100644 --- a/components/popconfirm/index.jsx +++ b/components/popconfirm/index.jsx @@ -11,6 +11,7 @@ const noop = () => {}; export default class Popconfirm extends React.Component { static defaultProps = { transitionName: 'zoom-big', + openClassName: 'ant-popup', placement: 'top', trigger: 'click', overlayStyle: {}, diff --git a/components/popconfirm/index.md b/components/popconfirm/index.md index 7ff27f6486..3258595eaa 100644 --- a/components/popconfirm/index.md +++ b/components/popconfirm/index.md @@ -25,3 +25,5 @@ english: Popconfirm | onVisibleChange | 显示隐藏的回调 | function(visible) | 无 | | okText | 确认按钮文字 | String | 确定 | | cancelText| 取消按钮文字 | String | 取消 | +| openClassName | 气泡框展现时触发器添加的class,可用于触发时触发器的样式指定 | string | ant-popup | + diff --git a/components/popover/index.md b/components/popover/index.md index f4a094f8bf..5c87d0f325 100644 --- a/components/popover/index.md +++ b/components/popover/index.md @@ -26,3 +26,4 @@ english: Popover | visible | 用于手动控制浮层显隐 | boolean | false | | onVisibleChange | 显示隐藏改变的回调 | function | 无 | | getTooltipContainer | 菜单渲染父节点。默认渲染到 body 上,如果你遇到菜单滚动定位问题,试试修改为滚动的区域,并相对其定位。[示例](http://codepen.io/anon/pen/ONjyba?editors=001) | Function(triggerNode) | () => document.body | +| openClassName | 气泡框展现时触发器添加的类名,可用于打开浮层时高亮触发器 | string | ant-popover-open | diff --git a/components/tooltip/index.jsx b/components/tooltip/index.jsx index df7eca4185..9c4962e4bd 100644 --- a/components/tooltip/index.jsx +++ b/components/tooltip/index.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { cloneElement } from 'react'; import RcTooltip from 'rc-tooltip'; import getPlacements from '../popover/placements'; @@ -62,21 +62,29 @@ export default class Tooltip extends React.Component { } render() { + const { prefixCls, title, overlay, children, transitionName } = this.props; // Hide tooltip when there is no title let visible = this.state.visible; - if (!this.props.title && !this.props.overlay) { + if (!title && !overlay) { visible = false; } + if ('visible' in this.props) { + visible = this.props.visible; + } + const openClassName = this.props.openClassName || `${prefixCls}-open`; + const childrenCls = (children && children.props && children.props.className) + ? `${children.props.className} ${openClassName}` : openClassName; return ( - - {this.props.children} + {visible ? cloneElement(children, { className: childrenCls, }) : children} ); }