From 7e4da741ec4a526c08bf3705b83999dd6bcec0c8 Mon Sep 17 00:00:00 2001 From: Maksym Sadovnychyy Date: Fri, 20 May 2022 22:31:34 +0200 Subject: [PATCH] (feat): layout refactoring --- clientapp/src/App.tsx | 10 +- clientapp/src/layouts/public/Footer/index.tsx | 3 +- clientapp/src/layouts/public/index.tsx | 6 +- clientapp/src/pages/Blog/Catalog/index.tsx | 27 +- .../src/pages/Blog/SideWidgets/index.tsx | 5 + clientapp/src/pages/Home/index.tsx | 317 +++++++++++------- 6 files changed, 229 insertions(+), 139 deletions(-) create mode 100644 clientapp/src/pages/Blog/SideWidgets/index.tsx diff --git a/clientapp/src/App.tsx b/clientapp/src/App.tsx index f4b9561..bc91557 100644 --- a/clientapp/src/App.tsx +++ b/clientapp/src/App.tsx @@ -1,5 +1,5 @@ import React, { FC, useEffect } from 'react' -import { Route, Routes } from 'react-router' +import { Route, Routes, useLocation } from 'react-router' //Redux import { useSelector, useDispatch } from 'react-redux' @@ -36,6 +36,7 @@ const NestedRoutes = (routes: IRoute[], tag: string | undefined = undefined) => const App: FC = () => { + const { pathname } = useLocation() const dispatch = useDispatch() const { routes, adminRoutes, serviceRoutes } = useSelector((state: IReduxState) => state.settings) @@ -43,6 +44,13 @@ const App: FC = () => { dispatch(settingsActionCreators.requestSettings()) }, []) + useEffect(() => { + window.scrollTo({ + top: 0, + behavior: 'smooth', + }) + }, [pathname]) + return <> { NestedRoutes(routes, 'PublicLayout') } diff --git a/clientapp/src/layouts/public/Footer/index.tsx b/clientapp/src/layouts/public/Footer/index.tsx index b39422e..2f66c81 100644 --- a/clientapp/src/layouts/public/Footer/index.tsx +++ b/clientapp/src/layouts/public/Footer/index.tsx @@ -6,10 +6,9 @@ import { IReduxState } from '../../../interfaces' const Footer = () => { let { siteName } = useSelector((state: IReduxState) => state.settings) - return