import { Meta, ArgTypes, Story } from "@storybook/addon-docs/blocks";
import { Breadcrumbs } from "./Breadcrumbs";
import * as BreadcrumbsStories from "./Breadcrumbs.stories";

<Meta of={BreadcrumbsStories} />

# Breadcrumbs

Breadcrumbs display the navigational context of the current page and help users understand where they are in the website structure.

## Install

```bash
yarn add @simplybusiness/mobius
```

## Usage

```js
import { Breadcrumbs, BreadcrumbItem } from "@simplybusiness/mobius";
```

## Examples

Each `BreadcrumbItem` can contain a `Link` or a simple text. The last child is disabled by default.

<Story of={BreadcrumbsStories.Default} />

{/* prettier-ignore */}
```jsx
import { Breadcrumbs, BreadcrumbItem, Link } from "@simplybusiness/mobius";

<Breadcrumbs>
  <BreadcrumbItem key="business-insurance">
    <Link href="/business-insurance">Business insurance</Link>
  </BreadcrumbItem>
  <BreadcrumbItem key="tradesmen">
    <Link href="/tradesmen">Tradesmen</Link>
  </BreadcrumbItem>
  <BreadcrumbItem key="beauty-salon-insurance">
    Beauty salon insurance
  </BreadcrumbItem>
</Breadcrumbs>
```

`BreadcrumbItem` can also contain any other element like, for example, an SVG.

<Story of={BreadcrumbsStories.WithLogo} />

{/* prettier-ignore */}
```jsx
import { Breadcrumbs, BreadcrumbItem, Link } from "@simplybusiness/mobius";

<Breadcrumbs>
  <BreadcrumbItem key="root">
    <svg
      xmlns="http://www.w3.org/2000/svg"
      viewBox="0 0 299.8 85"
      height="32px"
    >
      <path d="M109.9 38.7c3.3-3.7 4.9-8.2 4.9-13.7 0-6.5-2.3-12.4-6.6-16.7-4.6-4.7-11.1-7.1-18.8-7.1H68.5c-5.3 0-9.1 3.8-9.1 9.1v64.8c0 5.2 3.9 9.1 9.1 9.1h24.8c8.8 0 16.1-2.6 21.2-7.6 4.7-4.6 7.3-11.1 7.3-18.3 0-4.7-1.2-8.9-3.5-12.4-2.1-3-4.9-5.4-8.4-7.2zM68.4 75.9c-.7 0-.9-.3-.9-.9V10.2c0-.8.2-.9.9-.9h20.9c3.8 0 9.2.8 13.1 4.7 2.7 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 4.4 9.8 10.5 0 .9-.8 1.9-1.9 1.9H246c.3 4 3.3 6 6.6 6 2 0 3.7-.8 4.8-1.4 1.1-.5 1.9-.4 2.4.6l.5.9c.5 1 .3 1.9-.6 2.4-1.4.9-4 2.2-7.5 2.2-7.3 0-11.9-5.3-11.9-11.5.1-6.8 4.7-11.6 11.3-11.6zm4.3 9c-.1-3.1-1.9-4.9-4.5-4.9-2.8 0-4.8 1.9-5.3 4.9h9.8zm8.5 9.3l.5-.8c.6-.9 1.4-1 2.5-.4 1 .6 2.7 1.5 4.9 1.5 1.9 0 3.1-.9 3.1-2.2 0-3.6-10.9-2.2-10.9-9.8 0-4.3 3.8-6.6 8.4-6.6 2.9 0 5 .9 6.1 1.6 1 .5 1.1 1.4.6 2.4l-.4.8c-.5 1-1.3 1.2-2.4.7-1-.4-2.4-1.1-4.2-1.1-1.9 0-3 .8-3 2.2 0 3.6 10.9 2.2 10.9 9.7 0 3.9-3.3 6.8-8.4 6.8-3.5 0-6-1.3-7.4-2.2-.9-.7-1-1.6-.3-2.6zm19.3 0l.5-.8c.6-.9 1.4-1 2.5-.4 1 .6 2.7 1.5 4.9 1.5 1.9 0 3.1-.9 3.1-2.2 0-3.6-10.9-2.2-10.9-9.8 0-4.3 3.8-6.6 8.4-6.6 2.9 0 5 .9 6.1 1.6 1 .5 1.1 1.4.6 2.4l-.4.8c-.5 1-1.3 1.2-2.4.7-1-.4-2.4-1.1-4.2-1.1-1.9 0-3 .8-3 2.2 0 3.6 10.9 2.2 10.9 9.7 0 3.9-3.3 6.8-8.4 6.8-3.5 0-6-1.3-7.4-2.2-.8-.7-.9-1.6-.3-2.6z" />
    </svg>
  </BreadcrumbItem>
  <BreadcrumbItem key="business-insurance">
    <Link href="/business-insurance">Business insurance</Link>
  </BreadcrumbItem>
  <BreadcrumbItem key="tradesmen">
    <Link href="/tradesmen">Tradesmen</Link>
  </BreadcrumbItem>
  <BreadcrumbItem key="beauty-salon-insurance">
    <Link href="/beauty">Beauty Salon</Link>
  </BreadcrumbItem>
</Breadcrumbs>
```

## Props

<ArgTypes of={Breadcrumbs} />

## Component HTML Structure and Class names

The following example HTML is rendered for a Breadcrumb:

```html
<nav class="mobius-breadcrumb" aria-label="Breadcrumbs">
  <ul>
    <li class="mobius-breadcrumb__item">
      <a class="mobius-link" href="{/path-to-item}" role="link"
        >{crumb link text}</a
      >
      <div class="mobius-box" aria-hidden="true">&gt;</div>
    </li>

    (more li items...)
  </ul>
</nav>
```
