Skip to content

Commit

Permalink
Merge pull request #593 from paulkrishanu4/update_scrollToTop
Browse files Browse the repository at this point in the history
fixed scroll to top on render of new page
  • Loading branch information
panwar8279 authored Jun 1, 2024
2 parents 48c9c40 + abec1f7 commit 0564320
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 8 deletions.
9 changes: 8 additions & 1 deletion frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ import OpenSource from "./Component/OpenSource";
import Review from "./Component/Review";
import AOS from 'aos';
import 'aos/dist/aos.css';

import { BrowserRouter } from 'react-router-dom';
import ScrollToTop from "./Component/ScrollToTop";
function App() {
const [searchQuery, setSearchQuery] = useState("");
AOS.init();
return (
<>
<BrowserRouter>
<ScrollToTop/>
<Navbar setSearchQuery={setSearchQuery} />


<Routes>
<Route path="/" element={<Home searchQuery={searchQuery} />}></Route>
<Route path="/bookmark" element={<BookMark />}></Route>
Expand All @@ -28,9 +33,11 @@ function App() {
<Route path="/review" element={<Review />}></Route>
<Route path="*" element={<NotFound />} /> {/* 404 route */}
</Routes>

<BackToTopButton />
<Footer />
<ChatAssistant/>
</BrowserRouter>
</>
);
}
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/ChatAssistant/ChatAssistant.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@

.Logo {
cursor: pointer;

height:50px;
width:50px;
}


height: 50px;
width: 50px;
}
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/ChatAssistant/ChatAssistant.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const ChatAssistant = () => {
setIsOpen(!isOpen);
};


<img className="Logo" src={chatbotLogo} alt="Logo" onClick={toggleChatbot} />}
<div className={`${isOpen?"chatbot-animation":"chatbot-close-animation"}`}>

const closeChatbot = () => {
setIsOpen(false);
};
Expand Down Expand Up @@ -56,6 +60,15 @@ const ChatAssistant = () => {
)}
</div>
</div>

</div>

);
}


export default ChatAssistant;

)}
</div>
);
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/Component/ScrollToTop.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

import {useEffect} from 'react'
import { useLocation } from 'react-router-dom'

function ScrollToTop() {
const { pathname } = useLocation();
useEffect(()=>{
window.scrollTo(0,0);
},[pathname])
return null;

}

export default ScrollToTop;
2 changes: 1 addition & 1 deletion frontend/src/index.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:root,
body,
html {
overflow-x: hidden;
scrollbar-width: none;
height: 100%;
}

Expand Down
8 changes: 2 additions & 6 deletions frontend/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import App from './App';
import { Provider } from 'react-redux';
import store from './Store/store'
import Darkmode from 'darkmode-js';
import { BrowserRouter } from 'react-router-dom';
import Preloader from './Component/Preloader';

const root = ReactDOM.createRoot(document.getElementById('root'));

const options = {
Expand All @@ -29,12 +29,8 @@ darkmode.showWidget();


root.render(
<React.StrictMode>
<BrowserRouter>
<Provider store={store}>
{/* <App /> */}
{ /*<App />*/ }
<Preloader/>
</Provider>
</BrowserRouter>
</React.StrictMode>
);

0 comments on commit 0564320

Please sign in to comment.