Skip to content
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

Updates MUI to v6 with Pigment CSS #19

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
8 changes: 4 additions & 4 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
"preview": "vite preview"
},
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@mui/icons-material": "5.15.21",
"@mui/material": "^5.15.21",
"@mui/icons-material": "^6.0.2",
"@mui/material": "^6.0.2",
"@mui/material-pigment-css": "^6.0.2",
"axios": "^1.7.4",
"classnames": "^2.5.1",
"dayjs": "^1.11.11",
Expand All @@ -37,6 +36,7 @@
"zustand": "^4.5.4"
},
"devDependencies": {
"@pigment-css/vite-plugin": "^0.0.22",
"@types/classnames": "^2.3.1",
"@types/node": "^20.14.9",
"@types/qs": "^6.9.15",
Expand Down
7 changes: 2 additions & 5 deletions frontend/src/app/components/accordion/Accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {
AccordionProps,
Accordion as MuiAccordion,
styled,
} from "@mui/material";
import { AccordionProps, Accordion as MuiAccordion } from "@mui/material";
import { styled } from "@mui/material-pigment-css";
import style from "@styles/style.module.scss";

const StyledMuiAccordion = styled(MuiAccordion)({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import CaretIcon from "@icons/CaretIcon";
import {
AccordionSummaryProps,
AccordionSummary as MuiAccordionSummary,
styled,
} from "@mui/material";
import { styled } from "@mui/material-pigment-css";
import style from "@styles/style.module.scss";

const StyledMuiAccordionSummary = styled(MuiAccordionSummary)({
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/components/button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ButtonProps, Button as MuiButton, styled } from "@mui/material";
import { ButtonProps, Button as MuiButton } from "@mui/material";
import { styled } from "@mui/material-pigment-css";
import style from "@styles/style.module.scss";

const StyledMuiButton = styled(MuiButton)({
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/components/dialog/Dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Slide from "@components/slide/Slide";
import { DialogProps, Dialog as MuiDialog, styled } from "@mui/material";
import { DialogProps, Dialog as MuiDialog } from "@mui/material";
import { styled } from "@mui/material-pigment-css";
import style from "@styles/style.module.scss";

const StyledMuiDialog = styled(MuiDialog)({
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/components/link/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ExternalLinkOutlined from "@icons/ExternalLinkOutlined";
import { LinkProps, Link as MuiLink, styled } from "@mui/material";
import { LinkProps, Link as MuiLink } from "@mui/material";
import { styled } from "@mui/material-pigment-css";
import style from "@styles/style.module.scss";

const StyledMuiLink = styled(MuiLink)({
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/components/switch/Switch.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Switch as MuiSwitch, styled, SwitchProps } from "@mui/material";
import { Switch as MuiSwitch, SwitchProps } from "@mui/material";
import { styled } from "@mui/material-pigment-css";
import style from "@styles/style.module.scss";

const StyledMuiSwitch = styled(MuiSwitch)({
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/components/tableRow/TableRow.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
TableRow as MuiTableRow,
styled,
TableCell,
TableRowProps,
} from "@mui/material";
import { styled } from "@mui/material-pigment-css";
import style from "@styles/style.module.scss";

interface ITableRow extends TableRowProps {
Expand Down
7 changes: 2 additions & 5 deletions frontend/src/app/components/textField/TextField.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {
TextField as MuiTextField,
TextFieldProps,
styled,
} from "@mui/material";
import { TextField as MuiTextField, TextFieldProps } from "@mui/material";
import { styled } from "@mui/material-pigment-css";
import style from "@styles/style.module.scss";
import { ChangeEvent } from "react";

Expand Down
7 changes: 4 additions & 3 deletions frontend/src/app/components/uikit/uikitColor/UikitColor.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Grid, Palette, PaletteColor, useTheme } from "@mui/material";
import { Palette, PaletteColor } from "@mui/material";
import Grid from "@mui/material/Grid2";
import { useTheme } from "@mui/material-pigment-css";
import { useCallback, useMemo } from "react";

interface IUikitColor {
Expand All @@ -15,9 +17,8 @@ export default function UikitColor({ color }: IUikitColor) {
const colorItem = useCallback((bgColor: string, label: string) => {
return (
<Grid
item
className="flex align-center justify-center"
xs
// xs
height={50}
bgcolor={bgColor}
>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/pages/uikit/UiKit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import Typography from "@components/typography/Typography";
import UikitBlock from "@components/uikit/uikitBlock/UikitBlock";
import UikitColor from "@components/uikit/uikitColor/UikitColor";
import UikitNav, { INavItem } from "@components/uikit/uikitNav/UikitNav";
import { Grid, TextField } from "@mui/material";
import Grid from "@mui/material/Grid2";
import { TextField } from "@mui/material";
import { useCallback, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { ValidationError } from "yup";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { createTheme } from "@mui/material";
import style from "@styles/style.module.scss";
// import style from "@/styles/style.module.scss";
luisdlopez marked this conversation as resolved.
Show resolved Hide resolved

const parseMedia = (media: string) => parseInt(media.replace("px", ""));
// const parseMedia = (media: string) => parseInt(media.replace("px", ""));

const theme = createTheme({
const theme = createTheme(
{
cssVariables: true,
},
/* {
breakpoints: {
values: {
xs: parseMedia(style["media-xs"]),
Expand Down Expand Up @@ -31,6 +35,7 @@ const theme = createTheme({
contrastText: style["basic-brightest"],
},
},
});
} */
);

export default theme;
8 changes: 3 additions & 5 deletions frontend/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { ThemeProvider } from "@emotion/react";
import { StrictMode } from "react";
import * as ReactDOM from "react-dom/client";
import { HelmetProvider } from "react-helmet-async";
import App from "./App";
import theme from "./app/shared/theme";

import "@mui/material-pigment-css/styles.css";

ReactDOM.createRoot(
document.getElementById("root") as ReactDOM.Container,
).render(
<StrictMode>
<HelmetProvider>
<ThemeProvider theme={theme}>
<App />
</ThemeProvider>
<App />
</HelmetProvider>
</StrictMode>,
);
19 changes: 19 additions & 0 deletions frontend/src/material-ui-pigment-css.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Theme, SxProps } from "@mui/material/styles";
import {} from "@mui/material/themeCssVarsAugmentation";

declare module "@mui/material-pigment-css" {
interface ThemeArgs {
theme: Theme;
}
}

declare global {
namespace React {
interface HTMLAttributes {
sx?: SxProps<Theme>;
}
interface SVGProps {
sx?: SxProps<Theme>;
}
}
}
2 changes: 1 addition & 1 deletion frontend/tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"strict": true,
"noEmit": true
},
"include": ["vite.config.ts"]
"include": ["vite.config.ts", "src/app/shared/theme.ts"]
}
9 changes: 8 additions & 1 deletion frontend/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";
import { pigment } from "@pigment-css/vite-plugin";
import theme from "./src/app/shared/theme";
import path from "path";

const pigmentConfig = {
theme,
transformLibraries: ["@mui/material"],
luisdlopez marked this conversation as resolved.
Show resolved Hide resolved
};

export default ({ mode }: { mode: string }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };

return defineConfig({
plugins: [react()],
plugins: [react(), pigment(pigmentConfig)],
build: {
sourcemap: process.env.VITE_GENERATE_SOURCEMAP === "true",
},
Expand Down
Loading