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 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') => {
|
const getLeftOffset = (caretX = 0, align?: 'left' | 'right' | 'center') => {
|
||||||
if (align === 'left') {
|
if (align === 'left') {
|
||||||
return caretX + offset;
|
return caretX + offset;
|
||||||
@ -73,23 +61,29 @@ const getLeftOffset = (caretX = 0, align?: 'left' | 'right' | 'center') => {
|
|||||||
export const ChartTooltipContainer: FC<IChartTooltipProps> = ({
|
export const ChartTooltipContainer: FC<IChartTooltipProps> = ({
|
||||||
tooltip,
|
tooltip,
|
||||||
children,
|
children,
|
||||||
}) => (
|
}) => {
|
||||||
<Box
|
const top = tooltip?.caretY ?? 0 + offset;
|
||||||
sx={(theme) => ({
|
const left = getLeftOffset(tooltip?.caretX, tooltip?.align);
|
||||||
top: (tooltip?.caretY || 0) + offset,
|
return (
|
||||||
left: getLeftOffset(tooltip?.caretX, tooltip?.align),
|
<Box
|
||||||
width: '1px',
|
sx={(theme) => ({
|
||||||
position: 'absolute',
|
top: 0,
|
||||||
display: tooltip ? 'flex' : 'none',
|
left: 0,
|
||||||
pointerEvents: 'none',
|
transform: `translate(${left}px, ${top}px)`,
|
||||||
zIndex: theme.zIndex.tooltip,
|
transition: 'transform 0.2s ease-in-out',
|
||||||
flexDirection: 'column',
|
width: '1px',
|
||||||
alignItems: getAlign(tooltip?.align),
|
position: 'absolute',
|
||||||
})}
|
display: tooltip ? 'flex' : 'none',
|
||||||
>
|
pointerEvents: 'none',
|
||||||
{children}
|
zIndex: theme.zIndex.tooltip,
|
||||||
</Box>
|
flexDirection: 'column',
|
||||||
);
|
alignItems: 'center',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const ChartTooltip: VFC<IChartTooltipProps> = ({ tooltip }) => (
|
export const ChartTooltip: VFC<IChartTooltipProps> = ({ tooltip }) => (
|
||||||
<ChartTooltipContainer tooltip={tooltip}>
|
<ChartTooltipContainer tooltip={tooltip}>
|
||||||
|
Loading…
Reference in New Issue
Block a user