2024-04-18 11:22:43 +01:00
|
|
|
"use client";
|
|
|
|
|
2024-04-14 18:46:37 +01:00
|
|
|
import Link from "next/link";
|
2024-04-18 11:22:43 +01:00
|
|
|
import { usePathname } from "next/navigation";
|
2024-04-18 03:51:41 +01:00
|
|
|
import { ReactElement } from "react";
|
2024-04-18 07:46:22 +01:00
|
|
|
import { HrefButton } from "./href-button";
|
2024-04-14 18:46:37 +01:00
|
|
|
import Logo from "./logo";
|
2024-04-16 21:18:08 +01:00
|
|
|
import { ToggleThemeButton } from "./theme-toggle-button";
|
2024-04-19 15:22:03 +01:00
|
|
|
import { GithubStar } from "@/app/components/github-star";
|
2024-04-14 18:46:37 +01:00
|
|
|
|
|
|
|
type Page = {
|
2024-04-18 07:06:16 +01:00
|
|
|
/**
|
|
|
|
* The name of the button for the navbar.
|
|
|
|
*/
|
|
|
|
name: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The URL to go to.
|
|
|
|
*/
|
2024-04-14 18:46:37 +01:00
|
|
|
url: string;
|
2024-04-18 07:06:16 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether clicking the button will
|
|
|
|
* open the link in a new tab.
|
|
|
|
*/
|
2024-04-18 01:45:27 +01:00
|
|
|
openInNewTab?: boolean;
|
2024-04-14 18:46:37 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const pages: Page[] = [
|
2024-04-18 07:06:16 +01:00
|
|
|
{ name: "Player", url: "/player" },
|
|
|
|
{ name: "Server", url: "/server/java" },
|
|
|
|
{ name: "Mojang", url: "/mojang/status" },
|
|
|
|
{ name: "API", url: "https://api.mcutils.xyz", openInNewTab: true },
|
2024-04-14 18:46:37 +01:00
|
|
|
];
|
|
|
|
|
2024-04-18 03:51:41 +01:00
|
|
|
export default function NavBar(): ReactElement {
|
2024-04-18 11:22:43 +01:00
|
|
|
const path = usePathname();
|
|
|
|
|
2024-04-14 18:46:37 +01:00
|
|
|
return (
|
2024-04-19 15:29:26 +01:00
|
|
|
<div className="bg-secondary relative w-full rounded-lg flex justify-between items-center gap-3 mt-2 px-3 bg-opacity-85 h-12">
|
|
|
|
{/* Left */}
|
2024-04-19 15:22:03 +01:00
|
|
|
<Link href="/" className="flex items-center gap-2">
|
2024-04-14 18:46:37 +01:00
|
|
|
<Logo />
|
2024-04-18 03:16:05 +01:00
|
|
|
<p className="hidden md:block">Minecraft Utilities</p>
|
2024-04-16 22:07:43 +01:00
|
|
|
</Link>
|
2024-04-18 03:32:38 +01:00
|
|
|
|
2024-04-19 15:29:26 +01:00
|
|
|
{/* Links */}
|
|
|
|
<div className="absolute inset-x-0 flex justify-center">
|
|
|
|
<div className="flex gap-4">
|
|
|
|
{pages.map((page, index) => {
|
|
|
|
const isActive = path.includes(page.url);
|
2024-04-18 11:22:43 +01:00
|
|
|
|
2024-04-19 15:29:26 +01:00
|
|
|
return (
|
|
|
|
<HrefButton
|
|
|
|
className={isActive ? "text-primary" : ""}
|
|
|
|
key={index}
|
|
|
|
title={page.name}
|
|
|
|
url={page.url}
|
|
|
|
openInNewTab={page.openInNewTab}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</div>
|
2024-04-18 05:18:25 +01:00
|
|
|
</div>
|
2024-04-16 19:27:48 +01:00
|
|
|
|
2024-04-19 15:29:26 +01:00
|
|
|
{/* Right */}
|
2024-04-19 15:22:03 +01:00
|
|
|
<div className="flex gap-4 items-center">
|
2024-04-16 21:18:08 +01:00
|
|
|
<ToggleThemeButton />
|
2024-04-19 15:22:03 +01:00
|
|
|
<GithubStar />
|
2024-04-16 19:27:48 +01:00
|
|
|
</div>
|
2024-04-14 18:46:37 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|