From 1f3ad14be003bc7ff7f80a03dd76714416598bc7 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Fri, 29 Jul 2022 00:36:15 +0200 Subject: [PATCH] Feat: better style --- src/components/Header.tsx | 4 ++-- src/data/Context.tsx | 9 +++++++++ src/pages/CalendarPage.tsx | 9 +++++---- src/pages/SpeedFlowchartPage.tsx | 25 +++++++++++++++++-------- src/utils/ContextWrapper.tsx | 8 +++++++- src/utils/PageTemplate.tsx | 5 ++++- 6 files changed, 44 insertions(+), 16 deletions(-) diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 7e9af58..adc2b24 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -16,10 +16,10 @@ import { Context } from '../data/Context'; * @return {JSX.Element} */ export default function Header() { - const { title } = useContext(Context); + const { title, containerMaxWidth } = useContext(Context); return ( - + diff --git a/src/data/Context.tsx b/src/data/Context.tsx index b48d7ad..a52e2c2 100644 --- a/src/data/Context.tsx +++ b/src/data/Context.tsx @@ -1,3 +1,4 @@ +import { Breakpoint } from '@mui/material/styles'; import { createContext } from 'react'; import { DigitalrockAPi } from './DigitalrockApi'; @@ -10,6 +11,9 @@ export const Context = createContext<{ title: string; setTitle: (title: string) => void; + + containerMaxWidth: false | Breakpoint | undefined; + setContainerMaxWidth: (maxWidth: false | Breakpoint | undefined) => void; }>({ api: new DigitalrockAPi(), @@ -17,4 +21,9 @@ export const Context = createContext<{ setTitle: () => { return; }, + + containerMaxWidth: 'lg', + setContainerMaxWidth: () => { + return; + }, }); diff --git a/src/pages/CalendarPage.tsx b/src/pages/CalendarPage.tsx index 26e7183..2250ca8 100644 --- a/src/pages/CalendarPage.tsx +++ b/src/pages/CalendarPage.tsx @@ -23,11 +23,12 @@ export default function CalendarPage() { React.useState(); const [filter, setFilter] = React.useState(); - const { api, setTitle } = React.useContext(Context); + const { api, setTitle, setContainerMaxWidth } = React.useContext(Context); const navigate = useNavigate(); React.useEffect(() => { setTitle('DAV calendar'); + setContainerMaxWidth('lg'); }, []); React.useEffect(() => { @@ -62,8 +63,8 @@ export default function CalendarPage() { return ( <> - - + + {filteredCompetitions?.map(competition => ( - + diff --git a/src/pages/SpeedFlowchartPage.tsx b/src/pages/SpeedFlowchartPage.tsx index 131ae59..4579397 100644 --- a/src/pages/SpeedFlowchartPage.tsx +++ b/src/pages/SpeedFlowchartPage.tsx @@ -13,7 +13,7 @@ import { Card, CardContent, Grid, Skeleton, Typography } from '@mui/material'; */ export default function SpeedFlowchartPage() { const { competitionId, categoryId } = useParams(); - const { api, setTitle } = useContext(Context); + const { api, setTitle, setContainerMaxWidth } = useContext(Context); const [loading, setLoading] = useState(true); const [flowchartResult, setFlowchartResult] = @@ -24,6 +24,7 @@ export default function SpeedFlowchartPage() { return; } setTitle(''); + setContainerMaxWidth(false); api.getCompetitionResults(competitionId, categoryId).then(r => { setTitle( @@ -55,19 +56,26 @@ export default function SpeedFlowchartPage() { xs={12} md={12 / flowchartResult.rounds.length} > -

{round.roundName}

- + + + {round.roundName} + + + + {round.pairs.map((pair, pairKey) => ( - + A: {pair.laneA?.participant.firstName}{' '} @@ -77,6 +85,7 @@ export default function SpeedFlowchartPage() { B: {pair.laneB?.participant.firstName}{' '} diff --git a/src/utils/ContextWrapper.tsx b/src/utils/ContextWrapper.tsx index fa096f6..42944ae 100644 --- a/src/utils/ContextWrapper.tsx +++ b/src/utils/ContextWrapper.tsx @@ -1,3 +1,4 @@ +import { Breakpoint } from '@mui/material/styles'; import React from 'react'; import { Context } from '../data/Context'; import { DigitalrockAPi } from '../data/DigitalrockApi'; @@ -12,9 +13,14 @@ export default function ContextWrapper(props: { children: JSX.Element }) { const api = new DigitalrockAPi(); const [title, setTitle] = React.useState(''); + const [containerMaxWidth, setContainerMaxWidth] = React.useState< + false | Breakpoint | undefined + >('lg'); return ( - + {children} ); diff --git a/src/utils/PageTemplate.tsx b/src/utils/PageTemplate.tsx index 77941dd..ba317db 100644 --- a/src/utils/PageTemplate.tsx +++ b/src/utils/PageTemplate.tsx @@ -1,4 +1,6 @@ import Container from '@mui/material/Container'; +import React from 'react'; +import { Context } from '../data/Context'; import LocalizationProviderWrapper from './LocalizationProviderWrapper'; /** @@ -8,13 +10,14 @@ import LocalizationProviderWrapper from './LocalizationProviderWrapper'; */ export default function PageTemplate(props: { children: JSX.Element }) { const { children } = props; + const { containerMaxWidth } = React.useContext(Context); return ( {children}