ehsan-dashboards/dashboards/VPN_chanel/frontend/components/InfoTooltip.tsx

39 lines
1.3 KiB
TypeScript

'use client';
import React, { useState } from 'react';
import { Info } from 'lucide-react';
interface InfoTooltipProps {
text: string;
title?: string;
className?: string;
}
export const InfoTooltip: React.FC<InfoTooltipProps> = ({ text, title, className = '' }) => {
const [visible, setVisible] = useState(false);
return (
<div className={`relative inline-flex items-center align-middle ${className}`}>
<button
type="button"
onMouseEnter={() => setVisible(true)}
onMouseLeave={() => setVisible(false)}
onClick={() => setVisible(!visible)}
className="p-1 rounded-full text-slate-400 hover:text-indigo-400 hover:bg-slate-800 transition focus:outline-none"
aria-label="راهنما و نحوه محاسبه"
>
<Info className="w-3.5 h-3.5" />
</button>
{visible && (
<div
className="absolute z-50 bottom-full right-0 mb-2 w-64 p-3 bg-slate-900 border border-slate-700/80 rounded-xl shadow-2xl text-xs text-slate-200 backdrop-blur-md transition-all pointer-events-none text-right"
dir="rtl"
>
{title && <div className="font-bold text-indigo-400 mb-1 border-b border-slate-800 pb-1">{title}</div>}
<p className="leading-relaxed text-slate-300">{text}</p>
</div>
)}
</div>
);
};