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
62 changes: 32 additions & 30 deletions components/figma-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useGithubStars } from "@/hooks/use-github-stars";
import { cn } from "@/lib/utils";
import { formatCompactNumber } from "@/utils/format";
import { Menu, X } from "lucide-react";
import { motion } from "motion/react";
import { AnimatePresence, motion } from "motion/react";
import Link from "next/link";
import { ThemeToggle } from "./theme-toggle";

Expand Down Expand Up @@ -77,35 +77,37 @@ export function FigmaHeader({ isScrolled, mobileMenuOpen, setMobileMenuOpen }: F
</div>

{/* Mobile menu - simplified */}
{mobileMenuOpen && (
<motion.div
initial={{ opacity: 0, y: -20 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -20 }}
className="bg-background/95 absolute inset-x-0 top-16 border-b backdrop-blur-lg md:hidden"
>
<div className="container mx-auto flex flex-col gap-4 px-4 py-4">
<motion.div
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.3, delay: 0.1 }}
className="border-border/30 border-t pt-2"
>
<Button variant="ghost" asChild className="w-full justify-start">
<a
href="https://github.com/jnsahaj/tweakcn"
target="_blank"
rel="noopener noreferrer"
onClick={() => setMobileMenuOpen(false)}
>
<GitHubIcon className="mr-2 size-5" />
GitHub {stargazersCount > 0 && `(${formatCompactNumber(stargazersCount)})`}
</a>
</Button>
</motion.div>
</div>
</motion.div>
)}
<AnimatePresence>
{mobileMenuOpen && (
<motion.div
initial={{ opacity: 0, y: -20 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -20 }}
className="bg-background/95 absolute inset-x-0 top-16 border-b backdrop-blur-lg md:hidden"
>
<div className="container mx-auto flex flex-col gap-4 px-4 py-4">
<motion.div
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.3, delay: 0.1 }}
className="border-border/30 border-t pt-2"
>
<Button variant="ghost" asChild className="w-full justify-start">
<a
href="https://github.com/jnsahaj/tweakcn"
target="_blank"
rel="noopener noreferrer"
onClick={() => setMobileMenuOpen(false)}
>
<GitHubIcon className="mr-2 size-5" />
GitHub {stargazersCount > 0 && `(${formatCompactNumber(stargazersCount)})`}
</a>
</Button>
</motion.div>
</div>
</motion.div>
)}
</AnimatePresence>
</header>
);
}
84 changes: 43 additions & 41 deletions components/home/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useGithubStars } from "@/hooks/use-github-stars";
import { cn } from "@/lib/utils";
import { formatCompactNumber } from "@/utils/format";
import { ChevronRight, Menu, X } from "lucide-react";
import { motion } from "motion/react";
import { AnimatePresence, motion } from "motion/react";
import Link from "next/link";
import { ThemeToggle } from "../theme-toggle";

Expand Down Expand Up @@ -137,47 +137,49 @@ export function Header({ isScrolled, mobileMenuOpen, setMobileMenuOpen }: Header
</div>
</div>
{/* Mobile menu */}
{mobileMenuOpen && (
<motion.div
initial={{ opacity: 0, y: -20 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -20 }}
className="bg-background/95 absolute inset-x-0 top-16 border-b backdrop-blur-lg md:hidden"
>
<div className="container mx-auto flex flex-col gap-4 px-4 py-4">
{navbarItems.map((item, i) => (
<motion.a
key={item.label}
initial={{ opacity: 0, x: -10 }}
animate={{ opacity: 1, x: 0 }}
transition={{ duration: 0.2, delay: i * 0.05 }}
href={item.href}
onClick={(e) => {
handleScrollToSection(e);
setMobileMenuOpen(false);
}}
className="group relative overflow-hidden py-2 text-sm font-medium"
<AnimatePresence>
{mobileMenuOpen && (
<motion.div
initial={{ opacity: 0, y: -20 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -20 }}
className="bg-background/95 absolute inset-x-0 top-16 border-b backdrop-blur-lg md:hidden"
>
<div className="container mx-auto flex flex-col gap-4 px-4 py-4">
{navbarItems.map((item, i) => (
<motion.a
key={item.label}
initial={{ opacity: 0, x: -10 }}
animate={{ opacity: 1, x: 0 }}
transition={{ duration: 0.2, delay: i * 0.05 }}
href={item.href}
onClick={(e) => {
handleScrollToSection(e);
setMobileMenuOpen(false);
}}
Comment on lines +156 to +159
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fix navigation bug: Conditionally call handleScrollToSection.

The onClick handler unconditionally calls handleScrollToSection for all menu items, but this breaks the "/pricing" link because handleScrollToSection calls e.preventDefault(). The desktop version (line 79) correctly calls handleScrollToSection only for hash links.

🔎 Apply this diff to fix the navigation bug:
                  onClick={(e) => {
-                   handleScrollToSection(e);
+                   if (item.href.startsWith("#")) {
+                     handleScrollToSection(e);
+                   }
                    setMobileMenuOpen(false);
                  }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
onClick={(e) => {
handleScrollToSection(e);
setMobileMenuOpen(false);
}}
onClick={(e) => {
if (item.href.startsWith("#")) {
handleScrollToSection(e);
}
setMobileMenuOpen(false);
}}
🤖 Prompt for AI Agents
In components/home/header.tsx around lines 156 to 159, the onClick handler
currently always calls handleScrollToSection which prevents navigation for
normal links (e.g. /pricing); change it to first read the clicked link's href
(e.g. const href = (e.currentTarget as HTMLAnchorElement).getAttribute('href'))
and only call handleScrollToSection(e) when href is a hash link
(startsWith('#')); always call setMobileMenuOpen(false) afterwards so the menu
still closes for all links.

className="group relative overflow-hidden py-2 text-sm font-medium"
>
<span className="relative z-10">{item.href}</span>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix critical bug: Display label instead of href.

Line 162 displays item.href instead of item.label, which would show technical values like "#examples" or "/pricing" instead of user-friendly labels like "Examples" or "Pricing".

🔎 Apply this diff to fix the display bug:
-                  <span className="relative z-10">{item.href}</span>
+                  <span className="relative z-10">{item.label}</span>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<span className="relative z-10">{item.href}</span>
<span className="relative z-10">{item.label}</span>
🤖 Prompt for AI Agents
In components/home/header.tsx around line 162 the span currently renders
item.href which shows raw route values; change it to render the human-facing
item.label (e.g., replace item.href with item.label), optionally using a safe
fallback like item.label || item.href to avoid breaking if label is missing.

<span className="bg-primary absolute bottom-0 left-0 h-0.5 w-0 transition-all duration-300 group-hover:w-full"></span>
</motion.a>
))}
<motion.div
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.3, delay: 0.3 }}
className="border-border/30 mt-2 border-t pt-2"
>
<span className="relative z-10">{item.href}</span>
<span className="bg-primary absolute bottom-0 left-0 h-0.5 w-0 transition-all duration-300 group-hover:w-full"></span>
</motion.a>
))}
<motion.div
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.3, delay: 0.3 }}
className="border-border/30 mt-2 border-t pt-2"
>
<Link href="/editor/theme" onClick={() => setMobileMenuOpen(false)}>
<Button className="w-full rounded-full">
Try It Now
<ChevronRight className="ml-2 size-4" />
</Button>
</Link>
</motion.div>
</div>
</motion.div>
)}
<Link href="/editor/theme" onClick={() => setMobileMenuOpen(false)}>
<Button className="w-full rounded-full">
Try It Now
<ChevronRight className="ml-2 size-4" />
</Button>
</Link>
</motion.div>
</div>
</motion.div>
)}
</AnimatePresence>
</header>
);
}