import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks';
import { Button } from './button.component';
import { FlowPropsTable, ExternalReferenceLink } from '../../../utils';
import { Box } from '../../..';
import { Link } from '../../typography';

<Meta title="Components/Actions/Primary Button" component={Button} />;

# Button

<Link href={'/?path=/story/components-actions-accessibility-tips--page'}>
  <b>Accessibility tips</b>
</Link>

A branded primary button.

The `Button` component either renders a button element or a link element based on whether a `href` prop is passed in.

## Size Medium (default):

<Canvas>
  <Box stacked="row" justify="space-around">
    <Story id="components-actions-primary-button--as-link" />
    <Story id="components-actions-primary-button--as-button" />
    <Story id="components-actions-primary-button--as-button-loading" />
    <Story id="components-actions-primary-button--as-button-disabled" />
  </Box>
</Canvas>

## Size Small:

<Canvas>
  <Box stacked="row" justify="space-around">
    <Story id="components-actions-primary-button--as-link-sm" />
    <Story id="components-actions-primary-button--as-button-sm" />
    <Story id="components-actions-primary-button--as-button-loading-sm" />
    <Story id="components-actions-primary-button--as-button-disabled-sm" />
  </Box>
</Canvas>

## Supported Property Mixins:

Spacing:

<Canvas>
  <Story id="components-actions-primary-button--mixins-spacing" />
</Canvas>

Stackee:

<Canvas>
  <Story id="components-actions-primary-button--mixins-stackee" />
</Canvas>

## Props

<FlowPropsTable ofComponent={Button} />

## Accessibility notes

At least one of `href` and `onClick` must be provided for this component to be functional. If `href` is provided,
a styled `a` element will be rendered, otherwise a `button` element will be rendered.

If both props are provided, an `a` element will be rendered with both an `href` and `onClick` callback attached.

## External Reference

<ExternalReferenceLink
  src="https://www.figma.com/file/r5zKXblbSt0b869OEcOWXu/Patchwork-Web?node-id=637%3A9"
  type="figma"
/>
<ExternalReferenceLink
  src="https://github.com/wealthsimple/patchwork/tree/master/src/core/actions/button"
  type="github"
/>
