Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added Breadcrumb Component #117

Merged
merged 11 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Coderwelsch marked this conversation as resolved.
Show resolved Hide resolved
}) => {
return (
<a
mnlfischer marked this conversation as resolved.
Show resolved Hide resolved
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.
mnlfischer marked this conversation as resolved.
Show resolved Hide resolved
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
Loading