import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';

import { ButtonLink } from './button-link';
import { ButtonBase } from '../button-base';

# ButtonLink

The `ButtonLink` is an extension of `ButtonBase` to support link styles

<Canvas>
  <Story id="components-componentlibrary-buttonlink--default-story" />
</Canvas>

## Props

The `ButtonLink` accepts all props below as well as all [Box](/docs/components-ui-box--default-story#props) and [ButtonBase](/docs/components-componentlibrary-buttonbase--default-story#props) component props

<ArgsTable of={ButtonLink} />

The `ButtonLink` accepts all [ButtonBase](/docs/components-componentlibrary-buttonbase--default-story#props) component props

<ArgsTable of={ButtonBase} />

### Size

Use the `size` prop and the `SIZES` object from `./ui/helpers/constants/design-system.js` to change the size of `ButtonLink`. Defaults to `SIZES.AUTO`.

Optional: `BUTTON_LINK_SIZES` from `../../component-library` object can be used instead of `SIZES`

Possible sizes include:

- `SIZES.AUTO` sets the height to auto but retains `ButtonLink` font-size
- `SIZES.SM` 32px
- `SIZES.MD` 40px
- `SIZES.LG` 48px
- `SIZES.INHERIT` inherits the font-size of the parent element. Used for inline links in paragraphs.

<Canvas>
  <Story id="components-componentlibrary-buttonlink--size" />
</Canvas>

```jsx
import { SIZES } from '../../../helpers/constants/design-system';
import { ButtonLink, Text, TEXT } from '../../component-library';

<ButtonLink size={SIZES.AUTO}>
  Auto (default)
</ButtonLink>
<ButtonLink size={SIZES.SM}>
  Small
</ButtonLink>
<ButtonLink size={SIZES.MD}>
  Medium
</ButtonLink>
<ButtonLink size={SIZES.LG}>
  Large
</ButtonLink>

<Text variant={TEXT.BODY_LG_MEDIUM}>
  Inherits the font-size of the parent element. <ButtonLink size={SIZES.INHERIT}>Learn more</ButtonLink>
</Text>
<Text variant={TEXT.BODY_MD}>
  Inherits the font-size of the parent element. <ButtonLink size={SIZES.INHERIT}>Learn more</ButtonLink>
</Text>
<Text variant={TEXT.BODY_SM}>
  Inherits the font-size of the parent element. <ButtonLink size={SIZES.INHERIT}>Learn more</ButtonLink>
</Text>
<Text variant={TEXT.BODY_XS}>
    Inherits the font-size of the parent element and example with textProps override for a success color.
    <ButtonLink
      size={SIZES.INHERIT}
      textProps={{ color: COLORS.SUCCESS_DEFAULT }}
    >
      Learn more
    </ButtonLink>
</Text>
```

### Danger

Use the `danger` boolean prop to change the `ButtonLink` to danger color.

<Canvas>
  <Story id="components-componentlibrary-buttonlink--danger" />
</Canvas>

```jsx
import { ButtonLink } from '../../component-library';

<ButtonLink>Normal</ButtonLink>
<ButtonLink danger>Danger</ButtonLink>
```

### Href

When an `href` prop is passed it will change the element to an anchor(`a`) tag.

<Canvas>
  <Story id="components-componentlibrary-buttonlink--href" />
</Canvas>

```jsx
import { ButtonLink } from '../../component-library';

<ButtonLink href="/">Href example</ButtonLink>;
```

### Hit area

The default hit area for `ButtonLink` is the width of the text and height based on the `size` prop which is set to `SIZES.AUTO` by default. There may be times when you want to increase the hit area of the `ButtonLink`. To do this you can use the `Box` props `paddingLeft` and `paddingRight`. Or alternatively you can use the `block` prop which sets the width to 100%.

<Canvas>
  <Story id="components-componentlibrary-buttonlink--hit-area" />
</Canvas>

```jsx
import { ButtonLink } from '../../component-library';

<ButtonLink paddingLeft={4} paddingRight={4}>
  Auto (default)
</ButtonLink>
<ButtonLink size={SIZES.SM} paddingLeft={4} paddingRight={4}>
  Small
</ButtonLink>
<ButtonLink size={SIZES.MD} paddingLeft={4} paddingRight={4}>
  Medium
</ButtonLink>
<ButtonLink size={SIZES.LG} paddingLeft={4} paddingRight={4}>
  Large
</ButtonLink>
<ButtonLink size={SIZES.LG} block>
  Large block
</ButtonLink>
```
