feat(breadcrumb): separate to container and element components

This commit is contained in:
RadoslavDimchev 2024-04-25 23:13:08 +03:00 committed by Emil Ivanichkov
parent b65bf26127
commit 7123388306
2 changed files with 35 additions and 15 deletions

View File

@ -1,25 +1,19 @@
import { Text } from '@status-im/components'
import { ChevronRightIcon } from '@status-im/icons'
import { XStack } from 'tamagui'
import BreadcrumbElement from './BreadcrumbElement'
type BreadcrumbBarProps = {
type BreadcrumbProps = {
breadcrumbList: string[]
}
const Breadcrumb = ({ breadcrumbList }: BreadcrumbBarProps) => {
const Breadcrumb = ({ breadcrumbList }: BreadcrumbProps) => {
return (
<XStack space={'$2'} alignItems="center">
{breadcrumbList.map((item, index) => {
const isNotLast = index !== breadcrumbList.length - 1
return (
<XStack space={'$2'} alignItems="center" key={index}>
<Text size={15} color={isNotLast ? '#647084' : ''}>
{item}
</Text>
{isNotLast && <ChevronRightIcon size={20} color="#647084" />}
</XStack>
)
})}
{breadcrumbList.map((element, index) => (
<BreadcrumbElement
element={element}
isLastElement={index === breadcrumbList.length - 1}
/>
))}
</XStack>
)
}

View File

@ -0,0 +1,26 @@
import { Text } from '@status-im/components'
import { ChevronRightIcon } from '@status-im/icons'
import { XStack } from 'tamagui'
type BreadcrumbElementProps = {
element: string
isLastElement: boolean
}
const BreadcrumbElement = ({
element,
isLastElement,
}: BreadcrumbElementProps) => {
return (
<XStack space={'$2'} alignItems="center">
<Text size={15} color={isLastElement ? '' : '#647084'}>
{element}
</Text>
{isLastElement === false && (
<ChevronRightIcon size={20} color="#647084" />
)}
</XStack>
)
}
export default BreadcrumbElement