1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00
metamask-extension/ui/components/component-library/avatar-icon
George Marshall 419bf92282
Removing Box props description from TS component docs (#20451)
* Removing Box props description from TS component docs

* Making style utility prop comments more generic
2023-08-16 10:34:08 -07:00
..
__snapshots__ Migrate AvatarIcon (#19107) 2023-07-26 14:18:36 -07:00
avatar-icon.stories.tsx Migrate AvatarIcon (#19107) 2023-07-26 14:18:36 -07:00
avatar-icon.test.tsx Migrate AvatarIcon (#19107) 2023-07-26 14:18:36 -07:00
avatar-icon.tsx Migrate AvatarIcon (#19107) 2023-07-26 14:18:36 -07:00
avatar-icon.types.ts migration of button icon to use TS box version (#20227) 2023-08-03 12:23:47 -07:00
index.ts Migrate AvatarIcon (#19107) 2023-07-26 14:18:36 -07:00
README.mdx Removing Box props description from TS component docs (#20451) 2023-08-16 10:34:08 -07: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

<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 `AvatarIconSize` enum to change the size of `AvatarIcon`

Possible sizes include:

- `AvatarIconSize.Xs` 16px
- `AvatarIconSize.Sm` 24px
- `AvatarIconSize.Md` 32px
- `AvatarIconSize.Lg` 40px
- `AvatarIconSize.Xl` 48px

Defaults to `AvatarIconSize.Md`

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

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

    <AvatarIcon {...args} size={AvatarIconSize.Xs} />
    <AvatarIcon {...args} size={AvatarIconSize.Sm} />
    <AvatarIcon {...args} size={AvatarIconSize.Md} />
    <AvatarIcon {...args} size={AvatarIconSize.Lg} />
    <AvatarIcon {...args} size={AvatarIconSize.Xl} />
```

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

Use the required `iconName` prop with `IconName` enum 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-story" />
</Canvas>

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

<AvatarIcon iconName={IconName.SwapHorizontal} />
<AvatarIcon iconName={IconName.Confirmation} />
<AvatarIcon iconName={IconName.Info} />
<AvatarIcon iconName={IconName.Warning} />
<AvatarIcon iconName={IconName.Danger} />
```

### Color and Background Color

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

`color` default: `IconColor.primaryDefault`
`backgroundColor` default: `BackgroundColor.primaryMuted`

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

```jsx
import { BackgroundColor, IconColor } from '../../../helpers/constants/design-system';
import { AvatarIcon } from '../../component-library';

<AvatarIcon color={IconColor.primaryDefault} backgroundColor={BackgroundColor.primaryMuted} />
<AvatarIcon color={IconColor.primaryInverse} backgroundColor={BackgroundColor.primaryDefault} />
<AvatarIcon color={IconColor.successDefault} backgroundColor={BackgroundColor.successMuted} />
<AvatarIcon color={IconColor.infoDefault} backgroundColor={BackgroundColor.infoMuted} />
<AvatarIcon color={IconColor.warningDefault} backgroundColor={BackgroundColor.warningMuted} />
<AvatarIcon color={IconColor.errorDefault} backgroundColor={BackgroundColor.errorMuted} />
```