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

import Accordion from '.';

export default {
  title: 'Theme/Organisms/Accordion',
  component: Accordion,
  argTypes: {
    module: {
      name: 'module',
      type: { name: 'object', required: true },
      defaultValue: '',
      description: 'The accordion items data.',
      table: {
        type: { summary: 'object `{items:[]}`' },
        defaultValue: { summary: '' },
      },
    },
    openAll: {
      name: 'openAll',
      type: { name: 'boolean', required: false },
      defaultValue: false,
      description: 'True set all items opened on first load.',
      table: {
        type: { summary: 'boolean' },
        defaultValue: { summary: false },
      },
    },
    closeOthers: {
      name: 'closeOthers',
      type: { name: 'boolean', required: false },
      defaultValue: false,
      description: 'True set other items closed when the user opens one.',
      table: {
        type: { summary: 'boolean' },
        defaultValue: { summary: false },
      },
    },
    openItem: {
      name: 'openItem',
      type: { name: 'number', required: false },
      defaultValue: '',
      description: 'Number of the item you wnat to be opened on first load.',
      table: {
        type: { summary: 'number' },
        defaultValue: { summary: '' },
      },
    },
  },
  parameters: {
    docs: {
      description: {
        component:
          'A component that accepts a list of items and options and generates a graphical control element comprising a vertically stacked list of collapsible items, such as labels or contents.',
      },
      page: () => (
        <>
          <Title />
          <Description />
          <Primary />
          <ArgsTable story={PRIMARY_STORY} />
        </>
      ),
    },
  },
};

const Template = (args) => <Accordion {...args} />;

export const Default = Template.bind({});
Default.args = {
  module: {
    items: [
      {
        title: 'Item One',
        content: `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, 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`,
      },
      {
        title: 'Item Two',
        content: `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, 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`,
      },
      {
        title: 'Item Three',
        content: `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, 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`,
      },
    ],
  },
  openAll: false,
  openItem: 2,
  closeOthers: false,
};
