Skip to content

Commit

Permalink
code improvements of header, and layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Neha committed Jun 14, 2024
1 parent d907a57 commit 397bd6b
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 226 deletions.
37 changes: 0 additions & 37 deletions app/(marketing)/layout.tsx

This file was deleted.

39 changes: 0 additions & 39 deletions app/about/layout.tsx

This file was deleted.

26 changes: 0 additions & 26 deletions app/collaboration/layout.tsx

This file was deleted.

36 changes: 0 additions & 36 deletions app/jobs/layout.tsx

This file was deleted.

33 changes: 21 additions & 12 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
import type { Metadata } from 'next'
import { Inter } from 'next/font/google'
import './globals.css'

const inter = Inter({ subsets: ['latin'] })

import type { Metadata } from "next";
import { Inter } from "next/font/google";
import { Work_Sans } from "next/font/google";
import { Footer } from "@/components/Footer";
import { Header } from "@/components/Header";
import "./globals.css";
const inter = Inter({ subsets: ["latin"] });
const workSans = Work_Sans({ subsets: ["latin"] });
export const metadata: Metadata = {
title: 'JSLovers',
description: 'JSLovers - a community for the developers',
}
title: "JSLovers",
description: "JSLovers - a community for the developers",
};

export default function RootLayout({
children,
}: {
children: React.ReactNode
children: React.ReactNode;
}) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
<body className={inter.className}>
{" "}
<div className="flex min-h-screen flex-col">
<Header />
<main className={`${workSans.className} flex-1`}>{children}</main>
<Footer />
</div>
</body>
</html>
)
);
}
26 changes: 0 additions & 26 deletions app/meetups/layout.tsx

This file was deleted.

26 changes: 0 additions & 26 deletions app/speakers/layout.tsx

This file was deleted.

12 changes: 12 additions & 0 deletions components/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { MainNav } from "@/components/navigation/MainNav";
import { MARKETING } from "@/config/marketing";

export function Header() {
return (
<header className="container z-40 bg-background">
<div className="flex h-32 items-center py-6">
<MainNav items={MARKETING.Navigation} />
</div>
</header>
);
}
14 changes: 14 additions & 0 deletions components/navigation/Logo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use client";
import Link from "next/link";
import { Icons } from "../Icons";

export function Logo() {
return (
<h1>
<Link href="/">
<span className="sr-only">JSLovers</span>
<Icons.logo />
</Link>
</h1>
);
}
58 changes: 34 additions & 24 deletions components/navigation/MainNav.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,52 @@
"use client"

import { NavItem } from "@/types";
"use client";
import Link from "next/link";
import { Icons } from "../Icons";
import { usePathname } from 'next/navigation';
import { NavItem } from "@/types";
import { usePathname } from "next/navigation";
import { Logo } from "./Logo";
import { buttonVariants } from "@/components/Button";
import { cn } from "@/lib/utils";

interface MainNavProps {
items?: NavItem[];
children?: React.ReactNode;
}
const createNavigation = (items: NavItem[], currentPath: string) => {
return items.map((item, index) => (
<Link
key={index}
href={item.href || ""}
className={`flex items-center border-b-4 sm:text-sm md:text-lg ${
currentPath === item.href ? "border-black" : "border-white"
}`}
>
{item.title}
</Link>
));
};

export function MainNav({ items }: MainNavProps) {
const currentPath = usePathname();

return (
<div className="flex gap-6 md:gap-10">
<h1>
<Link href="/">
<span className="sr-only">JSLovers</span>
<Icons.logo />
</Link>
</h1>
<div className="flex justify-between w-full">
<div className="flex">
<Logo />

{items?.length ? (
<nav className="hidden gap-10 lg:flex">
{items.map((item, index) => (
<nav className="hidden gap-10 lg:flex">
{items && createNavigation(items, currentPath)}
</nav>
</div>
<nav>
<Link
key={index}
href={item.href || ""}
className={`flex items-center border-b-4 md:text-lg sm:text-sm ${
currentPath === item.href ? "border-black" : "border-white"
}`}
href="/register"
className={cn(
buttonVariants(),
"border-solid border-2 border-border"
)}
>
{item.title}
Register Now
</Link>
))}
</nav>
) : null}
</nav>
</div>
);
}

0 comments on commit 397bd6b

Please sign in to comment.