-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c81d9d5
commit 82d5311
Showing
8 changed files
with
195 additions
and
5 deletions.
There are no files selected for viewing
Binary file not shown.
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
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,149 @@ | ||
import { useState, useRef, MouseEvent } from "react"; | ||
import { motion, useAnimation, AnimatePresence } from "framer-motion"; | ||
import { Github, Heart } from "lucide-react"; | ||
import { | ||
TooltipProvider, | ||
Tooltip, | ||
TooltipContent, | ||
TooltipTrigger, | ||
} from "@/components/ui/tooltip"; | ||
import { Button } from "@/components/ui/button"; | ||
import { FaXTwitter } from "react-icons/fa6"; | ||
|
||
export function Attr() { | ||
const controls = useAnimation(); | ||
const [isOpen, setIsOpen] = useState(false); | ||
const timeoutRef = useRef(null); | ||
|
||
const handleOpen = () => { | ||
if (timeoutRef.current) clearTimeout(timeoutRef.current); | ||
setIsOpen(true); | ||
controls.start({ | ||
scale: [1, 1.2, 1], | ||
transition: { duration: 0.5 }, | ||
}); | ||
}; | ||
|
||
const handleClose = () => { | ||
if (timeoutRef.current) clearTimeout(timeoutRef.current); | ||
// @ts-ignore | ||
timeoutRef.current = setTimeout(() => { | ||
setIsOpen(false); | ||
}, 150); | ||
}; | ||
|
||
const handleTooltipMouseEnter = () => { | ||
if (timeoutRef.current) clearTimeout(timeoutRef.current); | ||
setIsOpen(true); | ||
}; | ||
|
||
const handleTooltipMouseLeave = () => { | ||
handleClose(); | ||
}; | ||
|
||
const handleClick = () => { | ||
setIsOpen(!isOpen); | ||
}; | ||
|
||
const handleLinkClick = (e: MouseEvent<HTMLAnchorElement>) => { | ||
e.stopPropagation(); | ||
setIsOpen(false); | ||
}; | ||
|
||
return ( | ||
<TooltipProvider> | ||
<Tooltip open={isOpen}> | ||
<motion.div | ||
className="p-4 bg-gradient-to-t from-background/80 to-transparent backdrop-blur-sm" | ||
initial={{ opacity: 0, y: 20 }} | ||
animate={{ opacity: 1, y: 0 }} | ||
transition={{ duration: 0.5 }} | ||
> | ||
<motion.div | ||
className="max-w-md mx-auto flex items-center justify-center lg:space-x-3 text-foreground" | ||
onMouseEnter={handleOpen} | ||
onMouseLeave={handleClose} | ||
> | ||
<span className="text-sm font-medium hidden lg:inline"> | ||
built with | ||
</span> | ||
<motion.div | ||
animate={{ | ||
rotateY: [0, 360], | ||
transition: { duration: 2, repeat: Infinity, ease: "linear" }, | ||
}} | ||
> | ||
<Heart className="size-5 text-red-500" fill="currentColor" /> | ||
</motion.div> | ||
<motion.span | ||
className="text-sm font-medium hidden lg:inline" | ||
initial={{ opacity: 0, x: -10 }} | ||
animate={{ opacity: 1, x: 0 }} | ||
transition={{ delay: 0.2 }} | ||
> | ||
by{" "} | ||
<TooltipTrigger asChild> | ||
<Button | ||
variant="link" | ||
className="p-0 h-auto font-medium underline-offset-4 hover:underline" | ||
onClick={handleClick} | ||
onFocus={handleOpen} | ||
onBlur={handleClose} | ||
> | ||
listlessbird | ||
</Button> | ||
</TooltipTrigger> | ||
</motion.span> | ||
</motion.div> | ||
</motion.div> | ||
<AnimatePresence> | ||
{isOpen && ( | ||
<TooltipContent | ||
side="top" | ||
sideOffset={5} | ||
onMouseEnter={handleTooltipMouseEnter} | ||
onMouseLeave={handleTooltipMouseLeave} | ||
className="select-none cursor-default" | ||
> | ||
<motion.div | ||
className="flex flex-col items-center space-y-2" | ||
initial={{ opacity: 0, y: 10 }} | ||
animate={{ opacity: 1, y: 0 }} | ||
exit={{ opacity: 0, y: 10 }} | ||
> | ||
<div className="flex items-center space-x-2"> | ||
<Github className="size-4" /> | ||
<a | ||
href="https://github.com/listlessbird" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className="hover:underline" | ||
onClick={handleLinkClick} | ||
onFocus={handleOpen} | ||
onBlur={handleClose} | ||
> | ||
github.com/listlessbird | ||
</a> | ||
</div> | ||
<div className="flex items-center space-x-2"> | ||
<FaXTwitter className="size-4" /> | ||
<a | ||
href="https://twitter.com/listlessbird" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className="hover:underline" | ||
onClick={handleLinkClick} | ||
onFocus={handleOpen} | ||
onBlur={handleClose} | ||
> | ||
@listlessbird | ||
</a> | ||
</div> | ||
</motion.div> | ||
</TooltipContent> | ||
)} | ||
</AnimatePresence> | ||
</Tooltip> | ||
</TooltipProvider> | ||
); | ||
} |
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
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 @@ | ||
"use client" | ||
|
||
import * as React from "react" | ||
import * as TooltipPrimitive from "@radix-ui/react-tooltip" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const TooltipProvider = TooltipPrimitive.Provider | ||
|
||
const Tooltip = TooltipPrimitive.Root | ||
|
||
const TooltipTrigger = TooltipPrimitive.Trigger | ||
|
||
const TooltipContent = React.forwardRef< | ||
React.ElementRef<typeof TooltipPrimitive.Content>, | ||
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> | ||
>(({ className, sideOffset = 4, ...props }, ref) => ( | ||
<TooltipPrimitive.Content | ||
ref={ref} | ||
sideOffset={sideOffset} | ||
className={cn( | ||
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)) | ||
TooltipContent.displayName = TooltipPrimitive.Content.displayName | ||
|
||
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } |