Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix custom workspace avatar border radius is different #24088

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/Avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ function Avatar(props) {

const imageStyle =
props.imageStyles && props.imageStyles.length
? [StyleUtils.getAvatarStyle(props.size), ...props.imageStyles, StyleUtils.getAvatarBorderRadius(props.size, props.type)]
: [StyleUtils.getAvatarStyle(props.size), StyleUtils.getAvatarBorderStyle(props.size, props.type)];
? [StyleUtils.getAvatarStyle(props.size), ...props.imageStyles, styles.noBorderRadius]
: [StyleUtils.getAvatarStyle(props.size), styles.noBorderRadius];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanation of the problem:

In our previous PR, we are removing multiple border radius that is applied on both parent and child view. However, we forget to cover the case where the workspace avatar is a custom image because it is rendered differently.

{_.isFunction(props.source) || imageError ? (
<View style={iconStyle}>
<Icon
src={imageError ? fallbackAvatar : props.source}
height={iconSize}
width={iconSize}
fill={imageError ? themeColors.offline : iconFillColor}
additionalStyles={[
StyleUtils.getAvatarBorderStyle(props.size, props.type),
isWorkspace ? StyleUtils.getDefaultWorkspaceAvatarColor(props.name) : {},
imageError ? StyleUtils.getBackgroundColorStyle(themeColors.fallbackIconColor) : {},
...props.iconAdditionalStyles,
]}
/>
</View>
) : (
<View style={[iconStyle, StyleUtils.getAvatarBorderStyle(props.size, props.type), ...props.iconAdditionalStyles]}>
<Image
source={{uri: props.source}}
style={imageStyle}
onError={() => setImageError(true)}
/>
</View>
)}

Screenshot 2023-08-03 at 12 45 44

So, in this PR, I removed the border radius from the image style.

The reason StyleUtils.getAvatarBorderStyle(props.size, props.type) is added is because StyleUtils.getAvatarStyle(props.size) set the border-radius value to be the same as the width and height of the avatar. This makes the avatar will always completely rounded, which is wrong for workspace avatar.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I found that we have a previous commit that is trying to remove the redundant border-radius, but because there are lot of changes to the avatar, the redundant border-radius happen again.

const iconStyle = props.imageStyles && props.imageStyles.length ? [StyleUtils.getAvatarStyle(props.size), styles.bgTransparent, ...props.imageStyles] : undefined;

Expand Down
Loading