Skip to content

Commit

Permalink
feat: added Breadcrumb Component
Browse files Browse the repository at this point in the history
  • Loading branch information
coderwelsch committed Mar 12, 2024
1 parent ce5bf9b commit edd7128
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/breadcrumb/breadcrumb-arrow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from "react";
import { ChevronRightIcon } from "../../icons";

export const BreadcrumbArrow = () => {
return <ChevronRightIcon className="h-3 w-3 text-neutral-800" />;
};
30 changes: 30 additions & 0 deletions src/components/breadcrumb/breadcrumb-item.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from "react";
import { classNames } from "../../util/class-names";

interface BreadcrumbItemProps {
children: React.ReactNode;
className?: string;
href?: string;
active?: boolean;
}

export const BreadcrumbItem: React.FC<BreadcrumbItemProps> = ({
children,
className,
href,
active,
}) => {
return (
<a
className={classNames(
"headline-500 text-neutral-800",
!active && "cursor-pointer underline-offset-2 hover:underline",
active && "text-black",
className
)}
href={href}
>
{children}
</a>
);
};
33 changes: 33 additions & 0 deletions src/components/breadcrumb/breadcrumb.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { Meta, StoryObj } from "@storybook/react";
import React from "react";
import { Breadcrumb } from "./breadcrumb";

const meta: Meta<typeof Breadcrumb> = {
title: "Breadcrumb",
component: Breadcrumb,
args: {},
};

export default meta;

type Story = StoryObj<typeof Breadcrumb>;

export const Base: Story = {
render: () => (
<div className="p-4">
<Breadcrumb>
<Breadcrumb.Item href="/">Home</Breadcrumb.Item>

<Breadcrumb.Arrow />

<Breadcrumb.Item href="/">Library</Breadcrumb.Item>

<Breadcrumb.Arrow />

<Breadcrumb.Item href="/" active>
Book
</Breadcrumb.Item>
</Breadcrumb>
</div>
),
};
20 changes: 20 additions & 0 deletions src/components/breadcrumb/breadcrumb.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react";
import { BreadcrumbItem } from "./breadcrumb-item";
import { BreadcrumbArrow } from "./breadcrumb-arrow";

export interface BreadcrumbProps {
children: React.ReactNode;
}

const Breadcrumb = ({ children }: BreadcrumbProps) => {

Check failure on line 9 in src/components/breadcrumb/breadcrumb.tsx

View workflow job for this annotation

GitHub Actions / format-check

Exported variable 'Breadcrumb' has or is using name 'BreadcrumbItemProps' from external module "/home/runner/work/hailstorm/hailstorm/src/components/breadcrumb/breadcrumb-item" but cannot be named.
return (
<nav className="flex flex-row items-center justify-center gap-1" role="navigation">
{children}
</nav>
);
};

Breadcrumb.Item = BreadcrumbItem;
Breadcrumb.Arrow = BreadcrumbArrow;

export { Breadcrumb };
1 change: 1 addition & 0 deletions src/components/breadcrumb/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Breadcrumb } from "./breadcrumb";
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export { Alert, AlertIntent } from "./alert";
export { Avatar } from "./avatar";
export { Badge, BadgeType } from "./badge";
export { Breadcrumb } from "./breadcrumb";
export { Button } from "./button";
export { Checkbox } from "./checkbox";
export { Dialog } from "./dialog";
Expand Down

0 comments on commit edd7128

Please sign in to comment.