1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00
metamask-extension/ui/components/component-library/avatar-base
George Marshall 09d29ef00d
Renaming broken stories to clean up console (#16905)
* Renaming broken stories. Fixing deprecated default arg syntax for stories using defaultValue

* Fixing imports
2022-12-15 14:46:30 -08:00
..
__snapshots__ avatar base component housekeeping (#16583) 2022-11-23 22:12:43 +05:30
avatar-base.constants.js avatar base component housekeeping (#16583) 2022-11-23 22:12:43 +05:30
avatar-base.js avatar base component housekeeping (#16583) 2022-11-23 22:12:43 +05:30
avatar-base.scss avatar base component housekeeping (#16583) 2022-11-23 22:12:43 +05:30
avatar-base.stories.js Renaming broken stories to clean up console (#16905) 2022-12-15 14:46:30 -08:00
avatar-base.test.js avatar base component housekeeping (#16583) 2022-11-23 22:12:43 +05:30
index.js avatar base component housekeeping (#16583) 2022-11-23 22:12:43 +05:30
README.mdx avatar base component housekeeping (#16583) 2022-11-23 22:12:43 +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="ui-components-component-library-avatar-base-avatar-base-stories-js--default-story" />
</Canvas>

## Props

The `AvatarBase` accepts all props below as well as all [Box](/docs/ui-components-ui-box-box-stories-js--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`

<Canvas>
  <Story id="ui-components-component-library-avatar-base-avatar-base-stories-js--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="ui-components-component-library-avatar-base-avatar-base-stories-js--children" />
</Canvas>

```jsx
import { AvatarBase } from '../../component-library';
<AvatarBase>
  <img src="./images/eth_logo.svg" />
</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="ui-components-component-library-avatar-base-avatar-base-stories-js--color-background-color-and-border-color" />
</Canvas>

```jsx
import { COLORS } from '../../../helpers/constants/design-system';
import { AvatarBase } from '../../component-library';
<AvatarBase>B</AvatarBase>
<AvatarBase
  backgroundColor={COLORS.GOERLI}
  borderColor={COLORS.GOERLI}
  color={COLORS.PRIMARY_INVERSE}
  >
  G
</AvatarBase>
<AvatarBase
  backgroundColor={COLORS.SEPOLIA}
  borderColor={COLORS.SEPOLIA}
  color={COLORS.PRIMARY_INVERSE}
>
  S
</AvatarBase>
```