Add: ToolTip for Follow Buttons
This commit is contained in:
@@ -16,6 +16,8 @@ const FollowButton: React.FC<FollowButtonProps> = ({ category }) => {
|
|||||||
const [isFollowing, setIsFollowing] = useState<boolean | null>(category.isFollowing);
|
const [isFollowing, setIsFollowing] = useState<boolean | null>(category.isFollowing);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const { followCategory, unfollowCategory } = useCategoryFollow();
|
const { followCategory, unfollowCategory } = useCategoryFollow();
|
||||||
|
const [showTip, setTip] = useState(false);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsFollowing(category.isFollowing);
|
setIsFollowing(category.isFollowing);
|
||||||
@@ -52,10 +54,13 @@ const FollowButton: React.FC<FollowButtonProps> = ({ category }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div>
|
||||||
<button
|
<button
|
||||||
className="absolute top-2 right-2 bg-black bg-opacity-50 p-2 rounded-full hover:bg-opacity-75 transition z-[1]"
|
className="absolute top-2 right-2 bg-black bg-opacity-50 p-2 rounded-full hover:bg-opacity-75 transition z-[1]"
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
disabled={isLoading}
|
disabled={isLoading}
|
||||||
|
onMouseEnter={() => setTip(true)}
|
||||||
|
onMouseLeave={() => setTip(false)}
|
||||||
>
|
>
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<span className="text-white w-5 h-5">⏳</span>
|
<span className="text-white w-5 h-5">⏳</span>
|
||||||
@@ -67,6 +72,26 @@ const FollowButton: React.FC<FollowButtonProps> = ({ category }) => {
|
|||||||
<CirclePlus className="text-white w-5 h-5" />
|
<CirclePlus className="text-white w-5 h-5" />
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
{/* Tooltip */}
|
||||||
|
{showTip && mode === "pencil" && (
|
||||||
|
<div className="absolute top-10 right-0 bg-gray-900 text-white text-xs px-2 py-1 rounded shadow-md">
|
||||||
|
Edit category
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{showTip && mode === "minus" && (
|
||||||
|
<div className="absolute top-10 right-0 bg-gray-900 text-white text-xs px-2 py-1 rounded shadow-md">
|
||||||
|
Unfollow Category
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{showTip && mode === "plus" && (
|
||||||
|
<div className="absolute top-10 right-0 bg-gray-900 text-white text-xs px-2 py-1 rounded shadow-md">
|
||||||
|
Follow Category
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export default FollowButton;
|
export default FollowButton;
|
||||||
|
|||||||
Reference in New Issue
Block a user