Skip to content

Commit 26aa528

Browse files
committed
continue removing makeStyles
1 parent 6151e51 commit 26aa528

File tree

13 files changed

+216
-335
lines changed

13 files changed

+216
-335
lines changed

src/components/Changeset/ChangesetBanner.tsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,26 @@ import {
44
Edit as EditIcon,
55
} from '@mui/icons-material';
66
import { Alert, AlertTitle, Tooltip } from '@mui/material';
7-
import { makeStyles } from 'tss-react/mui';
87
import { IconButton } from '../IconButton';
98

10-
const useStyles = makeStyles()(({ spacing, breakpoints }) => ({
11-
root: {
12-
maxWidth: breakpoints.values.md,
13-
margin: spacing(0, 2),
14-
},
15-
}));
16-
179
interface Props {
1810
changesetId: string | undefined;
1911
onEdit?: () => void;
2012
onClose?: () => void;
2113
}
2214

2315
export const ChangesetBanner = (props: Props) => {
24-
const { classes } = useStyles();
25-
2616
if (!props.changesetId) {
2717
return null;
2818
}
2919
return (
3020
<Alert
3121
severity="info"
3222
icon={<ChangeIcon fontSize="inherit" />}
33-
className={classes.root}
23+
sx={(theme) => ({
24+
maxWidth: theme.breakpoints.values.md,
25+
margin: theme.spacing(0, 2),
26+
})}
3427
action={
3528
<>
3629
{props.onEdit && (

src/components/Error/Error.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
11
import { ApolloError } from '@apollo/client';
22
import { Button, Grid, Typography } from '@mui/material';
3+
import { useTheme } from '@mui/material/styles';
34
import { usePrevious } from 'ahooks';
45
import { isPlainObject } from 'lodash';
56
import { ElementType, isValidElement, ReactNode, useEffect } from 'react';
67
import { useErrorBoundary } from 'react-error-boundary';
78
import { useLocation } from 'react-router-dom';
8-
import { makeStyles } from 'tss-react/mui';
99
import { getErrorInfo } from '~/api';
1010
import { ButtonLink, StatusCode, useNavigate } from '../Routing';
1111
import { ErrorRenderers, renderError } from './error-handling';
1212

13-
const useStyles = makeStyles()(({ spacing }) => ({
14-
page: {
15-
overflow: 'auto',
16-
padding: spacing(4, 0, 0, 4),
17-
},
18-
buttons: {
19-
marginTop: spacing(3),
20-
},
21-
}));
22-
2313
export interface ErrorProps {
2414
/**
2515
* The error body to display.
@@ -62,8 +52,8 @@ export const Error = ({
6252
disableButtons,
6353
component: Component = 'div',
6454
}: ErrorProps) => {
65-
const { classes, cx } = useStyles();
6655
const navigate = useNavigate();
56+
const theme = useTheme();
6757

6858
useResetErrorOnLocationChange();
6959

@@ -87,14 +77,29 @@ export const Error = ({
8777
error && getErrorInfo(error).codes.includes('NotFound') ? 404 : 500;
8878

8979
return (
90-
<Component className={cx(page && classes.page)}>
80+
<Component
81+
style={
82+
page
83+
? {
84+
overflow: 'auto',
85+
padding: theme.spacing(4, 0, 0, 4),
86+
}
87+
: undefined
88+
}
89+
>
9190
{/* Default status code to be helpful for the most common ones. The
9291
children can still override this by rendering <StatusCode /> themselves */}
9392
<StatusCode code={statusCode} />
9493
<Typography gutterBottom>Oops, Sorry.</Typography>
9594
{rendered}
9695
{!disableButtons && (
97-
<Grid container spacing={3} className={classes.buttons}>
96+
<Grid
97+
container
98+
spacing={3}
99+
style={{
100+
marginTop: theme.spacing(3),
101+
}}
102+
>
98103
<Grid item>
99104
<Button
100105
onClick={() => navigate(-1)}

src/components/FieldOverviewCard/FieldOverviewCard.tsx

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,49 +5,18 @@ import {
55
CardActions,
66
Grid,
77
Skeleton,
8+
Stack,
89
Tooltip,
910
TooltipProps,
1011
Typography,
1112
} from '@mui/material';
1213
import { To } from 'history';
1314
import { ReactNode } from 'react';
14-
import { makeStyles } from 'tss-react/mui';
1515
import { DateTimeOrISO } from '~/common';
1616
import { FormattedDateTime } from '../Formatters';
1717
import { HugeIcon, HugeIconProps } from '../Icons';
1818
import { ButtonLink, CardActionAreaLink } from '../Routing';
1919

20-
const useStyles = makeStyles()(({ spacing, palette }) => ({
21-
root: {
22-
flex: 1,
23-
height: '100%',
24-
display: 'flex',
25-
flexDirection: 'column',
26-
},
27-
topArea: {
28-
flex: 1,
29-
display: 'flex',
30-
justifyContent: 'space-evenly',
31-
padding: spacing(3, 4),
32-
},
33-
rightContent: {
34-
flex: 1,
35-
alignSelf: 'flex-start',
36-
paddingLeft: spacing(4),
37-
display: 'flex',
38-
flexDirection: 'column',
39-
justifyContent: 'space-evenly',
40-
},
41-
emptyValue: {
42-
color: palette.action.disabled,
43-
},
44-
bottomArea: {
45-
paddingRight: spacing(1),
46-
alignItems: 'center',
47-
justifyContent: 'space-between',
48-
},
49-
}));
50-
5120
interface FieldOverviewCardData {
5221
value?: ReactNode;
5322
updatedAt?: DateTimeOrISO;
@@ -82,30 +51,36 @@ export const FieldOverviewCard = ({
8251
title,
8352
viewLabel: buttonLabel,
8453
}: FieldOverviewCardProps) => {
85-
const { classes, cx } = useStyles();
54+
// Styles removed, now using sx and component props
8655

8756
const showData = !loading && !redacted;
8857
const ActionArea = showData && data?.to ? CardActionAreaLink : CardActionArea;
8958
const Btn = data?.to ? ButtonLink : Button;
9059

9160
const card = (
92-
<Card className={cx(classes.root, className)}>
61+
<Card
62+
className={className}
63+
sx={{ flex: 1, height: '100%', display: 'flex', flexDirection: 'column' }}
64+
>
9365
<ActionArea
9466
disabled={!data || redacted}
9567
to={data?.to ?? ''}
96-
className={classes.topArea}
68+
sx={{
69+
flex: 1,
70+
display: 'flex',
71+
justifyContent: 'space-evenly',
72+
p: [3, 4],
73+
}}
9774
onClick={onClick}
9875
>
9976
<HugeIcon icon={icon} loading={!data} />
100-
<div className={classes.rightContent}>
77+
<Stack flex={1} alignSelf="flex-start" pl={4} spacing={2}>
10178
<Typography variant="h4">
10279
{loading ? <Skeleton width="80%" /> : data ? title : ''}
10380
</Typography>
10481
<Typography
10582
variant="h1"
106-
className={cx({
107-
[classes.emptyValue]: data && !data.value,
108-
})}
83+
sx={data && !data.value ? { color: 'action.disabled' } : undefined}
10984
>
11085
{loading || redacted ? (
11186
<Skeleton animation={loading ? 'pulse' : false} />
@@ -115,15 +90,19 @@ export const FieldOverviewCard = ({
11590
''
11691
)}
11792
</Typography>
118-
</div>
93+
</Stack>
11994
</ActionArea>
12095
{buttonLabel && (
12196
<CardActions>
12297
<Grid
12398
container
12499
spacing={loading ? 4 : 2}
125100
wrap="nowrap"
126-
className={classes.bottomArea}
101+
sx={{
102+
pr: 1,
103+
alignItems: 'center',
104+
justifyContent: 'space-between',
105+
}}
127106
>
128107
<Grid item xs={loading}>
129108
<Btn

src/components/FundingAccountCard/FundingAccountCard.tsx

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,30 @@
11
import { Card, CardActions, CardContent, Typography } from '@mui/material';
2-
import { makeStyles } from 'tss-react/mui';
32
import { DisplaySimpleProperty } from '../DisplaySimpleProperty';
43
import { FormattedDateTime } from '../Formatters';
54
import { FundingAccountCardFragment } from './FundingAccountCard.graphql';
65

7-
const useStyles = makeStyles()(({ spacing }) => {
8-
return {
9-
root: {
10-
width: '100%',
11-
maxWidth: 400,
12-
},
13-
name: {
14-
marginBottom: spacing(2),
15-
},
16-
cardActions: {
17-
justifyContent: 'flex-end',
18-
},
19-
};
20-
});
21-
226
interface FundingAccountCardProps {
237
className?: string;
248
fundingAccount: FundingAccountCardFragment;
259
}
2610

11+
// Candidate for Removal
2712
export const FundingAccountCard = ({
2813
className,
2914
fundingAccount,
3015
}: FundingAccountCardProps) => {
31-
const { classes, cx } = useStyles();
32-
3316
return (
34-
<Card className={cx(classes.root, className)}>
17+
<Card className={className} sx={{ width: '100%', maxWidth: 400 }}>
3518
<CardContent>
36-
<Typography variant="h4" className={classes.name}>
19+
<Typography variant="h4" sx={{ mb: 2 }}>
3720
{fundingAccount.name.value}
3821
</Typography>
3922
<DisplaySimpleProperty
4023
label="Account Number"
4124
value={fundingAccount.accountNumber.value}
4225
/>
4326
</CardContent>
44-
<CardActions className={classes.cardActions}>
27+
<CardActions sx={{ justifyContent: 'flex-end' }}>
4528
<Typography variant="caption" color="textSecondary">
4629
Created <FormattedDateTime date={fundingAccount.createdAt} />
4730
</Typography>

src/components/LanguageEngagementListItemCard/LanguageEngagementListItemCard.tsx

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import {
33
CardActions,
44
CardContent,
55
Grid,
6+
Stack,
67
Typography,
78
} from '@mui/material';
8-
import { makeStyles } from 'tss-react/mui';
99
import { EngagementStatusLabels } from '~/api/schema.graphql';
1010
import { labelFrom } from '~/common';
1111
import { idForUrl } from '../Changeset';
@@ -14,33 +14,6 @@ import { useNumberFormatter } from '../Formatters';
1414
import { ButtonLink, CardActionAreaLink } from '../Routing';
1515
import { LanguageEngagementListItemFragment } from './LanguageEngagementListItem.graphql';
1616

17-
const useStyles = makeStyles()(({ spacing }) => ({
18-
root: {
19-
width: '100%',
20-
},
21-
card: {
22-
display: 'flex',
23-
alignItems: 'initial',
24-
},
25-
26-
cardContent: {
27-
flex: 1,
28-
padding: spacing(2, 3),
29-
display: 'flex',
30-
},
31-
leftContent: {
32-
flex: 1,
33-
},
34-
rightContent: {
35-
flex: 0,
36-
textAlign: 'right',
37-
marginLeft: spacing(2),
38-
display: 'flex',
39-
flexDirection: 'column',
40-
justifyContent: 'flex-end',
41-
},
42-
}));
43-
4417
export type LanguageEngagementListItemCardProps =
4518
LanguageEngagementListItemFragment & {
4619
className?: string;
@@ -52,7 +25,6 @@ export const LanguageEngagementListItemCard = (
5225
const { language: securedLanguage, className, status, products } = props;
5326

5427
const numberFormatter = useNumberFormatter();
55-
const { classes, cx } = useStyles();
5628

5729
const language = securedLanguage.value;
5830
const name = language?.name.value ?? language?.displayName.value;
@@ -62,18 +34,28 @@ export const LanguageEngagementListItemCard = (
6234
const ethnologueCode = language?.ethnologue.code.value;
6335

6436
return (
65-
<Card className={cx(classes.root, className)}>
37+
<Card className={className} sx={{ width: '100%' }}>
6638
<CardActionAreaLink
6739
to={`/engagements/${idForUrl(props)}`}
68-
className={classes.card}
40+
sx={{
41+
display: 'flex',
42+
alignItems: 'initial',
43+
}}
6944
>
70-
<CardContent className={classes.cardContent}>
45+
<CardContent
46+
sx={{
47+
flex: 1,
48+
px: 3,
49+
py: 2,
50+
display: 'flex',
51+
}}
52+
>
7153
<Grid
7254
container
7355
direction="column"
7456
justifyContent="space-between"
7557
spacing={1}
76-
className={classes.leftContent}
58+
sx={{ flex: 1 }}
7759
>
7860
<Grid item>
7961
<Typography variant="h4">{name}</Typography>
@@ -99,7 +81,14 @@ export const LanguageEngagementListItemCard = (
9981
wrap={(node) => <Grid item>{node}</Grid>}
10082
/>
10183
</Grid>
102-
<div className={classes.rightContent}>
84+
<Stack
85+
sx={{
86+
flex: 0,
87+
textAlign: 'right',
88+
ml: 2,
89+
justifyContent: 'flex-end',
90+
}}
91+
>
10392
<DisplaySimpleProperty aria-hidden="true" />
10493
<div>
10594
<Typography variant="h1">
@@ -109,7 +98,7 @@ export const LanguageEngagementListItemCard = (
10998
Goals
11099
</Typography>
111100
</div>
112-
</div>
101+
</Stack>
113102
</CardContent>
114103
</CardActionAreaLink>
115104
<CardActions>

0 commit comments

Comments
 (0)