-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30624 from kubabutkiewicz/ts-migration/ConfirmPop…
…over/component [TS migration] Migrate 'Popover.js' component to TypeScript
- Loading branch information
Showing
5 changed files
with
96 additions
and
41 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 was deleted.
Oops, something went wrong.
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,27 @@ | ||
import React from 'react'; | ||
import Modal from '@components/Modal'; | ||
import CONST from '@src/CONST'; | ||
import {PopoverProps} from './types'; | ||
|
||
/* | ||
* This is a convenience wrapper around the Modal component for a responsive Popover. | ||
* On small screen widths, it uses BottomDocked modal type, and a Popover type on wide screen widths. | ||
*/ | ||
function Popover({animationIn, animationOut, popoverAnchorPosition, disableAnimation, anchorPosition = {}, fromSidebarMediumScreen, ...propsWithoutAnimation}: PopoverProps) { | ||
return ( | ||
<Modal | ||
type={fromSidebarMediumScreen ? CONST.MODAL.MODAL_TYPE.POPOVER : CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED} | ||
popoverAnchorPosition={fromSidebarMediumScreen ? anchorPosition : undefined} | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...propsWithoutAnimation} | ||
// Mobile will always has fullscreen menu | ||
fullscreen | ||
animationIn="slideInUp" | ||
animationOut="slideOutDown" | ||
/> | ||
); | ||
} | ||
|
||
Popover.displayName = 'Popover'; | ||
|
||
export default Popover; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import BaseModalProps, {PopoverAnchorPosition} from '@components/Modal/types'; | ||
import {WindowDimensionsProps} from '@components/withWindowDimensions/types'; | ||
|
||
type AnchorAlignment = {horizontal: string; vertical: string}; | ||
|
||
type PopoverDimensions = { | ||
width: number; | ||
height: number; | ||
}; | ||
|
||
type PopoverProps = BaseModalProps & { | ||
/** The anchor position of the popover */ | ||
anchorPosition?: PopoverAnchorPosition; | ||
|
||
/** The anchor alignment of the popover */ | ||
anchorAlignment: AnchorAlignment; | ||
|
||
/** The anchor ref of the popover */ | ||
anchorRef: React.RefObject<HTMLElement>; | ||
|
||
/** Whether disable the animations */ | ||
disableAnimation: boolean; | ||
|
||
/** Whether we don't want to show overlay */ | ||
withoutOverlay: boolean; | ||
|
||
/** The dimensions of the popover */ | ||
popoverDimensions?: PopoverDimensions; | ||
|
||
/** The ref of the popover */ | ||
withoutOverlayRef?: React.RefObject<HTMLElement>; | ||
|
||
/** Whether we want to show the popover on the right side of the screen */ | ||
fromSidebarMediumScreen?: boolean; | ||
|
||
/** The popover children */ | ||
children: React.ReactNode; | ||
}; | ||
|
||
type PopoverWithWindowDimensionsProps = PopoverProps & WindowDimensionsProps; | ||
|
||
export type {PopoverProps, PopoverWithWindowDimensionsProps}; |