var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

import React from 'react';
import { storiesOf } from '@storybook/react';
import { withKnobs, select, text, array, boolean, color, number } from '@storybook/addon-knobs';
import { assets, svgOptions } from './Icon.knob.options';
import Icon from './index';
import IconDisplay from './IconDisplay';

storiesOf('brand|icons', module).addDecorator(withKnobs({ escapeHTML: false })).add('Icon', function () {
  // This needs to be dynamic somehow.

  var name = select('name', svgOptions, 'alert');
  var svgWidth = text('svgWidth', 40);
  var svgHeight = text('svgHeight', 40);
  var title = text('title', 'Icon Title Here');
  var classes = array('classes', ['']);
  var ariaHidden = boolean('ariaHidden', false);
  var fill = color('fill color', '#000');
  var props = {
    name: name,
    svgWidth: svgWidth,
    svgHeight: svgHeight,
    title: title,
    classes: classes,
    ariaHidden: ariaHidden,
    fill: fill
  };
  if (window.location.search.indexOf('backstop') > -1) {
    return Object.entries(assets).map(function (_ref) {
      var key = _ref[0];

      var backstopProps = {
        key: key,
        name: key,
        svgWidth: svgWidth,
        svgHeight: svgHeight,
        title: title
      };
      return React.createElement(Icon, backstopProps);
    });
  }
  return React.createElement(Icon, props);
});

storiesOf('brand|icons', module).addDecorator(withKnobs({ escapeHTML: false })).add('All Icons', function () {
  var svgWidth = number('svgWidth', 40);
  var svgHeight = number('svgHeight', 40);
  var title = text('title', 'Icon Title Here');
  var classes = array('classes', ['']);
  var ariaHidden = boolean('ariaHidden', false);
  var fill = color('fill color', '#000');
  var allIconProps = Object.keys(assets).map(function (key) {
    return {
      key: key,
      name: key,
      svgWidth: svgWidth,
      svgHeight: svgHeight,
      title: title,
      classes: classes,
      ariaHidden: ariaHidden,
      fill: fill
    };
  });
  return React.createElement(
    'ul',
    { className: 'sg-icons' },
    allIconProps.map(function (iconProp) {
      return React.createElement(IconDisplay, _extends({}, iconProp, { key: 'icon_' + iconProp.key }));
    })
  );
});