import React from 'react';
import { Wrapper, Link, LastItem } from './style';
import Icon from 'kwai-icon';
import { IBread } from './types';

export const Breadcrumb = function({ options, ...rest }: IBread) {
    return (
        <Wrapper {...rest}>
            {options.map((o, index) =>
                index === options.length - 1 ? (
                    <LastItem key={index}>
                        {o.icon && <Icon name={o.icon} color="inherit" />}
                        {o.label}
                    </LastItem>
                ) : (
                    <Link to={o.link || ''} key={index}>
                        {o.icon && <Icon name={o.icon} color="inherit" />}
                        {o.label}
                    </Link>
                )
            )}
        </Wrapper>
    );
};

export default Breadcrumb;
