Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Tippy tooltips in animation controls #2888

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions src/components/src/common/animation-control/play-control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import React from 'react';
import classnames from 'classnames';
import {FormattedMessage} from '@kepler.gl/localization';
import {Tooltip} from '../styled-components';
import IconButton from '../icon-button';

const DELAY_SHOW = 500;
import TippyTooltip from '../tippy-tooltip';

function PlayControlFactory() {
const PlayControl = ({
Expand All @@ -21,23 +19,24 @@ function PlayControlFactory() {
buttonHeight
}) => {
return showAnimationWindowControl ? null : (
<IconButton
data-tip
data-for="animate-play-pause"
className={classnames('playback-control-button', {active: isAnimating})}
onClick={isAnimating ? pauseAnimation : startAnimation}
hide={isSpeedControlVisible}
{...btnStyle}
<TippyTooltip
placement="top"
delay={[500, 0]}
render={() => <FormattedMessage id={isAnimating ? 'tooltip.pause' : 'tooltip.play'} />}
>
{isAnimating ? (
<playbackIcons.pause height={buttonHeight} />
) : (
<playbackIcons.play height={buttonHeight} />
)}
<Tooltip id="animate-play-pause" place="top" delayShow={DELAY_SHOW} effect="solid">
<FormattedMessage id={isAnimating ? 'tooltip.pause' : 'tooltip.play'} />
</Tooltip>
</IconButton>
<IconButton
className={classnames('playback-control-button', {active: isAnimating})}
onClick={isAnimating ? pauseAnimation : startAnimation}
hide={isSpeedControlVisible}
{...btnStyle}
>
{isAnimating ? (
<playbackIcons.pause height={buttonHeight} />
) : (
<playbackIcons.play height={buttonHeight} />
)}
</IconButton>
</TippyTooltip>
);
};

Expand Down
23 changes: 9 additions & 14 deletions src/components/src/common/animation-control/reset-control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

import React from 'react';
import {FormattedMessage} from '@kepler.gl/localization';
import {Tooltip} from '../styled-components';
import IconButton from '../icon-button';

const DELAY_SHOW = 500;
import TippyTooltip from '../tippy-tooltip';

function ResetControlFactory() {
const ResetControl = ({
Expand All @@ -17,18 +15,15 @@ function ResetControlFactory() {
buttonHeight
}) => {
return showAnimationWindowControl ? null : (
<IconButton
data-tip
data-for="animate-reset"
className="playback-control-button"
onClick={resetAnimation}
{...btnStyle}
<TippyTooltip
placement="top"
delay={[500, 0]}
render={() => <FormattedMessage id="tooltip.reset" />}
>
<playbackIcons.reset height={buttonHeight} />
<Tooltip id="animate-reset" place="top" delayShow={DELAY_SHOW} effect="solid">
<FormattedMessage id="tooltip.reset" />
</Tooltip>
</IconButton>
<IconButton className="playback-control-button" onClick={resetAnimation} {...btnStyle}>
<playbackIcons.reset height={buttonHeight} />
</IconButton>
</TippyTooltip>
);
};

Expand Down
26 changes: 13 additions & 13 deletions src/components/src/common/animation-control/speed-control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

import React from 'react';
import styled from 'styled-components';
import {Tooltip} from '../styled-components';
import IconButton from '../icon-button';
import {media} from '@kepler.gl/styles';
import {preciseRound} from '@kepler.gl/utils';
import TippyTooltip from '../tippy-tooltip';

const StyledSpeedControl = styled.div`
display: flex;
Expand All @@ -20,7 +20,6 @@ const StyledSpeedControl = styled.div`
}
`;

const DELAY_SHOW = 500;
const PRECISE_SPEED_ROUND = 1;

function SpeedControlFactory(AnimationSpeedSlider) {
Expand All @@ -36,18 +35,19 @@ function SpeedControlFactory(AnimationSpeedSlider) {
}) => {
return showAnimationWindowControl || !updateAnimationSpeed ? null : (
<StyledSpeedControl>
<IconButton
data-tip
data-for="animate-speed"
className="playback-control-button"
{...btnStyle}
onClick={hideAndShowSpeedControl}
<TippyTooltip
placement="top"
delay={[500, 0]}
render={() => <span>{preciseRound(speed, PRECISE_SPEED_ROUND)}x</span>}
>
<playbackIcons.speed height={buttonHeight} />
<Tooltip id="animate-speed" place="top" delayShow={DELAY_SHOW} effect="solid">
<span>{preciseRound(speed, PRECISE_SPEED_ROUND)}x</span>
</Tooltip>
</IconButton>
<IconButton
className="playback-control-button"
{...btnStyle}
onClick={hideAndShowSpeedControl}
>
<playbackIcons.speed height={buttonHeight} />
</IconButton>
</TippyTooltip>
{isSpeedControlVisible ? (
<AnimationSpeedSlider
onHide={hideAndShowSpeedControl}
Expand Down
Loading