-
Notifications
You must be signed in to change notification settings - Fork 10
HOV-50 | Added New component Breadcrumb #133
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7f87f3d
Initial commit for Breadcrumb
AnilHash 0183567
Changed Breadcrumb PR
AnilHash 2edac84
Merge pull request #1 from AnilHash/anilBreadcrumb
AnilHash 5f85aac
default separator
AnilHash ed51026
Merge branch 'antstackio:main' into main
AnilHash 417d596
Breadcrumb- Source code
AnilHash 5ce548d
Index file added
AnilHash 8733e00
Merge branch 'antstackio:main' into anilBreadcrumb
AnilHash f18ce3c
Merge branch 'main' into anilBreadcrumb
AnilHash 4377cd3
Refs added for component
AnilHash 6054667
Merge pull request #5 from AnilHash/anilBreadcrumb
AnilHash 2bcde36
Updated doc
AnilHash 57e2db8
Merge pull request #6 from AnilHash/anilBreadcrumb
AnilHash 657ee06
Merge branch 'antstackio:main' into main
AnilHash b9d8b1a
Added Example
AnilHash 918a6be
Merge pull request #7 from AnilHash/anilBreadcrumb
AnilHash File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,60 @@ | ||
| # Breadcrumb | ||
|
|
||
| To display hierarchy with respect to current location and help with navigation. | ||
|
|
||
| ### Quick start | ||
|
|
||
| Here's a quick start guide to get started with the Breadcrumb component | ||
|
|
||
| ### Importing Component | ||
|
|
||
| ```jsx | ||
| import { Breadcrumb } from "@hover-design/react"; | ||
| ``` | ||
|
|
||
| ### Code Snippets and Examples | ||
|
|
||
| import "@hover-design/react/dist/style.css"; | ||
| import { Breadcrumb, Card } from "@hover-design/react"; | ||
| export const BreadcrumbComponent = ({ list, separator = "/" }) => ( | ||
| <Breadcrumb crumbs={list} separator={separator} /> | ||
| ); | ||
| const list = [ | ||
| { title: "Hover" }, | ||
| { title: "Components", href: "#" }, | ||
| { title: "Docs", href: "#" }, | ||
| ]; | ||
|
|
||
| ```jsx | ||
| const App = () => { | ||
| const list = [ | ||
| { title: "Hover" }, | ||
| { title: "Components", href: "#" }, | ||
| { title: "Docs", href: "#" }, | ||
| ]; | ||
| return ( | ||
| <div className="App"> | ||
| <Breadcrumb crumbs={list} separator={"/"} /> | ||
| </div> | ||
| ); | ||
| }; | ||
| ``` | ||
|
|
||
| #### Example | ||
|
|
||
| <Card variant="shadow"> | ||
| <BreadcrumbComponent list={list} separator=">" /> | ||
| </Card> | ||
|
|
||
| ### Breadcrumb | ||
|
|
||
| | Property | Description | Type | Default Version | | ||
| | :-------- | :---------------------- | :------------------ | :-------------- | | ||
| | crumbs | List of Breadcrumbs | Array[crumb] | - | | ||
| | separator | Separator between links | string or ReactNode | `/` | | ||
|
|
||
| ### crumbs | ||
|
|
||
| | Property | Description | Type | Default Version | | ||
| | :------- | :---------------------------------------- | :----- | :-------------- | | ||
| | crumb | Object with title(must) & href properties | Object | | |
This file contains hidden or 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,23 @@ | ||
| import { Breadcrumb, BreadcrumbProps } from "./Breadcrumb"; | ||
| import type { Story } from "@ladle/react"; | ||
|
|
||
| export const Controls: Story<BreadcrumbProps> = ({ | ||
| crumbs, | ||
| separator = "/", | ||
| className, | ||
| ...nativeProps | ||
| }) => ( | ||
| <> | ||
| <Breadcrumb crumbs={crumbs} separator={separator} {...nativeProps} /> | ||
| </> | ||
| ); | ||
| const crumbs = [ | ||
| { title: "Hover" }, | ||
| { title: "Documantation", href: "#" }, | ||
| { title: "About", href: "#" }, | ||
| ]; | ||
| const separator = ">"; | ||
| Controls.args = { | ||
| crumbs, | ||
| separator, | ||
| }; |
This file contains hidden or 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,46 @@ | ||
| import React, { forwardRef } from "react"; | ||
| import { | ||
| breadcrumbWrapper, | ||
| crumbSeparator, | ||
| crumbTitle, | ||
| } from "./breadcrumb.css"; | ||
|
|
||
| type crumb = { | ||
| title: string; | ||
| href?: string; | ||
| }; | ||
|
|
||
| export interface BreadcrumbProps { | ||
| crumbs: Array<crumb>; | ||
| separator?: string | React.ReactNode; | ||
| className?: string; | ||
| } | ||
|
|
||
| const Breadcrumb: React.ForwardRefRenderFunction< | ||
| HTMLDivElement, | ||
| BreadcrumbProps | ||
| > = ({ crumbs, separator = "/", className, ...nativeProps }, ref) => { | ||
| return ( | ||
| <div | ||
| ref={ref} | ||
| className={`${breadcrumbWrapper} ${className}`} | ||
| {...nativeProps} | ||
| > | ||
| {crumbs.map((b, index, arr) => { | ||
| return ( | ||
| <React.Fragment key={index}> | ||
| <a className={`${crumbTitle}`} href={b.href}> | ||
| {b.title} | ||
| </a> | ||
| {arr.length - 1 !== index && ( | ||
| <span className={`${crumbSeparator}`}>{separator}</span> | ||
| )} | ||
| </React.Fragment> | ||
| ); | ||
| })} | ||
| </div> | ||
| ); | ||
| }; | ||
| const BreadcrumbWithRef = forwardRef(Breadcrumb); | ||
|
|
||
| export { BreadcrumbWithRef as Breadcrumb }; | ||
This file contains hidden or 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,12 @@ | ||
| import { style } from "@vanilla-extract/css"; | ||
|
|
||
| export const breadcrumbWrapper = style({ | ||
| display: "flex", | ||
| alignItems: "center" | ||
| }); | ||
| export const crumbTitle = style({ | ||
| paddingLeft:"1em" | ||
| }) | ||
| export const crumbSeparator = style({ | ||
| paddingLeft:"1em" | ||
| }) |
This file contains hidden or 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,2 @@ | ||
| export * from "./Breadcrumb"; | ||
| export * from "./breadcrumb.css"; |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move this into a seperate file called
breadcrumb.types.ts