import React from 'react';
import { configure, addParameters, addDecorator } from '@storybook/react';
import { withInfo } from '@storybook/addon-info';
import { Provider } from 'react-redux';
import { withKnobs } from '@storybook/addon-knobs';
import '@vincent_za/styles/src/reset.css';
import store from '../src/storybook/configureStore';

import './overrides/reset.css';

import { Table, styles } from './overrides/Info'
import theme from './overrides/theme';

const req = require.context('../src', true, /stories.js$/);
// const req = require.context('../dist', true, /stories.js$/);

function loadStories() {
  req.keys().forEach(filename => req(filename));
}

addParameters({
  options: {
    panelPosition: 'right',
    theme,
  },
});
addDecorator(withInfo({
  inline: true,
  maxPropObjectKeys: 10,
  maxPropsIntoLine: 1,
  TableComponent: Table,
  styles,
}));
addDecorator((getStory) => (
  <Provider store={store()}>
    {getStory()}
  </Provider>
))
addDecorator(withKnobs)
configure(loadStories, module);
