mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-11 18:33:53 +00:00
54442dc9a1
* style: create tag to display network messages * style: create button style for playback * style: review style for QuickEntry * style: review style for Info panel * style: review style for Event blocks * style: review style for Message control panel * style: review style for Playback control * style: review application styles * style: review block styles * refactor: TapButton has active state * style: small style tweaks * refactor: type checks
34 lines
914 B
TypeScript
34 lines
914 B
TypeScript
import { useCallback, useState } from 'react';
|
|
import { IconButton, IconButtonProps, Tooltip } from '@chakra-ui/react';
|
|
|
|
interface TooltipLoadingActionBtnProps extends IconButtonProps {
|
|
clickHandler: () => void;
|
|
tooltip: string;
|
|
openDelay?: number;
|
|
}
|
|
|
|
export default function TooltipLoadingActionBtn(props: TooltipLoadingActionBtnProps) {
|
|
const { clickHandler, icon, size = 'xs', tooltip, openDelay = 0, ...rest } = props;
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
const handleClick = useCallback(() => {
|
|
setLoading(true);
|
|
clickHandler();
|
|
}, [clickHandler, setLoading]);
|
|
|
|
return (
|
|
<Tooltip label={tooltip} shouldWrapChildren={loading} openDelay={openDelay}>
|
|
<IconButton
|
|
{...rest}
|
|
aria-label={tooltip}
|
|
size={size}
|
|
icon={icon}
|
|
onClick={handleClick}
|
|
disabled={loading}
|
|
isLoading={loading}
|
|
/>
|
|
</Tooltip>
|
|
);
|
|
}
|
|
|