feat(FE-91): create Tooltip component

This commit is contained in:
ValdiANS
2025-10-16 10:01:14 +07:00
parent eb0f04310e
commit 156de6112b
+60
View File
@@ -0,0 +1,60 @@
import { ReactNode } from 'react';
import { cn } from '@/lib/helper';
import { Color } from '@/types/theme';
interface TooltipProps {
children?: ReactNode;
content?: ReactNode;
className?: {
wrapper?: string;
content?: string;
};
open?: boolean;
color?: Color;
position?: 'top' | 'bottom' | 'left' | 'right';
}
const Tooltip = ({
children,
content,
className,
open,
color,
position,
}: TooltipProps) => {
const tooltipBaseClassName = cn('tooltip', {
'tooltip-open': typeof open === 'boolean' && open,
'tooltip-top': position === 'top',
'tooltip-bottom': position === 'bottom',
'tooltip-left': position === 'left',
'tooltip-right': position === 'right',
'tooltip-primary': color === 'primary',
'tooltip-secondary': color === 'secondary',
'tooltip-accent': color === 'accent',
'tooltip-neutral': color === 'neutral',
'tooltip-info': color === 'info',
'tooltip-success': color === 'success',
'tooltip-warning': color === 'warning',
'tooltip-error': color === 'error',
});
return (
<div className={cn(tooltipBaseClassName, className?.wrapper)}>
<div
className={cn(
'tooltip-content',
'max-w-60 sm:max-w-xs',
className?.content
)}
>
{content}
</div>
{children}
</div>
);
};
export default Tooltip;