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

import Content from '.';
import {
  contentImage,
  floatRightImage,
  floatLeftImage,
  fullWidthImage,
  alignRightImage,
  alignLeftImage,
} from '~tests/factories/modules/content.factory';

export default {
  title: 'Theme/Modules/Content/Common/Text and Images',
  component: Content,
  argTypes: {
    module: {
      name: 'module',
      type: { name: 'object', required: false },
      defaultValue: '',
      description: 'The module data object',
      table: {
        type: { summary: 'object' },
        defaultValue: { summary: '' },
      },
    },
  },
  parameters: {
    docs: {
      description: {
        component:
          'The content component displays content received from Hercules and replaces all images within the data with the lazy image component.',
      },
      page: () => (
        <>
          <Title />
          <Description />
          <Primary />
          <ArgsTable story={PRIMARY_STORY} />
        </>
      ),
    },
  },
};

const TemplateContentImage = (args) => <Content {...args} />;

export const Text = TemplateContentImage.bind({});
Text.story = {
  parameters: {
    docs: {
      storyDescription:
        'In Hercules, clicking on an image in the content module will prompt several image alignment options. These include float right, float left, align right, align left and align center.',
    },
  },
  args: {
    module: contentImage,
  },
};

export const FloatRightImage = TemplateContentImage.bind({});
FloatRightImage.story = {
  parameters: {
    docs: {
      storyDescription:
        'In Hercules, clicking on an image in the content module will prompt several image alignment options. These include float right, float left, align right, align left and align center.',
    },
  },
  args: {
    module: floatRightImage,
  },
};

export const FloatLeftImage = TemplateContentImage.bind({});
FloatLeftImage.story = {
  parameters: {
    docs: {
      storyDescription:
        'In Hercules, clicking on an image in the content module will prompt several image alignment options. These include float right, float left, align right, align left and align center.',
    },
  },
  args: {
    module: floatLeftImage,
  },
};

export const FullWidthImage = TemplateContentImage.bind({});
FullWidthImage.story = {
  parameters: {
    docs: {
      storyDescription:
        'In Hercules, clicking on an image in the content module will prompt several image alignment options. These include float right, float left, align right, align left and align center.',
    },
  },
  args: {
    module: fullWidthImage,
  },
};

export const AlignRightImage = TemplateContentImage.bind({});
AlignRightImage.story = {
  parameters: {
    docs: {
      storyDescription:
        'In Hercules, clicking on an image in the content module will prompt several image alignment options. These include float right, float left, align right, align left and align center.',
    },
  },
  args: {
    module: alignRightImage,
  },
};

export const AlignLeftImage = TemplateContentImage.bind({});
AlignLeftImage.story = {
  parameters: {
    docs: {
      storyDescription:
        'In Hercules, clicking on an image in the content module will prompt several image alignment options. These include float right, float left, align right, align left and align center.',
    },
  },
  args: {
    module: alignLeftImage,
  },
};
