feat: add scroll to top button with progress indicator
Closes #204
π Added Scroll to Top Button
π Description
Implemented an enhanced scroll-to-top button with smooth animations and visual progress indicator to improve user navigation experience.
π― Changes Made
- Created
ScrollToTopcomponent atFrontend/src/components/ui/scroll-to-top.tsx - Integrated component into
App.tsx - Implemented on branch
feature/scroll-to-top
β¨ Features
- Auto-appears after scrolling 300px down
- Circular progress ring indicating scroll position
- Gradient purple/indigo background matching brand colors
- Smooth scroll animation to top
- Hover tooltip "Back to top"
- Fade in/out transitions
- Bounce animation on hover
π Technical Implementation
- Framework: React 19 + TypeScript
- Styling: Tailwind CSS with custom gradients
- Icons: Lucide React (
ArrowUp) - Performance:
requestAnimationFramethrottling for scroll events - Accessibility: WCAG 2.1 compliant with proper ARIA attributes
π§ͺ Testing
- β Chrome, Firefox, Safari compatibility verified
- β Mobile responsive (tested on iOS/Android)
- β No performance degradation during scroll
- β Accessibility validated (keyboard navigation, screen readers)
- β No console errors or warnings
πΈ Preview
https://github.com/user-attachments/assets/e9d7c766-7691-4962-b1e2-417d99df36e2
β Checklist
- [x] Follows project code style guidelines
- [x] No console errors or warnings
- [x] Component is reusable and maintainable
- [x] Meets accessibility standards (ARIA labels, focus states)
- [x] Performance optimized (passive listeners, RAF throttling)
- [x] Cross-browser compatible
- [x] Mobile responsive
- [x] TypeScript types properly defined
π¦ Files Changed
Frontend/src/components/ui/scroll-to-top.tsx(new)Frontend/src/App.tsx(modified)
Summary by CodeRabbit
- New Features
- Added a floating scroll-to-top control that appears after scrolling, shows scroll progress with a circular indicator, and smoothly returns you to the top when clicked. Includes animated visuals, hover tooltip, and responsive sizing.
- Integrated the control globally so it works automatically across route changes.
βοΈ Tip: You can customize this high-level summary in your review settings.
Walkthrough
A ScrollToTop React component was added and mounted in App.tsx inside the AuthProvider/Router tree. It shows a floating button after 300px scroll, renders a circular progress ring reflecting page scroll percentage, and smooth-scrolls to top when clicked.
Changes
| Cohort / File(s) | Summary |
|---|---|
New Scroll-To-Top Component Frontend/src/components/ui/scroll-to-top.tsx |
Adds a React component that: tracks scroll position (visible after 300px), computes scroll progress, updates via requestAnimationFrame, renders a circular SVG progress ring with gradient/button UI and hover tooltip, and scrolls to top smoothly on click. Cleans up listeners/animation frame on unmount. |
App Integration Frontend/src/App.tsx |
Imports and renders ScrollToTop within the AuthProvider/Router tree to enable global scroll-to-top behavior across routes. |
Sequence Diagram(s)
sequenceDiagram
participant U as User (browser)
participant C as ScrollToTop Component
participant W as Window (scroll/resize)
Note over U,C: Page loads
U->>C: mount()
C->>W: addEventListener(scroll)
C->>W: addEventListener(resize)
Note right of W: On scroll (debounced via requestAnimationFrame)
W-->>C: scroll event
C->>C: compute isVisible & scrollProgress
C-->>U: update UI (show/hide, ring offset)
alt User clicks button
U->>C: click()
C->>W: window.scrollTo({ top:0, behavior:"smooth" })
Note over W,C: smooth scroll animates back to top
end
Note over C: on unmount -> remove listeners, cancel RAF
Estimated code review effort
π― 3 (Moderate) | β±οΈ ~20 minutes
- Pay attention to event listener lifecycle and RAF cancellation in
Frontend/src/components/ui/scroll-to-top.tsx. - Verify scroll progress calculation across short and long pages and correct SVG dash-offset mapping.
- Check keyboard accessibility and ARIA attributes on the button.
- Confirm styling (Tailwind classes/gradients) matches existing design tokens if required.
Poem
πβ¨ I hopped in code with ears held high,
A glowing ring to mark the sky,
When pages stretch and journeys long,
I sing a tiny carrot songβ
Tap my paw and up you fly!
Pre-merge checks and finishing touches
β Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | β οΈ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
β Passed checks (4 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 a scroll-to-top button with a progress indicator component. |
| Linked Issues check | β Passed | The pull request implements all primary objectives from issue #204: scroll-to-top button appearing after 300px, circular progress ring, gradient purple/indigo design, smooth animation, tooltip, keyboard/ARIA support, and React hooks with RAF optimization. |
| Out of Scope Changes check | β Passed | All changes are within scope: new ScrollToTop component file and App.tsx integration to implement the scroll-to-top feature requested in issue #204. |
β¨ Finishing touches
- [ ] π Generate docstrings
π§ͺ Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
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.
Comment @coderabbitai help to get the list of available commands and usage tips.
Hi @chandansgowda
Raised a PR here here #205 .Please review and let me know if any further changes required. Thank you.