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
2023-01-20 20:27:46 +01:00
The `AvatarIcon` accepts all props below as well as all [Box](/docs/components-ui-box--default-story#props) component props
2022-12-08 19:25:19 +01:00
<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-02-14 18:33:04 +01:00
Use the `size` prop and the `Size` object from `./ui/helpers/constants/design-system.js` to change the size of `AvatarIcon`
2022-12-08 19:25:19 +01:00
2023-02-02 21:15:26 +01:00
Optional: `AVATAR_ICON_SIZES` from `./ui/components/component-library` object can be used instead of `Size`
2022-12-08 19:25:19 +01:00
Possible sizes include:
2023-02-02 21:15:26 +01:00
- `Size.XS` 16px
- `Size.SM` 24px
- `Size.MD` 32px
- `Size.LG` 40px
- `Size.XL` 48px
2022-12-08 19:25:19 +01:00
2023-02-14 18:33:04 +01:00
Defaults to `Size.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-02-02 21:15:26 +01:00
import { Size } from '../../../helpers/constants/design-system';
2023-04-05 18:11:10 +02:00
import { AvatarIcon, IconName } from '../ui/component-library';
2022-12-08 19:25:19 +01:00
2023-02-02 21:15:26 +01:00
<AvatarIcon {...args} size={Size.XS} />
<AvatarIcon {...args} size={Size.SM} />
<AvatarIcon {...args} size={Size.MD} />
<AvatarIcon {...args} size={Size.LG} />
<AvatarIcon {...args} size={Size.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-04-05 18:11:10 +02:00
import { AvatarIcon, IconName } from '../ui/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';
2022-12-08 19:25:19 +01:00
import { AvatarIcon } from '../ui/component-library';
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
```