Skip to content

Commit 79801be

Browse files
authored
[fix] Tippy tooltips in animation controls (#2888)
- Replacing react-tooltip tooltips in animation controls which don't work correctly when used in programable environments Signed-off-by: Ihor Dykhta <[email protected]>
1 parent 0ad5372 commit 79801be

File tree

3 files changed

+40
-46
lines changed

3 files changed

+40
-46
lines changed

src/components/src/common/animation-control/play-control.tsx

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
import React from 'react';
55
import classnames from 'classnames';
66
import {FormattedMessage} from '@kepler.gl/localization';
7-
import {Tooltip} from '../styled-components';
87
import IconButton from '../icon-button';
9-
10-
const DELAY_SHOW = 500;
8+
import TippyTooltip from '../tippy-tooltip';
119

1210
function PlayControlFactory() {
1311
const PlayControl = ({
@@ -21,23 +19,24 @@ function PlayControlFactory() {
2119
buttonHeight
2220
}) => {
2321
return showAnimationWindowControl ? null : (
24-
<IconButton
25-
data-tip
26-
data-for="animate-play-pause"
27-
className={classnames('playback-control-button', {active: isAnimating})}
28-
onClick={isAnimating ? pauseAnimation : startAnimation}
29-
hide={isSpeedControlVisible}
30-
{...btnStyle}
22+
<TippyTooltip
23+
placement="top"
24+
delay={[500, 0]}
25+
render={() => <FormattedMessage id={isAnimating ? 'tooltip.pause' : 'tooltip.play'} />}
3126
>
32-
{isAnimating ? (
33-
<playbackIcons.pause height={buttonHeight} />
34-
) : (
35-
<playbackIcons.play height={buttonHeight} />
36-
)}
37-
<Tooltip id="animate-play-pause" place="top" delayShow={DELAY_SHOW} effect="solid">
38-
<FormattedMessage id={isAnimating ? 'tooltip.pause' : 'tooltip.play'} />
39-
</Tooltip>
40-
</IconButton>
27+
<IconButton
28+
className={classnames('playback-control-button', {active: isAnimating})}
29+
onClick={isAnimating ? pauseAnimation : startAnimation}
30+
hide={isSpeedControlVisible}
31+
{...btnStyle}
32+
>
33+
{isAnimating ? (
34+
<playbackIcons.pause height={buttonHeight} />
35+
) : (
36+
<playbackIcons.play height={buttonHeight} />
37+
)}
38+
</IconButton>
39+
</TippyTooltip>
4140
);
4241
};
4342

src/components/src/common/animation-control/reset-control.tsx

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33

44
import React from 'react';
55
import {FormattedMessage} from '@kepler.gl/localization';
6-
import {Tooltip} from '../styled-components';
76
import IconButton from '../icon-button';
8-
9-
const DELAY_SHOW = 500;
7+
import TippyTooltip from '../tippy-tooltip';
108

119
function ResetControlFactory() {
1210
const ResetControl = ({
@@ -17,18 +15,15 @@ function ResetControlFactory() {
1715
buttonHeight
1816
}) => {
1917
return showAnimationWindowControl ? null : (
20-
<IconButton
21-
data-tip
22-
data-for="animate-reset"
23-
className="playback-control-button"
24-
onClick={resetAnimation}
25-
{...btnStyle}
18+
<TippyTooltip
19+
placement="top"
20+
delay={[500, 0]}
21+
render={() => <FormattedMessage id="tooltip.reset" />}
2622
>
27-
<playbackIcons.reset height={buttonHeight} />
28-
<Tooltip id="animate-reset" place="top" delayShow={DELAY_SHOW} effect="solid">
29-
<FormattedMessage id="tooltip.reset" />
30-
</Tooltip>
31-
</IconButton>
23+
<IconButton className="playback-control-button" onClick={resetAnimation} {...btnStyle}>
24+
<playbackIcons.reset height={buttonHeight} />
25+
</IconButton>
26+
</TippyTooltip>
3227
);
3328
};
3429

src/components/src/common/animation-control/speed-control.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
import React from 'react';
55
import styled from 'styled-components';
6-
import {Tooltip} from '../styled-components';
76
import IconButton from '../icon-button';
87
import {media} from '@kepler.gl/styles';
98
import {preciseRound} from '@kepler.gl/utils';
9+
import TippyTooltip from '../tippy-tooltip';
1010

1111
const StyledSpeedControl = styled.div`
1212
display: flex;
@@ -20,7 +20,6 @@ const StyledSpeedControl = styled.div`
2020
}
2121
`;
2222

23-
const DELAY_SHOW = 500;
2423
const PRECISE_SPEED_ROUND = 1;
2524

2625
function SpeedControlFactory(AnimationSpeedSlider) {
@@ -36,18 +35,19 @@ function SpeedControlFactory(AnimationSpeedSlider) {
3635
}) => {
3736
return showAnimationWindowControl || !updateAnimationSpeed ? null : (
3837
<StyledSpeedControl>
39-
<IconButton
40-
data-tip
41-
data-for="animate-speed"
42-
className="playback-control-button"
43-
{...btnStyle}
44-
onClick={hideAndShowSpeedControl}
38+
<TippyTooltip
39+
placement="top"
40+
delay={[500, 0]}
41+
render={() => <span>{preciseRound(speed, PRECISE_SPEED_ROUND)}x</span>}
4542
>
46-
<playbackIcons.speed height={buttonHeight} />
47-
<Tooltip id="animate-speed" place="top" delayShow={DELAY_SHOW} effect="solid">
48-
<span>{preciseRound(speed, PRECISE_SPEED_ROUND)}x</span>
49-
</Tooltip>
50-
</IconButton>
43+
<IconButton
44+
className="playback-control-button"
45+
{...btnStyle}
46+
onClick={hideAndShowSpeedControl}
47+
>
48+
<playbackIcons.speed height={buttonHeight} />
49+
</IconButton>
50+
</TippyTooltip>
5151
{isSpeedControlVisible ? (
5252
<AnimationSpeedSlider
5353
onHide={hideAndShowSpeedControl}

0 commit comments

Comments
 (0)