File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,24 +2,46 @@ import { Tooltip } from "flowbite-react";
22import { ReactElement , ReactNode } from "react" ;
33import { MdHelpOutline } from "react-icons/md" ;
44
5+ export type HintPosition = "top" | "left" | "right" | "bottom" ;
6+
57interface HintProps {
68 children : ReactElement ;
79 hintContent : ReactNode ;
10+ position ?: HintPosition ;
811 className ?: string ;
12+ trigger ?: "icon" | "child" ;
913}
1014
15+ const tooltipClassName = "bg-gray-600 z-10 border-1 max-w-xl" ;
16+
1117export function Hint ( props : HintProps ) : ReactElement {
18+ const placement = props . position ?? "top" ;
19+ const trigger = props . trigger ?? "icon" ;
20+
21+ if ( trigger === "child" ) {
22+ return (
23+ < Tooltip
24+ content = { props . hintContent }
25+ arrow = { false }
26+ placement = { placement }
27+ className = { tooltipClassName }
28+ >
29+ { props . children }
30+ </ Tooltip >
31+ ) ;
32+ }
33+
1234 return (
1335 < div
14- className = { `flex items-center justify-center gap-2 ${ props . className } ` }
36+ className = { `flex items-center justify-center gap-2 ${ props . className ?? "" } ` }
1537 >
1638 < div > { props . children } </ div >
1739 < div >
1840 < Tooltip
1941 content = { props . hintContent }
2042 arrow = { false }
21- placement = "top"
22- className = "bg-gray-600 z-10 border-1 max-w-xl"
43+ placement = { placement }
44+ className = { tooltipClassName }
2345 >
2446 < MdHelpOutline />
2547 </ Tooltip >
Original file line number Diff line number Diff line change 11import { useEffect , useRef , useState } from "react" ;
22import { NavLink } from "react-router-dom" ;
3- import { Tooltip } from "flowbite-react" ;
43import { MdInfo , MdSearch , MdTableChart } from "react-icons/md" ;
4+ import { Hint } from "../core/Hint" ;
55import { Link } from "../core/Link" ;
66
77const navItems = [
@@ -34,12 +34,11 @@ export function Navbar() {
3434 < >
3535 < nav className = "fixed left-0 top-0 h-screen w-12 flex flex-col items-center pt-4 pb-4 gap-2 bg-[#1a1a1a] z-20" >
3636 { navItems . map ( ( item ) => (
37- < Tooltip
37+ < Hint
3838 key = { item . to }
39- content = { item . label }
40- placement = "right"
41- arrow = { false }
42- className = "bg-gray-600 z-10 backdrop-blur-sm bg-opacity-99 border-1"
39+ hintContent = { item . label }
40+ position = "right"
41+ trigger = "child"
4342 >
4443 < NavLink
4544 to = { item . to }
@@ -54,7 +53,7 @@ export function Navbar() {
5453 >
5554 { item . icon }
5655 </ NavLink >
57- </ Tooltip >
56+ </ Hint >
5857 ) ) }
5958
6059 < div className = "mt-auto" >
You can’t perform that action at this time.
0 commit comments