-
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tooltip beside city refinement search box
- Loading branch information
Parthiv
committed
Feb 29, 2024
1 parent
5ad340d
commit 66a996a
Showing
3 changed files
with
77 additions
and
15 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 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 |
---|---|---|
@@ -1,22 +1,43 @@ | ||
import "@fortawesome/fontawesome-svg-core/styles.css" | ||
import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons" | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" | ||
import React from "react" | ||
import React, { FC, RefObject, useState } from "react" | ||
import { OverlayTrigger, Tooltip } from "react-bootstrap" | ||
import { Placement } from "react-bootstrap/esm/types" | ||
|
||
export const QuestionTooltip = ({ text }: { text: string }) => { | ||
export const QuestionTooltip: FC< | ||
React.PropsWithChildren<{ | ||
placement: Placement, | ||
nodeRef: RefObject<HTMLDivElement> | ||
}> | ||
> = ({ placement, nodeRef, children }) => { | ||
const [show, setShow] = useState(false); | ||
const onMouseOver = (s: boolean) => setShow(s); | ||
return ( | ||
<OverlayTrigger | ||
placement="auto" | ||
overlay={ | ||
<Tooltip id="tooltip-text"> | ||
<p>{text}</p> | ||
</Tooltip> | ||
} | ||
> | ||
<span className="m-1"> | ||
<FontAwesomeIcon icon={faQuestionCircle} className="text-secondary" /> | ||
</span> | ||
</OverlayTrigger> | ||
<div ref={nodeRef}> | ||
<OverlayTrigger | ||
show={show} | ||
placement={placement} | ||
overlay={ | ||
<Tooltip | ||
onMouseEnter={() => onMouseOver(true)} | ||
onMouseLeave={() => onMouseOver(false)} | ||
id="tooltip-text" | ||
> | ||
{children} | ||
</Tooltip> | ||
} | ||
> | ||
<span className="m-1"> | ||
<FontAwesomeIcon | ||
onMouseEnter={() => onMouseOver(true)} | ||
onMouseLeave={() => onMouseOver(false)} | ||
size={"lg"} | ||
icon={faQuestionCircle} | ||
className="text-secondary" | ||
/> | ||
</span> | ||
</OverlayTrigger> | ||
</div> | ||
) | ||
} |