import React from 'react';
import { storiesOf } from '@storybook/react';
import { withKnobs, text } from '@storybook/addon-knobs';

import Breadcrumb from './index';
import BreadcrumbItem from './item';
import { Link } from '../../../index';

var getLink = function getLink() {
  var sampleText = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Sample Link';
  var index = arguments[1];

  var linkProps = {
    text: text('Breadcrumb ' + index + ': text', sampleText, 'Breadcrumb ' + index),
    href: text('Breadcrumb ' + index + ': href', 'http://www.mass.gov/', 'Breadcrumb ' + index),
    icon: null
  };
  return React.createElement(Link, linkProps);
};

var getItem = function getItem(itemText, index, currentPage) {
  return React.createElement(
    BreadcrumbItem,
    { currentPage: currentPage },
    getLink(itemText, index)
  );
};

storiesOf('molecules', module).addDecorator(withKnobs({ escapeHTML: false })).add('Breadcrumb', function () {
  var currentItemProp = {
    currentPage: text('currentPage', 'Suffolk DA - Historical Spending')
  };
  return React.createElement(
    Breadcrumb,
    null,
    getItem('Appropriation Recommendation', 0),
    getItem('Independents', 1),
    getItem('District Attorneys', 2),
    React.createElement(BreadcrumbItem, currentItemProp)
  );
});