Skip to content

Commit 1ea5d68

Browse files
authored
feat: add animated underline to navigation and hero links (#18)
1 parent 1615b25 commit 1ea5d68

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

app/page.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,31 @@ export default function Home() {
2929
We work at the intersection of{" "}
3030
<Link
3131
href="/research"
32-
className="underline decoration-foreground/40 decoration-1 underline-offset-4 transition-colors hover:decoration-foreground"
32+
className="group relative inline-block"
3333
>
3434
computational neuroscience
35+
<span className="absolute -bottom-0.5 left-0 h-[1px] w-full bg-foreground/25" />
36+
<span className="absolute -bottom-0.5 left-0 h-[1px] w-0 bg-foreground transition-all duration-300 group-hover:w-full" />
3537
</Link>{" "}
3638
and{" "}
3739
<Link
3840
href="/research"
39-
className="underline decoration-foreground/40 decoration-1 underline-offset-4 transition-colors hover:decoration-foreground"
41+
className="group relative inline-block"
4042
>
4143
machine learning
44+
<span className="absolute -bottom-0.5 left-0 h-[1px] w-full bg-foreground/25" />
45+
<span className="absolute -bottom-0.5 left-0 h-[1px] w-0 bg-foreground transition-all duration-300 group-hover:w-full" />
4246
</Link>
4347
</h1>
4448
<p className="animate-slide-up text-sm leading-relaxed text-muted-foreground sm:text-base lg:text-base">
4549
We are interested in understanding{" "}
4650
<Link
4751
href="/publications"
48-
className="underline decoration-muted-foreground/50 decoration-1 underline-offset-2 transition-colors hover:decoration-foreground"
52+
className="group relative inline-block transition-colors hover:text-foreground"
4953
>
5054
behavior
55+
<span className="absolute -bottom-0.5 left-0 h-[1px] w-full bg-muted-foreground/30" />
56+
<span className="absolute -bottom-0.5 left-0 h-[1px] w-0 bg-foreground transition-all duration-300 group-hover:w-full" />
5157
</Link>{" "}
5258
in computational terms and in reverse-engineering the algorithms of the brain.
5359
</p>

components/header.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,15 @@ export function Header() {
9494
key={item.name}
9595
href={item.href}
9696
className={cn(
97-
"text-sm font-medium transition-colors hover:text-primary",
98-
isActive ? "text-foreground" : "text-muted-foreground"
97+
"group relative text-sm font-medium transition-all duration-200",
98+
isActive ? "text-foreground" : "text-muted-foreground hover:text-foreground"
9999
)}
100100
>
101101
{item.name}
102+
<span className={cn(
103+
"absolute -bottom-1 left-0 h-0.5 bg-foreground transition-all duration-300",
104+
isActive ? "w-full" : "w-0 group-hover:w-full"
105+
)} />
102106
</Link>
103107
)
104108
})}
@@ -113,20 +117,21 @@ export function Header() {
113117
createPortal(
114118
<div
115119
id="mobile-nav"
116-
className="fixed inset-x-0 bottom-0 z-50 overflow-y-auto border-t border-border bg-background/95 shadow-lg backdrop-blur supports-[backdrop-filter]:bg-background/80 lg:hidden"
120+
className="fixed inset-x-0 bottom-0 z-50 animate-slide-down overflow-y-auto border-t border-border bg-background/95 shadow-lg backdrop-blur supports-[backdrop-filter]:bg-background/80 lg:hidden"
117121
style={{ top: headerOffset }}
118122
>
119123
<div className="section-container space-y-1 py-6">
120-
{navigation.map((item) => {
124+
{navigation.map((item, index) => {
121125
const isActive = pathname === item.href || pathname === `${item.href}/`
122126
return (
123127
<Link
124128
key={item.name}
125129
href={item.href}
126130
className={cn(
127-
"block rounded-md px-3 py-2 text-base transition-colors hover:bg-accent",
131+
"block rounded-md px-3 py-2 text-base transition-all hover:bg-accent hover:pl-4",
128132
isActive ? "bg-accent text-foreground" : "text-muted-foreground"
129133
)}
134+
style={{ animationDelay: `${index * 50}ms` }}
130135
onClick={() => setMobileMenuOpen(false)}
131136
>
132137
{item.name}

0 commit comments

Comments
 (0)