-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
coderwelsch
committed
Mar 12, 2024
1 parent
ce5bf9b
commit edd7128
Showing
6 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / format-check
|
||
return ( | ||
<nav className="flex flex-row items-center justify-center gap-1" role="navigation"> | ||
{children} | ||
</nav> | ||
); | ||
}; | ||
|
||
Breadcrumb.Item = BreadcrumbItem; | ||
Breadcrumb.Arrow = BreadcrumbArrow; | ||
|
||
export { Breadcrumb }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Breadcrumb } from "./breadcrumb"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters