Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ const useStyles = () => {
alignItems: 'center',
flexDirection: 'row',
gap: primitives.spacingXs,
paddingTop: primitives.spacingXs,
paddingBottom: primitives.spacingXxs,
},
messageRepliesText: {
color: shouldUseOverlayStyles ? semantics.textOnAccent : semantics.textPrimary,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,134 +27,143 @@ exports[`TypingIndicator should match typing indicator snapshot 1`] = `
>
<View
style={
[
{
"alignItems": "center",
"flexDirection": "row",
},
{
"width": 51.2,
},
]
{
"flexDirection": "row",
}
}
>
<View
style={
[
{
"position": "absolute",
"alignItems": "center",
"flexDirection": "row",
},
{
"left": 0,
"height": 32,
"width": 51.2,
},
]
}
>
<View
testID="user-avatar"
style={
[
{
"position": "absolute",
},
{
"left": 0,
},
]
}
>
<View
style={
[
{
"alignItems": "center",
"borderRadius": 9999,
"justifyContent": "center",
"overflow": "hidden",
},
{
"height": 32,
"width": 32,
},
{
"backgroundColor": "#fcd579",
},
{
"borderColor": "rgba(0, 0, 0, 0.1)",
"borderWidth": 1,
},
undefined,
]
}
testID="avatar-image"
testID="user-avatar"
>
<Image
onError={[Function]}
source={
{
"uri": "https://i.imgur.com/LuuGvh0.png",
}
}
<View
style={
[
{},
{
"alignItems": "center",
"borderRadius": 9999,
"justifyContent": "center",
"overflow": "hidden",
},
{
"height": 32,
"width": 32,
},
{
"backgroundColor": "#fcd579",
},
{
"borderColor": "rgba(0, 0, 0, 0.1)",
"borderWidth": 1,
},
undefined,
]
}
/>
testID="avatar-image"
>
<Image
onError={[Function]}
source={
{
"uri": "https://i.imgur.com/LuuGvh0.png",
}
}
style={
[
{},
{
"height": 32,
"width": 32,
},
]
}
/>
</View>
</View>
</View>
</View>
<View
style={
[
{
"position": "absolute",
},
{
"left": 19.2,
},
]
}
>
<View
testID="user-avatar"
style={
[
{
"position": "absolute",
},
{
"left": 19.2,
},
]
}
>
<View
style={
[
{
"alignItems": "center",
"borderRadius": 9999,
"justifyContent": "center",
"overflow": "hidden",
},
{
"height": 32,
"width": 32,
},
{
"backgroundColor": "#8febbd",
},
{
"borderColor": "rgba(0, 0, 0, 0.1)",
"borderWidth": 1,
},
undefined,
]
}
testID="avatar-image"
testID="user-avatar"
>
<Image
onError={[Function]}
source={
{
"uri": "https://i.imgur.com/spueyAP.png",
}
}
<View
style={
[
{},
{
"alignItems": "center",
"borderRadius": 9999,
"justifyContent": "center",
"overflow": "hidden",
},
{
"height": 32,
"width": 32,
},
{
"backgroundColor": "#8febbd",
},
{
"borderColor": "rgba(0, 0, 0, 0.1)",
"borderWidth": 1,
},
undefined,
]
}
/>
testID="avatar-image"
>
<Image
onError={[Function]}
source={
{
"uri": "https://i.imgur.com/spueyAP.png",
}
}
style={
[
{},
{
"height": 32,
"width": 32,
},
]
}
/>
</View>
</View>
</View>
</View>
Expand Down
79 changes: 46 additions & 33 deletions package/src/components/ui/Avatar/AvatarStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { UserAvatar } from './UserAvatar';
import { BadgeCount } from '../Badge';

export type AvatarStackProps = {
avatarSize?: 'sm' | 'md' | 'xs';
avatarSize?: 'md' | 'sm' | 'xs';
maxVisible?: number;
items: React.ReactNode[];
overlap?: number;
Expand All @@ -24,41 +24,50 @@ export const AvatarStack = (props: AvatarStackProps) => {
const visibleItems = items.slice(0, maxVisible);
const extraCount = items.length - visibleItems.length;

if (extraCount > 0) {
visibleItems.push(
<BadgeCount
count={extraCount}
size={avatarSize === 'sm' || avatarSize === 'md' ? 'md' : 'sm'}
/>,
);
}

const totalWidth = diameter + (visibleItems.length - 1) * visiblePortion;

const badgeCountSize = avatarSize === 'md' ? 'lg' : avatarSize === 'sm' ? 'md' : 'sm';

return (
<View
style={[
styles.container,
{
width: totalWidth,
},
]}
>
{visibleItems.map((item, index) => {
return (
<View
style={[
styles.item,
{
left: index * visiblePortion,
},
]}
key={index}
>
{item}
</View>
);
})}
<View style={styles.wrapper}>
<View
style={[
styles.container,
{
width: totalWidth,
height: diameter,
},
]}
>
{visibleItems.map((item, index) => {
return (
<View
style={[
styles.item,
{
left: index * visiblePortion,
},
]}
key={index}
>
{item}
</View>
);
})}
</View>

{extraCount > 0 && (
<View
style={[
styles.badgeCount,
{
marginLeft: -(overlap * diameter),
},
]}
>
<BadgeCount count={extraCount} size={badgeCountSize} />
</View>
)}
</View>
);
};
Expand Down Expand Up @@ -100,6 +109,10 @@ const useStyles = () => {
item: {
position: 'absolute',
},
badgeCount: {},
wrapper: {
flexDirection: 'row',
},
}),
[],
);
Expand Down