1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00
metamask-extension/ui/components/component-library/avatar-base
George Marshall d2779c9ef1
Updating Avatar components to forward refs (#18678)
Co-authored-by: Brad Decker <bhdecker84@gmail.com>
2023-04-21 08:51:34 -07:00
..
__snapshots__ update text component color to use box color (#18246) 2023-03-23 13:00:37 -07:00
avatar-base.constants.js feature: migrate design-system.ts (#17518) 2023-02-02 20:15:26 +00:00
avatar-base.js UX Multichain: Added product tour component (#18571) 2023-04-21 20:58:18 +05:30
avatar-base.scss AvatarBase font-size logic (#18203) 2023-03-17 10:06:59 -07:00
avatar-base.stories.js UX Multichain: updated ethereum logo icon (#18528) 2023-04-19 20:55:19 +05:30
avatar-base.test.js Updating Avatar components to forward refs (#18678) 2023-04-21 08:51:34 -07:00
index.js avatar base component housekeeping (#16583) 2022-11-23 22:12:43 +05:30
README.mdx UX Multichain: updated ethereum logo icon (#18528) 2023-04-19 20:55:19 +05:30

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

import { AvatarBase } from './avatar-base';

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

# AvatarBase

The `AvatarBase` is a wrapper component responsible for enforcing dimensions and border radius for Avatar components

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

## Props

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

<ArgsTable of={AvatarBase} />

### Size

Use the `size` prop to set the size of the `AvatarBase`.

Possible sizes include:

- `xs` 16px
- `sm` 24px
- `md` 32px
- `lg` 40px
- `xl` 48px

Defaults to `md`

The text styles of the `AvatarBase` is based on the `size` prop. To override this use the `Text` component's `variant` prop. `AvatarBase` also accepts all `Text` component props.

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

```jsx
import { AVATAR_BASE_SIZES } from '../ui/component-library/avatar-base';
import { AvatarBase } from '../../component-library';
<AvatarBase size={AVATAR_BASE_SIZES.XS} />
<AvatarBase size={AVATAR_BASE_SIZES.SM} />
<AvatarBase size={AVATAR_BASE_SIZES.MD} />
<AvatarBase size={AVATAR_BASE_SIZES.LG} />
<AvatarBase size={AVATAR_BASE_SIZES.XL} />
```

### Children

The `AvatarBase` component can contain images, icons or text

<Canvas>
  <Story id="components-componentlibrary-avatarbase--children" />
</Canvas>

```jsx
import { AvatarBase } from '../../component-library';
<AvatarBase>
  <img src="./images/eth_logo.png" />
</AvatarBase>
<AvatarBase>
  <img width="100%" src="./images/arbitrum.svg" />
</AvatarBase>
<AvatarBase>
  <img width="100%" src="./images/avax-token.png" />
</AvatarBase>
<AvatarBase>A</AvatarBase>
```

### Color, Background Color And Border Color

Use the `color`, `backgroundColor` and `borderColor` props to set the text color, background-color and border-color of the `AvatarBase`.

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

```jsx
import {   TextColor,
           BackgroundColor,
           BorderColor } from '../../../helpers/constants/design-system';
import { AvatarBase } from '../../component-library';
<AvatarBase>B</AvatarBase>
<AvatarBase
    backgroundColor={BackgroundColor.goerli}
    borderColor={BorderColor.goerli}
    color={TextColor.primaryInverse}
  >
  G
</AvatarBase>
<AvatarBase
   backgroundColor={BackgroundColor.sepolia}
   borderColor={BorderColor.sepolia}
   color={TextColor.primaryInverse}
>
  S
</AvatarBase>
```