1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 12:29:06 +01:00
metamask-extension/ui/components/component-library/avatar-base/README.mdx
Suryansh Anand c92d7380df
Migrates avatar base to TypeScript (#18494)
* Converted file extension from .js to .tsx

* Updated README docs to match the enums. Resolved type errors

* Updated AvatarBaseSizes enum values to string literals

* Added TEXT_TRANSFORM.UPPERCASE as default value of textTransform in base file

* lint fix

* Solved liniting errors in avatar-base

* Made enum more consistent, added desc for AvatarBaseProps

* Updated snapshots of AvatarBase and exported AvatarBaseProps in index.ts

* Made textTransform property accept right values in avatar-base.tsx

* Adding temporary changed extensions

* Reverted files back to tsx and resolved conflicts

* Solved linting errors

* AvatarBaseProps now extends TextProps

* Changing extension to resolve conflict

* Reverted extensions back to tsx after resolving conflicts

* Added forwardRef in AvatarBase

* Updated import name of AvatarBaseSize in README.mdx. Removed empty children attribute from AvatarBase storybook file

---------

Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
Co-authored-by: Brad Decker <bhdecker84@gmail.com>
2023-05-03 17:30:07 -07:00

102 lines
2.7 KiB
Plaintext

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 { AvatarBaseSize } from '../ui/component-library/avatar-base/avatar-base.types';
import { AvatarBase } from '../../component-library/avatar-base';
<AvatarBase size={AvatarBaseSize.XS} />
<AvatarBase size={AvatarBaseSize.SM} />
<AvatarBase size={AvatarBaseSize.MD} />
<AvatarBase size={AvatarBaseSize.LG} />
<AvatarBase size={AvatarBaseSize.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>
```