Skip to content

feat: add Back to Top button fixed to bottom-right corner#458

Open
nishupr wants to merge 2 commits into
FireFistisDead:masterfrom
nishupr:feat/back-to-top
Open

feat: add Back to Top button fixed to bottom-right corner#458
nishupr wants to merge 2 commits into
FireFistisDead:masterfrom
nishupr:feat/back-to-top

Conversation

@nishupr
Copy link
Copy Markdown

@nishupr nishupr commented Jun 1, 2026

Closes #337

What's Changed

  • Added BackToTop.jsx component fixed to bottom-right corner
  • Button appears only after scrolling 300px down the page
  • Smooth scroll to top on click
  • Styled with the site's neon green accent color (#C8F135) to match existing design

Screenshots

Screenshot (573)

Summary by CodeRabbit

  • New Features
    • Added a "Back to Top" button that appears after scrolling down and smoothly returns the page to the top when clicked.
    • Integrated the "Back to Top" button into the landing page layout (appears after the How It Works section).

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

Someone is attempting to deploy a commit to the firefistisdead's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 08c0a94f-cd35-4ea7-b039-f31bbf36c5e7

📥 Commits

Reviewing files that changed from the base of the PR and between f09db1d and c06220b.

📒 Files selected for processing (1)
  • frontend/src/components/BackToTop.jsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/components/BackToTop.jsx

📝 Walkthrough

Walkthrough

A new BackToTop React component tracks window.scrollY and conditionally displays a fixed button that smoothly scrolls the page to the top. The component is rendered on the landing page immediately after the HowItWorks section.

Changes

Back to Top Button

Layer / File(s) Summary
BackToTop component implementation
frontend/src/components/BackToTop.jsx
New component manages visible state based on window.scrollY > 300, registers a scroll event listener on mount and removes it on unmount, conditionally renders null when not visible, and renders a fixed circular button that calls window.scrollTo({ top: 0, behavior: 'smooth' }) on click.
Landing page integration
frontend/src/components/Landing/LandingPage.jsx
Imports BackToTop and renders it after the HowItWorks section in the landing page JSX tree.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant BackToTop
  participant Window
  User->>BackToTop: Mounts component
  BackToTop->>Window: addEventListener('scroll', onScroll)
  User->>Window: Scrolls page
  Window->>BackToTop: onScroll (reads scrollY)
  BackToTop->>BackToTop: toggle visible when scrollY > 300
  alt visible
    User->>BackToTop: Clicks button
    BackToTop->>Window: scrollTo({ top: 0, behavior: "smooth" })
  end
  User->>BackToTop: Unmounts component
  BackToTop->>Window: removeEventListener('scroll', onScroll)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A button small, round, and spry,
Watching pages sweep on by,
When a reader drifts too far below,
A single hop — up they go!
— From a rabbit with a bouncing sigh 🐰⬆️

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description is incomplete. It lacks required sections such as Testing checklist, Code style/review checklist, and Security declaration from the template. Add the missing sections from the description template including Testing checkboxes, Checklist items (code style, self-review, comments), and Security confirmation.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and clearly describes the main change: adding a Back to Top button fixed to the bottom-right corner, matching the primary objective of the PR.
Linked Issues check ✅ Passed The PR successfully implements all requirements from issue #337: a Back to Top button fixed to bottom-right corner, visible only after 300px scroll, with smooth scroll to top on click, and matching the site's design.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the Back to Top feature from issue #337. The component addition and integration into LandingPage are both in scope.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@github-actions github-actions Bot added feature A new feature or improvement fix A targeted fix or cleanup frontend Frontend-related work labels Jun 1, 2026
Copy link
Copy Markdown
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

🧹 Nitpick comments (1)
frontend/src/components/BackToTop.jsx (1)

8-9: ⚡ Quick win

Use a passive scroll listener for smoother scrolling.

This listener never calls preventDefault, so passive mode is a safe perf win on scroll-heavy pages.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/components/BackToTop.jsx` around lines 8 - 9, The scroll
listener added for handleScroll should be registered as passive for better
performance; update the addEventListener call that currently uses "scroll" and
handleScroll to pass an options object with { passive: true } and ensure the
matching removeEventListener uses the same options (or the same boolean capture
value) so the handler is removed correctly; locate the listener registration
around the handleScroll useEffect in BackToTop.jsx and change both
addEventListener/removeEventListener accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/src/components/BackToTop.jsx`:
- Around line 6-10: The visibility state in BackToTop.jsx isn't initialized on
mount so visible remains false until the next scroll; in the useEffect that
defines handleScroll and adds the "scroll" listener, call handleScroll() once
(or setVisible(typeof window !== 'undefined' && window.scrollY > 300) on mount)
immediately after adding the event listener to initialize state based on current
window.scrollY, while keeping the existing window.removeEventListener cleanup.

---

Nitpick comments:
In `@frontend/src/components/BackToTop.jsx`:
- Around line 8-9: The scroll listener added for handleScroll should be
registered as passive for better performance; update the addEventListener call
that currently uses "scroll" and handleScroll to pass an options object with {
passive: true } and ensure the matching removeEventListener uses the same
options (or the same boolean capture value) so the handler is removed correctly;
locate the listener registration around the handleScroll useEffect in
BackToTop.jsx and change both addEventListener/removeEventListener accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 04b1f25f-c039-4bb6-8d85-ceddb33dc407

📥 Commits

Reviewing files that changed from the base of the PR and between 055d3af and f09db1d.

📒 Files selected for processing (2)
  • frontend/src/components/BackToTop.jsx
  • frontend/src/components/Landing/LandingPage.jsx

Comment thread frontend/src/components/BackToTop.jsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature A new feature or improvement fix A targeted fix or cleanup frontend Frontend-related work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add "Back to Top" button

1 participant