Skip to content

Commit c7a2e0f

Browse files
committed
refactor: refactor some css to improve compatibility with future changes
1 parent 9f18ef9 commit c7a2e0f

File tree

20 files changed

+201
-212
lines changed

20 files changed

+201
-212
lines changed

src/components/BaseCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ export const BaseCard = ({
103103
sx={(theme) => ({
104104
marginLeft: "auto",
105105
transform: `rotate(${expanded ? 180 : 0}deg)`,
106-
transition: `${theme.transitions.create("transform", {
106+
transition: theme.transitions.create("transform", {
107107
duration: theme.transitions.duration.shortest,
108-
})}`,
108+
}),
109109
})}
110110
onClick={() => {
111111
setExpanded(!expanded);

src/components/DataTable/DataTable.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,7 @@ export const DataTable = <Data extends Record<string, any>>(props: DataTableProp
263263
const tableContents = (
264264
<>
265265
{!!ToolbarChild || !!enableSearch ? (
266-
<Toolbar
267-
sx={(theme) => ({
268-
pt: 2,
269-
alignItems: "flex-start",
270-
gap: theme.spacing(1),
271-
})}
272-
>
266+
<Toolbar sx={{ pt: 2, alignItems: "flex-start", gap: 1 }}>
273267
{ToolbarChild}
274268
{!!enableSearch && (
275269
<TextField
@@ -342,11 +336,9 @@ export const DataTable = <Data extends Record<string, any>>(props: DataTableProp
342336
<TableCell
343337
{...customCellProps}
344338
key={cell.id}
345-
sx={{
346-
pl: cell.column.getCanSort()
347-
? (theme) => theme.spacing(2 + 2 * row.depth)
348-
: undefined,
349-
}}
339+
sx={(theme) => ({
340+
pl: cell.column.getCanSort() ? theme.spacing(2 + 2 * row.depth) : undefined,
341+
})}
350342
>
351343
{flexRender(cell.column.columnDef.cell, cell.getContext())}
352344
</TableCell>

src/components/instances/JobDetails/JobLink.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export const JobLink = ({ projectId, path: originalPath, isFile }: JobLinkProps)
7272
sx={{
7373
alignItems: "center",
7474
display: "flex",
75-
gap: (theme) => theme.spacing(1),
75+
gap: 1,
7676
wordBreak: "break-all",
7777
}}
7878
>
@@ -101,7 +101,7 @@ export const JobLink = ({ projectId, path: originalPath, isFile }: JobLinkProps)
101101
}
102102

103103
return (
104-
<Box sx={{ alignItems: "center", display: "flex", gap: (theme) => theme.spacing(1) }}>
104+
<Box sx={{ alignItems: "center", display: "flex", gap: 1 }}>
105105
<Tooltip title="Show directory in project">
106106
<A
107107
legacyBehavior

src/components/logo/HeaderLogo.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,5 @@ export const HeaderLogo = () => {
2323
const LogoLink = styled(NextLink)(({ theme }) => ({
2424
display: "inline-block",
2525
maxHeight: "68px",
26-
paddingTop: theme.spacing(0.5),
27-
paddingBottom: theme.spacing(0.5),
26+
padding: theme.spacing(0.5, 0),
2827
}));

src/components/modals/ModalWrapper.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
DialogTitle,
1010
IconButton,
1111
Typography,
12-
useTheme,
1312
} from "@mui/material";
1413

1514
import { SlideUpTransition } from "../SlideUpTransition";
@@ -51,7 +50,6 @@ export const ModalWrapper: React.FC<ModalWrapperProps> = ({
5150
onSubmit,
5251
DialogProps,
5352
}) => {
54-
const theme = useTheme();
5553
return (
5654
<Dialog
5755
{...DialogProps}
@@ -66,13 +64,13 @@ export const ModalWrapper: React.FC<ModalWrapperProps> = ({
6664
</Typography>
6765
<IconButton
6866
size="small"
69-
sx={{
67+
sx={(theme) => ({
7068
zIndex: theme.zIndex.appBar + 1,
7169
position: "absolute",
7270
right: theme.spacing(2),
7371
top: theme.spacing(1.5),
7472
color: "text.primary",
75-
}}
73+
})}
7674
onClick={onClose}
7775
>
7876
<CloseRoundedIcon />

src/components/projects/CreateProject/CreateProjectForm.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import {
2424
MenuItem,
2525
Tooltip,
2626
Typography,
27-
useMediaQuery,
2827
useTheme,
2928
} from "@mui/material";
3029
import { useQueryClient } from "@tanstack/react-query";
@@ -88,8 +87,6 @@ export const CreateProjectForm = ({
8887
isPrivate: isPrivateDefaultValues[defaultPrivacy],
8988
};
9089
const theme = useTheme();
91-
const biggerThanSm = useMediaQuery(theme.breakpoints.up("sm"));
92-
9390
const queryClient = useQueryClient();
9491

9592
const { data, isLoading, isError, error } = useGetProductTypes();
@@ -170,7 +167,10 @@ export const CreateProjectForm = ({
170167
component="fieldset"
171168
sx={{
172169
display: "grid",
173-
gridTemplateColumns: biggerThanSm ? "1fr 1fr auto" + (modal ? "" : " auto") : "1fr",
170+
gridTemplateColumns: {
171+
xs: "1fr",
172+
sm: "1fr 1fr auto" + (modal ? "" : " auto"),
173+
},
174174
gap: 1,
175175
alignItems: "baseline",
176176
}}

src/components/results/DateTimeListItem/ResponsiveListItem.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
import { ListItem, ListItemText, useMediaQuery, useTheme } from "@mui/material";
1+
import { ListItem, ListItemText } from "@mui/material";
22

33
export interface ResponsiveListItemProps {
44
primary: string;
55
secondary?: string;
66
}
77

88
export const ResponsiveListItem = ({ primary, secondary }: ResponsiveListItemProps) => {
9-
const theme = useTheme();
10-
const biggerThanMd = useMediaQuery(theme.breakpoints.up("md"));
119
return (
12-
<ListItem sx={{ ml: biggerThanMd ? "auto" : undefined }}>
10+
<ListItem sx={{ ml: { xs: undefined, md: "auto" } }}>
1311
<ListItemText primary={primary} secondary={secondary} />
1412
</ListItem>
1513
);

src/components/runCards/ApplicationCard/ApplicationCard.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { type ApplicationSummary } from "@squonk/data-manager-client";
22

3-
import { CircularProgress, useTheme } from "@mui/material";
3+
import { CircularProgress } from "@mui/material";
44
import dynamic from "next/dynamic";
55

66
import { useIsUserAdminOrEditorOfCurrentProject } from "../../../hooks/projectHooks";
@@ -30,8 +30,6 @@ export interface ApplicationCardProps extends Pick<ApplicationModalButtonProps,
3030
* existing instances.
3131
*/
3232
export const ApplicationCard = ({ app, projectId }: ApplicationCardProps) => {
33-
const theme = useTheme();
34-
3533
const hasPermission = useIsUserAdminOrEditorOfCurrentProject();
3634

3735
return (
@@ -51,7 +49,7 @@ export const ApplicationCard = ({ app, projectId }: ApplicationCardProps) => {
5149
title: app.kind,
5250
subtitle: app.group,
5351
avatar: app.kind[0],
54-
color: theme.palette.secondary.dark,
52+
color: "secondary.dark",
5553
}}
5654
/>
5755
);

src/components/runCards/JobCard/JobCard.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { type JobSummary } from "@squonk/data-manager-client";
22

3-
import { Alert, Chip, CircularProgress, Link, Typography, useTheme } from "@mui/material";
3+
import { Alert, Chip, CircularProgress, Link, Typography } from "@mui/material";
44
import dynamic from "next/dynamic";
55

66
import { BaseCard } from "../../BaseCard";
@@ -29,8 +29,6 @@ export interface ApplicationCardProps extends Pick<RunJobButtonProps, "projectId
2929
* existing instances.
3030
*/
3131
export const JobCard = ({ projectId, job, disabled = false }: ApplicationCardProps) => {
32-
const theme = useTheme();
33-
3432
return (
3533
<BaseCard
3634
actions={({ setExpanded }) => (
@@ -47,7 +45,7 @@ export const JobCard = ({ projectId, job, disabled = false }: ApplicationCardPro
4745
/>
4846
}
4947
header={{
50-
color: theme.palette.primary.main,
48+
color: "primary.main",
5149
subtitle: job.name,
5250
avatar: job.job[0],
5351
title: job.job,

src/components/runCards/JobCard/JobInputFields.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export const InputSection = ({ children, title, required, error }: InputSectionP
159159
<Grid size={{ xs: 12 }}>
160160
<Typography
161161
component="h4"
162-
sx={{ color: error ? (theme) => theme.palette.error.main : undefined }}
162+
sx={{ color: error ? "error.main" : undefined }}
163163
variant="subtitle1"
164164
>
165165
<em>
@@ -168,7 +168,7 @@ export const InputSection = ({ children, title, required, error }: InputSectionP
168168
</em>
169169
</Typography>
170170
{children}
171-
<Typography sx={(theme) => ({ color: theme.palette.error.main })}>{error}</Typography>
171+
<Typography sx={{ color: "error.main" }}>{error}</Typography>
172172
</Grid>
173173
);
174174
};

0 commit comments

Comments
 (0)