-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert tool tip components to TypeScript (#2013)
Convert tool tip components to TypeScript.
- Loading branch information
1 parent
a728779
commit 1d8596b
Showing
14 changed files
with
205 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.