Files
twenty_crm/packages/twenty-ui/src/display/tooltip/AppTooltip.tsx
Rushikesh Tarapure bc8c895b0e Feat : Introduced Delay Options for Tooltip (#5766)
Fixes https://github.com/twentyhq/twenty/issues/5727

---------

Co-authored-by: Rushikesh Tarapure <rushikeshtarapure@gofynd.com>
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-06-19 16:37:44 +02:00

93 lines
1.9 KiB
TypeScript

import { PlacesType, PositionStrategy, Tooltip } from 'react-tooltip';
import styled from '@emotion/styled';
import { RGBA } from '@ui/theme/constants/Rgba';
export enum TooltipPosition {
Top = 'top',
Left = 'left',
Right = 'right',
Bottom = 'bottom',
}
export enum TooltipDelay {
noDelay = '0ms',
shortDelay = '300ms',
mediumDelay = '500ms',
}
const StyledAppTooltip = styled(Tooltip)`
backdrop-filter: ${({ theme }) => theme.blur.strong};
background-color: ${({ theme }) => RGBA(theme.color.gray80, 0.8)};
border-radius: ${({ theme }) => theme.border.radius.sm};
box-shadow: ${({ theme }) => theme.boxShadow.light};
color: ${({ theme }) => theme.grayScale.gray0};
font-size: ${({ theme }) => theme.font.size.sm};
font-weight: ${({ theme }) => theme.font.weight.regular};
max-width: 40%;
overflow: visible;
padding: ${({ theme }) => theme.spacing(2)};
word-break: break-word;
z-index: ${({ theme }) => theme.lastLayerZIndex};
`;
export type AppTooltipProps = {
className?: string;
anchorSelect?: string;
content?: string;
children?: React.ReactNode;
offset?: number;
noArrow?: boolean;
isOpen?: boolean;
place?: PlacesType;
delay?: TooltipDelay;
positionStrategy?: PositionStrategy;
clickable?: boolean;
};
export const AppTooltip = ({
anchorSelect,
className,
content,
isOpen,
noArrow,
offset,
delay = TooltipDelay.mediumDelay,
place,
positionStrategy,
children,
clickable,
}: AppTooltipProps) => {
const delayInMs =
delay === TooltipDelay.noDelay
? 0
: delay === TooltipDelay.shortDelay
? 300
: 500;
return (
<StyledAppTooltip
{...{
anchorSelect,
className,
content,
delayShow: delayInMs,
delayHide: delayInMs,
isOpen,
noArrow,
offset,
place,
positionStrategy,
children,
clickable,
}}
/>
);
};