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

Feature/mui 6 and pigment css #20

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ module.exports = {
"react-hooks/rules-of-hooks": ERROR,
eqeqeq: ERROR,
"@typescript-eslint/array-type": [WARNING, { default: "array-simple" }],
// With Pigment CSS, the SX property is now available on html elements
"react/no-unknown-property": ["error", { ignore: ["sx"] }],
// "sort-keys": WARNING,
},
settings: {
Expand All @@ -43,7 +45,7 @@ module.exports = {
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: ["./tsconfig.eslint.json"],
project: ["./tsconfig.eslint.json", "./src/material-ui-pigment-css.d.ts"],
tsconfigRootDir: __dirname,
},
};
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.1.0",
"@mui/material": "^6.1.0",
"@mui/material-pigment-css": "^6.1.0",
"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.23",
"@types/classnames": "^2.3.1",
"@types/node": "^20.14.9",
"@types/qs": "^6.9.15",
Expand Down
14 changes: 5 additions & 9 deletions frontend/src/app/components/accordion/Accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import {
AccordionProps,
Accordion as MuiAccordion,
styled,
} from "@mui/material";
import style from "@styles/style.module.scss";
import { AccordionProps, Accordion as MuiAccordion } from "@mui/material";
import { styled } from "@mui/material-pigment-css";

const StyledMuiAccordion = styled(MuiAccordion)({
border: `1px solid ${style["stone-veryLight"]}`,
const StyledMuiAccordion = styled(MuiAccordion)(({ theme }) => ({
border: `1px solid ${theme.palette.grey[300]}`,
"&:not(:last-child)": {
borderBottom: 0,
},
"&::before": {
display: "none",
},
});
}));

export default function Accordion({ children, ...props }: AccordionProps) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ import CaretIcon from "@icons/CaretIcon";
import {
AccordionSummaryProps,
AccordionSummary as MuiAccordionSummary,
styled,
} from "@mui/material";
import style from "@styles/style.module.scss";
import { styled } from "@mui/material-pigment-css";

const StyledMuiAccordionSummary = styled(MuiAccordionSummary)({
const StyledMuiAccordionSummary = styled(MuiAccordionSummary)(({ theme }) => ({
flexDirection: "row-reverse",
"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded": {
transform: "rotate(90deg)",
},
"& .MuiAccordionSummary-content": {
marginLeft: style["spacing-md"],
marginLeft: theme.spacing(1),
alignItems: "center",
},
});
}));

export default function AccordionSummary({
children,
Expand Down
11 changes: 5 additions & 6 deletions frontend/src/app/components/button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { ButtonProps, Button as MuiButton, styled } from "@mui/material";
import style from "@styles/style.module.scss";

const StyledMuiButton = styled(MuiButton)({
borderRadius: style["border-radius-xs"],
});
import { ButtonProps, Button as MuiButton } from "@mui/material";
import { styled } from "@mui/material-pigment-css";

const StyledMuiButton = styled(MuiButton)(({ theme }) => ({
borderRadius: theme.customProperties.borderRadius.xs,
}));
interface IButton extends ButtonProps {
target?: string;
}
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/app/components/dialog/Dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Slide from "@components/slide/Slide";
import { DialogProps, Dialog as MuiDialog, styled } from "@mui/material";
import style from "@styles/style.module.scss";
import { DialogProps, Dialog as MuiDialog } from "@mui/material";
import { styled } from "@mui/material-pigment-css";

const StyledMuiDialog = styled(MuiDialog)({
const StyledMuiDialog = styled(MuiDialog)(({ theme }) => ({
"& .MuiDialog-paper": {
margin: style["spacing-md"],
margin: theme.spacing(2),
},
});
}));

export default function Dialog({ ...props }: DialogProps) {
return (
Expand Down
23 changes: 15 additions & 8 deletions frontend/src/app/components/errorHelperText/ErrorHelperText.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Typography from "@components/typography/Typography";
import Typography from "@mui/material/Typography";
import { RefObject, useEffect, useRef, useState } from "react";
import { CSSTransition, TransitionGroup } from "react-transition-group";
import "./error-helper-text.scss";
import classes from "./error-helper-text.module.css";

interface IErrorBox {
message: string;
Expand All @@ -21,16 +21,23 @@ export default function ErrorHelperText({ message }: IErrorBox) {
{activeMessage && (
<CSSTransition
classNames={{
enter: "error-helper-text__enter",
enterActive: "error-helper-text__enter-active",
exit: "error-helper-text__exit",
exitActive: "error-helper-text__exit-active",
enter: classes["enter"],
enterActive: classes["enter-active"],
exit: classes["exit"],
exitActive: classes["exit-active"],
}}
timeout={350}
nodeRef={nodeRef}
>
<div ref={nodeRef} className="error-helper-text__container">
<Typography.Caption>{activeMessage}</Typography.Caption>
<div
ref={nodeRef}
sx={(theme) => ({
marginTop: theme.spacing(0),
marginLeft: theme.spacing(1),
color: theme.palette.error.main,
})}
>
<Typography variant={"caption"}>{activeMessage}</Typography>
</div>
</CSSTransition>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.enter {
opacity: 0;
}

.enter-active {
opacity: 1;
/*
The time here is found in the theme.customProperties.time property.
Ideally we should be getting this value dynamically, from the theme.
*/
transition: opacity 0.35s ease-in;
}

.exit {
opacity: 1;
}

.exit-active {
opacity: 0;
transition: opacity 0.35s ease-out;
}
25 changes: 0 additions & 25 deletions frontend/src/app/components/errorHelperText/error-helper-text.scss

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ErrorHelperText from "@components/errorHelperText/ErrorHelperText";
import Typography from "@components/typography/Typography";
import Typography from "@mui/material/Typography";
import { useTranslation } from "react-i18next";
import { ValidationError } from "yup";

Expand Down Expand Up @@ -44,8 +44,8 @@ export default function FieldHelperText({
}

return (
<Typography.Caption className="mt-xxs ml-md">
<Typography variant="caption" className="mt-xxs ml-md">
{helperText}
</Typography.Caption>
</Typography>
);
}
65 changes: 57 additions & 8 deletions frontend/src/app/components/layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,74 @@
import classnames from "classnames";
import { ReactNode } from "react";
import "./layout.scss";
import { styled } from "@mui/material-pigment-css";

interface ILayout {
children: ReactNode;
className?: string;
}

const LayoutContainer = styled("main")(({ theme }) => ({
width: "100%",
display: "flex",
flexDirection: "column",
flexGrow: 1,
padding: theme.spacing(2),
alignItems: "center",
backgroundColor: "#fafafb", // TODO: get this from theme

[theme.breakpoints.up("md")]: {
padding: theme.spacing(4),
},

[theme.breakpoints.up("lg")]: {
padding: theme.spacing(6),
},

[theme.breakpoints.up("xl")]: {
padding: theme.spacing(8),
},

"> .content": {
maxWidth: "82.5rem",
width: "100%",
},
}));

function Container({ children, className }: ILayout) {
return (
<main className={classnames("layout__container", className)}>
<div className="layout__container-content">{children}</div>
</main>
<LayoutContainer className={className}>
<div className="content">{children}</div>
</LayoutContainer>
);
}

const LayoutAuth = styled("main")(({ theme }) => ({
width: "100%",
display: "flex",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
backgroundColor: "#fafafb", // TODO: get this from theme

[theme.breakpoints.up("xs")]: {
flex: "1 1 auto",
},

"> .content": {
maxWidth: "82.5rem",
width: "100%",

[theme.breakpoints.up("xs")]: {
maxWidth: 442,
padding: theme.spacing(2),
},
},
}));

function Auth({ children, className }: ILayout) {
return (
<main className={classnames("layout__auth", className)}>
<div className="layout__auth-content">{children}</div>
</main>
<LayoutAuth className={className}>
<div className="content">{children}</div>
</LayoutAuth>
);
}

Expand Down
53 changes: 0 additions & 53 deletions frontend/src/app/components/layout/layout.scss

This file was deleted.

10 changes: 5 additions & 5 deletions frontend/src/app/components/link/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import ExternalLinkOutlined from "@icons/ExternalLinkOutlined";
import { LinkProps, Link as MuiLink, styled } from "@mui/material";
import style from "@styles/style.module.scss";
import { LinkProps, Link as MuiLink } from "@mui/material";
import { styled } from "@mui/material-pigment-css";

const StyledMuiLink = styled(MuiLink)({
const StyledMuiLink = styled(MuiLink)(({ theme }) => ({
display: "flex",
color: style["primary-main"],
color: theme.palette.primary.main,
textDecorationColor: "unset",
cursor: "pointer",
});
}));

interface ILink extends LinkProps {
external?: boolean;
Expand Down
Loading