feat: split nav in preparation for mdx

This commit is contained in:
Dariusz Niemczyk 2025-02-15 00:35:20 +01:00
parent e11dcdf071
commit 615e4466de
No known key found for this signature in database
3 changed files with 62 additions and 50 deletions

View file

@ -4,11 +4,11 @@ import dynamic from 'next/dynamic';
import { Nav } from "@/components/nav";
import { jgs7 } from '@/fonts'; import { jgs7 } from '@/fonts';
import { Translations } from "@/i18n/translations"; import { Translations } from "@/i18n/translations";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { ReactElement, useEffect, useRef } from "react"; import { ReactElement, useEffect, useRef } from "react";
import { MainpageNav } from './nav';
import { NewsletterPopup } from './newsletter-form'; import { NewsletterPopup } from './newsletter-form';
import { useTheme } from "./providers"; import { useTheme } from "./providers";
import { Skeleton } from './ui/skeleton'; import { Skeleton } from './ui/skeleton';
@ -150,7 +150,7 @@ export default function LandingPage(
return ( return (
<div> <div>
<Nav t={t} /> <MainpageNav t={t} />
<main className="flex flex-col min-h-screen grid-gap-10 gap-10 pb-12"> <main className="flex flex-col min-h-screen grid-gap-10 gap-10 pb-12">
<section id="hero" className="h-screen relative overflow-hidden dark:bg-black light:bg-white "> <section id="hero" className="h-screen relative overflow-hidden dark:bg-black light:bg-white ">

View file

@ -0,0 +1,40 @@
'use client';
import { Button } from "@/components/ui/button";
import { MoonIcon, SunIcon } from "lucide-react";
import { useTheme } from "./providers";
import { LanguageSelector } from "./ui/language-selector";
export function NavContainer({ children, title, }: { children: React.ReactNode, title: string }) {
const { theme, setTheme } = useTheme();
return (
<nav className="fixed top-0 left-0 right-0 backdrop-blur-xs bg-background/40 border-b z-[10000]">
<div className="container mx-auto px-4">
<div className="flex items-center justify-between h-16">
<div className="flex gap-4">
<LanguageSelector />
<a href="#" className="text-xl font-bold tracking-tighter hover:text-primary transition-colors">
<h1>{title}</h1>
</a>
</div>
<div className="flex items-center">
{children}
<Button
variant="ghost"
size="icon"
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
className="ml-4"
>
{theme === "dark" ? (
<SunIcon className="h-5 w-5" />
) : (
<MoonIcon className="h-5 w-5" />
)}
</Button>
</div>
</div>
</div>
</nav>
);
}

View file

@ -1,13 +1,10 @@
"use client" "use client"
import { Button } from "@/components/ui/button"
import { useColorSections } from "@/hooks/color-sections" import { useColorSections } from "@/hooks/color-sections"
import { type translations } from "@/i18n/translations" import { type translations } from "@/i18n/translations"
import { cn } from "@/lib/utils" import { cn } from "@/lib/utils"
import { MoonIcon, SunIcon } from "lucide-react"
import { useRef } from "react" import { useRef } from "react"
import { MobileNav } from "./mobile-nav" import { MobileNav } from "./mobile-nav"
import { useTheme } from "./providers" import { NavContainer } from "./nav-container"
import { LanguageSelector } from "./ui/language-selector"
const linksOrder: Array<keyof (typeof translations.pl)["nav"]> = [ const linksOrder: Array<keyof (typeof translations.pl)["nav"]> = [
"hero", "hero",
@ -20,27 +17,17 @@ const linksOrder: Array<keyof (typeof translations.pl)["nav"]> = [
"contact", "contact",
] ]
export function Nav({ export function MainpageNav({
t, t,
}: { }: {
t: typeof translations.pl t: typeof translations.pl
}) { }) {
const { theme, setTheme } = useTheme()
const parent = useRef<HTMLDivElement>(null); const parent = useRef<HTMLDivElement>(null);
useColorSections(parent); useColorSections(parent);
return ( return (
<nav className="fixed top-0 left-0 right-0 backdrop-blur-xs bg-background/40 border-b z-[10000]"> <NavContainer title={t.nav.title}>
<div className="container mx-auto px-4"> <>
<div className="flex items-center justify-between h-16">
<div className="flex gap-4">
<LanguageSelector />
<a href="#" className="text-xl font-bold tracking-tighter hover:text-primary transition-colors">
<h1>{t.nav.title}</h1>
</a>
</div>
<div className="flex items-center">
{/* Desktop Navigation */}
<div className="hidden md:flex md:items-center md:gap-4 lg:gap-8" ref={parent}> <div className="hidden md:flex md:items-center md:gap-4 lg:gap-8" ref={parent}>
{linksOrder.map((value) => ( {linksOrder.map((value) => (
@ -55,26 +42,11 @@ export function Nav({
</a> </a>
))} ))}
</div> </div>
<Button
variant="ghost"
size="icon"
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
className="ml-4"
>
{theme === "dark" ? <SunIcon className="h-5 w-5" /> : <MoonIcon className="h-5 w-5" />}
</Button>
{/* Mobile Navigation */}
<div className="md:hidden ml-2"> <div className="md:hidden ml-2">
<MobileNav t={t} linksOrder={linksOrder} /> <MobileNav t={t} linksOrder={linksOrder} />
</div> </div>
</div> </>
</div> </NavContainer>
</div>
</nav>
) )
} }