diff --git a/src/components/PeopleTiles.css b/src/components/PeopleTiles.css index fd18b7c..bf3a8a5 100644 --- a/src/components/PeopleTiles.css +++ b/src/components/PeopleTiles.css @@ -10,17 +10,15 @@ --pl-gap: calc(0.875rem * var(--pl-scale)); --pl-pad: calc(0.5rem * var(--pl-scale)); --pl-photo-ratio: 1; - --pl-radius: 3px; /* color */ --pl-accent: var(--color-link); --pl-frame-bg: var(--color-surface); - --pl-frame-edge: color-mix(in srgb, var(--color-muted) 20%, transparent); + --pl-frame-edge: color-mix(in srgb, var(--color-brand) 45%, transparent); --pl-photo-bg: color-mix(in srgb, var(--color-muted) 15%, var(--color-surface)); --pl-ink: var(--color-ink); --pl-muted: var(--color-muted); - --pl-rule: rgba(45, 200, 224, 0.3); - --pl-shadow: 0 1px 1px rgba(15, 23, 42, 0.06), 0 10px 18px -14px rgba(15, 23, 42, 0.5); + --pl-rule: color-mix(in srgb, var(--color-brand) 35%, transparent); container-type: inline-size; display: flex; @@ -31,12 +29,10 @@ .pl[data-size="sm"] { --pl-base-w: 104px; - --pl-radius: 2px; } .pl[data-size="lg"] { --pl-base-w: 164px; - --pl-photo-ratio: 4 / 5; } /* groups --------------------------------------------------------------- */ @@ -141,10 +137,8 @@ padding: var(--pl-pad); padding-bottom: calc(var(--pl-pad) * 1.6); background: var(--pl-frame-bg); - border: 1px solid var(--pl-frame-edge); - border-radius: var(--pl-radius); - box-shadow: var(--pl-shadow); - transition: transform 160ms ease, box-shadow 160ms ease; + border: 2px solid var(--pl-frame-edge); + transition: transform 160ms ease, border-color 160ms ease; } .pl[data-tilt="on"] .pl__item:nth-child(odd) .pl__frame { @@ -160,7 +154,7 @@ .pl__tile--link:hover .pl__frame, .pl__tile--link:focus-visible .pl__frame { transform: translateY(-2px); - box-shadow: 0 1px 1px rgba(15, 23, 42, 0.06), 0 16px 24px -16px rgba(15, 23, 42, 0.6); + border-color: var(--pl-accent); } .pl__tile--button:focus-visible, @@ -176,7 +170,6 @@ .pl__tile[aria-expanded="true"] .pl__frame { border-color: var(--pl-accent); - box-shadow: 0 0 0 1px var(--pl-accent), 0 14px 22px -16px rgba(15, 23, 42, 0.6); } .pl__photo { @@ -185,7 +178,6 @@ aspect-ratio: var(--pl-photo-ratio); overflow: hidden; background: var(--pl-photo-bg); - border-radius: 1px; } .pl__img { @@ -196,30 +188,55 @@ } .pl__initials { - font-size: calc(1.25rem * var(--pl-scale)); - font-weight: 600; + display: grid; + place-items: center; + width: 100%; + height: 100%; + font-family: var(--font-display); + font-size: calc(1.5rem * var(--pl-scale)); + font-weight: 700; letter-spacing: 0.03em; - color: var(--pl-muted); } +/* A fixed height, two lines of name and two of title, so every card + in a row is the same height; longer text is cut with an ellipsis + (and the tile gets the chevron, PeopleTiles.tsx). The right padding + keeps the text clear of the chevron. */ .pl__caption { + --pl-name-lh: calc(0.875rem * var(--pl-scale) * 1.25); + --pl-title-lh: calc(0.75rem * var(--pl-scale) * 1.3); display: flex; flex-direction: column; - gap: 0.1rem; - padding: 0 calc(var(--pl-pad) * 0.25); - min-height: calc(1.1rem * var(--pl-scale)); + gap: 0.15rem; + padding: 0 calc(1.25rem * var(--pl-scale)) 0 calc(var(--pl-pad) * 0.25); + height: calc(var(--pl-name-lh) * 2); +} + +.pl__caption[data-title="on"] { + height: calc(var(--pl-name-lh) * 2 + 0.15rem + var(--pl-title-lh) * 2); +} + +.pl__name, +.pl__title { + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + line-clamp: 2; + overflow: hidden; } .pl__name { font-size: calc(0.875rem * var(--pl-scale)); font-weight: 600; line-height: 1.25; + max-height: calc(var(--pl-name-lh) * 2); } .pl__title { font-size: calc(0.75rem * var(--pl-scale)); line-height: 1.3; color: var(--pl-muted); + max-height: calc(var(--pl-title-lh) * 2); } .pl__badge { @@ -230,7 +247,6 @@ place-items: center; width: calc(1.25rem * var(--pl-scale)); height: calc(1.25rem * var(--pl-scale)); - border-radius: 999px; background: var(--pl-accent); color: #fff; transition: transform 160ms ease; @@ -248,7 +264,6 @@ gap: 0.65rem; padding: 1rem 1.1rem; border-left: 3px solid var(--pl-accent); - border-radius: 6px; background: color-mix(in srgb, var(--pl-accent) 7%, var(--color-surface)); max-width: 68ch; } @@ -277,7 +292,8 @@ width: 1.75rem; height: 1.75rem; border: 1px solid var(--pl-frame-edge); - border-radius: 999px; + border-radius: var(--btn-radius); + corner-shape: squircle; background: var(--color-surface); color: var(--pl-muted); font-size: 1.1rem; diff --git a/src/components/PeopleTiles.tsx b/src/components/PeopleTiles.tsx index cfbb158..1a87066 100644 --- a/src/components/PeopleTiles.tsx +++ b/src/components/PeopleTiles.tsx @@ -2,6 +2,7 @@ import { ArrowRight, CaretDown, X } from "@phosphor-icons/react"; import { useEffect, useId, + useLayoutEffect, useMemo, useRef, useState, @@ -15,6 +16,7 @@ import { get } from "../lib/api.ts"; import { isBadId, personHref } from "../lib/hrefs.ts"; import { mediaUrl, initials } from "../lib/media.ts"; import { useSmallImage } from "../lib/useSmallImage.ts"; +import { paletteFill } from "../lib/color.ts"; import "./PeopleTiles.css"; /** @@ -47,6 +49,13 @@ import "./PeopleTiles.css"; * public email or a bio. Not bio alone, the details panel is * worth opening before anyone has written prose. * + * At every size the photo is square and the caption a fixed two + * lines of name (and two of title), so a row's cards are one + * height. What doesn't fit ends in an ellipsis, and that tile gets + * the chevron too, opening the details with it in full. A person + * with no photo gets their initials on a palette color + * (paletteFill in color.ts). + * * Field names follow the API (is_owner, location_label), so a row * from /api/teams/:id/people drops in unchanged. * @@ -394,6 +403,9 @@ export function PeopleTilesView({ }) { const baseId = useId().replace(/:/g, ""); const [openKey, setOpenKey] = useState(null); + // Tiles whose name or title didn't fit and was cut off: they get + // the down arrow, and the details panel shows it whole. + const [clipped, setClipped] = useState>(() => new Set()); const rootRef = useRef(null); const resolvedSize: PeopleTilesSize = SIZE_FEATURES[size] ? size : "md"; @@ -428,7 +440,17 @@ export function PeopleTilesView({ return emptyMessage ?

{emptyMessage}

: null; } - const open = features.details ? findByKey(resolvedGroups, openKey) : null; + const open = openKey ? findByKey(resolvedGroups, openKey) : null; + + function markClipped(key: string, isClipped: boolean) { + setClipped((current) => { + if (current.has(key) === isClipped) return current; + const next = new Set(current); + if (isClipped) next.add(key); + else next.delete(key); + return next; + }); + } function toggle(group: PeopleGroup, person: Person, index: number) { const key = keyFor(group, person, index); @@ -486,7 +508,7 @@ export function PeopleTilesView({
    {group.people.map((person, index) => { const key = keyFor(group, person, index); - const expandable = features.details && hasDetails(person); + const expandable = (features.details && hasDetails(person)) || clipped.has(key); const isOpen = expandable && openKey === key; return ( @@ -506,6 +528,7 @@ export function PeopleTilesView({ isOpen={isOpen} panelId={`${baseId}-bio`} onToggle={() => toggle(group, person, index)} + onClip={(isClipped) => markClipped(key, isClipped)} /> ); @@ -537,6 +560,7 @@ function Tile({ isOpen, panelId, onToggle, + onClip, }: { person: Person; showTitle: boolean; @@ -544,15 +568,36 @@ function Tile({ isOpen: boolean; panelId: string; onToggle: () => void; + onClip: (isClipped: boolean) => void; }) { const title = titleOf(person); + const captionRef = useRef(null); + + // Every caption is the same height (two lines of name, two of + // title), so the row stays even; a name or title that needs more + // is cut with an ellipsis. Checked again whenever the tile resizes, + // which is also when the web font arrives. + useLayoutEffect(() => { + const caption = captionRef.current; + if (!caption) return undefined; + const check = () => + onClip( + Array.from(caption.children).some((line) => line.scrollHeight > line.clientHeight + 1), + ); + check(); + const observer = new ResizeObserver(check); + observer.observe(caption); + return () => observer.disconnect(); + // onClip is a fresh closure each render; the name and title are + // what can change the answer. + }, [person.name, title, showTitle]); const content = ( - + {person.name} {showTitle && title && {title}} @@ -592,9 +637,10 @@ function Tile({ function Photo({ src, name }: { src?: string | null; name: string }) { const img = useSmallImage(src); + // No photo: the initials on a palette color picked by the name. if (img.failed) { return ( -