Skip to content

Commit

Permalink
Merge pull request #77 from jslovers/#74-code-improvements
Browse files Browse the repository at this point in the history
code improvements of header, and layouts
  • Loading branch information
Neha authored Jun 15, 2024
2 parents d907a57 + 93fc2d7 commit a283825
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 260 deletions.
37 changes: 0 additions & 37 deletions app/(marketing)/layout.tsx

This file was deleted.

8 changes: 4 additions & 4 deletions app/(marketing)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SectionHeader from "@/components/SectionHeader";
import Workshop from "@/components/Workshop";
import { buttonVariants } from "@/components/Button";
import { cn } from "@/lib/utils";
import { MARKETING } from "@/config/marketing";
import { HOMEPAGE } from "@/config/home";
import SignupForMeetupCard from "@/components/SignupForMeetupCard";

export default async function page() {
Expand All @@ -13,7 +13,7 @@ export default async function page() {
<div className="container py-4">
<div className="max-w-2xl justify-between lg:flex lg:max-w-full lg:items-center gap-x-20">
<Workshop
workshopData={MARKETING.WorkshopData}
workshopData={HOMEPAGE.WorkshopData}
className={"w-full lg:w-1/2 max-w-2xl lg:shrink-0"}
/>

Expand Down Expand Up @@ -57,7 +57,7 @@ export default async function page() {
<div className="container py-16 space-y-16">
<SectionHeader header="Our Achivements" className="w-min mx-auto" />
<dl className="grid grid-cols-1 gap-x-8 gap-y-16 md:grid-cols-2 lg:grid-cols-4">
{MARKETING.Achievements.map((achievement) => {
{HOMEPAGE.Achievements.map((achievement) => {
return (
<div key={achievement.title} className="flex flex-col">
<dt className="text-xl xl:text-2xl text-center font-semibold">
Expand Down Expand Up @@ -89,7 +89,7 @@ export default async function page() {
<div className="container py-16 space-y-16 flex flex-col justify-center items-center">
<SectionHeader header="Previous talks" className="w-min" />
<div className="carousel carousel-center max-w-full flex flex-wrap justify-between gap-7 xl:gap-8 py-5">
{MARKETING.PreviousTalks.map((previousTalk, index) => {
{HOMEPAGE.PreviousTalks.map((previousTalk, index) => {
return (
<div
key={`previousTalk.title + ${index}`}
Expand Down
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 { NAVIGATION } from "@/config/navigation";

export function Header() {
return (
<header className="container z-40 bg-background">
<div className="flex h-32 items-center py-6">
<MainNav items={NAVIGATION.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>
);
}
Loading

0 comments on commit a283825

Please sign in to comment.