Skip to content

Commit a9061e7

Browse files
Merge pull request #330 from ritik4ever/feature/breadcrumb-component-316
feat: implement basic breadcrumb navigation component
2 parents aac2ed5 + 7fa370a commit a9061e7

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import Breadcrumb from './Breadcrumb';
2+
3+
// Example usage in a Dashboard page
4+
export const DashboardBreadcrumb = () => {
5+
return (
6+
<Breadcrumb
7+
items={[
8+
{ label: 'Home', href: '/' },
9+
{ label: 'Dashboard' }
10+
]}
11+
/>
12+
);
13+
};
14+
15+
// Example usage in a Profile page
16+
export const ProfileBreadcrumb = () => {
17+
return (
18+
<Breadcrumb
19+
items={[
20+
{ label: 'Home', href: '/' },
21+
{ label: 'Settings', href: '/settings' },
22+
{ label: 'Profile' }
23+
]}
24+
/>
25+
);
26+
};
27+
28+
// Example usage with nested navigation
29+
export const AssetDetailBreadcrumb = () => {
30+
return (
31+
<Breadcrumb
32+
items={[
33+
{ label: 'Home', href: '/' },
34+
{ label: 'Assets', href: '/assets' },
35+
{ label: 'Equipment', href: '/assets/equipment' },
36+
{ label: 'Laptop #12345' }
37+
]}
38+
/>
39+
);
40+
};
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React from 'react';
2+
import Link from 'next/link';
3+
4+
interface BreadcrumbItem {
5+
label: string;
6+
href?: string;
7+
}
8+
9+
interface BreadcrumbProps {
10+
items: BreadcrumbItem[];
11+
}
12+
13+
const Breadcrumb: React.FC<BreadcrumbProps> = ({ items }) => {
14+
return (
15+
<nav aria-label="Breadcrumb" className="flex gap-2 text-sm">
16+
{items.map((item, index) => {
17+
const isLast = index === items.length - 1;
18+
19+
return (
20+
<React.Fragment key={index}>
21+
{isLast ? (
22+
<span className="text-gray-600 font-medium" aria-current="page">
23+
{item.label}
24+
</span>
25+
) : (
26+
<React.Fragment>
27+
<Link
28+
href={item.href || '#'}
29+
className="text-blue-600 hover:text-blue-800 hover:underline transition-colors"
30+
>
31+
{item.label}
32+
</Link>
33+
<span className="text-gray-400" aria-hidden="true">
34+
/
35+
</span>
36+
</React.Fragment>
37+
)}
38+
</React.Fragment>
39+
);
40+
})}
41+
</nav>
42+
);
43+
};
44+
45+
export default Breadcrumb;

frontend/components/ui/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as Breadcrumb } from './Breadcrumb';

0 commit comments

Comments
 (0)