Question presented to candidate: "On our project cards we want to show who is on the team as a row of small overlapping profile pictures. Show at most four, then a +N bubble for the rest. Some people have no photo, and some photo URLs are broken, so fall back to their initials. Hovering or focusing an avatar should show the person's name, and clicking +N should list the hidden people."
Requirements:
- Overlapping circular avatars; the first one sits on top.
- At most
max(4) avatars, then a+Nbubble; never a+1bubble (just show the last person). - Photo when available; initials on a colour derived from the name when there is no photo or the image fails to load.
- A name tooltip on hover and on keyboard focus.
- The
+Nbubble is a button that toggles a list of the hidden names; Escape closes it.
What a strong answer should cover:
- Slicing into visible and hidden people as derived values from
peopleandmax, including the+1rule. - Image error handling with an
onError/@error/(error)handler and per-avatar failed state that resets when the URL changes. - Initials and a deterministic colour from the name; handling single names and extra spaces.
- Stacking with a negative margin and explicit
z-index, plus a raisedz-indexfor the hovered avatar so its tooltip is not covered. - Accessibility: each avatar exposed as one labelled image (
role="img"+aria-label), a list with a count label, and a real button for+Nwitharia-expanded.
Clarifying questions expected:
- "Should the +N bubble be interactive, or is a tooltip with the names enough?"
- "Which avatar should be on top: the first or the last?"
- "Do avatars link to profiles?"
Code / implementation expected: Yes. A reusable avatar group with an avatar child component (or equivalent) in the framework of your choice.