MCPcopy
hub / github.com/react-bootstrap/react-bootstrap / getDropdownMenuPlacement

Function getDropdownMenuPlacement

src/DropdownMenu.tsx:91–114  ·  view source on GitHub ↗
(
  alignEnd: boolean,
  dropDirection?: DropDirection,
  isRTL?: boolean,
)

Source from the content-addressed store, hash-verified

89};
90
91export function getDropdownMenuPlacement(
92 alignEnd: boolean,
93 dropDirection?: DropDirection,
94 isRTL?: boolean,
95) {
96 const topStart = isRTL ? 'top-end' : 'top-start';
97 const topEnd = isRTL ? 'top-start' : 'top-end';
98 const bottomStart = isRTL ? 'bottom-end' : 'bottom-start';
99 const bottomEnd = isRTL ? 'bottom-start' : 'bottom-end';
100 const leftStart = isRTL ? 'right-start' : 'left-start';
101 const leftEnd = isRTL ? 'right-end' : 'left-end';
102 const rightStart = isRTL ? 'left-start' : 'right-start';
103 const rightEnd = isRTL ? 'left-end' : 'right-end';
104
105 let placement: Placement = alignEnd ? bottomEnd : bottomStart;
106 if (dropDirection === 'up') placement = alignEnd ? topEnd : topStart;
107 else if (dropDirection === 'end')
108 placement = alignEnd ? rightEnd : rightStart;
109 else if (dropDirection === 'start')
110 placement = alignEnd ? leftEnd : leftStart;
111 else if (dropDirection === 'down-centered') placement = 'bottom';
112 else if (dropDirection === 'up-centered') placement = 'top';
113 return placement;
114}
115
116const DropdownMenu: BsPrefixRefForwardingComponent<'div', DropdownMenuProps> =
117 React.forwardRef<HTMLElement, DropdownMenuProps>(

Callers 3

Dropdown.tsxFile · 0.90
DropdownMenu.tsxFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…