2022-08-18 18:30:19 +02:00
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>
2023-01-20 20:27:46 +01:00
<Story id="components-componentlibrary-avatartoken--default-story" />
2022-08-18 18:30:19 +02:00
</Canvas>
## Props
2023-01-20 20:27:46 +01:00
The `AvatarToken` accepts all props below as well as all [Box](/docs/components-ui-box--default-story#props) component props
2022-08-18 18:30:19 +02:00
<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`
2023-03-17 18:06:59 +01:00
The fallback display of the `AvatarToken` is a circle with the initial letter of the network name. The size of the initial letter is calculated based on the size of the `AvatarToken` component.
2022-08-18 18:30:19 +02:00
<Canvas>
2023-02-14 18:33:04 +01:00
<Story id="components-componentlibrary-avatartoken--size-story" />
2022-08-18 18:30:19 +02:00
</Canvas>
2022-12-15 18:29:24 +01:00
```jsx
import { AvatarToken } from '../../component-library';
2022-08-18 18:30:19 +02:00
2023-02-02 21:15:26 +01:00
<AvatarToken size={Size.XS} />
<AvatarToken size={Size.SM} />
<AvatarToken size={Size.MD} />
<AvatarToken size={Size.LG} />
<AvatarToken size={Size.XL} />
2022-12-15 18:29:24 +01:00
```
### 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.
2022-08-18 18:30:19 +02:00
2023-03-17 18:06:59 +01:00
Use `Text` component props to change the `variant`, `font-weight`, `font-family`, etc.
2022-08-18 18:30:19 +02:00
<Canvas>
2023-01-20 20:27:46 +01:00
<Story id="components-componentlibrary-avatartoken--name" />
2022-08-18 18:30:19 +02:00
</Canvas>
2022-12-15 18:29:24 +01:00
```jsx
import { AvatarToken } from '../../component-library';
2023-02-02 21:15:26 +01:00
<AvatarToken name="eth" />;
2022-12-15 18:29:24 +01:00
```
### Src
2022-08-18 18:30:19 +02:00
2022-12-15 18:29:24 +01:00
Use the `src` prop to set the image to be rendered of the `AvatarToken`.
2022-08-18 18:30:19 +02:00
<Canvas>
2023-01-20 20:27:46 +01:00
<Story id="components-componentlibrary-avatartoken--src" />
2022-08-18 18:30:19 +02:00
</Canvas>
2022-12-15 18:29:24 +01:00
```jsx
import { AvatarToken } from '../../component-library';
2023-04-19 17:25:19 +02:00
<AvatarToken src="./images/eth_logo.png" />
2022-12-15 18:29:24 +01:00
<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" />
```
2022-08-18 18:30:19 +02:00
### Show Halo
2022-12-15 18:29:24 +01:00
Use the `showHalo` prop to display the component with halo effect. Only works if an image url is supplied to `src`
2022-08-18 18:30:19 +02:00
<Canvas>
2023-01-20 20:27:46 +01:00
<Story id="components-componentlibrary-avatartoken--show-halo" />
2022-08-18 18:30:19 +02:00
</Canvas>
2022-12-15 18:29:24 +01:00
```jsx
import { AvatarToken } from '../../component-library';
2023-04-19 17:25:19 +02:00
<AvatarToken src="./images/eth_logo.png" showHalo />;
2022-12-15 18:29:24 +01:00
```
2022-08-18 18:30:19 +02:00
### 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>
2023-01-20 20:27:46 +01:00
<Story id="components-componentlibrary-avatartoken--color-background-color-and-border-color" />
2022-08-18 18:30:19 +02:00
</Canvas>
2022-12-15 18:29:24 +01:00
```jsx
2023-02-02 21:15:26 +01:00
import { TextColor,
BackgroundColor,
BorderColor, } from '../../../helpers/constants/design-system';
2022-12-15 18:29:24 +01:00
import { AvatarToken } from '../../component-library';
<AvatarToken
2023-02-02 21:15:26 +01:00
backgroundColor={BackgroundColor.goerli}
borderColor={BorderColor.goerli}
name="G"
color={Color.primaryInverse}
2022-12-15 18:29:24 +01:00
>
G
</AvatarToken>
<AvatarToken
2023-02-02 21:15:26 +01:00
backgroundColor={BackgroundColor.sepolia}
borderColor={BorderColor.sepolia}
name="S"
color={Color.primaryInverse}
2022-12-15 18:29:24 +01:00
>
S
</AvatarToken>
```