Skip to content

Conversation

@PouriaDamavandi
Copy link
Contributor

@PouriaDamavandi PouriaDamavandi commented Sep 7, 2025

Description

Changes

Checks

  • Storybook updated
  • Build succeeds
  • Standards followed

Summary by CodeRabbit

  • Refactor
    • Desktop navbar rebuilt with a semantic navigation menu, improving accessibility and consistency.
    • “Browse” now triggers the menu while closing the cart for smoother interaction.
    • “Become an author” link includes an accessible label and direct navigation.
    • No changes to how users access the navbar overall.
  • Chores
    • Development server now runs on port 3001 instead of 3000.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 7, 2025

Walkthrough

Replaced desktop navbar links with NavigationMenu components and adjusted click handling. Updated UI package NavigationMenu components’ forwardRef types from ElementRef to ComponentRef. Changed core app dev script port from 3000 to 3001.

Changes

Cohort / File(s) Summary
Navbar NavigationMenu migration
apps/core/app/(landing)/_components/desktop-navbar/navbar-links.tsx
Switched to NavigationMenu primitives (Menu, List, Item, Trigger, Link). “Browse” now uses NavigationMenuTrigger invoking existing onClick (closeAddToCart, toggleOpenMegaMenu). “Become an author” now NavigationMenuLink to "/become-auther" with aria-label. Removed prior Link/typography structure.
UI NavigationMenu ref typing
packages/ui/src/components/atoms/navigation-menu.tsx
Updated forwardRef generic types from React.ElementRef to React.ComponentRef for Root/List/Trigger/Content/Viewport/Indicator. No runtime changes; exported ref types adjusted.
Core app dev script
apps/core/package.json
Changed dev script port: 3000 → 3001 (next dev --turbopack --port 3001).

Sequence Diagram(s)

sequenceDiagram
  participant U as User
  participant NV as NavigationMenu (Navbar)
  participant ST as Store/UI State

  U->>NV: Click "Browse" (NavigationMenuTrigger)
  NV->>ST: closeAddToCart()
  NV->>ST: toggleOpenMegaMenu()

  U->>NV: Click "Become an author" (NavigationMenuLink)
  NV->>U: Navigate to /become-auther
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • mrbadri

Poem

In menus I hop, from Trigger to Link,
Toggling the mega—quick as a wink.
Ports re-burrowed to 3001’s glen,
Typings trimmed, ref-shaped again.
A nibble of UI, a carrot of nav—
Thump-thump! Ship it, my clever dev. 🐇✨

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.
  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/navbar

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
apps/core/app/(landing)/_components/desktop-navbar/navbar-links.tsx (1)

28-31: Trigger without Content: consider a simple button for “Browse.”

NavigationMenuTrigger is intended to toggle NavigationMenuContent. Since none is rendered here, a button with the trigger styles is simpler and avoids odd ARIA/state expectations.

Apply:

 import {
   NavigationMenu,
   NavigationMenuItem,
   NavigationMenuLink,
   NavigationMenuList,
-  NavigationMenuTrigger,
+  NavigationMenuTrigger,
+  navigationMenuTriggerStyle,
 } from "@repo/ui/components/atoms/navigation-menu";
@@
-          <NavigationMenuTrigger onClick={onClick}>
-            <Typography variant="label/sm">Browse</Typography>
-          </NavigationMenuTrigger>
+          <button
+            type="button"
+            onClick={onClick}
+            className={`${navigationMenuTriggerStyle()} group`}
+          >
+            <Typography variant="label/sm">Browse</Typography>
+          </button>

Alternative: keep NavigationMenuTrigger but render asChild with a button.

Also applies to: 3-9

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between afc9553 and 2b9704b.

📒 Files selected for processing (3)
  • apps/core/app/(landing)/_components/desktop-navbar/navbar-links.tsx (2 hunks)
  • apps/core/package.json (1 hunks)
  • packages/ui/src/components/atoms/navigation-menu.tsx (6 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/core/app/(landing)/_components/desktop-navbar/navbar-links.tsx (2)
packages/ui/src/components/atoms/navigation-menu.tsx (5)
  • NavigationMenu (121-121)
  • NavigationMenuList (122-122)
  • NavigationMenuItem (123-123)
  • NavigationMenuTrigger (125-125)
  • NavigationMenuLink (126-126)
packages/ui/src/components/atoms/typography.tsx (1)
  • Typography (135-135)
🔇 Additional comments (1)
apps/core/package.json (1)

6-6: No lingering 3000 references found – ran rg -nC2 '\b3000\b|localhost:3000' --glob '!**/node_modules/**' . with no matches.

Comment on lines +33 to +39
<NavigationMenuLink
href="/become-auther"
aria-label="become an author"
>
<Typography variant="label/sm">Become an author</Typography>
</NavigationMenuLink>
</NavigationMenuItem>
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Typo and client-side navigation regression on “Become an author” link.

  • href typo: "auther" → likely "author".
  • Using Radix NavigationMenuLink directly renders an , losing Next.js client-side routing/prefetch.

Fix by using asChild and wrapping Next.js Link.

Apply:

-        <NavigationMenuItem>
-          <NavigationMenuLink
-            href="/become-auther"
-            aria-label="become an author"
-          >
-            <Typography variant="label/sm">Become an author</Typography>
-          </NavigationMenuLink>
-        </NavigationMenuItem>
+        <NavigationMenuItem>
+          <NavigationMenuLink asChild>
+            <Link href="/become-author">
+              <Typography variant="label/sm">Become an author</Typography>
+            </Link>
+          </NavigationMenuLink>
+        </NavigationMenuItem>

If the canonical route is different (e.g., /become-an-author), adjust accordingly.


🏁 Script executed:

#!/bin/bash
# Locate the navbar-links.tsx file in the repository
fd navbar-links.tsx

Length of output: 67


🏁 Script executed:

#!/bin/bash
# Inspect navbar-links.tsx for typo and navigation usage
FILE=apps/core/app/\(landing\)/_components/desktop-navbar/navbar-links.tsx

echo "=== Imports ==="
sed -n '1,20p' "$FILE"

echo
echo "=== Usage Snippet (lines 20-80) ==="
sed -n '20,80p' "$FILE"

echo
echo "=== Checking for typo in href ==="
grep -R "become-auther" -n "$FILE" || echo "No instances found"

echo
echo "=== Checking NavigationMenuLink usage ==="
grep -R "NavigationMenuLink" -n "$FILE"

echo
echo "=== Checking Next.js Link import ==="
grep -R "from 'next/link'" -n "$FILE" || echo "No import of Next.js Link"

Length of output: 1576


Fix “Become an author” link: correct typo and enable client-side routing

  • Change href from /become-auther to /become-author (or your canonical route).
  • Wrap Next.js <Link> using NavigationMenuLink asChild to preserve prefetch and client-side navigation.
-        <NavigationMenuItem>
-          <NavigationMenuLink
-            href="/become-auther"
-            aria-label="become an author"
-          >
-            <Typography variant="label/sm">Become an author</Typography>
-          </NavigationMenuLink>
-        </NavigationMenuItem>
+        <NavigationMenuItem>
+          <NavigationMenuLink asChild>
+            <Link href="/become-author" aria-label="become an author">
+              <Typography variant="label/sm">Become an author</Typography>
+            </Link>
+          </NavigationMenuLink>
+        </NavigationMenuItem>
📝 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
<NavigationMenuLink
href="/become-auther"
aria-label="become an author"
>
<Typography variant="label/sm">Become an author</Typography>
</NavigationMenuLink>
</NavigationMenuItem>
<NavigationMenuItem>
<NavigationMenuLink asChild>
<Link href="/become-author" aria-label="become an author">
<Typography variant="label/sm">Become an author</Typography>
</Link>
</NavigationMenuLink>
</NavigationMenuItem>
🤖 Prompt for AI Agents
In apps/core/app/(landing)/_components/desktop-navbar/navbar-links.tsx around
lines 33 to 39, the link href and routing are wrong: change
href="/become-auther" to href="/become-author" (or your canonical route) and
enable Next.js client-side navigation by using NavigationMenuLink with asChild
and nesting a Next.js Link component inside it (ensure Link is imported from
'next/link'); keep the Typography element inside the Link and preserve
aria-label (fix spelling if needed) so prefetching and SPA navigation work.

Comment on lines +10 to 11
React.ComponentRef<typeof NavigationMenuPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Root>
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Ref type regression: use React.ElementRef, not React.ComponentRef, for Radix primitives.

ComponentRef resolves to class component instances and is never for function components/primitives, breaking ref typings. ElementRef is the correct utility for Radix/shadcn components.

Apply:

-  React.ComponentRef<typeof NavigationMenuPrimitive.Root>,
+  React.ElementRef<typeof NavigationMenuPrimitive.Root>,
@@
-  React.ComponentRef<typeof NavigationMenuPrimitive.List>,
+  React.ElementRef<typeof NavigationMenuPrimitive.List>,
@@
-  React.ComponentRef<typeof NavigationMenuPrimitive.Trigger>,
+  React.ElementRef<typeof NavigationMenuPrimitive.Trigger>,
@@
-  React.ComponentRef<typeof NavigationMenuPrimitive.Content>,
+  React.ElementRef<typeof NavigationMenuPrimitive.Content>,
@@
-  React.ComponentRef<typeof NavigationMenuPrimitive.Viewport>,
+  React.ElementRef<typeof NavigationMenuPrimitive.Viewport>,
@@
-  React.ComponentRef<typeof NavigationMenuPrimitive.Indicator>,
+  React.ElementRef<typeof NavigationMenuPrimitive.Indicator>,

Run a quick TS check to ensure refs are typed correctly:

Expect: no matches.

Also applies to: 28-29, 49-51, 67-69, 84-86, 102-104


🏁 Script executed:

#!/bin/bash
rg -nP 'forwardRef<\s*React\.ComponentRef<' -g 'packages/ui/**.tsx' -S

Length of output: 148


🏁 Script executed:

#!/bin/bash
# Search for any usage of React.ComponentRef across all .tsx files
rg -nP 'React\.ComponentRef<' -t tsx -n

# Specifically look for forwardRef generics using React.ComponentRef
rg -nP 'forwardRef<\s*React\.ComponentRef<' -t tsx -n -C3

Length of output: 55


🏁 Script executed:

#!/bin/bash
# Search for any usage of React.ComponentRef in .tsx files by glob pattern
rg -nP 'React\.ComponentRef<' -g '*.tsx' -n

# Search for forwardRef generics explicitly using React.ComponentRef
rg -nP 'forwardRef<\s*React\.ComponentRef<' -g '*.tsx' -n -C3

Length of output: 705


Replace React.ComponentRef with React.ElementRef for Radix primitives
In packages/ui/src/components/atoms/navigation-menu.tsx at lines 10, 28, 49, 67, 84 and 102, swap all React.ComponentRef<typeof NavigationMenuPrimitive.> to React.ElementRef<typeof NavigationMenuPrimitive.> to ensure correct ref typings for function components.

🤖 Prompt for AI Agents
In packages/ui/src/components/atoms/navigation-menu.tsx around lines 10, 28, 49,
67, 84 and 102, the types use React.ComponentRef<typeof
NavigationMenuPrimitive.*> which is incorrect for Radix function components;
replace each React.ComponentRef<typeof NavigationMenuPrimitive.*> with
React.ElementRef<typeof NavigationMenuPrimitive.*> to ensure ref typing matches
function components (update all occurrences at the listed line ranges).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants