1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/components/component-library/button-icon
Nidhi Kumari c5368c152b
Added storybook check to CI ()
* added storybook test runner

* added test runner in ci

* updated test for ci and fixed lint error

* updated lavamoat policy

* updated test command

* updated playwright

* changed command to storybook;ci

* updated command

* updated instance for test-storybook

* updated playwright

* added playwright step

* replaced concurrently with start-server-and-test

* updated the static storybook directory

* replaced first with last

* updated lock file

* replaced first with last

* updated test-storybook with maxworkers

* updated .depchechrc

* updated yml

* removed id from banner base

* replaced broken stories with .stories-to-do.js extesnsion

* updated token allowance story

* removed duplicacies from yarn

* fixed lavamoat

* removed filename comment

* updated links for docs

* fixed file extension for stories

* updated path for stories.json

* updated stories.json path

* yarn updated

* updated stories

* updated yarn

* updated wait on
2023-01-21 00:57:46 +05:30
..
__snapshots__ Icon house keeping updates () 2022-11-23 09:58:43 -08:00
button-icon.constants.js
button-icon.js ButtonIcon: fix react component proptype () 2022-12-13 15:23:39 -06:00
button-icon.scss
button-icon.stories.js Added storybook check to CI () 2023-01-21 00:57:46 +05:30
button-icon.test.js Feat/16634/buttonicon housekeeping () 2022-12-01 09:26:31 -08:00
index.js
README.mdx Added storybook check to CI () 2023-01-21 00:57:46 +05:30

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

# ButtonIcon

The `ButtonIcon` is used for icons associated with a user action.

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

## Props

The `ButtonIcon` accepts all props below as well as all [Box](/docs/components-ui-box--default-story#props) component props

<ArgsTable of={ButtonIcon} />

### Icon Name<span style={{ color: 'red' }}>\*</span>

Use the required `iconName` prop with `ICON_NAMES` object from `./ui/components/component-library/icon` to select icon.

Use the [IconSearch](/story/components-componentlibrary-icon--default-story) story to find the icon you want to use.

<Canvas>
  <Story id="components-componentlibrary-buttonicon--icon-name" />
</Canvas>

```jsx
import { ButtonIcon } from '../ui/component-library';
import { ICON_NAMES } from '../icon';

<ButtonIcon iconName={ICON_NAMES.CLOSE_OUTLINE} ariaLabel="Close" />;
```

### Size

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

Optional: `BUTTON_ICON_SIZES` from `./button-icon` object can be used instead of `SIZES`.

Possible sizes include:

- `SIZES.SM` 24px
- `SIZES.LG` 32px

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

```jsx
import { SIZES } from '../../../helpers/constants/design-system';
import { ButtonIcon } from '../ui/component-library';

<ButtonIcon size={SIZES.SM} iconName={ICON_NAMES.CLOSE_OUTLINE} ariaLabel="Close"/>
<ButtonIcon size={SIZES.LG} iconName={ICON_NAMES.CLOSE_OUTLINE} ariaLabel="Close"/>
```

### Aria Label

Use the `ariaLabel` prop to set the name of the ButtonIcon for proper accessibility

<Canvas>
  <Story id="components-componentlibrary-buttonicon--aria-label" />
</Canvas>

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


<ButtonIcon as="button" iconName={ICON_NAMES.CLOSE_OUTLINE} ariaLabel="Close"/>
<ButtonIcon as="a" href="https://metamask.io/" target="_blank" iconName={ICON_NAMES.EXPORT} color={COLORS.PRIMARY_DEFAULT} ariaLabel="Visit MetaMask.io"/>
```

### As

Use the `as` box prop to change the element of `ButtonIcon`. Defaults to `button`.

Button `as` options:

- `button`
- `a`

<Canvas>
  <Story id="components-componentlibrary-buttonicon--as" />
</Canvas>

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


<ButtonIcon as="button" iconName={ICON_NAMES.CLOSE_OUTLINE} ariaLabel="Close"/>
<ButtonIcon as="a" href="https://metamask.io/" target="_blank" iconName={ICON_NAMES.EXPORT} color={COLORS.PRIMARY_DEFAULT} ariaLabel="Visit MetaMask.io"/>
```

### Href

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

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

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

<ButtonIcon
  href="https://metamask.io/"
  target="_blank"
  iconName={ICON_NAMES.EXPORT}
  color={COLORS.PRIMARY_DEFAULT}
  ariaLabel="Visit MetaMask.io"
/>;
```

### Color

Use the `color` prop and the `COLORS` object to change the color of the `ButtonIcon`. Defaults to `COLORS.ICON_DEFAULT`.

<Canvas>
  <Story id="components-componentlibrary-buttonicon--color" />
</Canvas>

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

<ButtonIcon
  iconName={ICON_NAMES.EXPORT}
  color={COLORS.PRIMARY_DEFAULT}
  ariaLabel="Visit MetaMask.io"
/>;
```

### Disabled

Use the boolean `disabled` prop to disable button

<Canvas>
  <Story id="components-componentlibrary-buttonicon--disabled" />
</Canvas>

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

<ButtonIcon iconName={ICON_NAMES.CLOSE_OUTLINE} disabled ariaLabel="Close" />;
```