@@ -2,27 +2,12 @@ import React from 'react';
22import { useSortable } from '@dnd-kit/sortable' ;
33import { CSS } from '@dnd-kit/utilities' ;
44import { 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
87import { SortOrder } from './sort' ;
98import IconTooltip from '../IconTooltip' ;
109import { 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-
2611type Props = {
2712 headCell : HeadCell ;
2813 order : SortOrder ;
@@ -33,7 +18,6 @@ type Props = {
3318
3419export 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