From e6f2a152569d52c9d97849010b3d9f36806b5c0b Mon Sep 17 00:00:00 2001 From: henrikmv <110386561+henrikmv@users.noreply.github.com> Date: Sun, 11 Aug 2024 12:56:39 +0200 Subject: [PATCH] refactor: [DHIS2-17652] Replace Material-UI Avatar (#3719) --- .../CardList/CardListItem.component.js | 10 ++-- .../CardImage/CardImage.component.js | 56 +++++++++++++++++++ 2 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 src/core_modules/capture-ui/CardImage/CardImage.component.js diff --git a/src/core_modules/capture-core/components/CardList/CardListItem.component.js b/src/core_modules/capture-core/components/CardList/CardListItem.component.js index 617e7699d3..a1fe4bc5d1 100644 --- a/src/core_modules/capture-core/components/CardList/CardListItem.component.js +++ b/src/core_modules/capture-core/components/CardList/CardListItem.component.js @@ -3,9 +3,10 @@ import i18n from '@dhis2/d2-i18n'; import React from 'react'; import moment from 'moment'; import type { ComponentType } from 'react'; -import { Avatar, Grid, withStyles } from '@material-ui/core'; +import { Grid, withStyles } from '@material-ui/core'; import { colors, Tag, IconCheckmark16, Tooltip } from '@dhis2/ui'; import { useTimeZoneConversion } from '@dhis2/app-runtime'; +import { CardImage } from '../../../capture-ui/CardImage/CardImage.component'; import type { CardDataElementsInformation, CardProfileImageElementInformation, @@ -63,8 +64,8 @@ const getStyles = (theme: Theme) => ({ flexGrow: 1, }, image: { - width: theme.typography.pxToRem(44), - height: theme.typography.pxToRem(44), + width: theme.typography.pxToRem(54), + height: theme.typography.pxToRem(54), marginRight: theme.typography.pxToRem(8), }, buttonMargin: { @@ -151,7 +152,8 @@ const CardListItemIndex = ({ const imageValue = item.values[imageElement.id]; return (
- {imageValue && } + {imageValue && } +
); }; diff --git a/src/core_modules/capture-ui/CardImage/CardImage.component.js b/src/core_modules/capture-ui/CardImage/CardImage.component.js new file mode 100644 index 0000000000..c4873cbb42 --- /dev/null +++ b/src/core_modules/capture-ui/CardImage/CardImage.component.js @@ -0,0 +1,56 @@ +// @flow +import React from 'react'; +import { withStyles } from '@material-ui/core/styles'; + +const sizes = { + extrasmall: { + height: 24, + width: 24, + }, + small: { + height: 36, + width: 36, + }, + medium: { + height: 48, + width: 48, + }, + large: { + height: 72, + width: 72, + }, + extralarge: { + height: 144, + width: 144, + }, +}; + +const styles = { + img: { + borderRadius: '50%', + objectFit: 'cover', + }, + ...sizes, +}; + +type Props = { + imageUrl: string, + dataTest: string, + classes: Object, + className: Object, + size: 'extrasmall' | 'small' | 'medium' | 'large' | 'extralarge', +}; + +const CardImagePlain = ({ imageUrl, dataTest, classes, className, size }: Props) => ( +
+ user avatar +
+); + + +export const CardImage = withStyles(styles)(CardImagePlain);