import React from 'react';
import clsx from 'clsx';
import {
  BreadcrumbsListItemWrapper,
  BreadcrumbsListItemWrapperProps,
} from '@digigov/react-core/BreadcrumbsListItemWrapper';
import Link from '@digigov/ui/navigation/Link';

export interface BreadcrumbsListItemProps
  extends BreadcrumbsListItemWrapperProps {
  href?: string;
  ariaCurrent?: 'page';
}

const BreadcrumbsListItem: React.FC<BreadcrumbsListItemProps> = ({
  href,
  children,
  ariaCurrent,
  ...props
}) => {
  return (
    <BreadcrumbsListItemWrapper {...props}>
      <Link
        href={href || ''}
        aria-current={ariaCurrent}
        defaultStyle={false}
        className={clsx({
          'ds-breadcrumbs__link': true,
          'ds-breadcrumbs__link--inactive': href === undefined || href === '',
        })}
      >
        {children}
      </Link>
    </BreadcrumbsListItemWrapper>
  );
};

export { BreadcrumbsListItem };
export default BreadcrumbsListItem;
