Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert tool tip components to TypeScript #2013

Merged
merged 4 commits into from
Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Attach `noreferrer` also to links without `target="_blank"` ([#2008](https://github.com/elastic/eui/pull/2008))
- Convert observer utility components to TypeScript ([#2009](https://github.com/elastic/eui/pull/2009))
- Convert tool tip components to TypeScript ([#2013](https://github.com/elastic/eui/pull/2013))

**Bug fixes**

Expand Down
2 changes: 1 addition & 1 deletion src/components/badge/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IconType } from '../icon';
/// <reference path="../tool_tip/index.d.ts" />
import { ToolTipPositions } from '../tool_tip/tool_tip';

import {
HTMLAttributes,
Expand Down
1 change: 0 additions & 1 deletion src/components/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
/// <reference path="./table/index.d.ts" />
/// <reference path="./tabs/index.d.ts" />
/// <reference path="./toast/index.d.ts" />
/// <reference path="./tool_tip/index.d.ts" />

declare module '@elastic/eui' {
// @ts-ignore
Expand Down
57 changes: 0 additions & 57 deletions src/components/tool_tip/icon_tip.js

This file was deleted.

62 changes: 62 additions & 0 deletions src/components/tool_tip/icon_tip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React, { FunctionComponent } from 'react';

import { Omit, PropsOf } from '../common';
import { EuiIcon, IconSize, IconType } from '../icon';
import { EuiToolTip, Props as EuiToolTipProps } from './tool_tip';

export interface EuiIconTipProps {
/**
* The icon color.
*/
color?: string;
/**
* The icon type.
*/
type?: IconType;
/**
* The icon size.
*/
size?: IconSize;
/**
* Explain what this icon means for screen readers.
*/
'aria-label'?: string;

/**
* Pass certain props down to `EuiIcon`
*/
// EuiIconTip's `type` is passed to EuiIcon, so we want to exclude `type` from
// iconProps; however, due to TS's bivariant function arguments `type` could be
// passed without any error/feedback so we explicitly set it to `never` type
iconProps?: Omit<PropsOf<EuiIcon>, 'type'> & { type?: never };
}

type Props = Omit<EuiToolTipProps, 'children' | 'delay' | 'position'> &
EuiIconTipProps & {
// This are copied from EuiToolTipProps, but made optional. Defaults
// are applied below.
delay?: EuiToolTipProps['delay'];
position?: EuiToolTipProps['position'];
};

export const EuiIconTip: FunctionComponent<Props> = ({
type = 'questionInCircle',
'aria-label': ariaLabel = 'Info',
color,
size,
iconProps,
position = 'top',
delay = 'regular',
...rest
}) => (
<EuiToolTip position={position} delay={delay} {...rest}>
<EuiIcon
tabIndex={0}
type={type}
color={color}
size={size}
aria-label={ariaLabel}
{...iconProps}
/>
</EuiToolTip>
);
38 changes: 0 additions & 38 deletions src/components/tool_tip/index.d.ts

This file was deleted.

File renamed without changes.
Loading