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

refactor: Remove makeStyles classes in favour of styled components #1707

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c2eb00c
feat: InputLabel
DafyddLlyr May 18, 2023
65b2af8
feat: ListManager
DafyddLlyr May 18, 2023
47b9cee
feat: StatusPage
DafyddLlyr May 18, 2023
d5a6515
feat: ReconciliationPage
DafyddLlyr May 18, 2023
0468ac3
feat: Settings
DafyddLlyr May 18, 2023
6e11962
feat: FormModal
DafyddLlyr May 18, 2023
51bf448
feat: FlowEditor
DafyddLlyr May 18, 2023
f2ca10c
feat: Teams
DafyddLlyr May 18, 2023
a87052e
feat: ErrorSummary
DafyddLlyr May 18, 2023
55413f4
feat: Card
DafyddLlyr May 18, 2023
02af69e
feat: Presentational
DafyddLlyr May 18, 2023
4ca84ad
feat: FileUpload
DafyddLlyr May 18, 2023
115a9eb
feat: Notice
DafyddLlyr May 18, 2023
1e842ac
feat: ButtonBase
DafyddLlyr May 18, 2023
54e35e9
feat: ImageButton
DafyddLlyr May 18, 2023
5ded860
feat: PreviewBrowser
DafyddLlyr May 18, 2023
f9a3d43
feat: Calculate
DafyddLlyr May 18, 2023
802b946
feat: Confirmation
DafyddLlyr May 18, 2023
b757a86
feat: DateInput
DafyddLlyr May 18, 2023
5ec6860
feat: Question
DafyddLlyr May 18, 2023
1b0bbdf
feat: Result
DafyddLlyr May 18, 2023
ab3bf94
feat: ResultReason
DafyddLlyr May 18, 2023
28505a1
feat: SimpleExpand
DafyddLlyr May 18, 2023
1d31aff
feat: DelayedLoadingIndicator
DafyddLlyr May 18, 2023
f610df5
feat: ContentPage
DafyddLlyr May 18, 2023
7d09ad3
feat: Questions
DafyddLlyr May 18, 2023
6534812
feat: DateInput
DafyddLlyr May 18, 2023
5586881
feat: ChecklistItem
DafyddLlyr May 18, 2023
eaf6494
feat: InputRowLabel
DafyddLlyr May 18, 2023
65c13f0
feat: Section
DafyddLlyr May 18, 2023
48328b0
feat: InputField
DafyddLlyr May 18, 2023
d5163a0
feat: NumberedList
DafyddLlyr May 18, 2023
e1655a1
feat: Checkbox
DafyddLlyr May 18, 2023
c58f0d7
fix: First tidy up pass
DafyddLlyr May 19, 2023
b9c4191
fix: Drop changes to card and fileupload
DafyddLlyr May 19, 2023
09fa3ed
fix: More tidy ups
DafyddLlyr May 19, 2023
1ae31b0
chore: Bump timeout
DafyddLlyr May 22, 2023
adb6d53
chore: Standard imports
DafyddLlyr May 22, 2023
0edd1f5
fix: Resolve build issue with latest MUI version
DafyddLlyr May 22, 2023
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 editor.planx.uk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"@feedback-fish/react": "^1.2.1",
"@material-ui/core": "^4.12.4",
"@mui/icons-material": "^5.11.16",
"@mui/material": "5.11.9",
"@mui/styles": "5.11.9",
"@mui/utils": "5.11.9",
"@mui/material": "5.12.3",
"@mui/styles": "5.12.3",
"@mui/utils": "5.12.3",
Comment on lines +14 to +16
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version bump fixed the annoying bug where the "Change" text within a button on the SummaryList wasn't correctly inheriting the font-family.

mui/material-ui#33621

However, upgrading right to the latest version (5.13.1) was causing issues which I spent a lot of time trying to resolve. This version just came out a few days ago so hopefully it's something that will get ironed out shortly.

"@opensystemslab/map": "^0.7.4",
"@opensystemslab/planx-core": "github:theopensystemslab/planx-core#026f43f",
"@opensystemslab/planx-document-templates": "github:theopensystemslab/planx-document-templates#debaeca",
Expand Down
266 changes: 200 additions & 66 deletions editor.planx.uk/pnpm-lock.yaml

Large diffs are not rendered by default.

17 changes: 7 additions & 10 deletions editor.planx.uk/src/@planx/components/Calculate/Editor.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import makeStyles from "@mui/styles/makeStyles";
import { styled } from "@mui/material/styles";
import { TYPES } from "@planx/components/types";
import {
EditorProps,
Expand All @@ -19,17 +19,14 @@ import { evaluate, getVariables, parseCalculate } from "./model";

export type Props = EditorProps<TYPES.Calculate, Calculate>;

const useClasses = makeStyles((_theme) => ({
were: {
alignSelf: "center",
margin: "auto 1rem",
textAlign: "center",
},
const Were = styled("span")(() => ({
alignSelf: "center",
margin: "auto 1rem",
textAlign: "center",
}));

const UNKNOWN = "unknown";
export default function Component(props: Props) {
const classes = useClasses();
const formik = useFormik({
initialValues: parseCalculate(props.node?.data),
onSubmit: (newValues) => {
Expand Down Expand Up @@ -123,10 +120,10 @@ export default function Component(props: Props) {
{variables?.length ? (
<>
<p>If</p>
{variables.map((variable, i) => (
{variables.map((variable) => (
<InputRow key={variable}>
<Input value={variable} disabled />
<span className={classes.were}>were</span>
<Were>were</Were>
<Input
name={`samples['${variable}']`}
value={formik.values.samples[variable]}
Expand Down
39 changes: 14 additions & 25 deletions editor.planx.uk/src/@planx/components/Confirmation/Public.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Check from "@mui/icons-material/Check";
import Box from "@mui/material/Box";
import { styled } from "@mui/material/styles";
import Typography from "@mui/material/Typography";
import makeStyles from "@mui/styles/makeStyles";
import Card from "@planx/components/shared/Preview/Card";
import { PublicProps } from "@planx/components/ui";
import { useStore } from "pages/FlowEditor/lib/store";
Expand All @@ -14,22 +14,17 @@ import ReactMarkdownOrHtml from "ui/ReactMarkdownOrHtml";
import { makeCsvData } from "../Send/uniform";
import type { Confirmation } from "./model";

const useClasses = makeStyles((theme) => ({
table: {
width: "100%",
borderCollapse: "collapse",
"& tr": {
borderBottom: `1px solid ${theme.palette.grey[400]}`,
"&:last-of-type": {
border: "none",
},
"& td": {
padding: theme.spacing(1.5, 1),
},
const Table = styled("table")(({ theme }) => ({
width: "100%",
borderCollapse: "collapse",
"& tr": {
borderBottom: `1px solid ${theme.palette.grey[400]}`,
"&:last-of-type": {
border: "none",
},
"& td": {
padding: theme.spacing(1.5, 1),
},
},
listHeading: {
marginBottom: theme.spacing(2),
},
}));

Expand All @@ -55,8 +50,6 @@ export default function ConfirmationComponent(props: Props) {
sessionId,
});

const classes = useClasses();

return (
<Box width="100%">
<Banner
Expand All @@ -73,7 +66,7 @@ export default function ConfirmationComponent(props: Props) {
</Banner>
<Card>
{props.details && (
<table className={classes.table}>
<Table>
<tbody>
{Object.entries(props.details).map((item, i) => (
<tr key={i}>
Expand All @@ -84,7 +77,7 @@ export default function ConfirmationComponent(props: Props) {
</tr>
))}
</tbody>
</table>
</Table>
)}

{
Expand All @@ -98,11 +91,7 @@ export default function ConfirmationComponent(props: Props) {

{props.nextSteps && Boolean(props.nextSteps?.length) && (
<Box pt={3}>
<Typography
variant="h3"
component="h2"
className={classes.listHeading}
>
<Typography variant="h3" component="h2" sx={{ mb: 2 }}>
What happens next?
</Typography>
<NumberedList items={props.nextSteps} heading="h3" />
Expand Down
18 changes: 5 additions & 13 deletions editor.planx.uk/src/@planx/components/DateInput/Public.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import makeStyles from "@mui/styles/makeStyles";
import Box from "@mui/material/Box";
import { visuallyHidden } from "@mui/utils";
import {
DateInput,
Expand All @@ -20,13 +20,6 @@ import { getPreviouslySubmittedData, makeData } from "../shared/utils";

export type Props = PublicProps<DateInput, UserData>;

const useClasses = makeStyles(() => ({
fieldset: {
border: 0,
padding: 0,
},
}));

const DateInputPublic: React.FC<Props> = (props) => {
const formik = useFormik({
initialValues: {
Expand All @@ -42,12 +35,11 @@ const DateInputPublic: React.FC<Props> = (props) => {
}),
});

const classes = useClasses();

return (
<Card handleSubmit={formik.handleSubmit}>
<fieldset
className={classes.fieldset}
<Box
component="fieldset"
sx={{ p: 0, border: 0 }}
role="group"
aria-describedby={[
props.description ? DESCRIPTION_TEXT : "",
Expand Down Expand Up @@ -76,7 +68,7 @@ const DateInputPublic: React.FC<Props> = (props) => {
id={props.id}
/>
</InputRow>
</fieldset>
</Box>
</Card>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ function Dropzone(props: any) {

return (
<>
{slots.map(({ id, file, status, progress, url }: any, index: number) => {
{slots.map(({ id, file, progress, url }: any, index: number) => {
return (
<Box key={id} className={classes.file}>
<IconButton
Expand Down
96 changes: 48 additions & 48 deletions editor.planx.uk/src/@planx/components/Notice/Public.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { mostReadable } from "@ctrl/tinycolor";
import ErrorOutline from "@mui/icons-material/ErrorOutline";
import Box from "@mui/material/Box";
import Button from "@mui/material/Button";
import { Theme } from "@mui/material/styles";
import makeStyles from "@mui/styles/makeStyles";
import { styled } from "@mui/material/styles";
import type { Notice } from "@planx/components/Notice/model";
import Card from "@planx/components/shared/Preview/Card";
import QuestionHeader from "@planx/components/shared/Preview/QuestionHeader";
Expand All @@ -17,51 +17,54 @@ interface StyleProps {
color: string;
}

const useStyles = makeStyles<Theme, StyleProps>((theme) => ({
container: {
position: "relative",
width: "100%",
display: "flex",
alignItems: "flex-start",
justifyContent: "space-between",
backgroundColor: (props) => props.color,
color: (props) =>
mostReadable(props.color, ["#fff", "#000"])?.toHexString(),
"&:before": {
content: "' '",
position: "absolute",
top: 0,
left: 0,
width: 10,
bottom: 0,
backgroundColor: (props) =>
mostReadable(props.color, ["#fff", "#000"])?.toHexString(),
opacity: 0.3,
},
padding: theme.spacing(2),
paddingLeft: `calc(${theme.spacing(2)} + 10px)`,
},
content: {
flex: 1,
const Container = styled(Box)<StyleProps>(({ theme, color }) => ({
position: "relative",
width: "100%",
display: "flex",
alignItems: "flex-start",
justifyContent: "space-between",
backgroundColor: color,
color: mostReadable(color, ["#fff", "#000"])?.toHexString(),
"&:before": {
content: "' '",
position: "absolute",
top: 0,
left: 0,
width: 10,
bottom: 0,
backgroundColor: mostReadable(color, ["#fff", "#000"])?.toHexString(),
opacity: 0.3,
},
title: {
fontSize: theme.typography.pxToRem(25),
fontWeight: 700,
margin: 0,
},
description: {
padding: theme.spacing(2),
paddingLeft: `calc(${theme.spacing(2)} + 10px)`,
}));

const Content = styled(Box)(() => ({
flex: 1,
}));

const Title = styled("h3")(({ theme }) => ({
fontSize: theme.typography.pxToRem(25),
fontWeight: 700,
margin: 0,
}));

interface DescriptionProps {
color: string;
}

const Description = styled(ReactMarkdownOrHtml)<DescriptionProps>(
({ theme, color }) => ({
fontSize: theme.typography.pxToRem(15),
fontWeight: 400,
margin: theme.spacing(2, 0, 0, 0),
"& a": {
color: (props) =>
getContrastTextColor(props.color, theme.palette.primary.main),
color: getContrastTextColor(color, theme.palette.primary.main),
},
},
}));
})
);

const NoticeComponent: React.FC<Props> = (props) => {
const styles = useStyles({ color: props.color || "#EFEFEF" });
const handleSubmit = !props.resetButton
? () => props.handleSubmit?.()
: undefined;
Expand All @@ -73,16 +76,13 @@ const NoticeComponent: React.FC<Props> = (props) => {
policyRef={props.policyRef}
howMeasured={props.howMeasured}
/>
<div className={styles.container}>
<div className={styles.content}>
<h3 className={styles.title}>{props.title}</h3>
<ReactMarkdownOrHtml
className={styles.description}
source={props.description}
/>
</div>
<Container color={props.color || "#EFEFEF"}>
<Content>
<Title>{props.title}</Title>
<Description color={props.color} source={props.description} />
</Content>
<ErrorOutline />
</div>
</Container>
{props.resetButton && (
<Button
variant="contained"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Box from "@mui/material/Box";
import Grid from "@mui/material/Grid";
import { useTheme } from "@mui/material/styles";
import makeStyles from "@mui/styles/makeStyles";
import { styled, useTheme } from "@mui/material/styles";
import { visuallyHidden } from "@mui/utils";
import DecisionButton from "@planx/components/shared/Buttons/DecisionButton";
import DescriptionButton from "@planx/components/shared/Buttons/DescriptionButton";
Expand All @@ -13,22 +13,15 @@ import React from "react";

import { IQuestion, QuestionLayout } from "./Question";

const useClasses = makeStyles(() => ({
fieldset: {
border: 0,
padding: 0,
},
gridContainer: {
// Overwrite Mui Grid style to align with "Continue" button
"& > .MuiGrid-item": {
padding: "0px 0px 8px 2px",
},
const StyledGrid = styled(Grid)(() => ({
// Overwrite Mui Grid style to align with "Continue" button
"& > .MuiGrid-item": {
padding: "0px 0px 8px 2px",
},
}));

const ButtonQuestion: React.FC<IQuestion> = (props) => {
const theme = useTheme();
const classes = useClasses();

const previousResponseId = props?.previouslySubmittedData?.answers?.[0];
const previousResponseKey = props.responses.find(
Expand Down Expand Up @@ -67,8 +60,9 @@ const ButtonQuestion: React.FC<IQuestion> = (props) => {
isValid={Boolean(formik.values.selected.id)}
>
<form>
<fieldset
className={classes.fieldset}
<Box
component="fieldset"
sx={{ p: 0, border: 0 }}
aria-describedby={props.description ? DESCRIPTION_TEXT : ""}
>
<legend style={visuallyHidden}>{props.text}</legend>
Expand All @@ -81,10 +75,9 @@ const ButtonQuestion: React.FC<IQuestion> = (props) => {
definitionImg={props.definitionImg}
img={props.img}
/>
<Grid
<StyledGrid
container
spacing={layout === QuestionLayout.Descriptions ? 2 : 1}
className={classes.gridContainer}
>
{!props.text?.startsWith("Sorry") &&
props.responses?.map((response) => {
Expand Down Expand Up @@ -129,8 +122,8 @@ const ButtonQuestion: React.FC<IQuestion> = (props) => {
);
}
})}
</Grid>
</fieldset>
</StyledGrid>
</Box>
</form>
</Card>
);
Expand Down
Loading