Skip to content

Commit

Permalink
[EuiToolTip] Misc types cleanup
Browse files Browse the repository at this point in the history
- Remove className maps - they're not actually being used and we should be using more modern `as const`/`typeof` instead of `keysOf`
  • Loading branch information
cee-chen committed Aug 7, 2023
1 parent 4d204ee commit 9ac1d5f
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/components/tool_tip/tool_tip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import React, {
} from 'react';
import classNames from 'classnames';

import { CommonProps, keysOf } from '../common';
import { CommonProps } from '../common';
import { findPopoverPosition, htmlIdGenerator } from '../../services';
import { enqueueStateChange } from '../../services/react';
import { EuiResizeObserver } from '../observer/resize_observer';
Expand All @@ -26,14 +26,8 @@ import { EuiToolTipAnchor } from './tool_tip_anchor';
import { EuiToolTipArrow } from './tool_tip_arrow';
import { toolTipManager } from './tool_tip_manager';

const positionsToClassNameMap: { [key in ToolTipPositions]: string } = {
top: 'euiToolTip--top',
right: 'euiToolTip--right',
bottom: 'euiToolTip--bottom',
left: 'euiToolTip--left',
};

export const POSITIONS = keysOf(positionsToClassNameMap);
export const POSITIONS = ['top', 'right', 'bottom', 'left'] as const;
const DISPLAYS = ['inlineBlock', 'block'] as const;

export type ToolTipDelay = 'regular' | 'long';

Expand All @@ -50,11 +44,6 @@ interface ToolTipStyles {
visibility?: 'hidden';
}

const displayToClassNameMap = {
inlineBlock: undefined,
block: 'euiToolTipAnchor--displayBlock',
};

const DEFAULT_TOOLTIP_STYLES: ToolTipStyles = {
// position the tooltip content near the top-left
// corner of the window so it can't create scrollbars
Expand Down Expand Up @@ -92,7 +81,7 @@ export interface EuiToolTipProps extends CommonProps {
/**
* Common display alternatives for the anchor wrapper
*/
display?: keyof typeof displayToClassNameMap;
display?: (typeof DISPLAYS)[number];
/**
* Delay before showing tooltip. Good for repeatable items.
*/
Expand Down

0 comments on commit 9ac1d5f

Please sign in to comment.