feat(breadcrumb): render breadcrumbs from the hook
This commit is contained in:
parent
08e95fdb47
commit
16f9280354
|
@ -1,5 +1,14 @@
|
||||||
import { XStack } from 'tamagui'
|
import { XStack } from 'tamagui'
|
||||||
|
import useBreadcrumbs, { BreadcrumbsRoute } from 'use-react-router-breadcrumbs'
|
||||||
|
import { NavLink } from 'react-router-dom'
|
||||||
|
|
||||||
import BreadcrumbElement from './BreadcrumbElement'
|
import BreadcrumbElement from './BreadcrumbElement'
|
||||||
|
import {
|
||||||
|
MANAGE_VALIDATOR_SUB_PATHS,
|
||||||
|
PATHS,
|
||||||
|
VALIDATOR_ONBOARDING_SUB_PATHS,
|
||||||
|
} from '../../../constants'
|
||||||
|
|
||||||
const CustomPropsBreadcrumb = ({ someProp }: any) => <span>{someProp}</span>
|
const CustomPropsBreadcrumb = ({ someProp }: any) => <span>{someProp}</span>
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
|
@ -75,14 +84,14 @@ const routes = [
|
||||||
]
|
]
|
||||||
|
|
||||||
const Breadcrumb = () => {
|
const Breadcrumb = () => {
|
||||||
|
const breadcrumbs = useBreadcrumbs(routes as BreadcrumbsRoute<string>[])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<XStack space={'$2'} alignItems="center">
|
<XStack space={'$2'} alignItems="center">
|
||||||
{breadcrumbList.map((element, index) => (
|
{breadcrumbs.map(({ match, breadcrumb }) => (
|
||||||
<BreadcrumbElement
|
<NavLink key={match.pathname} to={match.pathname}>
|
||||||
element={element}
|
{breadcrumb}
|
||||||
isLastElement={index === breadcrumbList.length - 1}
|
</NavLink>
|
||||||
/>
|
|
||||||
))}
|
))}
|
||||||
</XStack>
|
</XStack>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue