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

import Toplist from '.';
import { multiToplistData, singleToplistData } from '~tests/factories/modules/toplist.factory';

export default {
  title: 'Theme/Organisms/Toplist',
  component: Toplist,
  argTypes: {
    module: {
      name: 'module',
      type: { name: 'object', required: false },
      defaultValue: '',
      description: 'The toplist items passed to make a toplist or multi-toplist.',
      table: {
        type: { summary: 'object' },
        defaultValue: { summary: null },
      },
    },
    toplistHeading: {
      name: 'toplistHeading',
      type: { name: 'element', required: false },
      defaultValue: null,
      description:
        'An element containing headings for the toplist (see Variant One directly above the toplist items for example).',
      table: {
        type: { summary: 'element' },
        defaultValue: { summary: null },
      },
      control: { type: null },
    },
    CustomRow: {
      name: 'CustomRow',
      type: { name: 'function', required: false },
      defaultValue: null,
      description:
        'A custom toplist row. This is used to override the default toplist row with a theme or site specific row. For example the Variant One row is a CustomRow.',
      table: {
        type: { summary: 'function' },
        defaultValue: { summary: null },
      },
    },
    page: {
      name: 'page',
      type: { name: 'object', required: false },
      defaultValue: null,
      description: 'The page object.',
      table: {
        type: { summary: 'object' },
        defaultValue: { summary: null },
      },
    },
  },
  parameters: {
    docs: {
      description: {
        component:
          'List of casinos typically displaying bonus information, unique selling points and a CTA. Depending on the data received from Hercules, the toplist will display as a multi-toplist with tabs, single toplist, and/or with a load more button. The toplist rows are customizable, reusable and can even be displayed in grid style rather than rows.',
      },
      page: () => (
        <>
          <Title />
          <Description />
          <Primary />
          <Stories />
          <ArgsTable story={PRIMARY_STORY} />
        </>
      ),
    },
  },
};

const ToplistDefaultMulti = (args) => <Toplist {...args} />;
const ToplistDefaultSingle = (args) => <Toplist {...args} />;

export const DefaultMulti = ToplistDefaultMulti.bind({});
DefaultMulti.story = {
  parameters: {
    docs: {
      storyDescription:
        'Please note the default toplists are styled just for demonstration purposes. They are not used on sites with this style. Styles are overidden per site.',
    },
  },
  args: {
    module: multiToplistData,
  },
};

export const DefaultSingle = ToplistDefaultSingle.bind({});
DefaultSingle.story = {
  parameters: {
    docs: {
      storyDescription:
        'Default toplist with no tabs, single toplist. Displays `Load More` button in this example but does not necessarily need to. Load more button will display depending on the amount of toplist items received from Hercules.',
    },
  },
  args: {
    module: singleToplistData,
  },
};
