import React from "react";
import {
  Title,
  Subtitle,
  Description,
  Primary,
} from "@storybook/addon-docs/blocks";
import { Alert } from "../../../../src";
import { ExclaimIcon, InfoIcon, SuccessIcon } from "../../../../src/atoms/icon";
import { AlertIcon } from "../../../../src/molecules/alertIcon";
import { NavLink } from "../../../../src/atoms/nav";

export default {
  title: "Components/Alert",
  component: Alert,
  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>
            `Alert` are useful when you want to inform the user with some
            important information. There are 3 types of the `Alert` which you
            may use as a `props`:
          </Description>
          <Description>
            1. `success` in case you'd like to commend a user for a successfully
            completed task.
          </Description>
          <Description>
            2. `warning` in case you need to warning a user for a wrongly
            completed task.
          </Description>
          <Description>
            3. `info` in case you'd like to inform a user of some important
            information.
          </Description>
          <br />
          <Subtitle>
            To integrate Alert for using at your product, please read the
            information below, or check the example code in stories.
          </Subtitle>
          <Description>
            1. `import &#123; Alert &#125; from 'seturon';` or `import &#123;
            AlertIcon &#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 Alrert components,
            check it out:
          </Subtitle>
          <NavLink href="http://design.seturon.io/?path=/docs/components-alert--example">
            Example
          </NavLink>
        </>
      ),
    },
  },
  args: {
    success: true,
    warning: false,
    info: false,
  },
  argTypes: {
    props: {
      description: null,
      table: {
        type: {
          summary: null,
          detail: null,
        },
      },
      control: {
        type: null,
      },
    },
  },
};

export const Readme = (args) => (
  <>
    <Alert m2 {...args}>
      Modern ES6+ from the beginning: arrow functions, destructuring, spread
      operator, optional chaining (ES2020), etc.
    </Alert>
  </>
);

export const Example = () => (
  <>
    <Alert success m2>
      Modern ES6+ from the beginning: arrow functions, destructuring, spread
      operator, optional chaining (ES2020), etc.
    </Alert>
    <Alert warning m2>
      Modern ES6+ from the beginning: arrow functions, destructuring, spread
      operator, optional chaining (ES2020), etc.
    </Alert>
    <Alert info m2>
      Modern ES6+ from the beginning: arrow functions, destructuring, spread
      operator, optional chaining (ES2020), etc.
    </Alert>
    <AlertIcon
      success
      m2
      icon={<SuccessIcon width={18} height={18} fill={"#2ECC71"} />}
      text="Modern ES6+ from the beginning: arrow functions, destructuring, spread operator, optional chaining (ES2020), etc."
    />
    <AlertIcon
      warning
      m2
      icon={<ExclaimIcon width={32} height={32} fill={"#FA8700"} />}
      text="Modern ES6+ from the beginning: arrow functions, destructuring, spread operator, optional chaining (ES2020), etc."
    />
    <AlertIcon
      info
      m2
      icon={<InfoIcon width={18} height={18} fill={"#019E9A"} />}
      text="Modern ES6+ from the beginning: arrow functions, destructuring, spread operator, optional chaining (ES2020), etc."
    />
  </>
);

Example.storyName = "Example";

Example.parameters = {
  component: Alert,
  docs: {
    page: () => (
      <>
        <Title>Example</Title>
        <Subtitle>Props</Subtitle>
        <Description>
          `Alert` are useful when you want to inform the user with some
          important information. Here is a `props` you may use:
        </Description>
        <Description>
          1. `success` in case you'd like to commend a user for a successfully
          completed task.
        </Description>
        <Description>
          2. `warning` in case you need to warning a user for a wrongly
          completed task.
        </Description>
        <Description>
          3. `info` in case you'd like to inform a user of some important
          information.
        </Description>
        <Description>
          4. `icon` using this props, you may integrate any of the Icons form
          `seturon` and use it at your `AlertIcon` component
        </Description>
        <Description>
          5. `text` using this props, you may add the needed text at your
          `AlertIcon` component. information.
        </Description>
        <br />
        <Subtitle>
          Check the code below to get an idea of how to use it at your product👇
        </Subtitle>
        <Primary name="Example" />
      </>
    ),
  },
};
