Skip to content

[front] chore: upgrade Material UI to version 6 #2078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 29 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4329cf8
[front] chore: update mui packages
GresilleSiffle Apr 11, 2025
07eef35
[front] chore: update mui packages to 5.17.1
GresilleSiffle Apr 11, 2025
3fa4928
[front] chore: run yarn upgrade
GresilleSiffle Apr 11, 2025
f9183f3
[front] chore: upgrade typescript to 4.9
GresilleSiffle Apr 11, 2025
4898b22
Merge branch 'main' into front-update_mui
GresilleSiffle Apr 18, 2025
150f558
fix previous commit
GresilleSiffle Apr 18, 2025
94c773e
[front] chore: upgrade Material UI to version 6
GresilleSiffle Apr 18, 2025
49e3860
migrate ListItemText
GresilleSiffle Apr 18, 2025
d0989ab
migrate Menu
GresilleSiffle Apr 18, 2025
5025954
fix: duplicate definition of borderRadius
GresilleSiffle Apr 18, 2025
6fdb6ee
migrate TextField
GresilleSiffle Apr 18, 2025
21ebba8
migrate Typography
GresilleSiffle Apr 18, 2025
d7f1da7
fix side effect created by codemod deprecations/typography-props
GresilleSiffle Apr 18, 2025
fb618e8
fix: use Grid2 in Profile.tsx and fix side effect caused by codemod
GresilleSiffle Apr 18, 2025
6c299e6
fix: use Grid2 in Account.tsx and fix side effect caused by codemod
GresilleSiffle Apr 18, 2025
e95d161
fix: use Grid2 in Preferences.tsx and fix side effect caused by codemod
GresilleSiffle Apr 18, 2025
036e7d6
refactor: simplify how extra sx is handled in some components
GresilleSiffle Apr 18, 2025
7699121
fix: use the latest v6 mui package
GresilleSiffle Apr 18, 2025
be0e51c
use Grid2 instead of Grid in EntitySelector and EntitySelectorControls
GresilleSiffle Apr 18, 2025
64295f0
yarn upgrade
GresilleSiffle Apr 18, 2025
3d2499a
use Grid2 instead of Grid in EntityCardTitle and CreateVoucherForm
GresilleSiffle Apr 18, 2025
d4a5c04
replace 16px by 2
GresilleSiffle Apr 18, 2025
5525cfd
fix: custom style not being applied to TournesolScore
GresilleSiffle Apr 18, 2025
f1c9a8c
fix the tests
GresilleSiffle Apr 18, 2025
1fad727
replace Grid by Grid2 in the user preferences pages
GresilleSiffle Apr 18, 2025
b135ca0
replace Grid by Grid2 in the user preferences pages
GresilleSiffle Apr 18, 2025
90d20e3
replace Grid by Grid2 in several components
GresilleSiffle Apr 18, 2025
aa43e42
Merge branch 'main' into upgrade_mui_to_v6
GresilleSiffle Apr 25, 2025
020be17
chore: run npx @mui/codemod@latest v6.0.0/sx-prop
GresilleSiffle Apr 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"dependencies": {
"@emotion/react": "^11.7.1",
"@emotion/styled": "^11.6.0",
"@mui/icons-material": "^5.17.1",
"@mui/material": "^5.17.1",
"@mui/styles": "^5.17.1",
"@mui/icons-material": "^6.4.11",
"@mui/material": "^6.4.11",
"@mui/styles": "^6.4.11",
"@react-hook/resize-observer": "^1.2.5",
"@reduxjs/toolkit": "^1.7.1",
"@types/react": "^17",
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/app/PollRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ const PollRoutes = ({ pollName }: Props) => {

if (pollName !== currentPollName || !isReady) {
return (
<Box m={4} textAlign="center">
<Box
sx={{
m: 4,
textAlign: 'center',
}}
>
<CircularProgress color="secondary" size={50} />
</Box>
);
Expand Down
18 changes: 10 additions & 8 deletions frontend/src/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ const CustomCard = ({ children, sx, ...props }: Props) => {
return (
<Card
{...props}
sx={{
background: '#FFFFFF',
border: '1px solid #DCD8CB',
boxShadow:
'0px 0px 8px rgba(0, 0, 0, 0.02), 0px 2px 4px rgba(0, 0, 0, 0.05)',
borderRadius: '4px',
...(sx || {}),
}}
sx={[
{
background: '#FFFFFF',
border: '1px solid #DCD8CB',
boxShadow:
'0px 0px 8px rgba(0, 0, 0, 0.02), 0px 2px 4px rgba(0, 0, 0, 0.05)',
borderRadius: '4px',
},
sx || {},
]}
>
{children}
</Card>
Expand Down
24 changes: 16 additions & 8 deletions frontend/src/components/CollapseButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,22 @@ const CollapseButton = ({
aria-expanded={expanded}
aria-label="show more"
onClick={onClick}
sx={{
padding: '0 8px',
fontSize: variant === 'mainOptions' ? '1.1rem' : undefined,
color:
expanded || variant == 'mainOptions'
? theme.palette.secondary.main
: theme.palette.action.active,
}}
sx={[
{
padding: '0 8px',
color:
expanded || variant == 'mainOptions'
? theme.palette.secondary.main
: theme.palette.action.active,
},
variant === 'mainOptions'
? {
fontSize: '1.1rem',
}
: {
fontSize: null,
},
]}
>
{children}
</Button>
Expand Down
12 changes: 7 additions & 5 deletions frontend/src/components/ContentBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ const ContentBox = ({

return (
<Box
px={[noMinPaddingX ? 0 : 2, 2, 3]}
py={2}
// Push the global footer away, to avoid displaying it in the middle
// of the screen.
minHeight={`calc(100vh - ${topBarHeight}px)`}
sx={{
px: [noMinPaddingX ? 0 : 2, 2, 3],
py: 2,
// Push the global footer away, to avoid displaying it in the middle
// of the screen.
minHeight: `calc(100vh - ${topBarHeight}px)`,
}}
>
<Container maxWidth={maxWidth} disableGutters>
{children}
Expand Down
26 changes: 23 additions & 3 deletions frontend/src/components/ContentHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,20 @@ const ContentHeader = ({
chipLabel?: string;
}) => {
return (
<Box px={[2, 4]} pt={2} color="text.secondary">
<Grid container spacing={1} justifyContent="space-between">
<Box
sx={{
px: [2, 4],
pt: 2,
color: 'text.secondary',
}}
>
<Grid
container
spacing={1}
sx={{
justifyContent: 'space-between',
}}
>
<Grid item>
<Typography
variant="h4"
Expand Down Expand Up @@ -53,7 +65,15 @@ const ContentHeader = ({
</>
)}
</Grid>
{subtitle && <Typography mt={1}>{subtitle}</Typography>}
{subtitle && (
<Typography
sx={{
mt: 1,
}}
>
{subtitle}
</Typography>
)}
</Box>
);
};
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/components/CriteriaIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ const CriteriaIcon = ({
>
<Tooltip title={tooltipTitle}>
{emoji ? (
<Box fontSize={emojiSize}>{emoji}</Box>
<Box
sx={{
fontSize: emojiSize,
}}
>
{emoji}
</Box>
) : (
<img src={imagePath} width={imgWidth} alt={criteriaLabel} />
)}
Expand Down
15 changes: 13 additions & 2 deletions frontend/src/components/DialogBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,20 @@ const DialogBox = ({
>
{title}
</DialogTitle>
<Box py={2} px={3}>
<Box
sx={{
py: 2,
px: 3,
}}
>
<Box>{content}</Box>
<Box display="flex" justifyContent="flex-end" gap={1}>
<Box
sx={{
display: 'flex',
justifyContent: 'flex-end',
gap: 1,
}}
>
{additionalActionButton}
<Button variant="contained" onClick={handleClose}>
{t('dialogBox.continue')}
Expand Down
16 changes: 11 additions & 5 deletions frontend/src/components/LanguageSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ const LanguageSelector = ({ languageName = true }: LanguageSelectorProps) => {
const currentLanguage = i18n.resolvedLanguage || i18n.language;

return (
<Box color="neutral.main">
<Box
sx={{
color: 'neutral.main',
}}
>
<MenuButton
startIcon={<Language />}
sx={{
Expand Down Expand Up @@ -60,10 +64,12 @@ const LanguageSelector = ({ languageName = true }: LanguageSelectorProps) => {
>
{languageName && (
<Box
flexGrow={1}
textAlign="left"
fontWeight="bold"
sx={{ textTransform: 'capitalize' }}
sx={{
flexGrow: 1,
textAlign: 'left',
fontWeight: 'bold',
textTransform: 'capitalize',
}}
>
{codeToLanguage[currentLanguage]?.name ?? currentLanguage}
</Box>
Expand Down
17 changes: 15 additions & 2 deletions frontend/src/components/LegalDocument.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,23 @@ const ContentBoxLegalDocument = ({
}: LegalDocumentProps) => {
return (
<ContentBox maxWidth="md">
<Typography variant="h3" textAlign="center" mt={2} mb={4}>
<Typography
variant="h3"
sx={{
textAlign: 'center',
mt: 2,
mb: 4,
}}
>
{mainTitle}
</Typography>
<Box display="flex" flexDirection="column" gap={4}>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
gap: 4,
}}
>
{children}
</Box>
</ContentBox>
Expand Down
21 changes: 14 additions & 7 deletions frontend/src/components/LoaderWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,21 @@ const LoaderWrapper = ({
return (
<>
{isLoading && circularProgress && (
<Box position="relative" width="100%">
<Box
sx={{
position: 'relative',
width: '100%',
}}
>
<Box
position="absolute"
display="flex"
width="100%"
minHeight="100px"
alignItems="center"
justifyContent="center"
sx={{
position: 'absolute',
display: 'flex',
width: '100%',
minHeight: '100px',
alignItems: 'center',
justifyContent: 'center',
}}
>
<CircularProgress size={50} />
</Box>
Expand Down
16 changes: 9 additions & 7 deletions frontend/src/components/MenuButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Button, Menu } from '@mui/material';
import { Button, Menu, Theme } from '@mui/material';
import { ArrowDropDown } from '@mui/icons-material';

interface Props {
Expand Down Expand Up @@ -40,14 +40,16 @@ const MenuButton = ({
open={Boolean(anchorEl)}
anchorEl={anchorEl}
onClose={closeMenu}
MenuListProps={{
onClick: () => closeMenu(),
sx: {
backgroundColor: (t) => t.palette.background.menu,
'& .MuiListItemIcon-root': { color: '#CDCABC' },
{...menuProps}
slotProps={{
list: {
onClick: () => closeMenu(),
sx: {
backgroundColor: (t: Theme) => t.palette.background.menu,
'& .MuiListItemIcon-root': { color: '#CDCABC' },
},
},
}}
{...menuProps}
>
{menuContent}
</Menu>
Expand Down
22 changes: 15 additions & 7 deletions frontend/src/components/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ const Pagination = ({
flexWrap: 'wrap',
}}
>
<Box width="100%" display="flex" justifyContent="center">
<Box
sx={{
width: '100%',
display: 'flex',
justifyContent: 'center',
}}
>
<Typography variant="body2">
<Trans t={t} i18nKey="pagination.showingCounts" count={count}>
Showing {{ firstElementIdx }} - {{ lastElementIdx }} of {{ count }}
Expand All @@ -104,12 +110,14 @@ const Pagination = ({
}}
/>
<Box
width="100%"
display="flex"
justifyContent="center"
alignItems="center"
flexWrap="wrap"
gap={1}
sx={{
width: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
flexWrap: 'wrap',
gap: 1,
}}
>
<Button
id="pagination_1_prev"
Expand Down
20 changes: 11 additions & 9 deletions frontend/src/components/SettingsSection.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { Box, Divider, Grid, Typography } from '@mui/material';
import { Box, Divider, Grid2, Typography } from '@mui/material';

const SettingsSection = ({
title,
Expand All @@ -25,17 +25,19 @@ const SettingsSection = ({
);

return (
<Grid item container>
<Grid item xs={12}>
<Box marginBottom={2}>
<Grid2 container>
<Grid2 size={{ xs: 12 }}>
<Box
sx={{
marginBottom: 2,
}}
>
{sectionTitle}
<Divider />
</Box>
</Grid>
<Grid item {...rest}>
{children}
</Grid>
</Grid>
</Grid2>
<Grid2 size={rest}>{children}</Grid2>
</Grid2>
);
};

Expand Down
14 changes: 10 additions & 4 deletions frontend/src/components/TitledPaper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ const TitledPaper = ({
<Paper sx={sx}>
<Box
id={titleId}
p={2}
color="#fff"
bgcolor="background.emphatic"
sx={{
p: 2,
color: '#fff',
bgcolor: 'background.emphatic',
borderTopLeftRadius: 'inherit',
borderTopRightRadius: 'inherit',
}}
Expand All @@ -38,7 +38,13 @@ const TitledPaper = ({
title
)}
</Box>
<Box p={contentBoxPadding}>{children}</Box>
<Box
sx={{
p: contentBoxPadding,
}}
>
{children}
</Box>
</Paper>
);
};
Expand Down
Loading
Loading