Skip to content

Commit

Permalink
refactor: switch TableIconButton to JSX
Browse files Browse the repository at this point in the history
  • Loading branch information
fboulnois committed Jan 22, 2024
1 parent 4edb63c commit d90a17b
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/components/TableIconButton.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import React from 'react';
import { useEffect } from 'react';
import { Styles } from '../libs/theme';
import { h, span } from 'react-hyperscript-helpers';
import { applyHoverEffects, setDivAttributes, setStyle } from '../libs/utils';
import { makeStyles } from 'tss-react/mui';
import { isNil } from 'lodash';
import {useEffect} from 'react';
import ReactTooltip from 'react-tooltip';

const useStyles = makeStyles()({
'root': {
'backgroundColor': 'inherit',
'color': 'inherit',
'pointerEvents': 'none',
'fontSize': 28,
}
root: {
backgroundColor: 'inherit',
color: 'inherit',
pointerEvents: 'none',
fontSize: 28,
},
});

export default function TableIconButton(props) {

useEffect(() => {
ReactTooltip.rebuild();
}, []);
Expand All @@ -39,7 +38,7 @@ export default function TableIconButton(props) {
isRendered = true,
dataTip = '',
keyProp,
disabled = false
disabled = false,
} = props;
const Icon = props.icon;
const { classes } = useStyles();
Expand All @@ -49,12 +48,10 @@ export default function TableIconButton(props) {
//NOTE: span wrapper is needed for svg child elements due to flaky behavior onMouseEnter and onMouseLeave
// https://github.com/facebook/react/issues/4492 --> NOTE: though the issue is from the React repo, the bug is tied to browser specs, NOT React
return (
span(attributes, [
h(Icon, {
style: appliedStyle,
isRendered: isRendered && !isNil(Icon),
className: classes.root
})
])
<span {...attributes}>
{isRendered && !isNil(Icon) && (
<Icon style={appliedStyle} className={classes.root} />
)}
</span>
);
}

0 comments on commit d90a17b

Please sign in to comment.