import { Meta, Preview, Props, Story } from "@storybook/addon-docs/blocks";
import { boolean, text, withKnobs } from "@storybook/addon-knobs";
import ToggleSwitch from "../../ToggleSwitch";
import StorybookContainer from "../../../shared/StorybookContainer";

<Meta title="Toggle Switch" component={ToggleSwitch} decorators={[withKnobs]} />

# Toggle Switch

## Demo

<Preview>
  <Story name="Demo" parameters={{
    options: {
      showPanel: true
    }
  }}>
    {{
      components: {
        "h-toggle-switch": ToggleSwitch,
      },
      props: {
        disabled: {
          default: boolean("disabled", false),
        },
        showToggleState: {
          default: boolean("showToggleState", true),
        },
        label: {
          default: text("label", ""),
        },
      },
      data() {
        return {
          isChecked: false,
        };
      },
      template: `
        <div>
          <h-toggle-switch v-model="isChecked" :label="label" :showToggleState="showToggleState" :disabled="disabled" />
          <p>Checked: {{ isChecked }}</p>
        </div>
      `,
    }}
  </Story>
</Preview>

## Props

<Props of={ToggleSwitch} />

## States

### Checked

<Preview>
  <Story name="Checked" parameters={{
    options: {
      showPanel: false
    }
  }}>
    {{
      components: {
        "h-toggle-switch": ToggleSwitch,
      },
      data() {
        return {
          isChecked: true,
          notChecked: false,
        };
      },
      template: `
        <div>
          <h-toggle-switch v-model="isChecked" />
          <h-toggle-switch v-model="notChecked" />
        </div>
      `,
    }}
  </Story>
</Preview>

### Label

<Preview>
  <Story name="Label" parameters={{
    options: {
      showPanel: false
    }
  }}>
    {{
      components: {
        "h-toggle-switch": ToggleSwitch,
      },
      data() {
        return {
          isChecked: true,
          notChecked: false,
        };
      },
      template: `
        <div>
          <h-toggle-switch v-model="isChecked" label="Label" />
          <h-toggle-switch v-model="notChecked" label="Label" />
        </div>
      `,
    }}
  </Story>
</Preview>

### Show toggle state

<Preview>
  <Story name="Show toggle state" parameters={{
    options: {
      showPanel: false
    }
  }}>
    {{
      components: {
        "h-toggle-switch": ToggleSwitch,
      },
      data() {
        return {
          isChecked1: true,
          notChecked1: false,
          isChecked2: true,
          notChecked2: false,
        };
      },
      template: `
        <div>
          <h-toggle-switch v-model="isChecked1" label="showToggleState = true" />
          <h-toggle-switch v-model="notChecked1" label="showToggleState = true" />
          <h-toggle-switch v-model="isChecked2" :showToggleState="false" label="showToggleState = false" />
          <h-toggle-switch v-model="notChecked2" :showToggleState="false" label="showToggleState = false" />
        </div>
      `,
    }}
  </Story>
</Preview>

### Disabled

<Preview>
  <Story name="Disabled" parameters={{
    options: {
      showPanel: false
    }
  }}>
    {{
      components: {
        "h-toggle-switch": ToggleSwitch,
      },
      data() {
        return {
          isChecked: true,
        };
      },
      template: `<h-toggle-switch v-model="isChecked" disabled />`,
    }}
  </Story>
</Preview>
