-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from tonyghiani/feature/breadcrumb-component
feat(react-components): 🎸 add MntBreadcrumbs component
- Loading branch information
Showing
9 changed files
with
1,129 additions
and
967 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
11 changes: 11 additions & 0 deletions
11
packages/react-components/src/components/molecules/Breadcrumbs/Breadcrumbs.classes.ts
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,11 @@ | ||
const accordionClasses = { | ||
'.mnt-breadcrumbs': { | ||
'@apply flex': {}, | ||
'& > ol > li': { '@apply inline': {} }, | ||
'& > ol > li:not(:first-child)': { | ||
'@apply before:content-[attr(data-separator)] before:mx-1.5': {} | ||
} | ||
} | ||
}; | ||
|
||
export default accordionClasses; |
26 changes: 26 additions & 0 deletions
26
packages/react-components/src/components/molecules/Breadcrumbs/Breadcrumbs.stories.tsx
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,26 @@ | ||
import React from 'react'; | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { MntText } from '../../atoms/Typography'; | ||
|
||
import { MntBreadcrumbs } from './Breadcrumbs'; | ||
|
||
const meta = { | ||
title: 'Molecules/MntBreadcrumbs', | ||
component: MntBreadcrumbs, | ||
tags: ['autodocs'] | ||
} satisfies Meta<typeof MntBreadcrumbs>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Main: Story = { | ||
args: { | ||
separator: '/', | ||
children: [ | ||
<MntText key='home'>Home</MntText>, | ||
<MntText key='blog'>Blog</MntText>, | ||
<MntText key='post'>A design system called Mountain UI</MntText> | ||
] | ||
} | ||
}; |
32 changes: 32 additions & 0 deletions
32
packages/react-components/src/components/molecules/Breadcrumbs/Breadcrumbs.tsx
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,32 @@ | ||
import React from 'react'; | ||
import mnt from 'react-mnt'; | ||
|
||
export interface BreadcrumbsProps { | ||
/** | ||
* Optional separator to use between breadcrumbs | ||
*/ | ||
separator?: string; | ||
} | ||
|
||
const StyledBreadcrumbs = mnt('nav')<BreadcrumbsProps>` | ||
mnt-breadcrumbs | ||
`; | ||
|
||
export type MntBreadcrumbsProps = React.ComponentPropsWithRef<typeof StyledBreadcrumbs>; | ||
|
||
/** | ||
* Breadcrums component for displaying breadcrumb navigation. | ||
*/ | ||
export const MntBreadcrumbs = ({ children, separator = '/', ...props }: MntBreadcrumbsProps) => { | ||
const liChildren = React.Children.map(children, child => ( | ||
<li data-separator={separator}>{child}</li> | ||
)); | ||
|
||
return ( | ||
<StyledBreadcrumbs {...props}> | ||
<ol>{liChildren}</ol> | ||
</StyledBreadcrumbs> | ||
); | ||
}; | ||
|
||
MntBreadcrumbs.displayName = 'MntBreadcrumbs'; |
2 changes: 2 additions & 0 deletions
2
packages/react-components/src/components/molecules/Breadcrumbs/index.ts
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,2 @@ | ||
export { MntBreadcrumbs } from './Breadcrumbs'; | ||
export type { MntBreadcrumbsProps } from './Breadcrumbs'; |
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export * from './Accordion'; | ||
|
||
export * from './Breadcrumbs'; | ||
|
||
export * from './CodeBlock'; | ||
|
||
export * from './RangeInput'; |
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
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
Oops, something went wrong.