-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7dee90
commit 4ed8834
Showing
4 changed files
with
45 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface TooltipProps { | ||
tooltipText: string; | ||
} |
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,38 @@ | ||
'use client'; | ||
import {FC, PropsWithChildren, useState} from 'react'; | ||
import { Popover, Transition } from '@headlessui/react' | ||
import {TooltipProps} from "./Tooltip.interface"; | ||
|
||
export const TooltipPopover: FC<PropsWithChildren<TooltipProps>> = ({tooltipText, children}) => { | ||
const [open, setOpen] = useState(false) | ||
return ( | ||
<Popover className="relative"> | ||
<Popover.Button | ||
onMouseEnter={() => setOpen(true)} | ||
onMouseLeave={() => setOpen(false)} | ||
className="focus:outline-none" | ||
> | ||
{children} | ||
</Popover.Button> | ||
<Transition | ||
show={open} | ||
enter="transition duration-100 ease-out" | ||
enterFrom="transform scale-95 opacity-0" | ||
enterTo="transform scale-100 opacity-100" | ||
leave="transition duration-75 ease-out" | ||
leaveFrom="transform scale-100 opacity-100" | ||
leaveTo="transform scale-95 opacity-0" | ||
> | ||
<Popover.Panel | ||
static | ||
transition | ||
className={`absolute w-screen max-w-max z-10 bg-grey-800 px-3 py-2 rounded`} | ||
> | ||
<div className="shadow-lg max-w-[480px] text-sm text-white"> | ||
<p>{tooltipText}</p> | ||
</div> | ||
</Popover.Panel> | ||
</Transition> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {TooltipPopover as Tooltip} from './Tooltip'; |
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