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

import ModuleTitle from '.';

export default {
  title: 'Theme/Atoms/Module Title',
  component: ModuleTitle,
  argTypes: {
    module: {
      name: 'module',
      type: { name: 'object', required: false },
      defaultValue: '',
      description: 'The module object, to receive the module title, title tag and view more data.',
      table: {
        type: { summary: 'object' },
        defaultValue: { summary: '' },
      },
    },
    viewMoreIcon: {
      name: 'viewMoreIcon',
      type: { name: 'element', required: false },
      defaultValue: '',
      description: 'Icon for the view more link. Default is an arrow pointing right.',
      table: {
        type: { summary: 'element' },
        defaultValue: { summary: '<FaAngleRight />' },
      },
      control: null,
    },
  },
  parameters: {
    docs: {
      description: {
        component:
          'A component to display the module title coming from Hercules. The title is wrapped in a tag, depending on which title tag is selected in Hercules. Displays a link if the field is available in Hercules, `link_label` and `link_value`.',
      },
      page: () => (
        <>
          <Title />
          <Description />
          <Primary />
          <ArgsTable story={PRIMARY_STORY} />
        </>
      ),
    },
  },
};

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

export const Default = Template.bind({});
Default.args = {
  module: {
    module_title: 'Latest News',
    module_title_tag: 'h2',
    link_label: 'View More',
    link_value: '/all-slots',
  },
};
