import React from "react";
import {
  Title,
  Subtitle,
  Description,
  Primary,
} from "@storybook/addon-docs/blocks";
import { Button } from "../../../../src/atoms/button";
import {
  FormControl,
  FormCheckInput,
  InputGroup,
  InputGroupAppend,
  InputGroupPrepend,
  InputGroupText,
} from "../../../../src/atoms/form";
import { InputIcon } from "../../../../src/molecules/inputIcon";
import { SearchIcon } from "../../../../src/atoms/icon";
import { NavLink } from "../../../../src/atoms/nav";

export default {
  title: "Components/InputGroup",
  component: InputGroup,
  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>
            `InputGroup` to set editional components for your `Form`.
            `InputGroup` consist of:
          </Description>
          <Description>
            1. `InputGroupAppend` set item at the start.
          </Description>
          <Description>2. `InputGroupPrepend` set item at the end.</Description>
          <Description>3. `InputGroupText` set text.</Description>
          <br />
          <Subtitle>
            To integrate 'InputGroup' for using at your product, please read the
            information below, or check the example code in stories.
          </Subtitle>
          <Description>1. `import &#123;`</Description>
          <Description>`InputGroup,`</Description>
          <Description>`InputGroupAppend,`</Description>
          <Description>`InputGroupPrepend,`</Description>
          <Description>`InputGroupText,`</Description>
          <Description>`&#125; from 'seturon';`</Description>
          <Description>
            or `import &#123; InputIcon &#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 InputGroup
            components, check it out:
          </Subtitle>
          <NavLink href="http://design.seturon.io/?path=/docs/components-inputgroup--example">
            Example
          </NavLink>
        </>
      ),
    },
  },
  args: {
    props: null,
  },
  argTypes: {
    props: {
      description: null,
      table: {
        type: {
          summary: null,
          detail: null,
        },
      },
      control: {
        type: null,
      },
    },
  },
};

export const Readme = () => (
  <InputGroup>
    <InputGroupPrepend>
      <InputGroupText>@</InputGroupText>
    </InputGroupPrepend>
    <FormControl type="text" placeholder="Username" />
  </InputGroup>
);

export const Example = () => (
  <>
    <InputGroup>
      <InputGroupPrepend>
        <InputGroupText>@</InputGroupText>
      </InputGroupPrepend>
      <FormControl type="text" placeholder="Username" />
    </InputGroup>
    <br />
    <InputGroup>
      <FormControl type="text" placeholder="Recipient's username" />
      <InputGroupAppend>
        <InputGroupText>@example.com</InputGroupText>
      </InputGroupAppend>
    </InputGroup>
    <br />
    <InputGroup>
      <InputGroupPrepend>
        <InputGroupText>
          <FormCheckInput type="checkbox" />
        </InputGroupText>
      </InputGroupPrepend>
      <FormControl type="text" placeholder="Selectable input" />
      <InputGroupAppend>
        <Button outline>Select</Button>
      </InputGroupAppend>
    </InputGroup>
    <br />
    <InputGroup>
      <InputGroupPrepend>
        <InputGroupText>$</InputGroupText>
      </InputGroupPrepend>
      <FormControl type="text" />
      <InputGroupAppend>
        <InputGroupText>.00</InputGroupText>
      </InputGroupAppend>
    </InputGroup>
    <br />
    <InputGroup>
      <InputGroupPrepend>
        <InputGroupText>First and last name</InputGroupText>
      </InputGroupPrepend>
      <FormControl type="text" />
      <FormControl type="text" />
    </InputGroup>
    <br />
    <InputGroup>
      <InputGroupPrepend>
        <InputGroupText>$</InputGroupText>
        <InputGroupText>#</InputGroupText>
        <InputGroupText>%</InputGroupText>
      </InputGroupPrepend>
      <FormControl type="text" />
    </InputGroup>
    <br />
    <InputIcon
      type="text"
      placeholder="Search"
      icon={<SearchIcon width={24} height={24} fill={"#6E7191"} />}
    />
  </>
);

Example.storyName = "Example";

Example.parameters = {
  component: InputGroup,
  docs: {
    page: () => (
      <>
        <Title>Example</Title>
        <Subtitle>Props</Subtitle>
        <Description>
            `InputGroup` to set editional components for your `Form`.
            `InputGroup` consist of:
          </Description>
          <Description>
            1. `InputGroupAppend` set item at the start.
          </Description>
          <Description>2. `InputGroupPrepend` set item at the end.</Description>
          <Description>3. `InputGroupText` set text.</Description>
          <br />
          <Description>- Or you may use `InputIcon`, and setup it with props:</Description>
          <Description>1. `text`</Description>
          <Description>2. `icon`</Description>
        <br />
        <Subtitle>
          Check the code below to get an idea of how to use it at your product👇
        </Subtitle>
        <Primary name="Example" />
      </>
    ),
  },
};
