-
-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial work on tool tip integration #1516
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we shouldn't have to show/hide the overlay manually, bootstrap overlaytrigger should be taking care of that... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The bootstrap overlay trigger does take care of it, but when we have a link in tooltip, then clicking on the link did not seem possible unless state is maintained like I have done so. |
||
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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could pass the Icon in as a(n optional) prop and make this the base tooltip component for the project. (Keep the faquetioncircle icon as the default/fallback icon.) |
||
</OverlayTrigger> | ||
</div> | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize part of the tooltip existing in the project may have been built like this way back when (by me, probably). Sorry for the bum steer if so. I don't remember why I did it this way then, but we should make a different choice now...likely not the best choice at the time either? we'll never know for sure ....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did spend quite a bit of time looking into the search library options. It looked to me as we are using a package that is very customised for the use case, so most of the general documentation is not of very much help :(
Although the refinement list and it's elements are customisable, it does not fit in with the components which we have used :(