Skip to content

Commit

Permalink
feat(AvatarGroup): add highlight feature
Browse files Browse the repository at this point in the history
  • Loading branch information
plagoa authored and francisco-guilherme committed Apr 5, 2024
1 parent 54151ea commit 2fd2b97
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/core/src/AvatarGroup/AvatarGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export interface HvAvatarGroupProps extends HvBaseProps {
* If `undefined` a default `HvAvatar` will be displayed along with a HvTooltip with the count of overflowing items.
* */
overflowComponent?: (overflowCount: number) => React.ReactNode;
/**
* If `true` the avatars will be brought to the front when hovered.
*/
highlight?: boolean;
}

const getSpacingValue = (
Expand Down Expand Up @@ -70,6 +74,7 @@ export const HvAvatarGroup = forwardRef<HTMLDivElement, HvAvatarGroupProps>(
toBack = true,
maxVisible = 3,
overflowComponent,
highlight = false,
...others
} = useDefaultProps("HvAvatarGroup", props);
const { classes, cx } = useClasses(classesProp);
Expand All @@ -89,9 +94,6 @@ export const HvAvatarGroup = forwardRef<HTMLDivElement, HvAvatarGroupProps>(
{Children.map(children, (child: any, index: number) => {
if (index < maxVisible) {
return cloneElement(child, {
style: {
zIndex: 100 + index * zIndexMultiplier,
},
classes: {
container: css({
marginLeft:
Expand All @@ -103,6 +105,14 @@ export const HvAvatarGroup = forwardRef<HTMLDivElement, HvAvatarGroupProps>(
: 0
: 0,
}),
root: css({
zIndex: 100 + index * zIndexMultiplier,
...(highlight && {
"&:hover": {
zIndex: 100 + totalChildren + 1,
},
}),
}),
},
size,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const Main: StoryObj<HvAvatarGroupProps> = {
toBack: true,
maxVisible: 5,
direction: "row",
highlight: false,
},
argTypes: {
classes: { control: { disable: true } },
Expand Down

0 comments on commit 2fd2b97

Please sign in to comment.