Skip to content

Commit

Permalink
Clean up types
Browse files Browse the repository at this point in the history
- not super necessary to have a separate file for it, these types are only used within EuiPortal

- use `as const` array and typeof instead of `keyof`

- simplify insert positions map typing
  • Loading branch information
cee-chen committed Jul 12, 2023
1 parent 68af7cc commit 5fa5858
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 31 deletions.
9 changes: 7 additions & 2 deletions src/components/portal/portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ import { createPortal } from 'react-dom';
import { EuiNestedThemeContext } from '../../services';
import { useEuiComponentDefaults } from '../provider/component_defaults';

import { insertPositions } from './portal.types';
const INSERT_POSITIONS = ['after', 'before'] as const;
type EuiPortalInsertPosition = (typeof INSERT_POSITIONS)[number];
const insertPositions: Record<EuiPortalInsertPosition, InsertPosition> = {
after: 'afterend',
before: 'beforebegin',
};

export interface EuiPortalProps {
/**
Expand All @@ -28,7 +33,7 @@ export interface EuiPortalProps {
* If not specified, `EuiPortal` will insert itself
* into the end of the `document.body` by default
*/
insert?: { sibling: HTMLElement; position: 'before' | 'after' };
insert?: { sibling: HTMLElement; position: EuiPortalInsertPosition };
/**
* Optional ref callback
*/
Expand Down
29 changes: 0 additions & 29 deletions src/components/portal/portal.types.ts

This file was deleted.

0 comments on commit 5fa5858

Please sign in to comment.