diff --git a/src/client/channel/components/ChannelCouch.tsx b/src/client/channel/components/ChannelCouch.tsx index eeb1a7217..a6f993943 100644 --- a/src/client/channel/components/ChannelCouch.tsx +++ b/src/client/channel/components/ChannelCouch.tsx @@ -22,6 +22,7 @@ export interface ChannelCouchPerson { } const SEAT_WIDTH = 70; +const MIN_SEAT_WIDTH = 48; const SEAT_GUTTER = 24; const noSubscription = () => () => {}; const noSnapshot = () => null; @@ -47,13 +48,15 @@ export function ChannelCouch({ people, selfUserId, session, className = "", floa const others = people.filter(person => person.userId !== selfUserId); const selected = people.find(person => person.userId === target?.userId); const width = Math.min(availableWidth, Math.max(144, people.length * SEAT_WIDTH + 2 * SEAT_GUTTER)); - const guestSeats = Math.max(1, Math.floor((width - 2 * SEAT_GUTTER) / SEAT_WIDTH) - Number(Boolean(self))); - const guestWidth = Math.min(others.length, guestSeats) * SEAT_WIDTH; - const overflow = others.length * SEAT_WIDTH > guestWidth; + const seats = Math.max(1, Math.min(people.length, Math.floor((width - 2 * SEAT_GUTTER) / MIN_SEAT_WIDTH))); + const seatWidth = Math.min(SEAT_WIDTH, Math.max(MIN_SEAT_WIDTH, (width - 2 * SEAT_GUTTER) / seats)); + const guestSeats = Math.max(1, seats - Number(Boolean(self))); + const guestWidth = Math.min(others.length, guestSeats) * seatWidth; + const overflow = others.length * seatWidth > guestWidth; const visiblePeople = people.filter(person => { if (person.userId === selfUserId) return true; const seat = others.indexOf(person); - return seat * SEAT_WIDTH >= offset - 1 && (seat + 1) * SEAT_WIDTH <= offset + guestWidth + 1; + return seat * seatWidth >= offset - 1 && (seat + 1) * seatWidth <= offset + guestWidth + 1; }).map(person => ({ peerId: person.userId })); useEffect(() => { setTarget(null); }, [session?.key]); useLayoutEffect(() => { setTarget(null); }, [floating, surfaceDocument]); @@ -85,7 +88,7 @@ export function ChannelCouch({ people, selfUserId, session, className = "", floa ; } return
+ style={{ "--c3-couch-seat": `${seatWidth}px`, "--c3-couch-gutter": `${SEAT_GUTTER}px` } as CSSProperties}>
@@ -107,7 +110,7 @@ export function ChannelCouch({ people, selfUserId, session, className = "", floa = others.length * SEAT_WIDTH - guestWidth - 1} onClick={() => browse(1)} /> + disabled={offset >= others.length * seatWidth - guestWidth - 1} onClick={() => browse(1)} /> }
diff --git a/src/client/channel/components/channel-couch.css b/src/client/channel/components/channel-couch.css index e16650595..9d35355ad 100644 --- a/src/client/channel/components/channel-couch.css +++ b/src/client/channel/components/channel-couch.css @@ -10,7 +10,7 @@ .c3-couch-seat { display: grid; flex: 0 0 var(--c3-couch-seat); min-width: 0; justify-items: center; scroll-snap-align: start; } .c3-couch-people > .c3-couch-seat { padding-block: 11px 6px; } .c3-couch-seat > .lr-comic-tip-wrap { min-width: 0; max-width: 100%; } -.c3-couch-seat .lr-pawn { min-width: 0; max-width: 100%; } +.c3-couch-seat .lr-pawn { min-width: 44px; max-width: 100%; } .c3-couch-seat .lr-person { width: 42px; height: 50px; } .c3-couch-seat .lr-pawn-name { max-width: 100%; } .c3-couch-browse { position: absolute; top: 57px; }