1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-04 23:14:56 +01:00
metamask-extension/ui/components/component-library/base-icon
George Marshall fc23cff03c
Adding BaseIcon UI component (#15609)
* Adding BaseIcon component

* Updates to styles, docs and proptypes

* Updating box props link
2022-08-18 07:53:01 -07:00
..
base-icon.js Adding BaseIcon UI component (#15609) 2022-08-18 07:53:01 -07:00
base-icon.scss Adding BaseIcon UI component (#15609) 2022-08-18 07:53:01 -07:00
base-icon.stories.js Adding BaseIcon UI component (#15609) 2022-08-18 07:53:01 -07:00
base-icon.test.js Adding BaseIcon UI component (#15609) 2022-08-18 07:53:01 -07:00
index.js Adding BaseIcon UI component (#15609) 2022-08-18 07:53:01 -07:00
README.mdx Adding BaseIcon UI component (#15609) 2022-08-18 07:53:01 -07:00

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

import { BaseIcon } from './base-icon';

### This is a base component. It should not be used in your feature code directly but as a "base" for other UI components

# BaseIcon

The `BaseIcon` is the base component for all icons. It is used in conjunction with a script to create all icons it should not be used directly.

<Canvas>
  <Story id="ui-components-component-library-base-icon-base-icon-stories-js--default-story" />
</Canvas>

## Props

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

<ArgsTable of={BaseIcon} />

### Size

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

Possible sizes include:

- `SIZES.XXS` 10px
- `SIZES.XS` 12px
- `SIZES.SM` 16px
- `SIZES.MD` 20px
- `SIZES.LG` 24px
- `SIZES.XL` 32px

<Canvas>
  <Story id="ui-components-component-library-base-icon-base-icon-stories-js--size" />
</Canvas>

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

<BaseIcon size={SIZES.XXS} />
<BaseIcon size={SIZES.XS} />
<BaseIcon size={SIZES.SM} />
<BaseIcon size={SIZES.MD} />
<BaseIcon size={SIZES.LG} />
<BaseIcon size={SIZES.XL} />
```

### Color

Use the `color` prop and the `COLORS` object from `./ui/helpers/constants/design-system.js` to change the color of `BaseIcon`. Defaults to `COLORS.INHERIT` which will use the text color of the parent element. This is useful for inline icons.

<Canvas>
  <Story id="ui-components-component-library-base-icon-base-icon-stories-js--color" />
</Canvas>

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

<BaseIcon color={COLORS.INHERIT} />
<BaseIcon color={COLORS.ICON_DEFAULT} />
<BaseIcon color={COLORS.ICON_ALTERNATIVE} />
<BaseIcon color={COLORS.ICON_MUTED} />
<BaseIcon color={COLORS.OVERLAY_INVERSE} />
<BaseIcon color={COLORS.PRIMARY_DEFAULT} />
<BaseIcon color={COLORS.PRIMARY_INVERSE} />
<BaseIcon color={COLORS.ERROR_DEFAULT} />
<BaseIcon color={COLORS.ERROR_INVERSE} />
<BaseIcon color={COLORS.SUCCESS_DEFAULT} />
<BaseIcon color={COLORS.SUCCESS_INVERSE} />
<BaseIcon color={COLORS.WARNING_DEFAULT} />
<BaseIcon color={COLORS.WARNING_INVERSE} />
<BaseIcon color={COLORS.INFO_DEFAULT} />
<BaseIcon color={COLORS.INFO_INVERSE} />
```