-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CP-3146] Implemented Tooltip Flipping to Maintain Viewport Visibility (
- Loading branch information
Showing
3 changed files
with
111 additions
and
23 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
29 changes: 29 additions & 0 deletions
29
libs/generic-view/ui/src/lib/interactive/tooltip/tooltip-helpers.tsx
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,29 @@ | ||
/** | ||
* Copyright (c) Mudita sp. z o.o. All rights reserved. | ||
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md | ||
*/ | ||
|
||
import { TooltipPlacement } from "device/models" | ||
|
||
export const flipVertical = (placement: TooltipPlacement): TooltipPlacement => { | ||
return placement.startsWith("bottom") | ||
? (`top-${placement.split("-")[1]}` as TooltipPlacement) | ||
: (`bottom-${placement.split("-")[1]}` as TooltipPlacement) | ||
} | ||
|
||
export const flipHorizontal = ( | ||
placement: TooltipPlacement | ||
): TooltipPlacement => { | ||
return placement.endsWith("right") | ||
? (`-${placement.replace("right", "left")}` as TooltipPlacement) | ||
: (`-${placement.replace("left", "right")}` as TooltipPlacement) | ||
} | ||
|
||
export const flipTooltipPlacement = ( | ||
placement: TooltipPlacement | ||
): TooltipPlacement => { | ||
const [vertical, horizontal] = placement.split("-") | ||
const flippedVertical = vertical === "bottom" ? "top" : "bottom" | ||
const flippedHorizontal = horizontal === "right" ? "left" : "right" | ||
return `${flippedVertical}-${flippedHorizontal}` as TooltipPlacement | ||
} |
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