question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[AvatarGroup] Add prop for sorting Avatars rendering in ascendant or descendant order

See original GitHub issue

Hi, guys! 👋 This is my very first contribution to Material-UI and wanted to start with a small feature.

  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 💡

Add a prop to AvatarGroupProps to let the user specify how to sort Avatars out: descendant (default) or ascendant. It could be a boolean or an enum.

Examples 🌈

<AvatarGroup sort="ascendant">
  ...
</AvatarGroup>

The image below shows what I would like to achive image

Motivation 🔦

I am working on the development of a component library based on Material-UI. I need to create a component for displaying a list of Avatars and think that a wrapper of AvatarGroup with some customizations at the theme level should be enough. The thing is, our design shows Avatars from bottom to top, that is, first Avatar on the bottom and last one on the top. I looked up through the docs and the code and found out there is no actual way to do that: here is the line where z-index is calculated and it would be just a matter of multiplying it by -1 depending on the aforementioned prop.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
eps1loncommented, Mar 18, 2020

I don’t understand why you would want to display the rest on the top of the stack. That’s not how I would display cards in the real world.

However, you can do this already with

const useStyles = makeStyles({ avatar: { zIndex: "initial !important" } });

function GroupAvatars() {
  const classes = useStyles();

  return (
    <AvatarGroup classes={{ avatar: classes.avatar }}>
      <Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" />
      <Avatar alt="Travis Howard" src="/static/images/avatar/2.jpg" />
      <Avatar alt="Cindy Baker" src="/static/images/avatar/3.jpg" />
      <Tooltip title="Foo • Bar • Baz">
        <Avatar>+3</Avatar>
      </Tooltip>
    </AvatarGroup>
  );
}

https://codesandbox.io/s/avatargroup-reverse-stack-8q7f1

1reaction
JoshuaCS94commented, Mar 18, 2020

@JoshuaCS94 Follow #19427

Yeah! I was thinking about the same: module augmentation 👍 But seems like that guy havent finished the PR so I would have to do it locally on my project.

Ignoring the type here seems the best option.

Could go that way for now. Maybe raise the issue to csstype? After all it seems to be a limitation on their types and not yours…

Read more comments on GitHub >

github_iconTop Results From Across the Web

[AvatarGroup] Add prop for sorting Avatars rendering ... - GitHub
Add a prop to AvatarGroupProps to let the user specify how to sort Avatars out: descendant (default) or ascendant. It could be a...
Read more >
Avatar group - Examples - Components
An avatar group displays a number of avatars grouped together in a stack or ... you can add extra behavior into the overflow...
Read more >
CHANGELOG - Naive UI
n-avatar-group exports AvatarGroupOption type, closes #3879. n-transfer adds ... n-avatar adds fallback slot; n-transfer adds render-target-list prop.
Read more >
ZBrush VRCHAT Avatar and Prop Making Workflow - YouTube
Marc goes over the basics of creating a sculpted ice cream cone in ZBrush for later import into Blender. The workflow can be...
Read more >
So-Pro Warrior Presents The ULTIMATE Battle of the Decade ...
Soon the Reapers began attacking the entire Multiverse and in order to save ... of the Fire Nation and joined the Avatar's group...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found