-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: add HoverTooltip for socialicon
Signed-off-by: Zach <i@ssstttar.com>
- Loading branch information
Showing
3 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React, { ReactNode } from 'react' | ||
import { motion } from 'framer-motion' | ||
|
||
interface HoverTooltipProps { | ||
/** 要显示的内容 */ | ||
children: ReactNode | ||
/** 悬停时显示的文本 */ | ||
tooltipText: string | ||
/** 可选的自定义样式类名 */ | ||
className?: string | ||
} | ||
|
||
export const HoverTooltip: React.FC<HoverTooltipProps> = ({ | ||
children, | ||
tooltipText, | ||
className = '', | ||
}) => { | ||
return ( | ||
<motion.div | ||
className={`group relative ${className}`} | ||
whileHover={{ scale: 1.1 }} | ||
whileTap={{ scale: 0.9 }} | ||
> | ||
{children} | ||
<span className="absolute left-0 right-0 top-full mt-1 text-center text-xs text-gray-400 opacity-0 transition-opacity group-hover:opacity-100"> | ||
{tooltipText} | ||
</span> | ||
</motion.div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters