mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-24 17:51:14 +02:00
Merge 89bb5c23f2
into 3bb317ad6d
This commit is contained in:
commit
e22d67c968
@ -46,18 +46,6 @@ const StyledLabelIcon = styled('span')(({ theme }) => ({
|
||||
|
||||
const offset = 16;
|
||||
|
||||
const getAlign = (align?: 'left' | 'right' | 'center') => {
|
||||
if (align === 'left') {
|
||||
return 'flex-start';
|
||||
}
|
||||
|
||||
if (align === 'right') {
|
||||
return 'flex-end';
|
||||
}
|
||||
|
||||
return 'center';
|
||||
};
|
||||
|
||||
const getLeftOffset = (caretX = 0, align?: 'left' | 'right' | 'center') => {
|
||||
if (align === 'left') {
|
||||
return caretX + offset;
|
||||
@ -73,23 +61,29 @@ const getLeftOffset = (caretX = 0, align?: 'left' | 'right' | 'center') => {
|
||||
export const ChartTooltipContainer: FC<IChartTooltipProps> = ({
|
||||
tooltip,
|
||||
children,
|
||||
}) => (
|
||||
}) => {
|
||||
const top = tooltip?.caretY ?? 0 + offset;
|
||||
const left = getLeftOffset(tooltip?.caretX, tooltip?.align);
|
||||
return (
|
||||
<Box
|
||||
sx={(theme) => ({
|
||||
top: (tooltip?.caretY || 0) + offset,
|
||||
left: getLeftOffset(tooltip?.caretX, tooltip?.align),
|
||||
top: 0,
|
||||
left: 0,
|
||||
transform: `translate(${left}px, ${top}px)`,
|
||||
transition: 'transform 0.2s ease-in-out',
|
||||
width: '1px',
|
||||
position: 'absolute',
|
||||
display: tooltip ? 'flex' : 'none',
|
||||
pointerEvents: 'none',
|
||||
zIndex: theme.zIndex.tooltip,
|
||||
flexDirection: 'column',
|
||||
alignItems: getAlign(tooltip?.align),
|
||||
alignItems: 'center',
|
||||
})}
|
||||
>
|
||||
{children}
|
||||
</Box>
|
||||
);
|
||||
);
|
||||
};
|
||||
|
||||
export const ChartTooltip: VFC<IChartTooltipProps> = ({ tooltip }) => (
|
||||
<ChartTooltipContainer tooltip={tooltip}>
|
||||
|
Loading…
Reference in New Issue
Block a user