Skip to content

Commit

Permalink
Merge pull request #23580 from DrLoopFall/fix-workspace-icons-are-ali…
Browse files Browse the repository at this point in the history
…gned-to-the-left-22632

Fix MulitpleAvatars alignment
  • Loading branch information
Li357 authored Jul 27, 2023
2 parents b50948a + c931dd9 commit f3196c1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
11 changes: 1 addition & 10 deletions src/components/MultipleAvatars.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,9 @@ function MultipleAvatars(props) {
const overlapSize = oneAvatarSize.width / 3;

if (props.shouldStackHorizontally) {
let width;

// Height of one avatar + border space
const height = oneAvatarSize.height + 2 * oneAvatarBorderWidth;
if (props.icons.length > 4) {
const length = avatarRows.length > 1 ? Math.max(avatarRows[0].length, avatarRows[1].length) : avatarRows[0].length;
width = oneAvatarSize.width + overlapSize * 2 * (length - 1) + oneAvatarBorderWidth * (length * 2);
} else {
// one avatar width + overlaping avatar sizes + border space
width = oneAvatarSize.width + overlapSize * 2 * (props.icons.length - 1) + oneAvatarBorderWidth * (props.icons.length * 2);
}
avatarContainerStyles = StyleUtils.combineStyles([styles.alignItemsCenter, styles.flexRow, StyleUtils.getHeight(height), StyleUtils.getWidthStyle(width)]);
avatarContainerStyles = StyleUtils.combineStyles([styles.alignItemsCenter, styles.flexRow, StyleUtils.getHeight(height)]);
}

return (
Expand Down
4 changes: 2 additions & 2 deletions src/styles/StyleUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ function getHorizontalStackedAvatarBorderStyle({isHovered, isPressed, isInReport
*/
function getHorizontalStackedAvatarStyle(index, overlapSize, borderWidth, borderRadius) {
return {
left: -(overlapSize * index),
marginLeft: index > 0 ? -overlapSize : 0,
borderRadius,
borderWidth,
zIndex: index + 2,
Expand All @@ -921,7 +921,7 @@ function getHorizontalStackedOverlayAvatarStyle(oneAvatarSize, oneAvatarBorderWi
return {
borderWidth: oneAvatarBorderWidth,
borderRadius: oneAvatarSize.width,
left: -(oneAvatarSize.width * 2 + oneAvatarBorderWidth * 2),
marginLeft: -(oneAvatarSize.width + oneAvatarBorderWidth * 2),
zIndex: 6,
borderStyle: 'solid',
};
Expand Down

0 comments on commit f3196c1

Please sign in to comment.