Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ export default function RootLayout({
<body className="min-h-screen flex flex-col antialiased">
<ThemeProvider>
<HumanMachineProvider>
<Header />
<PrivyAuthProvider>
<Header />
<main className="flex-1">
<MachineContent>{children}</MachineContent>
</main>
<Footer />
<ViewModeBar />
</PrivyAuthProvider>
<Footer />
<ViewModeBar />
</HumanMachineProvider>
</ThemeProvider>
<Analytics />
Expand Down
44 changes: 31 additions & 13 deletions components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@
import { useState, useEffect } from "react";
import Link from "next/link";
import Image from "next/image";
import { usePrivy } from "@privy-io/react-auth";
import { siteConfig } from "@/lib/config";
import { nav } from "@/lib/nav";
import { useTheme } from "@/contexts/ThemeContext";
import { Sun, Moon } from "lucide-react";

export function Header() {
const { theme, toggleTheme } = useTheme();
const { ready, authenticated } = usePrivy();
const [mobileOpen, setMobileOpen] = useState(false);
const [scrolled, setScrolled] = useState(false);

// Only trust the auth state once Privy has resolved on the client. Until
// then (and on the server) `ready` is false, so both first renders show the
// signed-out CTAs — no hydration mismatch, then it swaps in place.
const signedIn = ready && authenticated;

useEffect(() => {
const onScroll = () => setScrolled(window.scrollY > 20);
window.addEventListener("scroll", onScroll, { passive: true });
Expand Down Expand Up @@ -69,18 +76,29 @@ export function Header() {
</svg>
</button>

<Link
href={siteConfig.appUrl}
className="hidden sm:inline-block text-[14px] font-ui font-medium text-(--foreground)/70 hover:text-(--foreground) transition-colors px-4 py-1.5 rounded-full border border-(--border) hover:border-(--foreground)/20"
>
Sign In
</Link>
<Link
href={siteConfig.appUrl}
className="bg-(--foreground) text-(--background) px-5 py-2 rounded-full text-[14px] font-ui font-semibold hover:opacity-90 transition-opacity"
>
Sign Up
</Link>
{signedIn ? (
<Link
href={siteConfig.appUrl}
className="bg-(--foreground) text-(--background) px-5 py-2 rounded-full text-[14px] font-ui font-semibold hover:opacity-90 transition-opacity"
>
Open app
</Link>
) : (
<>
<Link
href={siteConfig.appUrl}
className="hidden sm:inline-block text-[14px] font-ui font-medium text-(--foreground)/70 hover:text-(--foreground) transition-colors px-4 py-1.5 rounded-full border border-(--border) hover:border-(--foreground)/20"
>
Sign In
</Link>
<Link
href={siteConfig.appUrl}
className="bg-(--foreground) text-(--background) px-5 py-2 rounded-full text-[14px] font-ui font-semibold hover:opacity-90 transition-opacity"
>
Sign Up
</Link>
</>
)}
</div>
</div>

Expand All @@ -103,7 +121,7 @@ export function Header() {
className="block px-3 py-2.5 text-sm font-ui font-medium text-(--foreground)/70 sm:hidden"
onClick={() => setMobileOpen(false)}
>
Sign In
{signedIn ? "Open app" : "Sign In"}
</Link>
</div>
</div>
Expand Down