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

import Iframe from '.';

export default {
  title: 'Theme/Atoms/Iframe',
  component: Iframe,
  argTypes: {
    src: {
      name: 'src',
      type: { name: 'string', required: true },
      defaultValue: '',
      description: 'The URL of the external page.',
      table: {
        type: { summary: 'string' },
        defaultValue: { summary: '' },
      },
    },
    title: {
      name: 'title',
      type: { name: 'string', required: false },
      defaultValue: '',
      description: 'The title of the iframe.',
      table: {
        type: { summary: 'string' },
        defaultValue: { summary: '' },
      },
    },
    minHeight: {
      name: 'minHeight',
      type: { name: 'string', required: false },
      defaultValue: '',
      description: 'The minimum height of the iframe.',
      table: {
        type: { summary: 'string' },
        defaultValue: { summary: '' },
      },
    },
    lazyLoad: {
      name: 'lazyLoad',
      type: { name: 'boolean', required: false },
      defaultValue: true,
      description: 'Enables or disables using the lazy load.',
      table: {
        type: { summary: 'boolean' },
        defaultValue: { summary: true },
      },
    },
    frameBorder: {
      name: 'frameBorder',
      type: { name: 'number', required: false },
      defaultValue: 1,
      description: 'The iframe border.',
      table: {
        type: { summary: 'number' },
        defaultValue: { summary: 1 },
      },
    },
  },
  parameters: {
    docs: {
      description: {
        component:
          'A component that accepts a source URL  and options and generates an iframe to show a Youtube video or an external game page.',
      },
      page: () => (
        <>
          <Title />
          <Subtitle />
          <Description />
          <Primary />
          <ArgsTable story={PRIMARY_STORY} />
        </>
      ),
    },
  },
};

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

export const Default = Template.bind({});
Default.args = {
  src: 'https://www.youtube.com/embed/DU1Pio4n_N0',
  title: 'mySimpleTitle',
  minHeight: '45rem',
  lazyLoad: true,
  frameBorder: 1,
};
