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-token/README.mdx
Nidhi Kumari c5368c152b
Added storybook check to CI (#17092)
* added storybook test runner

* added test runner in ci

* updated test for ci and fixed lint error

* updated lavamoat policy

* updated test command

* updated playwright

* changed command to storybook;ci

* updated command

* updated instance for test-storybook

* updated playwright

* added playwright step

* replaced concurrently with start-server-and-test

* updated the static storybook directory

* replaced first with last

* updated lock file

* replaced first with last

* updated test-storybook with maxworkers

* updated .depchechrc

* updated yml

* removed id from banner base

* replaced broken stories with .stories-to-do.js extesnsion

* updated token allowance story

* removed duplicacies from yarn

* fixed lavamoat

* removed filename comment

* updated links for docs

* fixed file extension for stories

* updated path for stories.json

* updated stories.json path

* yarn updated

* updated stories

* updated yarn

* updated wait on
2023-01-21 00:57:46 +05:30

124 lines
3.2 KiB
Plaintext

import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';
import { AvatarToken } from './avatar-token';
# AvatarToken
The `AvatarToken` is a component responsible for display of the image of a given token
<Canvas>
<Story id="components-componentlibrary-avatartoken--default-story" />
</Canvas>
## Props
The `AvatarToken` accepts all props below as well as all [Box](/docs/components-ui-box--default-story#props) component props
<ArgsTable of={AvatarToken} />
### Size
Use the `size` prop to set the size of the `AvatarToken`.
Possible sizes include:
- `xs` 16px
- `sm` 24px
- `md` 32px
- `lg` 40px
- `xl` 48px
Defaults to `md`
<Canvas>
<Story id="components-componentlibrary-avatartoken--size" />
</Canvas>
```jsx
import { AvatarToken } from '../../component-library';
<AvatarToken size={SIZES.XS} />
<AvatarToken size={SIZES.SM} />
<AvatarToken size={SIZES.MD} />
<AvatarToken size={SIZES.LG} />
<AvatarToken size={SIZES.XL} />
```
### Name
Use the `name` prop to set the initial letter of the `AvatarToken`. This will be used as the fallback display if no image url is passed to the `src` prop.
<Canvas>
<Story id="components-componentlibrary-avatartoken--name" />
</Canvas>
```jsx
import { AvatarToken } from '../../component-library';
<AvatarToken name="eth" />
```
### Src
Use the `src` prop to set the image to be rendered of the `AvatarToken`.
<Canvas>
<Story id="components-componentlibrary-avatartoken--src" />
</Canvas>
```jsx
import { AvatarToken } from '../../component-library';
<AvatarToken src="./images/eth_logo.svg" />
<AvatarToken src="./images/arbitrum.svg" />
<AvatarToken src="./images/bnb.png" />
<AvatarToken src="https://static.metaswap.codefi.network/api/v1/tokenIcons/1/0x6b175474e89094c44da98b954eedeac495271d0f.png" />
<AvatarToken src="https://static.metaswap.codefi.network/api/v1/tokenIcons/1/0x0d8775f648430679a709e98d2b0cb6250d2887ef.png" />
<AvatarToken src="https://static.metaswap.codefi.network/api/v1/tokenIcons/1/0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0.png" />
<AvatarToken src="https://i.seadn.io/gae/lSm8ChaI-3RqC9MTpi0j3KBXdfdPd57PN5UeQLY49JA3twy9wSt2dpaa22sSc6oyiXi2OEUR6GeFX8jwkZHEMADu6_Bd4EwTJ-rg?w=500&auto=format" />
```
### Show Halo
Use the `showHalo` prop to display the component with halo effect. Only works if an image url is supplied to `src`
<Canvas>
<Story id="components-componentlibrary-avatartoken--show-halo" />
</Canvas>
```jsx
import { AvatarToken } from '../../component-library';
<AvatarToken src="./images/eth_logo.svg" showHalo/>
```
### 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 `AvatarToken`.
<Canvas>
<Story id="components-componentlibrary-avatartoken--color-background-color-and-border-color" />
</Canvas>
```jsx
import { COLORS } from '../../../helpers/constants/design-system';
import { AvatarToken } from '../../component-library';
<AvatarToken
backgroundColor={COLORS.GOERLI}
borderColor={COLORS.GOERLI}
name="G"
color={COLORS.PRIMARY_INVERSE}
>
G
</AvatarToken>
<AvatarToken
backgroundColor={COLORS.SEPOLIA}
borderColor={COLORS.SEPOLIA}
name="S"
color={COLORS.PRIMARY_INVERSE}
>
S
</AvatarToken>
```