mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-27 04:46:10 +01:00
c9560b75f2
* add avatar icon component * add avatar icon severities * avatar icon docs * update tests and remove stylesheet * aria label * remove aria label * update test * remove aria label * iconName prop type string * Update ui/components/component-library/avatar-icon/README.mdx Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/component-library/avatar-icon/README.mdx Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/component-library/avatar-icon/avatar-icon.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/component-library/avatar-icon/avatar-icon.stories.js Co-authored-by: George Marshall <george.marshall@consensys.net> * marginSizeControlOptions Co-authored-by: George Marshall <george.marshall@consensys.net>
98 lines
3.5 KiB
Plaintext
98 lines
3.5 KiB
Plaintext
import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';
|
|
|
|
import { AvatarBase } from '../';
|
|
import { AvatarIcon } from './avatar-icon';
|
|
|
|
# AvatarIcon
|
|
|
|
The `AvatarIcon` is an avatar component that renders only an icon inside and is built off the [AvatarBase](/docs/ui-components-component-library-avatar-base-avatar-base-stories-js--default-story#props) component
|
|
|
|
<Canvas>
|
|
<Story id="ui-components-component-library-avatar-icon-avatar-icon-stories-js--default-story" />
|
|
</Canvas>
|
|
|
|
## Props
|
|
|
|
The `AvatarIcon` accepts all props below as well as all [Box](/docs/ui-components-ui-box-box-stories-js--default-story) component props
|
|
|
|
<ArgsTable of={AvatarIcon} />
|
|
|
|
`AvatarIcon` accepts all [AvatarBase](/docs/ui-components-component-library-avatar-base-avatar-base-stories-js--default-story#props)
|
|
component props
|
|
|
|
<ArgsTable of={AvatarBase} />
|
|
|
|
### Size
|
|
|
|
Use the `size` prop and the `SIZES` object from `./ui/helpers/constants/design-system.js` to change the size of `AvatarIcon`
|
|
|
|
Optional: `AVATAR_ICON_SIZES` from `./ui/components/component-library` object can be used instead of `SIZES`
|
|
|
|
Possible sizes include:
|
|
|
|
- `SIZES.XS` 16px
|
|
- `SIZES.SM` 24px
|
|
- `SIZES.MD` 32px
|
|
- `SIZES.LG` 40px
|
|
- `SIZES.XL` 48px
|
|
|
|
Defaults to `SIZES.MD`
|
|
|
|
<Canvas>
|
|
<Story id="ui-components-component-library-avatar-icon-avatar-icon-stories-js--size" />
|
|
</Canvas>
|
|
|
|
```jsx
|
|
import { SIZES } from '../../../helpers/constants/design-system';
|
|
import { AvatarIcon, ICON_NAMES } from '../ui/component-library';
|
|
|
|
<AvatarIcon size={SIZES.XS} />
|
|
<AvatarIcon size={SIZES.SM} />
|
|
<AvatarIcon size={SIZES.MD} />
|
|
<AvatarIcon size={SIZES.LG} />
|
|
<AvatarIcon size={SIZES.XL} />
|
|
```
|
|
|
|
### Icon Name<span style={{ color: 'red' }}>\*</span>
|
|
|
|
Use the required `iconName` prop with `ICON_NAMES` object from `./ui/components/component-library` to select icon
|
|
|
|
Use the [IconSearch](/story/ui-components-component-library-icon-icon-stories-js--default-story) story to find the icon you want to use.
|
|
|
|
<Canvas>
|
|
<Story id="ui-components-component-library-avatar-icon-avatar-icon-stories-js--icon-name" />
|
|
</Canvas>
|
|
|
|
```jsx
|
|
import { AvatarIcon, ICON_NAMES } from '../ui/component-library';
|
|
|
|
<AvatarIcon iconName={ICON_NAMES.SWAP_HORIZONTAL_OUTLINE} />
|
|
<AvatarIcon iconName={ICON_NAMES.CHECK_CIRCLE_ON_FILLED} />
|
|
<AvatarIcon iconName={ICON_NAMES.INFO_FILLED} />
|
|
<AvatarIcon iconName={ICON_NAMES.WARNING_FILLED} />
|
|
<AvatarIcon iconName={ICON_NAMES.DANGER_FILLED} />
|
|
```
|
|
|
|
### Color and Background Color
|
|
|
|
Use the `color` and `backgroundColor` props with the `COLORS` object from `./ui/helpers/constants/design-system.js` to change the icon color and background color of `AvatarIcon`
|
|
|
|
`color` default: `COLORS.COLORS.PRIMARY_DEFAULT`
|
|
`backgroundColor` default: `COLORS.COLORS.PRIMARY_MUTED`
|
|
|
|
<Canvas>
|
|
<Story id="ui-components-component-library-avatar-icon-avatar-icon-stories-js--color-and-background-color" />
|
|
</Canvas>
|
|
|
|
```jsx
|
|
import { COLORS } from '../../../helpers/constants/design-system';
|
|
import { AvatarIcon } from '../ui/component-library';
|
|
|
|
<AvatarIcon color={COLORS.PRIMARY_DEFAULT} backgroundColor={BACKGROUND_COLORS.PRIMARY_MUTED} />
|
|
<AvatarIcon color={COLORS.PRIMARY_INVERSE} backgroundColor={BACKGROUND_COLORS.PRIMARY_DEFAULT} />
|
|
<AvatarIcon color={COLORS.SUCCESS_DEFAULT} backgroundColor={BACKGROUND_COLORS.SUCCESS_MUTED} />
|
|
<AvatarIcon color={COLORS.INFO_DEFAULT} backgroundColor={BACKGROUND_COLORS.INFO_MUTED} />
|
|
<AvatarIcon color={COLORS.WARNING_DEFAULT} backgroundColor={BACKGROUND_COLORS.WARNING_MUTED} />
|
|
<AvatarIcon color={COLORS.ERROR_DEFAULT} backgroundColor={BACKGROUND_COLORS.ERROR_MUTED} />
|
|
```
|