Skip to content

Commit d60fca8

Browse files
authored
Merge pull request #1 from steadyfall/dev
Merge dev branch #1
2 parents 7e105af + db0391f commit d60fca8

File tree

3 files changed

+65
-10
lines changed

3 files changed

+65
-10
lines changed

package-lock.json

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Navbar.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { cn } from '@/lib/utils';
44
import ThemeSwitch from './ThemeSwitch';
5+
import HoverHighlight from '@/components/ui/HoverHighlighter';
56
import Link from 'next/link';
67

78
const Navbar = () => {
@@ -14,10 +15,10 @@ const Navbar = () => {
1415
"max-w-full mx-auto px-8 sm:px-16 md:px-24 lg:max-w-4xl xl:max-w-5xl 2xl:max-w-6xl"
1516
)}>
1617
<ul className="flex gap-4 sm:gap-8">
17-
<li><Link href="/" className="hover:underline hover:underline-offset-4">home</Link></li>
18-
<li><Link href="/#experience" className="hover:underline hover:underline-offset-4">experience</Link></li>
19-
<li><Link href="/#projects" className="hover:underline hover:underline-offset-4">projects</Link></li>
20-
<li><Link href="/posts" className="hover:underline hover:underline-offset-4">blog</Link></li>
18+
<li><Link href="/"><HoverHighlight text="home" /></Link></li>
19+
<li><Link href="/#experience"><HoverHighlight text="experience"/></Link></li>
20+
<li><Link href="/#projects"><HoverHighlight text="projects"/></Link></li>
21+
<li><Link href="/posts"><HoverHighlight text="blog"/></Link></li>
2122
</ul>
2223
<div className="flex gap-0 sm:gap-4">
2324
<ThemeSwitch />
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { cn } from "@/lib/utils";
2+
3+
interface HoverHighlightProps {
4+
text: string
5+
color?: 'cyan' | 'pink' | 'violet-web' | 'slate-blue' | 'red' | 'yellow' | 'lemon' | 'laser-lemon' | 'background'
6+
}
7+
8+
/**
9+
* Highlights the given text with the highlighter of specified color UPON hover.
10+
*
11+
* @param text - the text to be highlighted
12+
* @param color - the color of the highlighter [cyan,pink,violet-web,slate-blue,red,yellow,lemon,laser-lemon,background]
13+
*
14+
*/
15+
export default function HoverHighlight({ text, color = "background" }: HoverHighlightProps) {
16+
let colorClass: string;
17+
18+
if (color === "cyan") {
19+
colorClass = "bg-cyan-200 dark:bg-cyan-500/30";
20+
}
21+
else if (color === "pink" || color === "violet-web") {
22+
colorClass = "bg-[#ffa7ee] dark:bg-[#f73ed2]/30";
23+
}
24+
else if (color === "slate-blue") {
25+
colorClass = "bg-[#a0a8ff] dark:bg-[#675bf9]/50";
26+
}
27+
else if (color === "red") {
28+
colorClass = "bg-[#ffa0a0] dark:bg-[#f83b3b]/50";
29+
}
30+
else if (color === "background") {
31+
colorClass = "dark:bg-neutral-100 bg-neutral-950";
32+
}
33+
else {
34+
// This covers "yellow", "lemon", "laser-lemon", and the default case
35+
colorClass = "bg-[#ffff77] dark:bg-[#fce913]/30";
36+
}
37+
38+
return (
39+
<span className="relative inline-block group">
40+
<span
41+
className={cn(
42+
colorClass,
43+
"absolute inset-0 transform scale-x-0 origin-left group-hover:scale-x-100 transition-transform duration-300 ease-in-out"
44+
)}
45+
></span>
46+
<span className={cn(
47+
"relative z-1",
48+
color === "background" ? "group-hover:dark:text-gray-800 group-hover:text-gray-200" : ""
49+
)}>{text}</span>
50+
</span>
51+
)
52+
}

0 commit comments

Comments
 (0)