import React from "react";
import {
  Title,
  Subtitle,
  Description,
  Primary,
} from "@storybook/addon-docs/blocks";
import { Button, LinkButton } from "../../../../src/atoms/button";
import { ArrowsLeftIcon } from "../../../../src/atoms/icon";
import { ButtonIcon } from "../../../../src/molecules/buttonIcon";
import { NavLink } from "../../../../src/atoms/nav";

export default {
  title: "Components/Button",
  component: Button,
  parameters: {
    docs: {
      page: () => (
        <>
          <Title>Readme</Title>
          <br />
          <Subtitle>
            Note, thise story is explains more about the basic usage of the
            component in your project, how to import and render it. You may find
            examples of code at the story Example.
          </Subtitle>
          <Description>
            `Button` are useful components for navigation and reaching an
            important destinations. There are 3 types of the `Button` which you
            may use as a `props`:
          </Description>
          <Description>- Color `props`:</Description>
          <Description>1. `primary`</Description>
          <Description>2. `secondary`</Description>
          <Description>3. `success`</Description>
          <Description>4. `danger`</Description>
          <Description>5. `warning`</Description>
          <Description>6. `info`</Description>
          <Description>7. `light`</Description>
          <Description>8. `dark`</Description>
          <br />
          <Description>- Size `props`:</Description>
          <Description>1. `sm` for small size</Description>
          <Description>2. `lg` for large size</Description>
          <br />
          <Description>- Visual appearance `props`:</Description>
          <Description>1. `outline`</Description>
          <Description>2. `disabled`</Description>
          <Description>3. `loadding`</Description>
          <Description>
            4. `icon` can be used just with `ButtonIcon`
          </Description>
          <Description>
            4. `text` can be used just with `ButtonIcon`
          </Description>
          <br />
          <Subtitle>
            To integrate Button for using at your product, please read the
            information below, or check the example code in stories.
          </Subtitle>
          <Description>
            1. `import &#123; Button &#125; from 'seturon';`, `import &#123;
            LinkButton &#125; from 'seturon';`,or `import &#123; ButtonIcon
            &#125; from 'seturon';`
          </Description>
          <Description>2. Set the component on the needed page.</Description>
          <Description>3. Set needed `props` at the component.</Description>
          <br />
          <Subtitle>
            To have more idea about the code and usage of the Button components,
            check it out:
          </Subtitle>
          <NavLink href="http://design.seturon.io/?path=/docs/components-button--example">
            Example
          </NavLink>
        </>
      ),
    },
  },
  args: {
    primary: true,
    secondary: false,
    success: false,
    danger: false,
    warning: false,
    info: false,
    light: false,
    dark: false,
    sm: false,
    lg: false,
    outline: false,
    disabled: false,
    loading: false,
  },
  argTypes: {
    props: {
      description: null,
      table: {
        type: {
          summary: null,
          detail: null,
        },
      },
      control: {
        type: null,
      },
    },
  },
};

export const Rreadme = (args) => (
  <>
    <Button m5 {...args}>
      Button
    </Button>
    <br />
    <LinkButton m5 {...args}>
      Link Button
    </LinkButton>
  </>
);

export const Example = () => (
  <>
    <Button m5 primary>
      Button primary color
    </Button>
    <Button m5 secondary>
      Button secondary color
    </Button>
    <Button m5 success>
      Button success color
    </Button>
    <Button m5 danger>
      Button danger color
    </Button>
    <Button m5 warning>
      Button warning color
    </Button>
    <Button m5 info>
      Button info color
    </Button>
    <Button m5 light>
      Button light color
    </Button>
    <Button m5 dark>
      Button dark color
    </Button>
    <br />
    <Button m5 primary sm>
      Button SM size
    </Button>
    <Button m5 primary>
      Button MD size
    </Button>
    <Button m5 primary lg>
      Button LG size
    </Button>
    <br />
    <ButtonIcon
      m5
      primary
      icon={<ArrowsLeftIcon width={18} height={18} fill={"#FFF"} />}
      text="Icon Button"
    />
    <br />
    <Button m5 primary outline>
      Button appearance outline
    </Button>
    <Button m5 primary disabled>
      Button appearance disabled
    </Button>
    <LinkButton m5 primary href="#">
      Button link primary
    </LinkButton>
    <LinkButton m5 danger href="#">
      Button link secondary
    </LinkButton>
    <br />
    <Button m5 primary sm loading>
      Button Loading sm
    </Button>
    <Button m5 primary loading>
      Button Loading MD
    </Button>
    <Button m5 primary lg loading>
      Button Loading LG
    </Button>
  </>
);

Example.storyName = "Example";

Example.parameters = {
  component: Button,
  docs: {
    page: () => (
      <>
        <Title>Example</Title>
        <Subtitle>Props</Subtitle>
        <Description>
          `Button` are useful components for navigation and reaching an
          important destinations. There are 3 types of the `Button` which you
          may use as a `props`:
        </Description>
        <Description>- Color `props`:</Description>
        <Description>1. `primary`</Description>
        <Description>2. `secondary`</Description>
        <Description>3. `success`</Description>
        <Description>4. `danger`</Description>
        <Description>5. `warning`</Description>
        <Description>6. `info`</Description>
        <Description>7. `light`</Description>
        <Description>8. `dark`</Description>
        <br />
        <Description>- Size `props`:</Description>
        <Description>1. `sm` for small size</Description>
        <Description>2. `lg` for large size</Description>
        <br />
        <Description>- Visual appearance `props`:</Description>
        <Description>1. `outline`</Description>
        <Description>2. `disabled`</Description>
        <Description>3. `loadding`</Description>
        <Description>4. `icon` can be used just with `ButtonIcon`</Description>
        <Description>4. `text` can be used just with `ButtonIcon`</Description>
        <br />
        <Subtitle>
          Check the code below to get an idea of how to use it at your product👇
        </Subtitle>
        <Primary name="Example" />
      </>
    ),
  },
};
