import React from 'react';
import {
  Title,
  Description,
  Primary,
  PRIMARY_STORY,
  ArgsTable,
} from '@storybook/addon-docs/blocks';

import Search from '.';
import NavigationProvider from '../navigation/navigationContext';
import styles from './search.module.scss';

export default {
  title: 'Theme/Organisms/Search',
  component: Search,
  argTypes: {
    searchIcon: {
      name: 'searchIcon',
      type: { name: 'element', required: false },
      defaultValue: null,
      description: `The search button icon.`,
      table: {
        type: { summary: 'element' },
        defaultValue: { summary: null },
      },
      control: {
        type: null,
      },
    },
    iconWidth: {
      name: 'iconWidth',
      type: { name: 'number', required: false },
      defaultValue: 24,
      description: `Search icon width.`,
      table: {
        type: { summary: 'number' },
        defaultValue: { summary: 24 },
      },
    },
    iconHeight: {
      name: 'iconHeight',
      type: { name: 'number', required: false },
      defaultValue: 24,
      description: `Search icon height.`,
      table: {
        type: { summary: 'number' },
        defaultValue: { summary: 24 },
      },
    },
    className: {
      name: 'className',
      type: { name: 'string', required: false },
      defaultValue: null,
      description: `The search form container class name.`,
      table: {
        type: { summary: 'string' },
        defaultValue: { summary: null },
      },
    },
  },
  parameters: {
    docs: {
      description: {
        component: 'The Search component that is used on navigation.',
      },
      page: () => (
        <>
          <Title />
          <Description />
          <Primary />
          <ArgsTable story={PRIMARY_STORY} />
        </>
      ),
    },
  },
};

const Template = (args) => (
  <NavigationProvider>
    <div className={styles.storyContainer}>
      <Search {...args} />
    </div>
  </NavigationProvider>
);
export const Default = Template.bind({});
Default.args = {
  searchIcon: null,
  className: 'my-class',
};
