import React from "react";
import {
  Title,
  Subtitle,
  Description,
  Primary,
} from "@storybook/addon-docs/blocks";
import { Button } from "../../../../src/atoms/button";
import {
  Dropdown,
  DropdownItem,
  DropdownMenu,
  DropdownDivider,
} from "../../../../src/atoms/dropdown";
import { NavLink } from "../../../../src/atoms/nav";
import { Container } from "../../../../src/atoms/container";

export default {
  title: "Components/Dropdown",
  component: Dropdown,
  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>
            `Dropdown` are useful when you want to improve some additional
            navigation. `Dropdown` component consist of:
          </Description>
          <Description>
            1. `DropdownMenu` menue of the items incide of a `Dropdown`.
          </Description>
          <Description>
            2. `DropdownItim` items incide the `DropdownMenu`.
          </Description>
          <br />
          <Subtitle>
            To integrate Dropdown for using at your product, please read the
            information below, or check the example code in stories.
          </Subtitle>
          <Description>
            1. `import &#123; Dropdown &#125; from 'seturon';`, `import &#123;
            DropdownMenu &#125; from 'seturon';`, `import &#123; DropdownItim
            &#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 Dropdown
            components, check it out:
          </Subtitle>
          <NavLink href="http://design.seturon.io/?path=/docs/components-dropdown--example">
            Example
          </NavLink>
        </>
      ),
    },
  },
  args: {
    right: true,
    left: false,
  },
  argTypes: {
    props: {
      description: null,
      table: {
        type: {
          summary: null,
          detail: null,
        },
      },
      control: {
        type: null,
      },
    },
  },
};

export const Readme = (args) => (
  <Dropdown>
    <Button primary dropdownToggle onClick={() => {}}>
      Long dropdown button with toggle
    </Button>
    <DropdownMenu {...args} hidden={false} toggle={() => {}}>
      <DropdownItem>Action</DropdownItem>
      <DropdownItem>Another action</DropdownItem>
      <DropdownItem>Something else here</DropdownItem>
      <DropdownDivider />
      <DropdownItem>Seperated link</DropdownItem>
    </DropdownMenu>
  </Dropdown>

);

export const Example = () => (
  <Container >
  <Dropdown>
    <Button primary dropdownToggle onClick={() => {}}>
      Long dropdown button with toggle
    </Button>
    <DropdownMenu right hidden={false} toggle={() => {}}>
      <DropdownItem>Action</DropdownItem>
      <DropdownItem>Another action</DropdownItem>
      <DropdownItem>Something else here</DropdownItem>
      <DropdownDivider />
      <DropdownItem>Seperated link</DropdownItem>
    </DropdownMenu>
  </Dropdown>
  </Container>
);

Example.storyName = "Example";

Example.parameters = {
  component: Dropdown,
  docs: {
    page: () => (
      <>
        <Title>Example</Title>
        <Subtitle>Props</Subtitle>
        <Description>
          `Dropdown` are useful when you want to improve some additional
          navigation. `Dropdown` component consist of:
        </Description>
        <Description>
          1. `DropdownMenu` menue of the items incide of a `Dropdown`.
        </Description>
        <Description>
          2. `DropdownItim` items incide the `DropdownMenu`.
        </Description>
        <Description>
          And `props` you may use for change the position of the `DropdownMenu`:
        </Description>
        <Description>1. `left`</Description>
        <Description>2. `right`</Description>
        <br />
        <Subtitle>
          Check the code below to get an idea of how to use it at your product👇
        </Subtitle>
        <Primary name="Example" />
      </>
    ),
  },
};
