People tiles: a whole list shares one row when it fits

When every group (a team's leads and members alike) fits side by
side with tiles at three quarters of full width or wider, 10 at most,
they share one line, each group's width following its head count; a
board of 7 is one row rather than 5 and 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-30 22:28:42 -05:00
parent bc88b45ee1
commit 01de6272f3
2 changed files with 41 additions and 4 deletions

View file

@ -66,6 +66,16 @@
border-left: 1px solid var(--pl-rule);
}
/* Everyone on one line (fitsOneRow in PeopleTiles.tsx): the groups
share it by head count, and the tiles narrow to fit. */
.pl__groups[data-row="one"] {
flex-wrap: nowrap;
}
.pl__groups[data-row="one"] .pl__group {
flex: var(--pl-share) 1 0;
}
.pl__group-head {
display: flex;
flex-direction: column;

View file

@ -56,7 +56,10 @@ import "./PeopleTiles.css";
* Rows fill (balancedColumns): as many tiles across as fit, never
* fewer than 2 or more than 10, one fewer when that would leave a
* lone tile on the last row. When 2 don't fit at full size they
* shrink.
* shrink. And when everyone (every group, leads and members alike)
* fits on one line with tiles at ONE_ROW_SHRINK of full width or
* wider, they all share that one line instead (fitsOneRow): a
* board of 7 reads as one row, not 5 and 2.
*
* Details open in a panel right under the tile, over what follows
* (flipped to end at the tile's right edge when it would run off
@ -484,6 +487,9 @@ export function PeopleTilesView({
}
const open = openKey ? findByKey(resolvedGroups, openKey) : null;
const oneRow =
room !== null && overflow !== "scroll" &&
fitsOneRow(resolvedGroups.map((group) => group.people.length), room.width, room.tile, room.gap);
const anchored = overflow !== "scroll";
const closePanel = () => {
setOpenKey(null);
@ -537,13 +543,17 @@ export function PeopleTilesView({
{...rest}
>
<span ref={probeRef} className="pl__probe" aria-hidden="true" />
<div className="pl__groups">
<div className="pl__groups" data-row={oneRow ? "one" : undefined}>
{resolvedGroups.map((group) => (
<section
key={group.id}
className="pl__group"
style={
group.accent ? ({ "--pl-accent": group.accent } as CSSProperties) : undefined
{
...(group.accent ? { "--pl-accent": group.accent } : null),
// Sharing one line: each group's width follows its head count.
...(oneRow ? { "--pl-share": group.people.length } : null),
} as CSSProperties
}
aria-label={group.label || undefined}
>
@ -559,7 +569,9 @@ export function PeopleTilesView({
style={
room
? ({
"--pl-cols": balancedColumns(group.people.length, room.width, room.tile, room.gap),
"--pl-cols": oneRow
? group.people.length
: balancedColumns(group.people.length, room.width, room.tile, room.gap),
} as CSSProperties)
: undefined
}
@ -834,6 +846,21 @@ function Chevron() {
/* ── Helpers ─────────────────────────────────────────────────── */
/* How small a tile may get so a whole list shares one line. */
export const ONE_ROW_SHRINK = 0.75;
/* Whether every group fits side by side on one line, 10 tiles at most,
with tiles no smaller than ONE_ROW_SHRINK of full width. Groups are
divided by a gap, padding and a 1px rule (PeopleTiles.css). */
export function fitsOneRow(counts: number[], width: number, tile: number, gap: number): boolean {
const total = counts.reduce((sum, n) => sum + n, 0);
if (total < 2 || total > 10) return false;
const smallest = tile * ONE_ROW_SHRINK;
const tiles = counts.reduce((sum, n) => sum + n * smallest + (n - 1) * gap, 0);
const dividers = (counts.length - 1) * (gap * 3 + 1);
return tiles + dividers <= width;
}
/* Tiles across a row: as many as fit, at least 2 and at most 10
(never more than there are). If that would leave one tile alone on
the last row, one fewer across, so the last row has two: 7 that fit