Skip to content

Commit

Permalink
refactor(Tooltip): rewrite Tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
BANG88 committed Jun 26, 2016
1 parent d737e7f commit 38b18ee
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ export { default as Tag } from './Tag';
export { default as TimePicker } from './time-picker';

export { default as Timeline } from './timeline';

export { default as Tooltip } from './tooltip';
19 changes: 15 additions & 4 deletions components/tooltip/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
import React, { cloneElement } from 'react';
import * as React from 'react';
const { cloneElement } = React;
import RcTooltip from 'rc-tooltip';
import getPlacements from '../popover/placements';

const placements = getPlacements({
verticalArrowShift: 8,
});
type PopoverPlacement = 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom'

export default class Tooltip extends React.Component {
// Tooltip
export interface TooltipProps {
/** 气泡框位置,可选 `top` `left` `right` `bottom` `topLeft` `topRight` `bottomLeft` `bottomRight` `leftTop` `leftBottom` `rightTop` `rightBottom`*/
placement?: PopoverPlacement,
/** 提示文字*/
title?: string | React.ReactNode,

style?: React.CSSProperties
}
export default class Tooltip extends React.Component<TooltipProps, any> {
static defaultProps = {
prefixCls: 'ant-tooltip',
placement: 'top',
transitionName: 'zoom-big',
mouseEnterDelay: 0.1,
mouseLeaveDelay: 0.1,
onVisibleChange() {},
onVisibleChange() { },
}

constructor(props) {
Expand Down Expand Up @@ -86,7 +97,7 @@ export default class Tooltip extends React.Component {
ref="tooltip"
{...this.props}
onVisibleChange={this.onVisibleChange}
>
>
{visible ? cloneElement(children, { className: childrenCls }) : children}
</RcTooltip>
);
Expand Down

0 comments on commit 38b18ee

Please sign in to comment.