aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/src/components/MenuItem.tsx
blob: 45358c8a3726662b3194957d38664ef0209716d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import type { IconDefinition } from "@fortawesome/fontawesome-svg-core";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Link, useLocation } from "wouter";

interface Props {
	path: string;
	label: string;
	icon: IconDefinition;
}

export function MenuItem({ path, label, icon }: Props) {
	const [location] = useLocation();
	const isActive = location === path;

	return (
		<Link
			href={path}
			className={`flex items-center space-x-2 px-3 py-2 rounded-md text-sm font-medium transition-colors ${
				isActive
					? "bg-blue-100 text-blue-700"
					: "text-gray-600 hover:text-gray-900 hover:bg-gray-100"
			}`}
		>
			<FontAwesomeIcon icon={icon} />
			<span>{label}</span>
		</Link>
	);
}