Skip to content

Commit

Permalink
Merge pull request #348 from syrok94/feature/add-tooltip-on-nav
Browse files Browse the repository at this point in the history
feat: add tooltips on navbar
  • Loading branch information
bryanlundberg authored Oct 3, 2024
2 parents 230c01b + 6d37e0d commit df24827
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 22 deletions.
1 change: 1 addition & 0 deletions messages/en.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"Index": {
"HomePage": {
"title":"Home",
"hint": "Hint",
"optimal-yellow-layer": "Optimal Yellow Layer",
"solving": "Solving...",
Expand Down
10 changes: 8 additions & 2 deletions src/components/navbar/NavItem.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Link, usePathname } from "@/i18n/routing";
import { twMerge } from "tailwind-merge";
import { InteractiveIcon } from "../timer/InteractiveIcon";

interface NavItem {
path: string;
icon: React.ReactNode;
toolTipMessage:string;
}

export function NavItem({ path, icon }: NavItem) {
export function NavItem({ path, icon , toolTipMessage}: NavItem) {
const pathname = usePathname();
return (
<>
Expand All @@ -20,7 +22,11 @@ export function NavItem({ path, icon }: NavItem) {
} transition duration-300 py-2 flex flex-col justify-center items-center font-medium `
)}
>
{icon}
<InteractiveIcon
icon={icon}
animation={false}
message={toolTipMessage}
/>
</Link>
</li>
</>
Expand Down
48 changes: 28 additions & 20 deletions src/components/navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,46 @@ import {
CubeIcon,
StackIcon,
} from "@radix-ui/react-icons";

const navigation: Navigation = [
{
path: "/",
icon: <ClockIcon />,
},
{
path: "/solves",
icon: <StackIcon />,
},
{
path: "/stats",
icon: <BarChartIcon />,
},
{
path: "/cubes",
icon: <CubeIcon />,
},
];
import { useTranslations } from "next-intl";

type Navigation = NavItem[];

interface NavItem {
path: string;
icon: React.ReactNode;
toolTipMessage: string;
}

export default function Navbar() {

const t = useTranslations("Index");

const navigation: Navigation = [
{
path: "/",
icon: <ClockIcon />,
toolTipMessage: t("HomePage.title"),
},
{
path: "/solves",
icon: <StackIcon />,
toolTipMessage: t("SolvesPage.title"),
},
{
path: "/stats",
icon: <BarChartIcon />,
toolTipMessage: t("StatsPage.title"),
},
{
path: "/cubes",
icon: <CubeIcon />,
toolTipMessage: t("CubesPage.title"),
},
];
return (
<NavContainer>
{navigation.map((item: NavItem) => {
return <NavItem key={item.path} path={item.path} icon={item.icon} />;
return <NavItem key={item.path} path={item.path} icon={item.icon} toolTipMessage={item.toolTipMessage} />;
})}
</NavContainer>
);
Expand Down

0 comments on commit df24827

Please sign in to comment.