This commit is contained in:
alorig
2025-11-19 21:56:03 +05:00
parent 7321803006
commit 38f6026e73
13 changed files with 2370 additions and 142 deletions

View File

@@ -0,0 +1,41 @@
/**
* Button component with tooltip support for disabled state
* Wraps Button component to show tooltip when disabled
*/
import { ReactNode } from 'react';
import Button, { ButtonProps } from './Button';
import { Tooltip } from '../tooltip/Tooltip';
interface ButtonWithTooltipProps extends ButtonProps {
tooltip?: string;
tooltipPlacement?: 'top' | 'bottom' | 'left' | 'right';
}
export default function ButtonWithTooltip({
tooltip,
tooltipPlacement = 'top',
disabled,
children,
...buttonProps
}: ButtonWithTooltipProps) {
// If button is disabled and has a tooltip, wrap it
if (disabled && tooltip) {
return (
<Tooltip text={tooltip} placement={tooltipPlacement}>
<span className="inline-block">
<Button {...buttonProps} disabled={disabled}>
{children}
</Button>
</span>
</Tooltip>
);
}
// Otherwise, render button normally
return (
<Button {...buttonProps} disabled={disabled}>
{children}
</Button>
);
}