From e76fd7ce9ab4a6adff05f5e816f385e1b5afc316 Mon Sep 17 00:00:00 2001 From: Daniil Demchenko Date: Wed, 15 Nov 2023 17:50:07 +0300 Subject: [PATCH] feat: lazy loading for userAvatar (#1124) Co-authored-by: Daniil Demchenko --- src/components/UserAvatar/README.md | 19 ++++++++++--------- src/components/UserAvatar/UserAvatar.tsx | 7 ++++++- .../__stories__/UserAvatar.stories.tsx | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 10 deletions(-) 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 `