Skip to content

Commit 6ef6c66

Browse files
committed
small styling fixes
1 parent e229df8 commit 6ef6c66

File tree

10 files changed

+55
-66
lines changed

10 files changed

+55
-66
lines changed

src/components/Debug/Code.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Box, BoxProps } from '@mui/material';
22
import { styled } from '@mui/material/styles';
3-
import { ChildrenProp } from '~/common';
3+
import { ChildrenProp, extendSx } from '~/common';
44

55
interface CodeProps extends Omit<BoxProps, 'component'> {
66
json?: any;
@@ -15,18 +15,17 @@ export const Code = ({
1515
return (
1616
<Box
1717
component="pre"
18-
sx={{
19-
p: 1,
20-
borderRadius: 1,
21-
margin: 0,
22-
color: 'common.white',
23-
bgcolor: 'grey.800',
24-
fontFamily: 'monospace',
25-
fontSize: '0.875rem',
26-
overflow: 'auto',
27-
whiteSpace: 'pre-wrap',
28-
...sx,
29-
}}
18+
sx={[
19+
(theme) => ({
20+
root: {
21+
padding: theme.spacing(1),
22+
borderRadius: theme.shape.borderRadius,
23+
color: theme.palette.background.paper,
24+
backgroundColor: theme.palette.grey[800],
25+
},
26+
}),
27+
...extendSx(sx),
28+
]}
3029
{...rest}
3130
>
3231
{json ? JSON.stringify(json, undefined, 2) : children}

src/components/Error/Error.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,7 @@ export const Error = ({
9393
<Typography gutterBottom>Oops, Sorry.</Typography>
9494
{rendered}
9595
{!disableButtons && (
96-
<Grid
97-
container
98-
spacing={3}
99-
style={{
100-
marginTop: theme.spacing(3),
101-
}}
102-
>
96+
<Grid container spacing={3} sx={{ mt: 3 }}>
10397
<Grid item>
10498
<Button
10599
onClick={() => navigate(-1)}

src/components/FieldOverviewCard/FieldOverviewCard.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
Card,
44
CardActionArea,
55
CardActions,
6+
CardProps,
67
Grid,
78
Skeleton,
89
Stack,
@@ -12,7 +13,7 @@ import {
1213
} from '@mui/material';
1314
import { To } from 'history';
1415
import { ReactNode } from 'react';
15-
import { DateTimeOrISO } from '~/common';
16+
import { DateTimeOrISO, extendSx } from '~/common';
1617
import { FormattedDateTime } from '../Formatters';
1718
import { HugeIcon, HugeIconProps } from '../Icons';
1819
import { ButtonLink, CardActionAreaLink } from '../Routing';
@@ -23,6 +24,8 @@ interface FieldOverviewCardData {
2324
to?: To;
2425
}
2526

27+
// removed duplicate import
28+
2629
export interface FieldOverviewCardProps extends Pick<HugeIconProps, 'icon'> {
2730
className?: string;
2831
data?: FieldOverviewCardData;
@@ -34,6 +37,7 @@ export interface FieldOverviewCardProps extends Pick<HugeIconProps, 'icon'> {
3437
redacted?: boolean;
3538
title?: string;
3639
viewLabel?: string;
40+
CardProps?: CardProps;
3741
}
3842

3943
const DEFAULT_EMPTY = <>&nbsp;</>;
@@ -50,17 +54,24 @@ export const FieldOverviewCard = ({
5054
redacted,
5155
title,
5256
viewLabel: buttonLabel,
57+
CardProps,
5358
}: FieldOverviewCardProps) => {
54-
// Styles removed, now using sx and component props
55-
5659
const showData = !loading && !redacted;
5760
const ActionArea = showData && data?.to ? CardActionAreaLink : CardActionArea;
5861
const Btn = data?.to ? ButtonLink : Button;
5962

6063
const card = (
6164
<Card
6265
className={className}
63-
sx={{ flex: 1, height: '100%', display: 'flex', flexDirection: 'column' }}
66+
sx={[
67+
{
68+
flex: 1,
69+
height: '100%',
70+
display: 'flex',
71+
flexDirection: 'column',
72+
},
73+
...extendSx(CardProps?.sx),
74+
]}
6475
>
6576
<ActionArea
6677
disabled={!data || redacted}
@@ -69,7 +80,8 @@ export const FieldOverviewCard = ({
6980
flex: 1,
7081
display: 'flex',
7182
justifyContent: 'space-evenly',
72-
p: [3, 4],
83+
py: 3,
84+
px: 4,
7385
}}
7486
onClick={onClick}
7587
>

src/components/MemberListSummary/MemberListSummary.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
} from '@mui/material';
88
import { To } from 'history';
99
import { compact } from 'lodash';
10-
// Removed makeStyles, using sx prop for layout and spacing
1110
import { listOrPlaceholders } from '~/common';
1211
import { Avatar } from '../Avatar';
1312
import { HugeIcon, HugeIconProps } from '../Icons';

src/components/MethodologiesCard/MethodologiesCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ export const MethodologiesCard = ({
8282
);
8383

8484
return (
85-
<Card className={className} sx={{ width: '100%', height: '100%' }}>
85+
<Card className={className} sx={{ width: '1', height: '1' }}>
8686
{data?.canEdit ? (
87-
<CardActionArea onClick={onClick} sx={{ height: '100%' }}>
87+
<CardActionArea onClick={onClick} sx={{ height: '1' }}>
8888
{content}
8989
</CardActionArea>
9090
) : (

src/components/PartnerListItemCard/PartnerListItemCard.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Card, CardContent, Skeleton, Stack, Typography } from '@mui/material';
22
import { random } from 'lodash';
3-
// Removed makeStyles, using sx prop for layout and positioning
43
import { PartialDeep } from 'type-fest';
54
import { PartnersQueryVariables } from '../../scenes/Partners/List/PartnerList.graphql';
65
import { CardActionAreaLink } from '../Routing';

src/components/ProgressButton/ProgressButton.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ export const ProgressButton = forwardRef<
3232
<>
3333
{progress ? (
3434
<div
35+
// This is to center spinner within button, while maintaining consistent button width.
36+
// If we were to replace the button text, the button size could change which we want to
37+
// avoid because the buttons shifting around is jarring for the user. Esp since the
38+
// spinner is only shown for a short time.
3539
style={{
3640
position: 'absolute',
3741
inset: 0,

src/components/ProjectChangeRequestListItem/ProjectChangeRequestListItem.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
Box,
23
Button,
34
Card,
45
CardActions,
@@ -7,7 +8,6 @@ import {
78
Tooltip,
89
Typography,
910
} from '@mui/material';
10-
import { useTheme } from '@mui/material/styles';
1111
import { ProjectChangeRequestTypeLabels } from '~/api/schema.graphql';
1212
import { labelsFrom } from '~/common';
1313
import { useProjectId } from '../../scenes/Projects/useProjectId';
@@ -27,7 +27,6 @@ export const ProjectChangeRequestListItem = ({
2727
}: ProjectChangeRequestListItemProps) => {
2828
const { projectId, changesetId: currentlyViewing } = useProjectId();
2929
const navigate = useNavigate();
30-
const theme = useTheme();
3130

3231
return (
3332
<Card className={className}>
@@ -51,14 +50,7 @@ export const ProjectChangeRequestListItem = ({
5150
>
5251
{!data ? <Skeleton width="100%" /> : data.status.value}
5352
</Typography>
54-
<span
55-
style={{
56-
color: theme.palette.text.secondary,
57-
margin: theme.spacing(0, 1),
58-
}}
59-
>
60-
61-
</span>
53+
<Box sx={{ color: 'text.secondary', mx: 1 }}></Box>
6254
<Typography
6355
component="span"
6456
variant="inherit"
@@ -84,10 +76,11 @@ export const ProjectChangeRequestListItem = ({
8476
</Typography>
8577
</CardContent>
8678
<CardActions
87-
sx={{
79+
sx={(theme) => ({
8880
display: 'flex',
81+
justifyContent: 'space-between',
8982
padding: theme.spacing(1, 2, 1, 1),
90-
}}
83+
})}
9184
>
9285
{!data || data.canEdit ? (
9386
<Button
@@ -105,7 +98,6 @@ export const ProjectChangeRequestListItem = ({
10598
Review
10699
</Button>
107100
</Tooltip>
108-
<div style={{ flex: 1 }} />
109101
<Typography variant="subtitle2" color="textSecondary">
110102
{!data ? (
111103
<Skeleton width="23ch" />

src/components/Redacted/Redacted.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Skeleton, SkeletonProps, Tooltip, TooltipProps } from '@mui/material';
22
import { Except } from 'type-fest';
3-
import { ChildrenProp } from '~/common';
3+
import { ChildrenProp, extendSx } from '~/common';
44

55
export interface RedactedProps {
66
info: TooltipProps['title'];
@@ -22,10 +22,12 @@ export const Redacted = ({
2222
animation={false}
2323
width={width}
2424
{...SkeletonProps}
25-
sx={{
26-
transform: 'initial',
27-
...SkeletonProps?.sx,
28-
}}
25+
sx={[
26+
{
27+
text: 'initial',
28+
},
29+
...extendSx(SkeletonProps?.sx),
30+
]}
2931
>
3032
{children}
3133
</Skeleton>

src/components/Upload/UploadItem.tsx

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,33 +82,21 @@ export const UploadItem = (props: UploadItemProps) => {
8282
)}
8383
</Stack>
8484
{error ? (
85-
<IconButton
86-
aria-label="clear"
87-
onClick={onClear}
88-
sx={(theme) => ({
89-
color: theme.palette.error.main,
90-
})}
91-
>
85+
<IconButton aria-label="clear" onClick={onClear} color="error">
9286
<CancelIcon />
9387
</IconButton>
9488
) : completedAt ? (
9589
<IconButton
9690
aria-label="completed"
91+
color="error"
9792
onClick={() => console.log('TODO: Add onCompleted click handler')}
98-
sx={(theme) => ({
99-
color: theme.palette.error.main,
100-
})}
10193
>
102-
<CheckIcon
103-
sx={(theme) => ({
104-
color: theme.palette.primary.main,
105-
})}
106-
/>
94+
<CheckIcon color="primary" />
10795
</IconButton>
10896
) : (
109-
<div
110-
style={{
111-
padding: '12px',
97+
<Box
98+
sx={{
99+
p: '12px',
112100
}}
113101
>
114102
<CircularProgress
@@ -117,7 +105,7 @@ export const UploadItem = (props: UploadItemProps) => {
117105
thickness={4.6}
118106
value={percentCompleted}
119107
/>
120-
</div>
108+
</Box>
121109
)}
122110
</Box>
123111
);

0 commit comments

Comments
 (0)