import React from "react";
import {
  Title,
  Subtitle,
  Description,
  Primary,
} from "@storybook/addon-docs/blocks";
import { Table, Tr } from "../../../../src/atoms/table";
import { TableCard } from "../../../../src/molecules/tableCard";
import { NavLink } from "../../../../src/atoms/nav";

export default {
  title: "Components/Table",
  component: Table,
  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>
            `Table` for displaing some statistics or information. To setup
            `Table` you may use next `props`:
          </Description>
          <Description>
            1. `striped` to make the coontent more readeble.
          </Description>
          <Description>2. `sm` for small size of rows.</Description>
          <Description>3. `loading` use it when load the page.</Description>
          <Description>
            4. `dark` for dark color of the table, don't forget to set the same
            `background` for the `Card`.
          </Description>
          <Description>5. `bordered` set borders</Description>
          <br />
          <Subtitle>
            To integrate 'Table' for using at your product, please read the
            information below, or check the example code in stories.
          </Subtitle>
          <Description>
            1. `import &#123; Table, Tr &#125; from 'seturon';` or `import &#123;
            TableCard &#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 Table components,
            check it out:
          </Subtitle>
          <NavLink href="http://design.seturon.io/?path=/docs/components-table--example">
            Example
          </NavLink>
        </>
      ),
    },
  },
  args: {
    striped: false,
    sm: false,
    loading: false,
  },
  argTypes: {
    props: {
      description: null,
      table: {
        type: {
          summary: null,
          detail: null,
        },
      },
      control: {
        type: null,
      },
    },
  },
};

export const Readme = (args) => (
  <TableCard
    {...args}
    headers={[
      "Data Analysis",
      "Correct",
      "Score",
      "Time",
    ]}
    row={[
      ["Russian language", "13 из 14", "13 из 14", "00:07:12"],
      ["Google Docs", "10 из 10", "10 из 10", "00:12:40"],
      ["Google Sheets", "9 из 12", "12 из 16", "00:19:08"],
      ["English language", "9 из 10", "16 из 19", "00:20:00"],
    ]}
  />
);

export const Example = () => (
  <>
    <Table bordered>
      <thead>
        <tr>
          <th scope="col">Data Analysis</th>
          <th scope="col">Correct</th>
          <th scope="col">Score</th>
          <th scope="col">Time</th>
        </tr>
      </thead>
      <tbody>
        <Tr light>
          <td>Russian language</td>
          <td>13 из 14</td>
          <td>13 из 14</td>
          <td>00:20:00</td>
        </Tr>
      </tbody>
    </Table>
    <br />
    <TableCard
    responsive
      headers={[
        "Data Analysis",
        "Correct",
        "Score",
        "Time",
      ]}
      row={[
        ["Russian language", "13 из 14", "13 из 14", "00:07:12"],
        ["Google Docs", "10 из 10", "10 из 10", "00:12:40"],
        ["Google Sheets", "9 из 12", "12 из 16", "00:19:08"],
        ["English language", "9 из 10", "16 из 19", "00:20:00"],
      ]}
    />
    <br />
    <TableCard
      sm
      headers={[
        "Data Analysis",
        "Correct",
        "Score",
        "Time",
      ]}
      row={[
        ["Russian language", "13 из 14", "13 из 14", "00:07:12"],
        ["Google Docs", "10 из 10", "10 из 10", "00:12:40"],
        ["Google Sheets", "9 из 12", "12 из 16", "00:19:08"],
        ["English language", "9 из 10", "16 из 19", "00:20:00"],
      ]}
    />
    <br />
    <TableCard
      tableDark
      background="#2d2f31"
      headers={[
        "Data Analysis",
        "Correct",
        "Score",
        "Time",
      ]}
      row={[
        ["Russian language", "13 из 14", "13 из 14", "00:07:12"],
        ["Google Docs", "10 из 10", "10 из 10", "00:12:40"],
        ["Google Sheets", "9 из 12", "12 из 16", "00:19:08"],
        ["English language", "9 из 10", "16 из 19", "00:20:00"],
      ]}
    />
    <br />
    <TableCard
      striped
      headers={[
        "Data Analysis",
        "Correct",
        "Score",
        "Time",
      ]}
      row={[
        ["Russian language", "13 из 14", "13 из 14", "00:07:12"],
        ["Google Docs", "10 из 10", "10 из 10", "00:12:40"],
        ["Google Sheets", "9 из 12", "12 из 16", "00:19:08"],
        ["English language", "9 из 10", "16 из 19", "00:20:00"],
      ]}
    />
    <br />
    <TableCard
      loading
      headers={[
        "Data Analysis",
        "Correct",
        "Score",
        "Time",
      ]}
      row={[
        ["Russian language", "13 из 14", "13 из 14", "00:07:12"],
        ["Google Docs", "10 из 10", "10 из 10", "00:12:40"],
        ["Google Sheets", "9 из 12", "12 из 16", "00:19:08"],
        ["English language", "9 из 10", "16 из 19", "00:20:00"],
      ]}
    />
    <br />
  </>
);

Example.storyName = "Example";

Example.parameters = {
  component: Table,
  docs: {
    page: () => (
      <>
        <Title>Example</Title>
        <Subtitle>Props</Subtitle>
        <Description>
          `Table` for displaing some statistics or information. To setup `Table`
          you may use next `props`:
        </Description>
        <Description>
          1. `striped` to make the coontent more readeble.
        </Description>
        <Description>2. `sm` for small size of rows.</Description>
        <Description>3. `loading` use it when load the page.</Description>
        <Description>
          4. `dark` for dark color of the table, don't forget to set the same
          `background` for the `Card`.
        </Description>
        <Description>5. `bordered` set borders</Description>
        <br />
        <Subtitle>
          Check the code below to get an idea of how to use it at your product👇
        </Subtitle>
        <Primary name="Example" />
      </>
    ),
  },
};
