Skip to content

Commit 0706d34

Browse files
committed
emotion: useClickableTableRow
1 parent 0587497 commit 0706d34

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed
Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import { useTheme, type CSSObject } from "@emotion/react";
12
import { type MouseEventHandler } from "react";
23
import { type TableRowProps } from "@mui/material/TableRow";
3-
import { makeStyles } from "@mui/styles";
44
import { useClickable, type UseClickableResult } from "./useClickable";
55

66
type UseClickableTableRowResult = UseClickableResult<HTMLTableRowElement> &
77
TableRowProps & {
8-
className: string;
8+
css: CSSObject;
99
hover: true;
1010
onAuxClick: MouseEventHandler<HTMLTableRowElement>;
1111
};
@@ -28,12 +28,24 @@ export const useClickableTableRow = ({
2828
onDoubleClick,
2929
onMiddleClick,
3030
}: UseClickableTableRowConfig): UseClickableTableRowResult => {
31-
const styles = useStyles();
3231
const clickableProps = useClickable(onClick);
32+
const theme = useTheme();
3333

3434
return {
3535
...clickableProps,
36-
className: styles.row,
36+
css: {
37+
cursor: "pointer",
38+
39+
"&:focus": {
40+
outline: `1px solid ${theme.palette.secondary.dark}`,
41+
outlineOffset: -1,
42+
},
43+
44+
"&:last-of-type": {
45+
borderBottomLeftRadius: theme.shape.borderRadius,
46+
borderBottomRightRadius: theme.shape.borderRadius,
47+
},
48+
},
3749
hover: true,
3850
onDoubleClick,
3951
onAuxClick: (event) => {
@@ -46,19 +58,3 @@ export const useClickableTableRow = ({
4658
},
4759
};
4860
};
49-
50-
const useStyles = makeStyles((theme) => ({
51-
row: {
52-
cursor: "pointer",
53-
54-
"&:focus": {
55-
outline: `1px solid ${theme.palette.secondary.dark}`,
56-
outlineOffset: -1,
57-
},
58-
59-
"&:last-of-type": {
60-
borderBottomLeftRadius: theme.shape.borderRadius,
61-
borderBottomRightRadius: theme.shape.borderRadius,
62-
},
63-
},
64-
}));

0 commit comments

Comments
 (0)