Skip to content

Commit

Permalink
Navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
krishna8421 committed Dec 22, 2023
1 parent 50029c9 commit 1aad6e8
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 11 deletions.
Binary file modified public/favicon.ico
Binary file not shown.
Binary file added public/mlsa-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions src/app/(main)/q/countdown-box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ const renderer = ({
<table>
<tr>
<td className="w-32 text-center text-7xl">
{days > 10 ? "" : "0"}
{days >= 10 ? "" : "0"}
{days}
</td>
<td className="w-32 text-center text-7xl">
{hours > 10 ? "" : "0"}
{hours >= 10 ? "" : "0"}
{hours}
</td>
<td className="w-32 text-center text-7xl">
{minutes > 10 ? "" : "0"}
{minutes >= 10 ? "" : "0"}
{minutes}
</td>
<td className="w-32 text-center text-7xl">
{seconds > 10 ? "" : "0"}
{seconds >= 10 ? "" : "0"}
{seconds}
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Toaster } from "sonner";
export const metadata = {
title: "Kryptic Hunt | MLSA KIIT Chapter",
description: "A Fun Kryptic Hunt Game by MLSA KIIT Chapter",
// icons: [{ rel: "icon", url: "/favicon.ico" }],
icons: [{ rel: "icon", url: "/favicon.ico" }],
};

export default function RootLayout({ children }: { children: ReactNode }) {
Expand Down
24 changes: 24 additions & 0 deletions src/components/nav-bar-auth-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { convertToInitials } from "@/lib/utils";
import { FaUser } from "react-icons/fa6";

interface NavBarAuthButtonProps {
isAuthenticated: boolean;
name?: string | null;
}

const NavBarAuthButton = ({ isAuthenticated, name }: NavBarAuthButtonProps) => {
if (isAuthenticated) {
return (
<span className="flex items-center justify-between gap-2">
<FaUser />
<span className="md:inline hidden">{name ?? "User"}</span>
<span className="md:hidden inline">{convertToInitials(name ?? "U s e r")}</span>

</span>
);
}

return <div></div>;
};

export default NavBarAuthButton;
49 changes: 43 additions & 6 deletions src/components/nav-bar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,46 @@
import React from 'react'
import Link from "next/link";
import { FiBook } from "react-icons/fi";
import { FaChartColumn } from "react-icons/fa6";
import Image from "next/image";
import { getServerAuthSession } from "@/server/auth";
import NavBarAuthButton from "./nav-bar-auth-button";

const NavBar = () => {
const NavBar = async () => {
const session = await getServerAuthSession();
return (
<nav> </nav>
)
}
<nav className="flex items-center justify-between p-4 px-6">
<span className="flex select-none items-center justify-between gap-4 text-xl font-semibold">
<Image
src="/mlsa-logo.png"
width={40}
height={40}
alt="MLSA Logo"
priority={true}
quality={100}
/>
<span className="md:inline hidden">Kryptic Hunt</span>

</span>
<ul className="flex items-center justify-between gap-6 text-gray-300">
<Link href="/rules">
<li className="flex items-center justify-center gap-2 hover:text-gray-100 hover:underline">
<FiBook />
Rules
</li>
</Link>
<Link href="/leaderboard">
<li className="flex items-center justify-center gap-2 hover:text-gray-100 hover:underline">
<FaChartColumn />
Leaderboard
</li>
</Link>
<li></li>
</ul>
<div>
<NavBarAuthButton isAuthenticated={session ? true : false} name={session?.user?.name} />
</div>
</nav>
);
};

export default NavBar
export default NavBar;
6 changes: 6 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const convertToInitials = (fullName: string) => {
return fullName
.split(" ")
.map((word) => word.charAt(0).toUpperCase())
.join(" ");
};

0 comments on commit 1aad6e8

Please sign in to comment.