Skip to content

Commit 5546ca8

Browse files
SW-5387 Fix tables are missing right padding on all pages (#559)
1 parent e643531 commit 5546ca8

File tree

2 files changed

+25
-21
lines changed

2 files changed

+25
-21
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@terraware/web-components",
3-
"version": "3.0.8",
3+
"version": "3.0.9-rc.0",
44
"author": "Terraformation Inc.",
55
"license": "Apache-2.0",
66
"repository": {

src/components/table/TableHeaderItem.tsx

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,12 @@ import React from 'react';
22
import { useSortable } from '@dnd-kit/sortable';
33
import { CSS } from '@dnd-kit/utilities';
44
import { DragHandle } from '@mui/icons-material';
5-
import { Box, TableCell, TableSortLabel, Theme } from '@mui/material';
6-
import { makeStyles } from '@mui/styles';
5+
import { Box, TableCell, TableSortLabel, useTheme } from '@mui/material';
76

87
import { SortOrder } from './sort';
98
import IconTooltip from '../IconTooltip';
109
import { HeadCell } from '.';
1110

12-
interface StyleProps {
13-
rightAligned?: boolean;
14-
}
15-
16-
const useStyles = makeStyles((theme: Theme) => ({
17-
dragIcon: {
18-
marginLeft: (props: StyleProps) => (props.rightAligned ? '0px' : '-20px'),
19-
color: theme.palette.common.white,
20-
'&:hover': {
21-
color: theme.palette.neutral[600],
22-
},
23-
},
24-
}));
25-
2611
type Props = {
2712
headCell: HeadCell;
2813
order: SortOrder;
@@ -33,7 +18,6 @@ type Props = {
3318

3419
export default function TableHeaderItem(props: Props): JSX.Element {
3520
const { headCell, order, orderBy, onRequestSort, i } = props;
36-
const classes = useStyles({ rightAligned: headCell.alignment === 'right' });
3721
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
3822
id: headCell.id,
3923
});
@@ -45,6 +29,7 @@ export default function TableHeaderItem(props: Props): JSX.Element {
4529
const createSortHandler = (property: string) => (event: React.MouseEvent<unknown>) => {
4630
onRequestSort(event, property);
4731
};
32+
const theme = useTheme();
4833

4934
return headCell.alignment === 'right' ? (
5035
<TableCell
@@ -71,10 +56,17 @@ export default function TableHeaderItem(props: Props): JSX.Element {
7156
)}
7257
{i > 0 && (
7358
<DragHandle
74-
className={classes.dragIcon}
7559
{...attributes}
7660
{...listeners}
77-
sx={{ verticalAlign: 'middle', display: 'inline-flex' }}
61+
sx={{
62+
verticalAlign: 'middle',
63+
display: 'inline-flex',
64+
marginLeft: headCell.alignment === 'right' ? '0px' : '-20px',
65+
color: theme.palette.common.white,
66+
'&:hover': {
67+
color: theme.palette.neutral[600],
68+
},
69+
}}
7870
/>
7971
)}
8072
</Box>
@@ -96,7 +88,19 @@ export default function TableHeaderItem(props: Props): JSX.Element {
9688
direction={orderBy === headCell.id ? order : 'asc'}
9789
onClick={createSortHandler(headCell.id)}
9890
>
99-
{i > 0 && <DragHandle className={classes.dragIcon} {...attributes} {...listeners} />}
91+
{i > 0 && (
92+
<DragHandle
93+
{...attributes}
94+
{...listeners}
95+
sx={{
96+
marginLeft: '-20px',
97+
color: theme.palette.common.white,
98+
'&:hover': {
99+
color: theme.palette.neutral[600],
100+
},
101+
}}
102+
/>
103+
)}
100104
{headCell.label}
101105
{headCell.tooltipTitle && <IconTooltip title={headCell.tooltipTitle} />}
102106
</TableSortLabel>

0 commit comments

Comments
 (0)