Skip to content

Commit d10f283

Browse files
fix: correct import path and address CodeRabbit review suggestions
Signed-off-by: Vaishnavi Thakur <vaaishnavi4713@gmail.com>
1 parent 7391bd4 commit d10f283

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

apps/web-dashboard/src/components/Layout/BackToTop.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { useState, useEffect } from 'react';
2+
23
function BackToTop() {
34
const [isVisible, setIsVisible] = useState(false);
5+
46
useEffect(() => {
57
const handleScroll = () => {
68
if (window.scrollY > 300) {
@@ -9,24 +11,30 @@ function BackToTop() {
911
setIsVisible(false);
1012
}
1113
};
14+
1215
window.addEventListener('scroll', handleScroll);
16+
1317
return () => {
1418
window.removeEventListener('scroll', handleScroll);
1519
};
1620
}, []);
21+
1722
const handleClick = () => {
1823
window.scrollTo({
1924
top: 0,
2025
behavior: 'smooth'
2126
});
2227
};
28+
2329
if (!isVisible) {
2430
return null;
2531
}
32+
2633
return (
2734
<button
2835
onClick={handleClick}
2936
title="Back to Top"
37+
aria-label="Back to Top"
3038
style={{
3139
position: 'fixed',
3240
bottom: '2rem',
@@ -50,4 +58,5 @@ function BackToTop() {
5058
</button>
5159
);
5260
}
61+
5362
export default BackToTop;

0 commit comments

Comments
 (0)