Skip to content

Issue #82 Resolved : Added and Updated Categories dropdown section to Navbar on HomePage #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ssz2605
Copy link

@ssz2605 ssz2605 commented Jul 4, 2025

Closes #82

📝 Description

This PR adds a new Categories dropdown section to the Navbar on the HomePage. The dropdown is placed at the beginning of the navbar and includes multiple items for better navigation.

🔧 Changes Made

  • Created a new dropdown component inside the Navbar
  • Added multiple category items in the dropdown
  • Integrated the dropdown into HomePage.tsx navigation bar

📷 Screenshots or Visual Changes (if applicable)

Main Issue

✅ Checklist

  • I have read the contributing guidelines.
  • I have tested the dropdown functionality visually.
  • I have added necessary documentation (if applicable).

Summary by CodeRabbit

  • New Features

    • Introduced a new navigation bar with links to "Features," "Pricing," "About," "Contact," and a "Categories" dropdown menu featuring grouped categories and hover-activated submenus.
  • Improvements

    • Enhanced dropdown menu usability with better open/close behavior and interaction handling.
    • Refined page layout and styling for a more consistent appearance across header, hero, and footer sections.

Copy link
Contributor

coderabbitai bot commented Jul 4, 2025

Walkthrough

The code removes an external navigation component and introduces a new inline MainNav component within the homepage file. This new navigation bar features a "Categories" dropdown with grouped items and hover interactions. Additional minor changes include relocating the features array inside the component and refining styling and layout classes.

Changes

File(s) Change Summary
Frontend/src/pages/HomePage.tsx Removed external MainNav import; added inline MainNav with "Categories" dropdown; moved features array inside component; simplified intersection observer logic; adjusted header, hero, and footer classes and formatting.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MainNav
    participant CategoriesDropdown

    User->>MainNav: Hover or click "Categories"
    MainNav->>CategoriesDropdown: Open dropdown menu
    User->>CategoriesDropdown: Hover category group
    CategoriesDropdown->>CategoriesDropdown: Show subcategories (if any)
    User->>CategoriesDropdown: Click outside or mouse leave
    CategoriesDropdown->>CategoriesDropdown: Close dropdown
Loading

Assessment against linked issues

Objective Addressed Explanation
Add “Categories” dropdown in navbar with specified items (Fashion, Makeup, Skincare, etc.) [#82]
Redesign navbar for better category discoverability and alignment with app styling [#82]

Poem

In the navbar, dropdowns gleam,
Categories now a browsing dream!
From Fashion to Tech, we hop with glee,
A rabbit’s guide to discovery.
With code so neat and menus bright,
Navigation now feels just right—
Hippity-hop, enjoy the site! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 6

🧹 Nitpick comments (1)
Frontend/src/pages/HomePage.tsx (1)

98-98: Consider using a URL-safe slug generation utility.

While the current URL generation works for basic cases, consider using a proper slug generation utility for edge cases (special characters, Unicode, etc.).

Example implementation:

// utils/slugify.ts
export const slugify = (text: string): string => {
  return text
    .toLowerCase()
    .replace(/[^\w\s-]/g, '') // Remove special characters
    .replace(/\s+/g, '-')      // Replace spaces with hyphens
    .replace(/--+/g, '-')      // Replace multiple hyphens with single
    .trim();
};
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af8eaf8 and 9230415.

📒 Files selected for processing (1)
  • Frontend/src/pages/HomePage.tsx (4 hunks)
🔇 Additional comments (2)
Frontend/src/pages/HomePage.tsx (2)

127-143: Good implementation of intersection observers with proper cleanup!

The intersection observer setup is well-implemented with:

  • Proper cleanup in the return function
  • Null checks before observing/unobserving
  • Clean destructured callback syntax

57-65: Categories dropdown placement doesn't match PR objectives.

According to the PR objectives, the Categories dropdown should be "positioned at the beginning of the navbar", but it's currently placed after all other navigation items.

Consider moving the Categories dropdown to the beginning:

     <nav className="hidden md:flex items-center gap-6 px-4 py-2 relative">
+      <div className="relative" ref={dropdownWrapperRef}>
+        <button onClick={handleClick} className="text-sm font-medium hover:text-purple-600">
+          Categories
+        </button>
+        {/* dropdown content */}
+      </div>
       <Link to="/features" className="text-sm font-medium hover:text-purple-600">Features</Link>
       <Link to="/pricing" className="text-sm font-medium hover:text-purple-600">Pricing</Link>
       <Link to="/about" className="text-sm font-medium hover:text-purple-600">About</Link>
       <Link to="/contact" className="text-sm font-medium hover:text-purple-600">Contact</Link>
-
-      <div className="relative" ref={dropdownWrapperRef}>
-        {/* ... */}
-      </div>

Likely an incorrect or invalid review comment.

Comment on lines +17 to +18
// ---------------- MainNav Component ------------------

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider extracting MainNav to a separate component file.

For better code organization and reusability, consider moving the MainNav component to a separate file (e.g., components/MainNav.tsx). This aligns with the single responsibility principle and makes the codebase more maintainable.

🤖 Prompt for AI Agents
In Frontend/src/pages/HomePage.tsx around lines 17 to 18, the MainNav component
should be extracted into its own file for better organization and reusability.
Create a new file named components/MainNav.tsx, move the MainNav component code
there, and then import MainNav into HomePage.tsx. This separation follows the
single responsibility principle and improves maintainability.

Comment on lines +25 to +32
const categoryGroups: Record<string, string[]> = {
Lifestyle: ["Fashion", "Makeup", "Skincare", "Parenting", "DIY"],
Wellness: ["Fitness", "Health"],
Media: ["Photography", "Travel"],
Tech: ["Electronics & Gadgets", "Gaming"],
Money: ["Finance", "Education"],
Others: ["Food", "Pets"],
};
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider externalizing category configuration.

The categoryGroups object is hardcoded within the component. For better maintainability and flexibility, consider:

  1. Moving it to a configuration file
  2. Passing it as props
  3. Fetching it from an API if categories are dynamic

This would make it easier to update categories without modifying the component code.

🤖 Prompt for AI Agents
In Frontend/src/pages/HomePage.tsx around lines 25 to 32, the categoryGroups
object is hardcoded inside the component, which reduces maintainability. To fix
this, move the categoryGroups data to a separate configuration file and import
it into the component, or alternatively pass it as props from a parent
component. If categories are dynamic, implement fetching them from an API and
update the component to use the fetched data instead of the hardcoded object.

Comment on lines +68 to +69
<div
className="absolute left-0 mt-2 flex flex-col bg-white shadow-lg rounded-md w-auto min-w-[12rem] z-50"
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add dark mode support to dropdown styling.

The dropdown uses hardcoded colors (bg-white, hover:bg-gray-100) that won't adapt to dark mode. Since the app includes a ModeToggle component, consider using theme-aware classes.

Apply this diff to support dark mode:

-            className="absolute left-0 mt-2 flex flex-col bg-white shadow-lg rounded-md w-auto min-w-[12rem] z-50"
+            className="absolute left-0 mt-2 flex flex-col bg-white dark:bg-gray-800 shadow-lg rounded-md w-auto min-w-[12rem] z-50"
-                  className="relative hover:bg-gray-100 cursor-pointer"
+                  className="relative hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer"
-                    <div className="absolute top-0 left-full ml-2 flex flex-col bg-white shadow-lg rounded-md min-w-max z-50">
+                    <div className="absolute top-0 left-full ml-2 flex flex-col bg-white dark:bg-gray-800 shadow-lg rounded-md min-w-max z-50">

Also applies to: 93-93

🤖 Prompt for AI Agents
In Frontend/src/pages/HomePage.tsx around lines 68-69 and line 93, the dropdown
styling uses hardcoded light mode colors like bg-white and hover:bg-gray-100,
which do not support dark mode. Update these class names to use theme-aware
Tailwind CSS classes that adapt to dark mode, such as replacing bg-white with
bg-white dark:bg-gray-800 and hover:bg-gray-100 with hover:bg-gray-100
dark:hover:bg-gray-700, to ensure the dropdown looks appropriate in both light
and dark modes.

Comment on lines +63 to +65
<button onClick={handleClick} className="text-sm font-medium hover:text-purple-600">
Categories
</button>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add accessibility support to the dropdown button.

The dropdown button lacks essential accessibility features:

  • No aria-expanded attribute
  • No aria-haspopup attribute
  • No keyboard navigation support

Apply this diff to improve accessibility:

-        <button onClick={handleClick} className="text-sm font-medium hover:text-purple-600">
+        <button 
+          onClick={handleClick} 
+          onKeyDown={(e) => {
+            if (e.key === 'Enter' || e.key === ' ') {
+              e.preventDefault();
+              handleClick();
+            }
+          }}
+          aria-expanded={isDropdownOpen}
+          aria-haspopup="true"
+          className="text-sm font-medium hover:text-purple-600"
+        >
📝 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
<button onClick={handleClick} className="text-sm font-medium hover:text-purple-600">
Categories
</button>
<button
onClick={handleClick}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
handleClick();
}
}}
aria-expanded={isDropdownOpen}
aria-haspopup="true"
className="text-sm font-medium hover:text-purple-600"
>
Categories
</button>
🤖 Prompt for AI Agents
In Frontend/src/pages/HomePage.tsx around lines 63 to 65, the dropdown button
lacks accessibility attributes and keyboard support. Add the aria-expanded
attribute to reflect the dropdown state, aria-haspopup to indicate it controls a
menu, and ensure the button supports keyboard navigation by handling key events
like Enter and Space to trigger the dropdown. Update the button element
accordingly to include these attributes and event handlers.

Comment on lines +38 to +53
useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
if (
dropdownWrapperRef.current &&
!dropdownWrapperRef.current.contains(event.target as Node)
) {
setIsDropdownOpen(false);
setHoveredCategory(null);
}
};

document.addEventListener("mousedown", handleClickOutside);
return () => {
document.removeEventListener("mousedown", handleClickOutside);
};
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Clear timeout on component unmount to prevent memory leaks.

The closeTimeout ref should be cleared when the component unmounts to prevent potential memory leaks.

Apply this diff to fix the issue:

     document.addEventListener("mousedown", handleClickOutside);
     return () => {
       document.removeEventListener("mousedown", handleClickOutside);
+      if (closeTimeout.current) {
+        clearTimeout(closeTimeout.current);
+      }
     };
📝 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
useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
if (
dropdownWrapperRef.current &&
!dropdownWrapperRef.current.contains(event.target as Node)
) {
setIsDropdownOpen(false);
setHoveredCategory(null);
}
};
document.addEventListener("mousedown", handleClickOutside);
return () => {
document.removeEventListener("mousedown", handleClickOutside);
};
}, []);
useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
if (
dropdownWrapperRef.current &&
!dropdownWrapperRef.current.contains(event.target as Node)
) {
setIsDropdownOpen(false);
setHoveredCategory(null);
}
};
document.addEventListener("mousedown", handleClickOutside);
return () => {
document.removeEventListener("mousedown", handleClickOutside);
if (closeTimeout.current) {
clearTimeout(closeTimeout.current);
}
};
}, []);
🤖 Prompt for AI Agents
In Frontend/src/pages/HomePage.tsx around lines 38 to 53, the useEffect hook
adds an event listener but does not clear any existing closeTimeout, which can
cause memory leaks. To fix this, add code in the cleanup function to check if
closeTimeout.current exists and clear it using clearTimeout. This ensures any
pending timeouts are properly cleared when the component unmounts.

Comment on lines +145 to +177
const features = [
{
icon: Handshake,
title: "AI-Driven Sponsorship Matchmaking",
desc: "Connect with brands based on audience demographics, engagement rates, and content style.",
},
{
icon: Users,
title: "Creator Collaboration Hub",
desc: "Find and partner with creators who have complementary audiences and content niches.",
},
{
icon: Layers,
title: "AI-Based Pricing Optimization",
desc: "Get fair sponsorship pricing recommendations based on engagement and market trends.",
},
{
icon: MessageSquare,
title: "Negotiation & Contract Assistant",
desc: "Structure deals, generate contracts, and optimize terms using AI insights.",
},
{
icon: BarChart3,
title: "Performance Analytics",
desc: "Track sponsorship performance, audience engagement, and campaign success.",
},
{
icon: Rocket,
title: "ROI Tracking",
desc: "Measure and optimize return on investment for both creators and brands.",
},
];

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Move static features array outside the component to avoid recreation on each render.

The features array is static data that gets recreated on every render. This is inefficient and goes against React best practices.

Move the array outside the component:

+const features = [
+  {
+    icon: Handshake,
+    title: "AI-Driven Sponsorship Matchmaking",
+    desc: "Connect with brands based on audience demographics, engagement rates, and content style.",
+  },
+  // ... rest of the features
+];

 export default function HomePage() {
   const featuresRef = useRef(null);
   const footerRef = useRef(null);
   const [isFeaturesVisible, setIsFeaturesVisible] = useState(false);
   const [isFooterVisible, setIsFooterVisible] = useState(false);
-
-  const features = [
-    // ... features array
-  ];
📝 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
const features = [
{
icon: Handshake,
title: "AI-Driven Sponsorship Matchmaking",
desc: "Connect with brands based on audience demographics, engagement rates, and content style.",
},
{
icon: Users,
title: "Creator Collaboration Hub",
desc: "Find and partner with creators who have complementary audiences and content niches.",
},
{
icon: Layers,
title: "AI-Based Pricing Optimization",
desc: "Get fair sponsorship pricing recommendations based on engagement and market trends.",
},
{
icon: MessageSquare,
title: "Negotiation & Contract Assistant",
desc: "Structure deals, generate contracts, and optimize terms using AI insights.",
},
{
icon: BarChart3,
title: "Performance Analytics",
desc: "Track sponsorship performance, audience engagement, and campaign success.",
},
{
icon: Rocket,
title: "ROI Tracking",
desc: "Measure and optimize return on investment for both creators and brands.",
},
];
// Move this to the top of the file, above the component
const features = [
{
icon: Handshake,
title: "AI-Driven Sponsorship Matchmaking",
desc: "Connect with brands based on audience demographics, engagement rates, and content style.",
},
{
icon: Users,
title: "Creator Collaboration Hub",
desc: "Find and partner with creators who have complementary audiences and content niches.",
},
{
icon: Layers,
title: "AI-Based Pricing Optimization",
desc: "Get fair sponsorship pricing recommendations based on engagement and market trends.",
},
{
icon: MessageSquare,
title: "Negotiation & Contract Assistant",
desc: "Structure deals, generate contracts, and optimize terms using AI insights.",
},
{
icon: BarChart3,
title: "Performance Analytics",
desc: "Track sponsorship performance, audience engagement, and campaign success.",
},
{
icon: Rocket,
title: "ROI Tracking",
desc: "Measure and optimize return on investment for both creators and brands.",
},
];
export default function HomePage() {
const featuresRef = useRef(null);
const footerRef = useRef(null);
const [isFeaturesVisible, setIsFeaturesVisible] = useState(false);
const [isFooterVisible, setIsFooterVisible] = useState(false);
// (Removed the inner `const features = […]` here)
return (
<main>
{/* … */}
<section ref={featuresRef}>
{features.map((feature) => (
<FeatureCard key={feature.title} {...feature} />
))}
</section>
{/* … */}
</main>
);
}
🤖 Prompt for AI Agents
In Frontend/src/pages/HomePage.tsx around lines 145 to 177, the static features
array is currently defined inside the component, causing it to be recreated on
every render. To fix this, move the entire features array declaration outside
the component function so it is only created once and reused, improving
performance and adhering to React best practices.

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.

FEATURE REQUEST: Feature Request: Add “Categories” Dropdown to Navbar
1 participant