From 7cfd257cdda5842ce71acd52fd0231c5c2aec1fd Mon Sep 17 00:00:00 2001 From: Erik Vroon Date: Sun, 10 Sep 2023 13:50:21 +0200 Subject: [PATCH] Improve responsiveness header (#250) --- frontend/src/components/navbar/_brand.tsx | 14 ++-- frontend/src/pages/_layout.tsx | 78 +++++++++---------- .../pages/tournaments/_tournament_layout.tsx | 12 ++- 3 files changed, 52 insertions(+), 52 deletions(-) diff --git a/frontend/src/components/navbar/_brand.tsx b/frontend/src/components/navbar/_brand.tsx index 3d657dc9..d1221d3b 100644 --- a/frontend/src/components/navbar/_brand.tsx +++ b/frontend/src/components/navbar/_brand.tsx @@ -12,16 +12,14 @@ export function Brand() { })} > - + { + await router.push('/'); + }} + > - { - await router.push('/'); - }} - > - Bracket - + Bracket diff --git a/frontend/src/pages/_layout.tsx b/frontend/src/pages/_layout.tsx index 41483522..e4a3d1ef 100644 --- a/frontend/src/pages/_layout.tsx +++ b/frontend/src/pages/_layout.tsx @@ -3,7 +3,7 @@ import { AppShell, Burger, Container, - Grid, + Group, Header, Menu, Text, @@ -13,7 +13,6 @@ import { useMantineColorScheme, useMantineTheme, } from '@mantine/core'; -import { useDisclosure } from '@mantine/hooks'; import { FaGithub } from '@react-icons/all-files/fa/FaGithub'; import { IconMoonStars, IconSun } from '@tabler/icons-react'; import { useRouter } from 'next/router'; @@ -86,29 +85,28 @@ interface HeaderActionProps { icon?: Component | null; links?: { link: string; label: string; icon?: ReactNode }[] | null; }[]; + navbarState: any; } -export function HeaderAction({ links }: HeaderActionProps) { +export function HeaderAction({ links, navbarState }: HeaderActionProps) { const { classes } = useStyles(); - const router = useRouter(); + + const [opened, { toggle }] = navbarState != null ? navbarState : [false, { toggle: () => {} }]; const { colorScheme, toggleColorScheme } = useMantineColorScheme(); - const [opened, { toggle }] = useDisclosure(false); + const router = useRouter(); const items = links.map((link) => { - const menuItems = link.links?.map((item) => ( - { - await router.push(item.link); - }} - > - - {item.icon} - {item.label} - - - )); - - if (menuItems) { + if (link.links) { + const menuItems = link.links?.map((item) => ( + { + await router.push(item.link); + }} + > + {item.label} + + )); return ( @@ -133,7 +131,6 @@ export function HeaderAction({ links }: HeaderActionProps) { return ( { @@ -145,29 +142,30 @@ export function HeaderAction({ links }: HeaderActionProps) { ); }); return ( -
- - - +
+ + + - - - - {items} - {/**/} - toggleColorScheme()} size={30} ml="1rem"> - {colorScheme === 'dark' ? : } - - - - + + + {items} + toggleColorScheme()} size={30} ml="1rem"> + {colorScheme === 'dark' ? : } + + +
); } -export default function Layout({ children, navbar }: any) { +export default function Layout({ children, navbar, navbarState }: any) { const theme = useMantineTheme(); return ( @@ -180,7 +178,7 @@ export default function Layout({ children, navbar }: any) { layout="default" navbarOffsetBreakpoint="sm" asideOffsetBreakpoint="sm" - header={} + header={} navbar={navbar} > {children} diff --git a/frontend/src/pages/tournaments/_tournament_layout.tsx b/frontend/src/pages/tournaments/_tournament_layout.tsx index 2bf4b7c4..13259d87 100644 --- a/frontend/src/pages/tournaments/_tournament_layout.tsx +++ b/frontend/src/pages/tournaments/_tournament_layout.tsx @@ -1,5 +1,6 @@ import { Navbar } from '@mantine/core'; -import React, { useState } from 'react'; +import { useDisclosure } from '@mantine/hooks'; +import React from 'react'; import { MainLinks } from '../../components/navbar/_main_links'; import { checkForAuthError, getTournaments } from '../../services/adapter'; @@ -7,7 +8,7 @@ import Layout from '../_layout'; function NavBar({ navBarOpened, links }: any) { return ( -