import type { Meta, StoryObj } from "@storybook/react";
import type { LinkProps } from "./Link";
import { Link } from "./Link";
import { excludeControls } from "../../utils";

type StoryType = StoryObj<typeof Link>;

const meta: Meta<typeof Link> = {
  title: "Components/Link",
  component: Link,
  argTypes: {
    target: {
      options: ["_self", "_blank", "_parent", "_top"],
      control: { type: "select" },
    },
    to: {
      control: { type: "text" },
    },
    title: {
      control: { type: "text" },
    },
    download: {
      control: { type: "boolean" },
    },
    rel: {
      options: ["noopener noreferrer", "canonical", "nofollow"],
      control: { type: "select" },
    },
    variant: {
      options: ["primary", "secondary"],
      control: { type: "radio" },
    },
    ...excludeControls("elementType", "style", "onClick", "children"),
  },
};

export const Default: StoryType = {
  render: (args: LinkProps) => <Link {...args}>Link text</Link>,
  args: {
    href: "https://www.google.com",
    isDisabled: false,
    download: false,
    to: undefined,
    title: undefined,
    variant: "primary",
  },
};

export const Secondary: StoryType = {
  render: (args: LinkProps) => <Link {...args}>Link text</Link>,
  args: {
    href: "https://www.google.com",
    isDisabled: false,
    download: false,
    to: undefined,
    title: undefined,
    variant: "secondary",
  },
};

export const Disabled: StoryType = {
  render: (args: LinkProps) => <Link {...args}>Link text</Link>,
  args: {
    href: "https://www.google.com",
    isDisabled: true,
    download: false,
    to: undefined,
    title: undefined,
  },
};

export default meta;
