diff --git a/src/components/UserAvatar/README.md b/src/components/UserAvatar/README.md index 8b79b403bc..17361b72f9 100644 --- a/src/components/UserAvatar/README.md +++ b/src/components/UserAvatar/README.md @@ -4,12 +4,13 @@ Component for displaying user avatar. ### PropTypes -| Name | Type | Required | Default | Description | -| :------------- | :--------------- | :------- | :------ | :--------------------------------------------------------- | -| imgUrl | `string` | | | Link to image | -| fallbackImgUrl | `string` | | | Link to fallback image | -| size | `UserAvatarSize` | | 'm' | Component size. Possible values: `xs`, `s`, `m`, `l`, `xl` | -| srcSet | `string` | | | `srcSet` attribute of the image | -| sizes | `string` | | | `sizes` attribute of the image | -| title | `string` | | | Tooltip text on hover | -| className | `string` | | | Class name | +| Name | Type | Required | Default | Description | +| :------------- | :--------------- | :------- | :------ | :------------------------------------------------------------------------------------------------------ | +| imgUrl | `string` | | | Link to image | +| fallbackImgUrl | `string` | | | Link to fallback image | +| size | `UserAvatarSize` | | 'm' | Component size. Possible values: `xs`, `s`, `m`, `l`, `xl` | +| srcSet | `string` | | | `srcSet` attribute of the image | +| sizes | `string` | | | `sizes` attribute of the image | +| title | `string` | | | Tooltip text on hover | +| className | `string` | | | Class name | +| loading | `eager \| lazy` | | | The loading attribute specifies whether a browser should load an image immediately or to defer loading. | diff --git a/src/components/UserAvatar/UserAvatar.tsx b/src/components/UserAvatar/UserAvatar.tsx index 1a6d406112..66ad3303f9 100644 --- a/src/components/UserAvatar/UserAvatar.tsx +++ b/src/components/UserAvatar/UserAvatar.tsx @@ -15,6 +15,7 @@ export interface UserAvatarProps { sizes?: string; title?: string; className?: string; + loading?: 'eager' | 'lazy'; /** @deprecated Use appropriate component, like `` instead */ onClick?: () => void; } @@ -22,7 +23,10 @@ export interface UserAvatarProps { const b = block('user-avatar'); export const UserAvatar = React.forwardRef( - ({imgUrl, fallbackImgUrl, size = 'm', srcSet, sizes, title, className, onClick}, ref) => { + ( + {imgUrl, fallbackImgUrl, size = 'm', srcSet, sizes, title, className, loading, onClick}, + ref, + ) => { const [isErrored, setIsErrored] = React.useState(false); const handleError = React.useCallback(() => { @@ -39,6 +43,7 @@ export const UserAvatar = React.forwardRef( // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions = (args) => ( + + {Array(10) + .fill(0) + .map((_, index) => { + return ( + + + + ); + })} + +); +LazyLoading.args = {imgUrl};