2022-10-28 10:15:46 +02:00
|
|
|
import { styled, Tooltip, TooltipProps } from '@mui/material';
|
|
|
|
import { HelpOutline } from '@mui/icons-material';
|
2023-03-30 17:57:35 +02:00
|
|
|
import { HtmlTooltip } from 'component/common/HtmlTooltip/HtmlTooltip';
|
2022-10-28 10:15:46 +02:00
|
|
|
|
|
|
|
const StyledContainer = styled('span')(({ theme }) => ({
|
|
|
|
display: 'inline-grid',
|
|
|
|
alignItems: 'center',
|
|
|
|
outline: 0,
|
|
|
|
cursor: 'pointer',
|
|
|
|
'&:is(:focus-visible, :active) > *, &:hover > *': {
|
|
|
|
outlineStyle: 'solid',
|
|
|
|
outlineWidth: 2,
|
|
|
|
outlineOffset: 0,
|
|
|
|
outlineColor: theme.palette.primary.main,
|
|
|
|
borderRadius: '100%',
|
|
|
|
color: theme.palette.primary.main,
|
|
|
|
},
|
|
|
|
'& svg': {
|
|
|
|
fontSize: theme.fontSizes.mainHeader,
|
2023-03-22 15:37:40 +01:00
|
|
|
color: theme.palette.action.active,
|
2022-10-28 10:15:46 +02:00
|
|
|
marginLeft: theme.spacing(0.5),
|
|
|
|
},
|
|
|
|
}));
|
2022-04-25 09:24:09 +02:00
|
|
|
|
|
|
|
interface IHelpIconProps {
|
2023-03-30 17:57:35 +02:00
|
|
|
tooltip: React.ReactNode;
|
|
|
|
htmlTooltip?: boolean;
|
2022-08-08 14:58:22 +02:00
|
|
|
placement?: TooltipProps['placement'];
|
2022-10-28 10:15:46 +02:00
|
|
|
children?: React.ReactNode;
|
2022-04-25 09:24:09 +02:00
|
|
|
}
|
|
|
|
|
2023-03-30 17:57:35 +02:00
|
|
|
export const HelpIcon = ({
|
|
|
|
tooltip,
|
|
|
|
htmlTooltip,
|
|
|
|
placement,
|
|
|
|
children,
|
|
|
|
}: IHelpIconProps) => {
|
|
|
|
if (htmlTooltip) {
|
|
|
|
return (
|
|
|
|
<HtmlTooltip title={tooltip} placement={placement} arrow>
|
2023-10-02 14:25:46 +02:00
|
|
|
<StyledContainer tabIndex={0} aria-label='Help'>
|
2023-03-30 17:57:35 +02:00
|
|
|
{children ?? <HelpOutline />}
|
|
|
|
</StyledContainer>
|
|
|
|
</HtmlTooltip>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-04-25 09:24:09 +02:00
|
|
|
return (
|
2022-08-08 14:58:22 +02:00
|
|
|
<Tooltip title={tooltip} placement={placement} arrow>
|
2023-10-02 14:25:46 +02:00
|
|
|
<StyledContainer tabIndex={0} aria-label='Help'>
|
2022-10-28 10:15:46 +02:00
|
|
|
{children ?? <HelpOutline />}
|
|
|
|
</StyledContainer>
|
2022-04-25 09:24:09 +02:00
|
|
|
</Tooltip>
|
|
|
|
);
|
|
|
|
};
|