import { Meta, Preview, Props, Story } from "@storybook/addon-docs/blocks";
import { ArrowButton } from "./ArrowButton";

export const decorators = [
  (storyFn) => (
    <div className="rounded p-8" style={{ backgroundColor: "#1c2c3a" }}>
      {storyFn()}
    </div>
  ),
];

<Meta
  title="Components/Buttons/Arrow Button"
  component={ArrowButton}
  decorators={decorators}
/>

export const Link = ({ to, children, ...rest }) => (
  <a href={to} {...rest}>
    {children}
  </a>
);

# ArrowButton

ArrowButton is a call-to-action button which uses Aptible’s branding styles.
It’s used on pages which are outside of the app (log in, sign up pages).

There are no use cases for this button to be used within the app.

It should always be used on top of a dark background.

ArrowButton renders as an anchor element by default. It can also render as a
button or React Router's `Link` component by passing it to the `as` prop.

```jsx
import { ArrowButton } from "@aptible/arrow-ds";
```

<Preview>
  <Story name="ArrowButton">
    <ArrowButton href="/">Arrow Button</ArrowButton>
  </Story>
</Preview>

## Props

<Props of={ArrowButton} />

## Demos

### Render as a button

Render as a button when an onClick handler is required.

<Preview>
  <Story name="ArrowButton as button">
    <ArrowButton
      as="button"
      onClick={() => {
        console.log("Clicked");
      }}
    >
      Button
    </ArrowButton>
  </Story>
</Preview>

### Render as a Link

Render as a Link when using React Router.

<Preview>
  <Story name="ArrowButton as Link">
    <ArrowButton as={Link} to="/">
      Link
    </ArrowButton>
  </Story>
</Preview>

### Disabled

<Preview>
  <Story name="DisabledLink">
    <ArrowButton as={Link} to="/" disabled>
      Disabled Link
    </ArrowButton>
  </Story>
  <Story name="DisabledButton">
    <ArrowButton
      as="button"
      onClick={() => {
        console.log("Clicked");
      }}
      disabled
    >
      Disabled Button
    </ArrowButton>
  </Story>
</Preview>

### Loading

<Preview>
  <Story name="Loading">
    <ArrowButton as={Link} to="/" loading>
      Loading
    </ArrowButton>
  </Story>
</Preview>
