From ece083a136b9334cb40403280ccca42f56d0dba9 Mon Sep 17 00:00:00 2001 From: matushl Date: Sun, 12 Nov 2023 02:08:29 +0100 Subject: [PATCH] Refactor and improve TopGrid --- .../PageLayout/Banner/Banner.module.scss | 6 +- .../PageLayout/PageLayout.module.scss | 2 - src/components/PageLayout/PageLayout.tsx | 2 - .../PageLayout/TopGrid/TopGrid.module.scss | 9 ++- .../TopGrid/TopGrid.module.scss.d.ts | 1 + src/components/PageLayout/TopGrid/TopGrid.tsx | 56 ++++++++++--------- 6 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/components/PageLayout/Banner/Banner.module.scss b/src/components/PageLayout/Banner/Banner.module.scss index 3cc381c5..adcfcefd 100644 --- a/src/components/PageLayout/Banner/Banner.module.scss +++ b/src/components/PageLayout/Banner/Banner.module.scss @@ -1,8 +1,5 @@ .banner{ - position: fixed; width: 100vw; - top: 10rem; - left: 0; height: 2rem; background-color: black; color: white; @@ -10,7 +7,8 @@ display: flex; align-items: center; padding: 0px; - z-index: 2; + z-index: 3; + margin-bottom: 0.5rem; } diff --git a/src/components/PageLayout/PageLayout.module.scss b/src/components/PageLayout/PageLayout.module.scss index 86c0fcc8..7429dc9c 100644 --- a/src/components/PageLayout/PageLayout.module.scss +++ b/src/components/PageLayout/PageLayout.module.scss @@ -5,8 +5,6 @@ .grid { display: grid; grid-template-columns: repeat(4, 1fr); - // top offset because of sticky menu/title/banner - padding-top: 12rem; // bottom offset because of sticky debug footer padding-bottom: 1rem; } diff --git a/src/components/PageLayout/PageLayout.tsx b/src/components/PageLayout/PageLayout.tsx index 2991dfcf..58900e72 100644 --- a/src/components/PageLayout/PageLayout.tsx +++ b/src/components/PageLayout/PageLayout.tsx @@ -4,7 +4,6 @@ import {FC, ReactNode} from 'react' import {BannerContainer} from '@/utils/BannerContainer' import {PageTitleContainer} from '@/utils/PageTitleContainer' -import {Banner} from './Banner/Banner' import {Footer} from './Footer/Footer' import {MenuMain} from './MenuMain/MenuMain' import styles from './PageLayout.module.scss' @@ -25,7 +24,6 @@ export const PageLayout: FC = ({contentWidth = 2, title = '', c
-
diff --git a/src/components/PageLayout/TopGrid/TopGrid.module.scss b/src/components/PageLayout/TopGrid/TopGrid.module.scss index 2cf9ddb9..e4f15c2f 100644 --- a/src/components/PageLayout/TopGrid/TopGrid.module.scss +++ b/src/components/PageLayout/TopGrid/TopGrid.module.scss @@ -1,13 +1,16 @@ .container { - position: fixed; + position: sticky; top: 0; left: 0; right: 0; - height: 10rem; + height: auto; background-color: white; z-index: 3; +} + +.grid { display: grid; - grid-template: 1fr 1fr / 1fr 2fr 1fr; + grid-template: 1fr auto / 1fr 2fr 1fr; } .menu { diff --git a/src/components/PageLayout/TopGrid/TopGrid.module.scss.d.ts b/src/components/PageLayout/TopGrid/TopGrid.module.scss.d.ts index 4cc72d4d..0a06808a 100644 --- a/src/components/PageLayout/TopGrid/TopGrid.module.scss.d.ts +++ b/src/components/PageLayout/TopGrid/TopGrid.module.scss.d.ts @@ -1,6 +1,7 @@ export type Styles = { active: string container: string + grid: string menu: string menuItem: string semesterPicker: string diff --git a/src/components/PageLayout/TopGrid/TopGrid.tsx b/src/components/PageLayout/TopGrid/TopGrid.tsx index f4011b14..6ed9e9e5 100644 --- a/src/components/PageLayout/TopGrid/TopGrid.tsx +++ b/src/components/PageLayout/TopGrid/TopGrid.tsx @@ -1,4 +1,4 @@ -import {Typography} from '@mui/material' +import {Stack, Typography} from '@mui/material' import clsx from 'clsx' import Link from 'next/link' import {useRouter} from 'next/router' @@ -8,6 +8,7 @@ import {SemesterPicker} from '@/components/SemesterPicker/SemesterPicker' import {PageTitleContainer} from '@/utils/PageTitleContainer' import {useSeminarInfo} from '@/utils/useSeminarInfo' +import {Banner} from '../Banner/Banner' import styles from './TopGrid.module.scss' export const TopGrid: FC = () => { @@ -19,32 +20,35 @@ export const TopGrid: FC = () => { const {pageTitle} = PageTitleContainer.useContainer() return ( -
-
-
- - Malynár - -
-
- - Matik - -
-
- - Strom - + +
+
+
+ + Malynár + +
+
+ + Matik + +
+
+ + Strom + +
+ + {pageTitle} + + {(page === 'zadania' || page === 'vysledky') && ( +
+ +
+ )}
- - {pageTitle} - - {(page === 'zadania' || page === 'vysledky') && ( -
- -
- )} -
+ + ) }