Skip to content

Commit 49178e1

Browse files
committed
use hint in navbar
1 parent f43d583 commit 49178e1

2 files changed

Lines changed: 31 additions & 10 deletions

File tree

src/components/core/Hint.tsx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,46 @@ import { Tooltip } from "flowbite-react";
22
import { ReactElement, ReactNode } from "react";
33
import { MdHelpOutline } from "react-icons/md";
44

5+
export type HintPosition = "top" | "left" | "right" | "bottom";
6+
57
interface 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+
1117
export 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>

src/components/ui/Navbar.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect, useRef, useState } from "react";
22
import { NavLink } from "react-router-dom";
3-
import { Tooltip } from "flowbite-react";
43
import { MdInfo, MdSearch, MdTableChart } from "react-icons/md";
4+
import { Hint } from "../core/Hint";
55
import { Link } from "../core/Link";
66

77
const 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">

0 commit comments

Comments
 (0)