2022-12-08 19:25:19 +01:00
import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';
import { AvatarBase } from '../';
import { AvatarIcon } from './avatar-icon';
# AvatarIcon
2023-01-20 20:27:46 +01:00
The `AvatarIcon` is an avatar component that renders only an icon inside and is built off the [AvatarBase](/docs/components-componentlibrary-avatarbase--default-story)) component
2022-12-08 19:25:19 +01:00
<Canvas>
2023-01-20 20:27:46 +01:00
<Story id="components-componentlibrary-avataricon--default-story" />
2022-12-08 19:25:19 +01:00
</Canvas>
## Props
<ArgsTable of={AvatarIcon} />
2023-01-20 20:27:46 +01:00
`AvatarIcon` accepts all [AvatarBase](/docs/components-componentlibrary-avatarbase--default-story))
2022-12-08 19:25:19 +01:00
component props
<ArgsTable of={AvatarBase} />
### Size
2023-07-26 23:18:36 +02:00
Use the `size` prop and the `AvatarIconSize` enum to change the size of `AvatarIcon`
2022-12-08 19:25:19 +01:00
Possible sizes include:
2023-07-26 23:18:36 +02:00
- `AvatarIconSize.Xs` 16px
- `AvatarIconSize.Sm` 24px
- `AvatarIconSize.Md` 32px
- `AvatarIconSize.Lg` 40px
- `AvatarIconSize.Xl` 48px
2022-12-08 19:25:19 +01:00
2023-07-26 23:18:36 +02:00
Defaults to `AvatarIconSize.Md`
2022-12-08 19:25:19 +01:00
<Canvas>
2023-02-14 18:33:04 +01:00
<Story id="components-componentlibrary-avataricon--size-story" />
2022-12-08 19:25:19 +01:00
</Canvas>
```jsx
2023-08-15 23:35:18 +02:00
import { AvatarIcon, AvatarIconSize } from '../../component-library';
2022-12-08 19:25:19 +01:00
2023-07-26 23:18:36 +02:00
<AvatarIcon {...args} size={AvatarIconSize.Xs} />
<AvatarIcon {...args} size={AvatarIconSize.Sm} />
<AvatarIcon {...args} size={AvatarIconSize.Md} />
<AvatarIcon {...args} size={AvatarIconSize.Lg} />
<AvatarIcon {...args} size={AvatarIconSize.Xl} />
2022-12-08 19:25:19 +01:00
```
### Icon Name<span style={{ color: 'red' }}>\*</span>
2023-04-05 18:11:10 +02:00
Use the required `iconName` prop with `IconName` enum from `./ui/components/component-library` to select icon
2022-12-08 19:25:19 +01:00
2023-01-20 20:27:46 +01:00
Use the [IconSearch](/story/components-componentlibrary-icon--default-story) story to find the icon you want to use.
2022-12-08 19:25:19 +01:00
<Canvas>
2023-04-05 18:11:10 +02:00
<Story id="components-componentlibrary-avataricon--icon-name-story" />
2022-12-08 19:25:19 +01:00
</Canvas>
```jsx
2023-08-15 23:35:18 +02:00
import { AvatarIcon, IconName } from '../../component-library';
2022-12-08 19:25:19 +01:00
2023-04-05 18:11:10 +02:00
<AvatarIcon iconName={IconName.SwapHorizontal} />
<AvatarIcon iconName={IconName.Confirmation} />
<AvatarIcon iconName={IconName.Info} />
<AvatarIcon iconName={IconName.Warning} />
<AvatarIcon iconName={IconName.Danger} />
2022-12-08 19:25:19 +01:00
```
### Color and Background Color
2023-02-02 21:15:26 +01:00
Use the `color` and `backgroundColor` props with the `IconColor` and `BackgroundColor` object from `./ui/helpers/constants/design-system.js` to change the icon color and background color of `AvatarIcon`
2022-12-08 19:25:19 +01:00
2023-02-02 21:15:26 +01:00
`color` default: `IconColor.primaryDefault`
`backgroundColor` default: `BackgroundColor.primaryMuted`
2022-12-08 19:25:19 +01:00
<Canvas>
2023-01-20 20:27:46 +01:00
<Story id="components-componentlibrary-avataricon--color-and-background-color" />
2022-12-08 19:25:19 +01:00
</Canvas>
```jsx
2023-02-02 21:15:26 +01:00
import { BackgroundColor, IconColor } from '../../../helpers/constants/design-system';
2023-08-15 23:35:18 +02:00
import { AvatarIcon } from '../../component-library';
2022-12-08 19:25:19 +01:00
2023-02-02 21:15:26 +01:00
<AvatarIcon color={IconColor.primaryDefault} backgroundColor={BackgroundColor.primaryMuted} />
<AvatarIcon color={IconColor.primaryInverse} backgroundColor={BackgroundColor.primaryDefault} />
<AvatarIcon color={IconColor.successDefault} backgroundColor={BackgroundColor.successMuted} />
<AvatarIcon color={IconColor.infoDefault} backgroundColor={BackgroundColor.infoMuted} />
<AvatarIcon color={IconColor.warningDefault} backgroundColor={BackgroundColor.warningMuted} />
<AvatarIcon color={IconColor.errorDefault} backgroundColor={BackgroundColor.errorMuted} />
2022-12-08 19:25:19 +01:00
```