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: [M3-6386] - MUI v5 Migration - Components > SelectableTableRow #9299

Merged
merged 2 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tech Stories
---

MUI v5 Migration - `Components > SelectableTableRow` ([#9299](https://github.com/linode/manager/pull/9299))
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
import { styled } from '@mui/material/styles';
import * as React from 'react';
import CheckBox from 'src/components/CheckBox';
import { makeStyles } from '@mui/styles';
import { TableCell } from 'src/components/TableCell';
import { TableRow } from 'src/components/TableRow';

const useStyles = makeStyles(() => ({
root: {
'& td': {
padding: '0px 15px',
},
},
checkBox: {
textAlign: 'center',
width: 25,
paddingLeft: 0,
paddingRight: 0,
'& svg': {
width: 20,
height: 20,
},
},
}));

interface Props {
interface SelectableTableRowProps {
children: JSX.Element[];
isChecked: boolean;
handleToggleCheck: () => void;
}

export const SelectableTableRow: React.FC<Props> = (props) => {
const { isChecked, handleToggleCheck } = props;
const classes = useStyles();
return (
<TableRow className={classes.root}>
<TableCell className={classes.checkBox}>
<CheckBox
checked={isChecked}
onChange={handleToggleCheck}
inputProps={{
'aria-label': `Select all entities on page`,
}}
/>
</TableCell>
{props.children}
</TableRow>
);
};
export const SelectableTableRow = React.memo(
(props: SelectableTableRowProps) => {
const { isChecked, handleToggleCheck } = props;

export default React.memo(SelectableTableRow);
return (
<TableRow
sx={{
'& td': {
padding: '0px 15px',
},
}}
>
<StyledTableCell>
<CheckBox
checked={isChecked}
onChange={handleToggleCheck}
inputProps={{
'aria-label': `Select all entities on page`,
}}
/>
</StyledTableCell>
{props.children}
</TableRow>
);
}
);

const StyledTableCell = styled(TableCell, {
label: 'StyledTableCell',
})({
textAlign: 'center',
width: 25,
paddingLeft: 0,
paddingRight: 0,
'& svg': {
width: 20,
height: 20,
},
});

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Hidden from 'src/components/core/Hidden';
import { useTheme } from '@mui/styles';
import { Theme } from '@mui/material/styles';
import useMediaQuery from '@mui/material/useMediaQuery';
import SelectableTableRow from 'src/components/SelectableTableRow';
import { SelectableTableRow } from 'src/components/SelectableTableRow/SelectableTableRow';
import { TableCell } from 'src/components/TableCell';
import { TableContentWrapper } from 'src/components/TableContentWrapper/TableContentWrapper';
import { useSpecificTypes } from 'src/queries/types';
Expand Down