Skip to content

Commit 5fa5858

Browse files
committed
Clean up types
- 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
1 parent 68af7cc commit 5fa5858

File tree

2 files changed

+7
-31
lines changed

2 files changed

+7
-31
lines changed

src/components/portal/portal.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ import { createPortal } from 'react-dom';
1717
import { EuiNestedThemeContext } from '../../services';
1818
import { useEuiComponentDefaults } from '../provider/component_defaults';
1919

20-
import { insertPositions } from './portal.types';
20+
const INSERT_POSITIONS = ['after', 'before'] as const;
21+
type EuiPortalInsertPosition = (typeof INSERT_POSITIONS)[number];
22+
const insertPositions: Record<EuiPortalInsertPosition, InsertPosition> = {
23+
after: 'afterend',
24+
before: 'beforebegin',
25+
};
2126

2227
export interface EuiPortalProps {
2328
/**
@@ -28,7 +33,7 @@ export interface EuiPortalProps {
2833
* If not specified, `EuiPortal` will insert itself
2934
* into the end of the `document.body` by default
3035
*/
31-
insert?: { sibling: HTMLElement; position: 'before' | 'after' };
36+
insert?: { sibling: HTMLElement; position: EuiPortalInsertPosition };
3237
/**
3338
* Optional ref callback
3439
*/

src/components/portal/portal.types.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)