Skip to content

Commit

Permalink
remove div for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Sep 13, 2024
1 parent c3a91d4 commit a7418a1
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions docs/data/material/components/material-icons/SearchIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,20 @@ function selectNode(node) {
selection.addRange(range);
}

const iconWidth = 35;

const StyledIcon = styled('span')(({ theme }) => ({
display: 'inline-flex',
flexDirection: 'column',
color: theme.palette.text.secondary,
margin: '0 4px',
'& > div': {
display: 'flex',
},
'& > div > *': {
flexGrow: 1,
fontSize: '.6rem',
overflow: 'hidden',
textOverflow: 'ellipsis',
textAlign: 'center',
width: 0,
width: `calc(${iconWidth}px + ${theme.spacing(2)} * 2 + 2px)`,
},
}));

Expand All @@ -116,6 +115,7 @@ const StyledSvgIcon = styled(SvgIcon)(({ theme }) => ({
cursor: 'pointer',
color: theme.palette.text.primary,
border: '1px solid transparent',
fontSize: iconWidth,
borderRadius: '12px',
transition: theme.transitions.create(['background-color', 'box-shadow'], {
duration: theme.transitions.duration.shortest,
Expand Down Expand Up @@ -143,7 +143,9 @@ const handleIconClick = (event) => {
}
};

const handleLabelClick = (event) => selectNode(event.currentTarget);
function handleLabelClick(event) {
selectNode(event.currentTarget);
}

function Icon(props) {
const { icon, onOpenClick } = props;
Expand All @@ -157,15 +159,12 @@ function Icon(props) {
>
<StyledSvgIcon
component={icon.Component}
fontSize="large"
tabIndex={-1}
onClick={onOpenClick}
title={icon.importName}
/>
<div>
{/* eslint-disable-next-line jsx-a11y/no-static-element-interactions -- TODO: a11y */}
<div onClick={handleLabelClick}>{icon.importName}</div>
</div>
{/* eslint-disable-next-line jsx-a11y/no-static-element-interactions -- TODO: a11y */}
<div onClick={handleLabelClick}>{icon.importName}</div>
{/* eslint-enable jsx-a11y/click-events-have-key-events */}
</StyledIcon>
);
Expand Down

0 comments on commit a7418a1

Please sign in to comment.