Skip to content

Commit

Permalink
Converted EuiToolTipPopover to TS (#1800)
Browse files Browse the repository at this point in the history
* Converted EuiToolTipPopover to TS

* Updated Changelog

* `EuiToolTipPopover` Code review fixes
  • Loading branch information
theodesp authored and chandlerprall committed Apr 8, 2019
1 parent 5e0c8b7 commit 68594fb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 31 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Converted `EuiToolTipPopover` to TS ([#1800](https://github.com/elastic/eui/pull/1800))
- Converted `EuiTableHeaderMobile` to TS ([#1786](https://github.com/elastic/eui/pull/1786))
- Added `menuLeft` and `menuRight` icons ([#1797](https://github.com/elastic/eui/pull/1797))
- Updated EuiNavDrawer’s collapse/expand button to use `menuLeft` and `menuRight` icons ([#1797](https://github.com/elastic/eui/pull/1797))
Expand Down
1 change: 1 addition & 0 deletions src/components/tool_tip/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { EuiToolTipPopover } from './tool_tip_popover';
import { ReactElement, ReactNode, FunctionComponent } from 'react';
import { EuiIcon } from '../icon';
import { Omit, PropsOf } from '../common';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import { EuiToolTipPopover } from './tool_tip_popover';
describe('EuiToolTipPopover', () => {
test('is rendered', () => {
const component = render(
// tslint:disable-next-line:no-empty
<EuiToolTipPopover positionToolTip={() => {}} {...requiredProps} />
);

expect(component)
.toMatchSnapshot();
expect(component).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React, {
Component,
} from 'react';
import PropTypes from 'prop-types';
import React, { HTMLAttributes, Component, ReactNode } from 'react';
import classNames from 'classnames';
import { CommonProps } from '../common';

export class EuiToolTipPopover extends Component {
static propTypes = {
children: PropTypes.node,
className: PropTypes.string,
title: PropTypes.node,
positionToolTip: PropTypes.func.isRequired,
popoverRef: PropTypes.func,
}
export type EuiToolTipPopoverProps = CommonProps &
HTMLAttributes<HTMLDivElement> & {
positionToolTip: (rect: ClientRect | DOMRect) => void;
children?: ReactNode;
title?: ReactNode;
popoverRef?: (ref: HTMLDivElement) => void;
};

export class EuiToolTipPopover extends Component<EuiToolTipPopoverProps> {
private popover: HTMLDivElement | undefined;

updateDimensions = () => {
requestAnimationFrame(() => {
Expand All @@ -22,12 +22,12 @@ export class EuiToolTipPopover extends Component {
});
};

setPopoverRef = ref => {
setPopoverRef = (ref: HTMLDivElement) => {
this.popover = ref;
if (this.props.popoverRef) {
this.props.popoverRef(ref);
}
}
};

componentDidMount() {
document.body.classList.add('euiBody-hasPortalContent');
Expand All @@ -46,29 +46,20 @@ export class EuiToolTipPopover extends Component {
children,
title,
className,
positionToolTip, // eslint-disable-line no-unused-vars
popoverRef, // eslint-disable-line no-unused-vars
positionToolTip,
popoverRef,
...rest
} = this.props;

const classes = classNames(
'euiToolTipPopover',
className
);
const classes = classNames('euiToolTipPopover', className);

let optionalTitle;
if (title) {
optionalTitle = (
<div className="euiToolTip__title">{title}</div>
);
optionalTitle = <div className="euiToolTip__title">{title}</div>;
}

return (
<div
className={classes}
ref={this.setPopoverRef}
{...rest}
>
<div className={classes} ref={this.setPopoverRef} {...rest}>
{optionalTitle}
{children}
</div>
Expand Down

0 comments on commit 68594fb

Please sign in to comment.