From 9ac1d5f03a60061864f0eb1f4777c419b839b723 Mon Sep 17 00:00:00 2001 From: Cee Chen Date: Mon, 7 Aug 2023 13:53:56 -0700 Subject: [PATCH] [EuiToolTip] Misc types cleanup - Remove className maps - they're not actually being used and we should be using more modern `as const`/`typeof` instead of `keysOf` --- src/components/tool_tip/tool_tip.tsx | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/components/tool_tip/tool_tip.tsx b/src/components/tool_tip/tool_tip.tsx index f1f4ce03fc2..4f17a0b6d98 100644 --- a/src/components/tool_tip/tool_tip.tsx +++ b/src/components/tool_tip/tool_tip.tsx @@ -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'; @@ -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'; @@ -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 @@ -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. */