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/avatar-icon
Garrett Bear 0bf6aeb5f5
icon audit, remove xxs icon size (#17089)
* icon audit, remove xxs icon size

* update icon file names and snapshots

* remove unused icon- code and fix icons with slash issue

* close icon fix

* remove icons id

* update snapshot

* font awesome icon list

* remove font awesome

* fix linting issue
2023-01-24 09:39:46 -08:00
..
__snapshots__ icon audit, remove xxs icon size (#17089) 2023-01-24 09:39:46 -08:00
avatar-icon.constants.js add avatar icon component (#16755) 2022-12-08 10:25:19 -08:00
avatar-icon.js Renaming broken stories to clean up console (#16905) 2022-12-15 14:46:30 -08:00
avatar-icon.stories.js icon audit, remove xxs icon size (#17089) 2023-01-24 09:39:46 -08:00
avatar-icon.test.js icon audit, remove xxs icon size (#17089) 2023-01-24 09:39:46 -08:00
index.js add avatar icon component (#16755) 2022-12-08 10:25:19 -08:00
README.mdx icon audit, remove xxs icon size (#17089) 2023-01-24 09:39:46 -08:00

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

import { AvatarBase } from '../';
import { AvatarIcon } from './avatar-icon';

# AvatarIcon

The `AvatarIcon` is an avatar component that renders only an icon inside and is built off the [AvatarBase](/docs/components-componentlibrary-avatarbase--default-story)) component

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

## Props

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

<ArgsTable of={AvatarIcon} />

`AvatarIcon` accepts all [AvatarBase](/docs/components-componentlibrary-avatarbase--default-story))
component props

<ArgsTable of={AvatarBase} />

### Size

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

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

Possible sizes include:

- `SIZES.XS` 16px
- `SIZES.SM` 24px
- `SIZES.MD` 32px
- `SIZES.LG` 40px
- `SIZES.XL` 48px

Defaults to `SIZES.MD`

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

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

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

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

Use the required `iconName` prop with `ICON_NAMES` object from `./ui/components/component-library` 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-avataricon--icon-name" />
</Canvas>

```jsx
import { AvatarIcon, ICON_NAMES } from '../ui/component-library';

<AvatarIcon iconName={ICON_NAMES.SWAP_HORIZONTAL} />
<AvatarIcon iconName={ICON_NAMES.CONFIRMATION} />
<AvatarIcon iconName={ICON_NAMES.INFO} />
<AvatarIcon iconName={ICON_NAMES.WARNING} />
<AvatarIcon iconName={ICON_NAMES.DANGER} />
```

### Color and Background Color

Use the `color` and `backgroundColor` props with the `COLORS` object from `./ui/helpers/constants/design-system.js` to change the icon color and background color of `AvatarIcon`

`color` default: `COLORS.COLORS.PRIMARY_DEFAULT`
`backgroundColor` default: `COLORS.COLORS.PRIMARY_MUTED`

<Canvas>
  <Story id="components-componentlibrary-avataricon--color-and-background-color" />
</Canvas>

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

<AvatarIcon color={COLORS.PRIMARY_DEFAULT} backgroundColor={BACKGROUND_COLORS.PRIMARY_MUTED} />
<AvatarIcon color={COLORS.PRIMARY_INVERSE} backgroundColor={BACKGROUND_COLORS.PRIMARY_DEFAULT} />
<AvatarIcon color={COLORS.SUCCESS_DEFAULT} backgroundColor={BACKGROUND_COLORS.SUCCESS_MUTED} />
<AvatarIcon color={COLORS.INFO_DEFAULT} backgroundColor={BACKGROUND_COLORS.INFO_MUTED} />
<AvatarIcon color={COLORS.WARNING_DEFAULT} backgroundColor={BACKGROUND_COLORS.WARNING_MUTED} />
<AvatarIcon color={COLORS.ERROR_DEFAULT} backgroundColor={BACKGROUND_COLORS.ERROR_MUTED} />
```