import { Meta, Preview, Props, Story } from "@storybook/addon-docs/blocks";
import { boolean, select, text, withKnobs } from "@storybook/addon-knobs";
import Toast from "../../Toast";
import { actions, template } from './Toast.data.js';

<Meta title="Toast" component={Toast} decorators={[withKnobs]} />

# Toast

<Story name="Demo" parameters={{
  docs: {
    disable: true
  },
  options: {
    showPanel: true
  }
}}>
  {{
    components: {
      "h-toast": Toast,
    },
    props: {
      id: {
        default: text("id", ""),
      },
      variant: {
        default: select(
          "variant",
          {
            Information: "information",
            Success: "success",
            Warning: "warning",
            Error: "error",
          },
        "information"),
      },
      title: {
        default: text("title", "Title"),
      },
      message: {
        default: text("message", "Message"),
      },
      show: {
        default: boolean("show", true),
      },
      closable: {
        default: boolean("closable", false),
      },
      ariaLabel: {
        default: text("ariaLabel", "Toast aria label"),
      },
      hasIcon: {
        default: boolean("hasIcon", false),
      },
      hasBorder: {
        default: boolean("hasBorder", true),
      },
      background: {
        default: select(
          "background",
          {
            True: true,
            False: false,
            Goldenrod: 'goldenrod',
          },
          false
        ),
      },
      buttonText: {
        default: text('buttonText', 'Button')
      }
    },
    template,
    methods: actions,
  }}
</Story>


## States

### Default

<Preview>
  <Story name="Default" parameters={{
    options: {
      showPanel: false
    }
  }}>
    {{
      components: {
        "h-toast": Toast,
      },
      template: `
        <div>
          <h-toast show variant="information" title="Title" message="Message" :hasBorder="false" :hasIcon="false" />
          <h-toast show variant="success" title="Title" message="Message" :hasBorder="false" :hasIcon="false" />
          <h-toast show variant="warning" title="Title" message="Message" :hasBorder="false" :hasIcon="false" />
          <h-toast show variant="error" title="Title" message="Message" :hasBorder="false" :hasIcon="false" />
        </div>
      `,
    }}
  </Story>
</Preview>


### Border

<Preview>
  <Story name="Border" parameters={{
    options: {
      showPanel: false
    }
  }}>
    {{
      components: {
        "h-toast": Toast,
      },
      template: `
        <div>
          <h-toast show variant="information" title="Title" message="Message" hasBorder />
          <h-toast show variant="success" title="Title" message="Message" hasBorder />
          <h-toast show variant="warning" title="Title" message="Message" hasBorder />
          <h-toast show variant="error" title="Title" message="Message" hasBorder />
        </div>
      `,
    }}
  </Story>
</Preview>

### Icon

<Preview>
  <Story name="Icon" parameters={{
    options: {
      showPanel: false
    }
  }}>
    {{
      components: {
        "h-toast": Toast,
      },
      template: `
        <div>
          <h-toast show variant="information" title="Title" message="Message" hasBorder hasIcon />
          <h-toast show variant="success" title="Title" message="Message" hasBorder hasIcon />
          <h-toast show variant="warning" title="Title" message="Message" hasBorder hasIcon />
          <h-toast show variant="error" title="Title" message="Message" hasBorder hasIcon />
        </div>
      `,
    }}
  </Story>
</Preview>

### Closable

<Preview>
  <Story name="Closable" parameters={{
    options: {
      showPanel: false
    }
  }}>
    {{
      components: {
        "h-toast": Toast,
      },
      template: `
        <div>
          <h-toast show variant="information" title="Title" message="Message" hasBorder hasIcon closable />
          <h-toast show variant="success" title="Title" message="Message" hasBorder hasIcon closable />
          <h-toast show variant="warning" title="Title" message="Message" hasBorder hasIcon closable />
          <h-toast show variant="error" title="Title" message="Message" hasBorder hasIcon closable />
        </div>
      `,
    }}
  </Story>
</Preview>

### Button

<Preview>
  <Story name="Button" parameters={{
    options: {
      showPanel: false
    }
  }}>
    {{
      components: {
        "h-toast": Toast,
      },
      template: `
        <div>
          <h-toast show variant="information" title="Title" message="Message" hasBorder hasIcon closable buttonText="Button" @click="onClick" />
          <h-toast show variant="success" title="Title" message="Message" hasBorder hasIcon closable buttonText="Button" @click="onClick" />
          <h-toast show variant="warning" title="Title" message="Message" hasBorder hasIcon closable buttonText="Button" @click="onClick" />
          <h-toast show variant="error" title="Title" message="Message" hasBorder hasIcon closable buttonText="Button" @click="onClick" />
        </div>
      `,
      methods: toastActionsData,
    }}
  </Story>
</Preview>

### Background

<Preview>
  <Story name="Background" parameters={{
    options: {
      showPanel: false
    }
  }}>
    {{
      components: {
        "h-toast": Toast,
      },
      template: `
        <div>
          <h-toast show variant="information" title="Title" message="Message" hasBorder hasIcon closable buttonText="Button" background @click="onClick" />
          <h-toast show variant="success" title="Title" message="Message" hasBorder hasIcon closable buttonText="Button" background @click="onClick" />
          <h-toast show variant="warning" title="Title" message="Message" hasBorder hasIcon closable buttonText="Button" background @click="onClick" />
          <h-toast show variant="error" title="Title" message="Message" hasBorder hasIcon closable buttonText="Button" background @click="onClick" />
        </div>
      `,
      methods: toastActionsData,
    }}
  </Story>
</Preview>

## Props

<Props of={Toast} />
