Skip to content

feat: add smooth scroll to hero section on logo click#333

Open
praveensaison wants to merge 1 commit intoapsinghdev:mainfrom
praveensaison:main
Open

feat: add smooth scroll to hero section on logo click#333
praveensaison wants to merge 1 commit intoapsinghdev:mainfrom
praveensaison:main

Conversation

@praveensaison
Copy link

@praveensaison praveensaison commented Jan 29, 2026

This pull request improves the user navigation experience on the landing page by allowing users to smoothly scroll back to the top (the hero section) when clicking the logo in the navbar. The main changes include adding an id to the hero section and implementing a click handler for the logo.

User navigation enhancements:

  • Added an id="hero" to the main hero section container in Hero.tsx to serve as a scroll target.
  • Implemented a handleLogoClick function in navbar.tsx that smoothly scrolls to the hero section when the logo is clicked, or to the top of the page if the hero section is not found.
  • Updated the logo container in the navbar to be clickable, trigger the scroll handler, display a pointer cursor, and include accessibility improvements.

Summary by CodeRabbit

  • New Features
    • Logo is now interactive—click it to smoothly scroll back to the hero section, improving site navigation.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Jan 29, 2026

@praveensaison is attempting to deploy a commit to the AJEET PRATAP SINGH's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 29, 2026

📝 Walkthrough

Walkthrough

The pull request adds smooth scroll-to-hero functionality when the logo is clicked. The Hero component gains an id attribute, and the Navbar receives a click handler that scrolls to this hero element using smooth scrolling, or to the top if the element is not found.

Changes

Cohort / File(s) Summary
Scroll-to-Hero Navigation
apps/web/src/components/landing-sections/Hero.tsx, apps/web/src/components/landing-sections/navbar.tsx
Hero component adds an explicit id="hero" identifier. Navbar logo becomes clickable with a handler that queries and smoothly scrolls to the hero element, or falls back to top scroll. Includes cursor styling and accessibility attributes (aria-label, userSelect).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰✨ A logo now dares to scroll with grace,
Where hero elements find their rightful place,
With just a tap, the page springs up to meet,
The top of dreams—smooth, swift, and oh so sweet! 🚀

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding smooth scroll behavior to the hero section when the logo is clicked, which is the primary feature introduced across both modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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

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

🤖 Fix all issues with AI agents
In `@apps/web/src/components/landing-sections/navbar.tsx`:
- Around line 14-22: The logo click handler handleLogoClick should be triggered
from a keyboard-accessible control: replace the clickable <div> used for the
logo in the Navbar component with a semantic <button> (or add role="button",
tabIndex={0}, aria-label and onKeyDown that calls handleLogoClick) so keyboard
users can activate it; remove any inline style like userSelect and use the
Tailwind utility class select-none instead; apply the same changes to the other
logo instance referenced in the component (lines ~91-106) so both logo controls
are keyboard-accessible and use Tailwind for styling.
🧹 Nitpick comments (1)
apps/web/src/components/landing-sections/navbar.tsx (1)

13-13: Remove the redundant comment (and avoid uppercase in code comments).
The handler name is self-explanatory, and the new comment is not lowercase.

♻️ Proposed cleanup
-    // Scroll to top of hero section
As per coding guidelines, "Always use lowercase when writing comments" and "Avoid unnecessary comments; code should be self-documenting when possible".

Comment on lines +14 to +22
const handleLogoClick = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
e.preventDefault();
const hero = document.getElementById('hero');
if (hero) {
hero.scrollIntoView({ behavior: 'smooth' });
} else {
window.scrollTo({ top: 0, behavior: 'smooth' });
}
};
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 | 🟠 Major

Make the logo control keyboard-accessible and drop inline styles.
A clickable div isn’t focusable by default, so keyboard users can’t activate it. Switch to a button (or add role/tabIndex/onKeyDown), and replace the inline userSelect style with Tailwind.

✅ Proposed fix
-    const handleLogoClick = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
-      e.preventDefault();
+    const handleLogoClick = () => {
       const hero = document.getElementById('hero');
       if (hero) {
         hero.scrollIntoView({ behavior: 'smooth' });
       } else {
         window.scrollTo({ top: 0, behavior: 'smooth' });
       }
     };
...
-        <div
-          className="text-xl md:text-2xl font-medium tracking-tighter flex items-center gap-2 cursor-pointer"
-          onClick={handleLogoClick}
-          aria-label="Scroll to top"
-          style={{ userSelect: 'none' }}
-        >
+        <button
+          type="button"
+          className="text-xl md:text-2xl font-medium tracking-tighter flex items-center gap-2 cursor-pointer select-none bg-transparent border-0 p-0"
+          onClick={handleLogoClick}
+          aria-label="Scroll to top"
+        >
...
-        </div>
+        </button>
As per coding guidelines, "Implement accessibility features on interactive elements (e.g., tabindex='0', aria-label, onClick, onKeyDown)", "Ensure keyboard navigation works in interactive components", and "Always use Tailwind classes for styling HTML elements; avoid using CSS or style tags".

Also applies to: 91-106

🤖 Prompt for AI Agents
In `@apps/web/src/components/landing-sections/navbar.tsx` around lines 14 - 22,
The logo click handler handleLogoClick should be triggered from a
keyboard-accessible control: replace the clickable <div> used for the logo in
the Navbar component with a semantic <button> (or add role="button",
tabIndex={0}, aria-label and onKeyDown that calls handleLogoClick) so keyboard
users can activate it; remove any inline style like userSelect and use the
Tailwind utility class select-none instead; apply the same changes to the other
logo instance referenced in the component (lines ~91-106) so both logo controls
are keyboard-accessible and use Tailwind for styling.

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.

1 participant