From c6b47c0d16694d9769ab410ac33c1ba979818d88 Mon Sep 17 00:00:00 2001 From: rtrembecky Date: Fri, 22 Nov 2024 22:53:27 +0100 Subject: [PATCH 1/2] fix #386 - restyle Results --- src/components/Results/Results.tsx | 8 ++- src/components/Results/ResultsRow.tsx | 41 +++++++----- src/theme.ts | 89 +++++++++++++++++++++++++++ 3 files changed, 121 insertions(+), 17 deletions(-) diff --git a/src/components/Results/Results.tsx b/src/components/Results/Results.tsx index 595df33d..9396b086 100644 --- a/src/components/Results/Results.tsx +++ b/src/components/Results/Results.tsx @@ -37,7 +37,13 @@ export const Results: FC = () => { return (
{resultsIsLoading && } - + {results.map((result, index) => ( ))} diff --git a/src/components/Results/ResultsRow.tsx b/src/components/Results/ResultsRow.tsx index a32f443e..3d2b2dad 100644 --- a/src/components/Results/ResultsRow.tsx +++ b/src/components/Results/ResultsRow.tsx @@ -1,4 +1,4 @@ -import {Box, Stack, Typography} from '@mui/material' +import {Box, Stack, Theme, Typography, useMediaQuery} from '@mui/material' import Tooltip from '@mui/material/Tooltip' import {FC} from 'react' @@ -42,9 +42,11 @@ export interface Result { export const ResultsRow: FC<{result: Result}> = ({result}) => { const {solutions, rank_changed, rank_start, registration, subtotal, total} = result + const smUp = useMediaQuery((theme) => theme.breakpoints.up('sm')) + return ( // `display: 'contents'` je taka HTML verzia fragmentu - tento div sa v strukture nepocita pre ucely parent gridu, - // miesto toho sa pouzivaju jednotlive children. preto aj hover tu targetuje children divy, lebo parent v podstate nema velkost + // miesto toho sa pouzivaju jednotlive children. preto aj hover tu targetuje children divy, lebo parent v podstate nema velkost. // takisto `justifyContent: 'center'` je na vsetkych elementoch osobitne div': {bgcolor: 'black', color: 'white'}}}> = ({result}) => { pl: 1, }} > - - {rank_changed && rank_start + '.'} - + {rank_changed && rank_start + '.'} - - + + {registration.profile.first_name + ' ' + registration.profile.last_name} - - {registration.school.name + ' ' + registration.school.street + ' ' + registration.school.city} + + {smUp + ? `${registration.school.name} ${registration.school.street} ${registration.school.city}` + : registration.school.abbreviation} - + {/* reused resultsName font */} + {registration.grade.tag} - + {solutions.map((series, index) => ( {series.map((solution, index) => ( - + {solution.points} ))} - + {subtotal[index]} @@ -95,9 +106,7 @@ export const ResultsRow: FC<{result: Result}> = ({result}) => { pr: 1, }} > - - {total} - + {total} diff --git a/src/theme.ts b/src/theme.ts index c02adc28..b8a58c65 100644 --- a/src/theme.ts +++ b/src/theme.ts @@ -12,6 +12,11 @@ declare module '@mui/material/styles' { postTitle: React.CSSProperties postBody: React.CSSProperties postDate: React.CSSProperties + resultsOrder: React.CSSProperties + resultsName: React.CSSProperties + resultsSchool: React.CSSProperties + resultsScore: React.CSSProperties + resultsTotal: React.CSSProperties } // allow configuration using `createTheme` @@ -24,6 +29,11 @@ declare module '@mui/material/styles' { postTitle?: React.CSSProperties postBody?: React.CSSProperties postDate?: React.CSSProperties + resultsOrder?: React.CSSProperties + resultsName?: React.CSSProperties + resultsSchool?: React.CSSProperties + resultsScore?: React.CSSProperties + resultsTotal?: React.CSSProperties } } @@ -38,6 +48,11 @@ declare module '@mui/material/Typography' { postTitle: true postBody: true postDate: true + resultsOrder: true + resultsName: true + resultsSchool: true + resultsScore: true + resultsTotal: true // disable these variants h4: false h5: false @@ -146,6 +161,30 @@ const _theme = createTheme({ textTransform: 'uppercase', fontWeight: 300, }, + resultsOrder: { + ...font.style, + fontWeight: 800, + fontStyle: 'italic', + }, + resultsName: { + ...font.style, + textTransform: 'uppercase', + fontWeight: 800, + fontStyle: 'italic', + }, + resultsSchool: { + ...font.style, + fontWeight: 400, + }, + resultsScore: { + ...font.style, + fontWeight: 400, + }, + resultsTotal: { + ...font.style, + fontWeight: 800, + fontStyle: 'italic', + }, }, components: { MuiTypography: { @@ -161,6 +200,11 @@ const _theme = createTheme({ postTitle: 'h1', postBody: 'span', postDate: 'span', + resultsOrder: 'span', + resultsName: 'span', + resultsSchool: 'span', + resultsScore: 'span', + resultsTotal: 'span', }, }, }, @@ -335,5 +379,50 @@ export const theme: Theme = { [xl]: {fontSize: pxToRem(20)}, lineHeight: 1.5, }, + resultsOrder: { + ..._theme.typography.resultsOrder, + fontSize: pxToRem(20), // design + [sm]: {fontSize: pxToRem(26)}, + [md]: {fontSize: pxToRem(26)}, + [lg]: {fontSize: pxToRem(32)}, + [xl]: {fontSize: pxToRem(48)}, // design + lineHeight: 1.5, + }, + resultsName: { + ..._theme.typography.resultsName, + fontSize: pxToRem(11), // design + [sm]: {fontSize: pxToRem(16)}, + [md]: {fontSize: pxToRem(20)}, + [lg]: {fontSize: pxToRem(24)}, + [xl]: {fontSize: pxToRem(30)}, // design + lineHeight: 1.5, + }, + resultsSchool: { + ..._theme.typography.resultsSchool, + fontSize: pxToRem(10), // design + [sm]: {fontSize: pxToRem(11)}, + [md]: {fontSize: pxToRem(12)}, + [lg]: {fontSize: pxToRem(13)}, + [xl]: {fontSize: pxToRem(14)}, // design + lineHeight: 1.5, + }, + resultsScore: { + ..._theme.typography.resultsScore, + fontSize: pxToRem(10), // design + [sm]: {fontSize: pxToRem(12)}, + [md]: {fontSize: pxToRem(14)}, + [lg]: {fontSize: pxToRem(16)}, + [xl]: {fontSize: pxToRem(18)}, // design + lineHeight: 1.5, + }, + resultsTotal: { + ..._theme.typography.resultsTotal, + fontSize: pxToRem(20), // design + [sm]: {fontSize: pxToRem(22)}, + [md]: {fontSize: pxToRem(24)}, + [lg]: {fontSize: pxToRem(26)}, + [xl]: {fontSize: pxToRem(30)}, // design + lineHeight: 1.5, + }, }, } From 318ca28f3738a1a5adc47da8152b8e59e145b5a8 Mon Sep 17 00:00:00 2001 From: matushl Date: Fri, 22 Nov 2024 23:49:11 +0100 Subject: [PATCH 2/2] Add margins --- src/components/Results/Results.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Results/Results.tsx b/src/components/Results/Results.tsx index 9396b086..2d92e0b8 100644 --- a/src/components/Results/Results.tsx +++ b/src/components/Results/Results.tsx @@ -41,6 +41,7 @@ export const Results: FC = () => { sx={{ display: 'grid', rowGap: {xs: '6px', sm: '10px'}, + mx: {xs: 1, sm: 3, md: undefined}, gridTemplateColumns: 'max-content 1fr repeat(3, max-content)', }} >