5.0.0 • Published 7 months ago
@lg-chat/avatar v5.0.0
Avatar
🚨 DEPRECATION NOTICE: This package is deprecated and will no longer receive updates.
Please use Avatar from @leafygreen-ui/avatar instead.
Installation
Yarn
yarn add @lg-chat/avatarNPM
npm install @lg-chat/avatarExample
import { Avatar } from '@lg-chat/avatar';
return <Avatar darkMode variant={Variant.Mongo} />;Output HTML
<div class="lg-ui-lg-message-avatar-0000">
<div class="leafygreen-ui-i5hsjh" data-testid="mongo-avatar">
<svg
role="img"
aria-label="MongoDB Logo"
class="leafygreen-ui-ebwjgf"
height="40"
viewBox="0 0 15 32"
fill="none"
>
<path />
</svg>
</div>
</div>Properties
| Prop | Type | Description | Default |
|---|---|---|---|
darkMode | boolean | Determines if the component will render in dark mode | false |
name | string | The name of the user who is represented by the avatar. The rendered text will be the initials of the text passed to this prop. | |
size | "small", "default" | Determines the size of the avatar | "default" |
sizeOverride | number | If provided, overrides the size prop to a customizable number (in px) | |
variant | "mongo", "user", "default" | Determines the Avatar component's variant | "default" |
... | HTMLElementProps<'div'> | Props spread on the root element |
Behavior
- When
variant = "user"and a value is not passed to thenameprop, an Avatar with the Person icon will be rendered as a fallback. - The
sizeprop is given default values responsinve to the chat container size. The chat container size is determined by the width of the first child inLeafyGreenChatContext. If asizeprop value is provided, however, it will override the default values.