File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { SoundProvider } from "./hooks/useSoundEffects";
77import { QueryProvider } from "./providers/QueryProvider" ;
88import ErrorBoundary from "./components/ErrorBoundary" ;
99import SoundToggle from "./components/SoundToggle" ;
10+ import BackToTop from "./components/BackToTop" ;
1011
1112const Login = lazy ( ( ) => import ( "./pages/Login" ) ) ;
1213const Dashboard = lazy ( ( ) => import ( "./pages/Dashboard" ) ) ;
@@ -94,6 +95,7 @@ const App = () => {
9495 } }
9596 />
9697 < SoundToggle />
98+ < BackToTop />
9799 </ BrowserRouter >
98100 </ SoundProvider >
99101 </ QueryProvider >
Original file line number Diff line number Diff line change 1+ import { useState , useEffect } from "react" ;
2+ import { ChevronUpIcon } from "@heroicons/react/24/outline" ;
3+ import { useSoundEffects } from "../hooks/useSoundEffects" ;
4+ import { SOUND_TYPES } from "../utils/soundUtils" ;
5+
6+ const BackToTop = ( ) => {
7+ const [ isVisible , setIsVisible ] = useState ( false ) ;
8+ const { playSound } = useSoundEffects ( ) ;
9+
10+ useEffect ( ( ) => {
11+ const handleScroll = ( ) => {
12+ // Show button when user scrolls down 300px
13+ if ( window . scrollY > 300 ) {
14+ setIsVisible ( true ) ;
15+ } else {
16+ setIsVisible ( false ) ;
17+ }
18+ } ;
19+
20+ window . addEventListener ( "scroll" , handleScroll ) ;
21+
22+ return ( ) => {
23+ window . removeEventListener ( "scroll" , handleScroll ) ;
24+ } ;
25+ } , [ ] ) ;
26+
27+ const scrollToTop = ( ) => {
28+ playSound ( SOUND_TYPES . CLICK ) ;
29+ window . scrollTo ( {
30+ top : 0 ,
31+ behavior : "smooth" ,
32+ } ) ;
33+ } ;
34+
35+ if ( ! isVisible ) return null ;
36+
37+ return (
38+ < button
39+ onClick = { scrollToTop }
40+ className = "fixed bottom-6 right-6 z-50 p-3 rounded-full bg-gradient-to-br from-indigo-500/70 to-purple-600/70 hover:from-indigo-600 hover:to-purple-700 shadow-lg hover:shadow-xl backdrop-blur-sm border border-white/20 transition-all duration-300 hover:scale-110 cursor-pointer group opacity-60 hover:opacity-100"
41+ aria-label = "Başa Dön"
42+ title = "Başa Dön"
43+ >
44+ < ChevronUpIcon className = "h-5 w-5 text-white group-hover:animate-pulse" />
45+ </ button >
46+ ) ;
47+ } ;
48+
49+ export default BackToTop ;
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ const SoundToggle = () => {
1717 return (
1818 < button
1919 onClick = { handleClick }
20- className = "fixed bottom-6 right -6 z-50 p-3 rounded-full bg-gradient-to-br from-indigo-500/70 to-purple-600/70 hover:from-indigo-600 hover:to-purple-700 shadow-lg hover:shadow-xl backdrop-blur-sm border border-white/20 transition-all duration-300 hover:scale-110 cursor-pointer group opacity-60 hover:opacity-100"
20+ className = "fixed bottom-6 left -6 z-50 p-3 rounded-full bg-gradient-to-br from-indigo-500/70 to-purple-600/70 hover:from-indigo-600 hover:to-purple-700 shadow-lg hover:shadow-xl backdrop-blur-sm border border-white/20 transition-all duration-300 hover:scale-110 cursor-pointer group opacity-60 hover:opacity-100"
2121 aria-label = { isSoundEnabled ? "Sesi Kapat" : "Sesi Aç" }
2222 title = { isSoundEnabled ? "Sesi Kapat" : "Sesi Aç" }
2323 >
You can’t perform that action at this time.
0 commit comments