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

import Tabs from '.';

export default {
  title: 'Theme/Hooks/Tabs',
  component: Tabs,
  argTypes: {
    children: {
      name: 'children',
      type: { name: 'element', required: true },
      defaultValue: '',
      description: 'Tabs contents in separated divs.',
      table: {
        type: { summary: 'element' },
        defaultValue: { summary: '' },
      },
      control: {
        type: null,
      },
    },
    showAll: {
      name: 'showAll',
      type: { name: 'string', required: false },
      defaultValue: '',
      description: 'If is not empty, displays a tab to show all tabs contents.',
      table: {
        type: { summary: 'string' },
        defaultValue: { summary: '' },
      },
    },
    tabsAlign: {
      name: 'tabsAlign',
      type: { name: 'string', required: false },
      defaultValue: '',
      description: 'Align tabs to left or right.',
      table: {
        type: { summary: 'string' },
        defaultValue: { summary: '' },
      },
      control: {
        type: 'inline-radio',
        options: ['right', 'left'],
      },
    },
    HeaderComp: {
      name: 'HeaderComp',
      type: { name: 'element', required: false },
      defaultValue: '',
      description: 'A custom header component.',
      table: {
        type: { summary: 'element | any' },
        defaultValue: { summary: '' },
      },
      control: {
        type: null,
      },
    },
    headerClass: {
      name: 'headerClass',
      type: { name: 'string', required: false },
      defaultValue: '',
      description: 'The tabs header class name.',
      table: {
        type: { summary: 'string' },
        defaultValue: { summary: '' },
      },
    },
    activeTabClass: {
      name: 'activeTabClass',
      type: { name: 'string', required: false },
      defaultValue: '',
      description: 'The active tab class name.',
      table: {
        type: { summary: 'string' },
        defaultValue: { summary: '' },
      },
    },
  },
  parameters: {
    docs: {
      description: {
        component: 'A component to show content on separeted tabs.',
      },
      page: () => (
        <>
          <Title />
          <Description />
          <Primary />
          <ArgsTable story={PRIMARY_STORY} />
        </>
      ),
    },
  },
};

const Template = (args) => (
  <Tabs {...args}>
    <div label="Tab One" key={1}>
      <h2>Tab One Content</h2>
      <p>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
        been the industry's standard dummy text ever since the 1500s,
      </p>
    </div>
    <div label="Tab Two" key={2}>
      <h2>Tab Two Content</h2>
      <p>
        when an unknown printer took a galley of type and scrambled it to make a type specimen book.
        It has survived not only five centuries, but also the leap into electronic typesetting,
        remaining essentially unchanged.
      </p>
    </div>
    <div label="Tab Three" key={3}>
      <h2>Tab Three Content</h2>
      <p>
        It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
        passages, and more recently with desktop publishing software like Aldus PageMaker including
        versions of Lorem Ipsum.
      </p>
    </div>
  </Tabs>
);

export const Default = Template.bind({});
Default.args = {
  tabsAlign: 'left',
  HeaderComp: <h3>Custom Header content</h3>,
  headerClass: 'my-header',
  showAll: 'All Tabs',
  activeTabClass: 'active',
};
