@@ -5,7 +5,7 @@ import React, {
55 Children ,
66 ReactElement ,
77} from 'react'
8- import styled from 'styled-components'
8+ import styled , { css } from 'styled-components'
99import { useBoolean } from 'react-hooks-shareable'
1010
1111import { Typography , TypographyProps } from '../Typography'
@@ -21,6 +21,8 @@ import { font } from '../theme'
2121 * aliigned to it's center.
2222 */
2323
24+ export const TOOLTIP_DELAY_MS = 250
25+
2426const BaseTooltipWrapper = styled . div `
2527 display: flex;
2628 max-width: 280px;
@@ -43,6 +45,20 @@ const TooltipWrapper = styled(BaseTooltipWrapper)`
4345 background-color: ${ ( { theme } ) => theme . color . text04 ( ) } ;
4446`
4547
48+ export const ExpandedTooltipAnimation = css `
49+ animation: fadein 200ms ease-out;
50+
51+ @keyframes fadein {
52+ from {
53+ opacity: 0;
54+ }
55+
56+ to {
57+ opacity: 1;
58+ }
59+ }
60+ `
61+
4662const ExpandedTooltipWrapper = styled ( BaseTooltipWrapper ) `
4763 flex-direction: column;
4864 align-items: flex-start;
@@ -59,17 +75,7 @@ const ExpandedTooltipWrapper = styled(BaseTooltipWrapper)`
5975
6076 word-break: break-word;
6177
62- animation: fadein 200ms ease-out;
63-
64- @keyframes fadein {
65- from {
66- opacity: 0;
67- }
68-
69- to {
70- opacity: 1;
71- }
72- }
78+ ${ ExpandedTooltipAnimation }
7379`
7480
7581const ExpandedTooltipTop = styled . div `
@@ -170,7 +176,7 @@ export const Tooltip: React.FC<TooltipProps | ExpandedTooltipProps> = ({
170176
171177 useEffect ( ( ) => {
172178 const delayVisible = ( ) => setDebouncedVisible ( visible )
173- const delayed = setTimeout ( delayVisible , 250 )
179+ const delayed = setTimeout ( delayVisible , TOOLTIP_DELAY_MS )
174180 return ( ) => {
175181 clearTimeout ( delayed )
176182 }
0 commit comments