1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-24 17:51:14 +02:00
unleash.unleash/frontend/src/component/common/Table/cells/FavoriteIconCell/FavoriteIconCell.tsx
Nuno Góis eb433185a1
fix: remove tooltip from favorites cell, some refactoring (#2687)
https://linear.app/unleash/issue/2-510/favorite-cell-tooltips-is-buggy-when-pinned-remove-tooltips

Tooltips were buggy when using the pinned feature, so I aligned with
@NicolaeUnleash and decided to remove them for now:
<img width="407" alt="image"
src="https://user-images.githubusercontent.com/14320932/207380515-476a4bec-c1c0-43af-adb8-f7001ae75e9c.png">

Also includes a slight refactor on this component.
2022-12-14 08:51:41 +00:00

51 lines
1.4 KiB
TypeScript

import { VFC } from 'react';
import { Box, IconButton, styled } from '@mui/material';
import {
Star as StarIcon,
StarBorder as StarBorderIcon,
} from '@mui/icons-material';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
const StyledCell = styled(Box)(({ theme }) => ({
paddingLeft: theme.spacing(1.25),
}));
const StyledIconButton = styled(IconButton)(({ theme }) => ({
color: theme.palette.primary.main,
padding: theme.spacing(1.25),
}));
const StyledIconButtonInactive = styled(StyledIconButton)({
opacity: 0,
});
interface IFavoriteIconCellProps {
value?: boolean;
onClick?: () => void;
}
export const FavoriteIconCell: VFC<IFavoriteIconCellProps> = ({
value,
onClick,
}) => (
<StyledCell>
<ConditionallyRender
condition={Boolean(value)}
show={
<StyledIconButton onClick={onClick} size="small">
<StarIcon fontSize="small" />
</StyledIconButton>
}
elseShow={
<StyledIconButtonInactive
className="show-row-hover"
onClick={onClick}
size="small"
>
<StarBorderIcon fontSize="small" />
</StyledIconButtonInactive>
}
/>
</StyledCell>
);