Overlapping faces with a +3 that opens everyone, for reviewers, editors and members.
Retry failed card payments7 reviewers · 3 approved
MP
Reviewers: 7 people
- Ada Lovelaceonline
- Ben Okaforaway
- Mira Pateldo not disturb
- Sam Riveraoffline
- Kenji Watanabe
- Lena Fischer
- Omar Haddad
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { AvatarGroup } from "./ui/uicontext/components/Avatar.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, font, radius, space } from "./ui/uicontext/components/tokens.stylex.ts"import { reviewers } from "./people.ts"const styles = stylex.create({ card: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: space.lg, inlineSize: "min(100%, 26rem)", paddingInline: space.xl, paddingBlock: space.lg, borderWidth: 1, borderStyle: "solid", borderColor: color.line, borderRadius: radius.lg, backgroundColor: color.panel, }, text: { display: "grid", minInlineSize: 0 }, title: { fontSize: font.base, fontWeight: 500, color: color.fg }, meta: { fontSize: font.sm, color: color.muted },})// a pull request's reviewers: four faces, then "+4" opens everyone with their statusexport const PullRequestReviewers = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.card)).children( h.div.attrs(sx(styles.text)).children( h.span.attrs(sx(styles.title)).children("Retry failed card payments"), h.span.attrs(sx(styles.meta)).children("7 reviewers · 3 approved"), ), AvatarGroup(h, { props: { label: "Reviewers", people: reviewers, max: 4, size: "md" } }), )Installation
pnpm dlx shadcn@latest add checkfu/uicontext/avatar-groupUsage
import { type AvatarPerson, AvatarGroup } from "./ui/uicontext/components/Avatar.ts"export const Reviewers = <M>(h: Html.H<M>, reviewers: ReadonlyArray<AvatarPerson>) => AvatarGroup(h, { props: { label: "Reviewers", people: reviewers, max: 4 } })Examples
Edge cases
One person, names that break layouts and a picture that fails to load, a workspace of 1,284 whose list shows the first 50, and a count with no list.
One person
Hard names
AWCMJF王
Editors: 8 people
- Aleksandra Wiśniewska-Kowalczykonline
- Christopher Alexander Montgomery III
- J
- 🦊 Fox
- 王秀英away
- Đặng Thị Ngọc Hân
- Dana Whitfield
- Relay Customer Escalations Assistant
1,284 members
ALBLMLSL
Workspace: 1,284 people
- Ada Lovelace
- Ben Lovelace
- Mira Lovelace
- Sam Lovelace
- Kenji Lovelace
- Lena Lovelace
- Omar Lovelace
- Priya Lovelace
- Jo Lovelace
- Rafael Lovelace
- Ines Lovelace
- Tomas Lovelace
- Ada Okafor
- Ben Okafor
- Mira Okafor
- Sam Okafor
- Kenji Okafor
- Lena Okafor
- Omar Okafor
- Priya Okafor
- Jo Okafor
- Rafael Okafor
- Ines Okafor
- Tomas Okafor
- Ada Patel
- Ben Patel
- Mira Patel
- Sam Patel
- Kenji Patel
- Lena Patel
- Omar Patel
- Priya Patel
- Jo Patel
- Rafael Patel
- Ines Patel
- Tomas Patel
- Ada Rivera
- Ben Rivera
- Mira Rivera
- Sam Rivera
- Kenji Rivera
- Lena Rivera
- Omar Rivera
- Priya Rivera
- Jo Rivera
- Rafael Rivera
- Ines Rivera
- Tomas Rivera
- Ada Watanabe
- Ben Watanabe
- and 1,234 more
Count only
ALBL
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { AvatarGroup } from "./ui/uicontext/components/Avatar.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, font } from "./ui/uicontext/components/tokens.stylex.ts"import { ada, workspace, worstPeople } from "./people.ts"const styles = stylex.create({ rows: { display: "grid", gap: 20 }, row: { display: "flex", flexWrap: "wrap", alignItems: "center", gap: 16 }, label: { inlineSize: "7rem", color: color.muted, fontSize: font.sm },})const cases = [ { key: "one", label: "One person", group: { label: "Assignee", people: [ada] } }, { key: "hard", label: "Hard names", group: { label: "Editors", people: worstPeople, max: 6 } }, { key: "big", label: "1,284 members", group: { label: "Workspace", people: workspace, max: 5, size: "lg" as const } }, { key: "count", label: "Count only", group: { label: "Watching", people: workspace.slice(0, 18), max: 3, size: "xs" as const, static: true } },]export const AvatarGroupEdges = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.rows)).children( cases.map(({ key, label, group }) => h.div.key(key).attrs(sx(styles.row)).children( h.span.attrs(sx(styles.label)).children(label), AvatarGroup(h, { key, props: group }), )), )API reference
AvatarGroupComponent
Props
| Name | Type | Default | Description |
|---|---|---|---|
peoplerequired | AvatarPerson[] | — | Who's in it, in the order they show. |
labelrequired | string | — | What the group is: "Reviewers", "In this doc". It names the group and heads the list. |
max | number | 4 | How many tiles show, the "+N" counted as one; 4 by default. |
size | AvatarSize | — | — |
static | boolean | — | The "+N" only counts, with no list to open: for a crowded row where the list lives elsewhere. |
AvatarView function
Options
| Name | Type | Default | Description |
|---|---|---|---|
key | string | — | Names this avatar among others in the same view; needed for more than one with a picture. |
size | "xs" | "sm" | "md" | "lg" | "xl" | sm | 20, 24, 32, 40 or 64px; sm by default. |
decorative | boolean | — | Leave the avatar out of the accessibility tree, when its name is already written beside it. |
style | Style | — | StyleX styles applied after the avatar's own. |