import React from 'react';
import { configure, addParameters } from '@storybook/react';
import { themes } from '../src/themes';
import { deriveStorybookTheme } from '../utils/storybook/addons/patchwork-theme';

window.__IS_STORYBOOK__ = true;

addParameters({
  options: {
    // Injected by webpack.
    /* eslint-disable no-undef */
    theme: deriveStorybookTheme(themes[DEFAULT_THEME_NAME]),
    /* eslint-enable no-undef */
    storySort: (a, b) => a[1].id.localeCompare(b[1].id),
    showNav: false,
    showPanel: false,
    isFullScreen: true,
    sidebarAnimations: false,
    isToolshown: false,
  },
});

// Jest doesn't work super well with the PROJECT_ROOT stuff and its context
// implementation.
const req = require.context(
  `${process.cwd()}/src`,
  true,
  /\.(story|stories)\.js$/,
);

configure(req, module);
