tangled
alpha
login
or
join now
isuggest.selfce.st
/
strand
3
fork
atom
alternative tangled frontend (extremely wip)
3
fork
atom
overview
issues
pulls
pipelines
feat: additional component
serenity
3 weeks ago
ce962e10
98dbdf60
+65
1 changed file
expand all
collapse all
unified
split
src
components
Animated
UnderlineIconLink.tsx
+65
src/components/Animated/UnderlineIconLink.tsx
···
1
1
+
import { motion, Transition, Variants } from "motion/react";
2
2
+
import { ReactNode } from "react";
3
3
+
4
4
+
export const UnderlineIconRouterLink = ({
5
5
+
href,
6
6
+
icon,
7
7
+
label,
8
8
+
className,
9
9
+
iconClassName = "text-[#cba6f7]",
10
10
+
labelClassName = "text-[#cba6f7]",
11
11
+
underlineClassName = "bg-[#cba6f7]",
12
12
+
position = "left",
13
13
+
iconVariants = {
14
14
+
hover: { rotate: [0, -10, 10, -10, 10, 0] },
15
15
+
},
16
16
+
iconTransitions = { duration: 0.3, ease: "easeInOut" },
17
17
+
}: {
18
18
+
href: string;
19
19
+
icon: ReactNode;
20
20
+
label: string;
21
21
+
className?: string;
22
22
+
iconClassName?: string;
23
23
+
labelClassName?: string;
24
24
+
underlineClassName?: string;
25
25
+
position?: "right" | "left";
26
26
+
iconVariants?: Variants;
27
27
+
iconTransitions?: Transition;
28
28
+
}) => {
29
29
+
const iconElement = (
30
30
+
<motion.div
31
31
+
variants={iconVariants}
32
32
+
transition={iconTransitions}
33
33
+
className={iconClassName}
34
34
+
>
35
35
+
{icon}
36
36
+
</motion.div>
37
37
+
);
38
38
+
39
39
+
return (
40
40
+
<motion.a
41
41
+
href={href}
42
42
+
className={`flex cursor-pointer items-center gap-1 pl-2 ${className}`}
43
43
+
initial="initial"
44
44
+
whileHover="hover"
45
45
+
>
46
46
+
{position === "left" && iconElement}
47
47
+
<motion.div className="relative inline-block">
48
48
+
<p className={labelClassName}>{label}</p>
49
49
+
<motion.span
50
50
+
className={`absolute bottom-1 left-0 h-0.25 w-full origin-center ${underlineClassName}`}
51
51
+
variants={{
52
52
+
initial: { scaleX: 0 },
53
53
+
hover: { scaleX: 1 },
54
54
+
}}
55
55
+
transition={{
56
56
+
type: "spring",
57
57
+
duration: 0.2,
58
58
+
bounce: 0.3,
59
59
+
}}
60
60
+
/>
61
61
+
</motion.div>
62
62
+
{position === "right" && iconElement}
63
63
+
</motion.a>
64
64
+
);
65
65
+
};