From 73a5615fac9c23b7952412e05ab7b9bb49a84d88 Mon Sep 17 00:00:00 2001 From: Karan Shrivas Date: Thu, 23 Oct 2025 00:14:10 +0530 Subject: [PATCH] Fixed double scrollbar issue and improved AOS animations --- client/src/Pages/LandingPage.jsx | 14 ++-- client/src/Pages/Tutorial.jsx | 114 ++++++++++++++----------------- client/src/index.css | 3 +- client/src/main.jsx | 2 +- 4 files changed, 65 insertions(+), 68 deletions(-) diff --git a/client/src/Pages/LandingPage.jsx b/client/src/Pages/LandingPage.jsx index 7a0ed41..ad8d4ab 100644 --- a/client/src/Pages/LandingPage.jsx +++ b/client/src/Pages/LandingPage.jsx @@ -28,10 +28,13 @@ const Home = () => { useEffect(() => { AOS.init({ - duration: 1200, - once: false, - mirror: true, - }); + duration: 1200, + once: true, + mirror: true, + +}); + + }, []); const features = [ @@ -78,7 +81,8 @@ const Home = () => { ]; return ( -
+
+ {/* Animated Background Elements */}
{/* Remove animated background blobs */} diff --git a/client/src/Pages/Tutorial.jsx b/client/src/Pages/Tutorial.jsx index b8d74d2..bb0d2a8 100644 --- a/client/src/Pages/Tutorial.jsx +++ b/client/src/Pages/Tutorial.jsx @@ -24,69 +24,61 @@ const Tutorial = () => { { name: "Appliances", query: "home appliance repair" }, ]; - useEffect(() => { - const storedSearchHistory = localStorage.getItem("searchHistory"); - const storedRecentlyViewed = localStorage.getItem("recentlyViewed"); - const storedBookmarkedTutorials = localStorage.getItem( - "refixly_savedTutorials" +useEffect(() => { + const storedSearchHistory = localStorage.getItem("searchHistory"); + const storedRecentlyViewed = localStorage.getItem("recentlyViewed"); + const storedBookmarkedTutorials = localStorage.getItem("refixly_savedTutorials"); + + if (storedSearchHistory) setSearchHistory(JSON.parse(storedSearchHistory)); + if (storedRecentlyViewed) setRecentlyViewed(JSON.parse(storedRecentlyViewed)); + if (storedBookmarkedTutorials) setBookmarkedTutorials(JSON.parse(storedBookmarkedTutorials)); +}, []); + +useEffect(() => { + localStorage.setItem("searchHistory", JSON.stringify(searchHistory)); +}, [searchHistory]); + +useEffect(() => { + localStorage.setItem("recentlyViewed", JSON.stringify(recentlyViewed)); +}, [recentlyViewed]); + +useEffect(() => { + localStorage.setItem("refixly_savedTutorials", JSON.stringify(bookmarkedTutorials)); +}, [bookmarkedTutorials]); + +const fetchTutorials = useCallback(async (objectName, pageToken = "", append = false) => { + if (!objectName.trim()) { + setError("Please enter a search term or select a category."); + setTutorials([]); + setNextPageToken(null); + return; + } + setLoading(true); + setError(null); + try { + const res = await fetch( + `https://refixly.onrender.com/api/tutorials/${encodeURIComponent(objectName)}?pageToken=${pageToken}` ); - if (storedSearchHistory) setSearchHistory(JSON.parse(storedSearchHistory)); - if (storedRecentlyViewed) - setRecentlyViewed(JSON.parse(storedRecentlyViewed)); - if (storedBookmarkedTutorials) - setBookmarkedTutorials(JSON.parse(storedBookmarkedTutorials)); - }, [fetchTutorials]); - - useEffect(() => { - localStorage.setItem("searchHistory", JSON.stringify(searchHistory)); - }, [searchHistory]); - - useEffect(() => { - localStorage.setItem("recentlyViewed", JSON.stringify(recentlyViewed)); - }, [recentlyViewed]); - - useEffect(() => { - localStorage.setItem( - "bookmarkedTutorials", - JSON.stringify(bookmarkedTutorials) + if (!res.ok) + throw new Error((await res.json()).message || "Failed to fetch"); + const data = await res.json(); + setTutorials((prev) => + append ? [...prev, ...data.tutorials] : data.tutorials ); - }, [bookmarkedTutorials]); - - const fetchTutorials = async (objectName, pageToken = "", append = false) => { - if (!objectName.trim()) { - setError("Please enter a search term or select a category."); - setTutorials([]); - setNextPageToken(null); - return; - } - setLoading(true); - setError(null); - try { - const res = await fetch( - `https://refixly.onrender.com/api/tutorials/${encodeURIComponent( - objectName - )}?pageToken=${pageToken}` - ); - if (!res.ok) - throw new Error((await res.json()).message || "Failed to fetch"); - const data = await res.json(); - setTutorials((prev) => - append ? [...prev, ...data.tutorials] : data.tutorials - ); - setNextPageToken(data.nextPageToken); - setSearchHistory((prev) => - [objectName, ...prev.filter((term) => term !== objectName)].slice(0, 5) - ); - } catch (e) { - setError(e.message); - if (!append) setTutorials([]); - setNextPageToken(null); - } finally { - setLoading(false); - } - }, - [setError, setTutorials, setNextPageToken, setSearchHistory] -); + setNextPageToken(data.nextPageToken); + setSearchHistory((prev) => + [objectName, ...prev.filter((term) => term !== objectName)].slice(0, 5) + ); + } catch (e) { + setError(e.message); + if (!append) setTutorials([]); + setNextPageToken(null); + } finally { + setLoading(false); + } +}, [setError, setTutorials, setNextPageToken, setSearchHistory]); + + const handleSearch = (e) => { e.preventDefault(); diff --git a/client/src/index.css b/client/src/index.css index 3939072..4805f87 100644 --- a/client/src/index.css +++ b/client/src/index.css @@ -4,10 +4,11 @@ body { @apply overflow-x-hidden; + } html { - scroll-behavior: smooth; + overflow-y: scroll; } .glow { diff --git a/client/src/main.jsx b/client/src/main.jsx index f66fc31..981fd88 100644 --- a/client/src/main.jsx +++ b/client/src/main.jsx @@ -4,7 +4,7 @@ import ReactDOM from 'react-dom/client'; import { BrowserRouter } from 'react-router-dom'; import App from './App.jsx'; import './index.css'; -import { ThemeProvider } from './context/ThemeContext.jsx'; +import { ThemeProvider } from './context/ThemeProvider.jsx'; ReactDOM.createRoot(document.getElementById('root')).render(