@@ -29,7 +29,6 @@ import {
2929
3030import { ensureLocalApi } from "../../localApi" ;
3131import { usePrimarySettings } from "../../hooks/useSettings" ;
32- import { observeResize } from "../../lib/observeResize" ;
3332import { cn } from "../../lib/utils" ;
3433import { formatUpcomingTimestamp } from "../../timestampFormat" ;
3534import { ProviderInstanceIcon } from "../chat/ProviderInstanceIcon" ;
@@ -286,7 +285,6 @@ function PoolSegment({
286285 readonly color : string ;
287286 readonly now : number ;
288287 readonly index : number ;
289- readonly labeled : boolean ;
290288 readonly showAccountName : boolean ;
291289} ) {
292290 return account . redeem ? (
@@ -332,14 +330,12 @@ function SegmentTriggers({
332330 color,
333331 now,
334332 index,
335- labeled,
336333 showAccountName,
337334} : SegmentPayload & {
338335 readonly refillPercent : number ;
339336 readonly color : string ;
340337 readonly now : number ;
341338 readonly index : number ;
342- readonly labeled : boolean ;
343339 readonly showAccountName : boolean ;
344340} ) {
345341 const popover = use ( SegmentPopoverContext ) ?? undefined ;
@@ -359,10 +355,7 @@ function SegmentTriggers({
359355 type = "button"
360356 style = { { gridColumn : index , gridRow : 1 } }
361357 aria-label = { `${ account . displayName ?? ( account . email ? accountInitials ( account . email ) : account . driver ) } : ${ remaining } % left${ resetsIn ? `, ${ resetsIn } ` : "" } ${ timeLeft === null ? "" : `, ${ timeLeft } % of the window left` } ${ credits ? `, ${ credits } reset ${ credits === 1 ? "credit" : "credits" } banked` : "" } ` }
362- className = { cn (
363- "relative min-w-0 cursor-pointer rounded-md bg-muted text-start outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background data-[popup-open]:ring-1 data-[popup-open]:ring-inset data-[popup-open]:ring-border" ,
364- labeled ? "h-8" : "h-5" ,
365- ) }
358+ className = "relative h-5 min-w-0 cursor-pointer rounded-md bg-muted text-start outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background data-[popup-open]:ring-1 data-[popup-open]:ring-inset data-[popup-open]:ring-border @2xl/pool:h-8"
366359 />
367360 }
368361 >
@@ -392,19 +385,11 @@ function SegmentTriggers({
392385 ) : null }
393386 < span
394387 aria-hidden
395- className = { cn (
396- "absolute inset-0 flex items-center justify-center overflow-hidden rounded-md text-3xs leading-none font-semibold text-foreground/80 tabular-nums" ,
397- labeled && "hidden" ,
398- ) }
388+ className = "absolute inset-0 flex items-center justify-center overflow-hidden rounded-md text-3xs leading-none font-semibold text-foreground/80 tabular-nums @2xl/pool:hidden"
399389 >
400390 { index }
401391 </ span >
402- < div
403- className = { cn (
404- "relative h-full min-w-0 items-center gap-1.5 overflow-hidden rounded-md px-2 text-xs" ,
405- labeled ? "flex" : "hidden" ,
406- ) }
407- >
392+ < div className = "relative hidden h-full min-w-0 items-center gap-1.5 overflow-hidden rounded-md px-2 text-xs @2xl/pool:flex" >
408393 { showAccountName ? (
409394 < AccountName
410395 account = { account }
@@ -432,7 +417,7 @@ function SegmentTriggers({
432417 ) : null }
433418 </ div >
434419 </ PopoverTrigger >
435- { labeled ? null : < LegendRow payload = { payload } color = { color } now = { now } index = { index } /> }
420+ < LegendRow payload = { payload } color = { color } now = { now } index = { index } />
436421 </ >
437422 ) ;
438423}
@@ -459,7 +444,7 @@ function LegendRow({
459444 payload = { payload }
460445 style = { { gridColumn : "1 / -1" , gridRow : index + 1 } }
461446 render = { < Button variant = "ghost" size = "compact" /> }
462- className = "min-w-0"
447+ className = "min-w-0 @2xl/pool:hidden "
463448 >
464449 < span className = "relative inline-flex size-4 shrink-0 items-center justify-center rounded-sm text-3xs leading-none font-semibold text-foreground/80 tabular-nums" >
465450 < span
@@ -494,8 +479,6 @@ function LegendRow({
494479 ) ;
495480}
496481
497- const LABELED_SEGMENT_MIN_WIDTH = 224 ;
498-
499482function PoolBar ( {
500483 pool,
501484 color,
@@ -506,32 +489,11 @@ function PoolBar({
506489 readonly now : number ;
507490} ) {
508491 const restores = new Map ( pool . resets . map ( ( reset ) => [ reset . member . account . key , reset ] ) ) ;
509- const columns = pool . columns . length ;
510- const [ dimensions , setDimensions ] = useState ( { width : 0 , gap : 0 } ) ;
511- const probeRef = useRef < HTMLDivElement > ( null ) ;
512- const gridRef = useRef < HTMLDivElement > ( null ) ;
513- useLayoutEffect ( ( ) => {
514- const probe = probeRef . current ;
515- const grid = gridRef . current ;
516- if ( ! probe || ! grid ) return ;
517- return observeResize ( probe , ( [ entry ] ) => {
518- if ( ! entry ) return ;
519- setDimensions ( {
520- width : entry . contentRect . width ,
521- gap : Number . parseFloat ( getComputedStyle ( grid ) . columnGap ) || 0 ,
522- } ) ;
523- } ) ;
524- } , [ ] ) ;
525- const labeled =
526- ( dimensions . width - dimensions . gap * ( columns - 1 ) ) / columns >= LABELED_SEGMENT_MIN_WIDTH ;
527492 return (
528- < div className = "min-w-0" >
529- { /* A height-independent probe keeps legend changes from triggering resize feedback. */ }
530- < div ref = { probeRef } />
493+ < div className = "@container/pool min-w-0" >
531494 < div
532- ref = { gridRef }
533495 className = "grid gap-x-1 gap-y-1"
534- style = { { gridTemplateColumns : `repeat(${ columns } , minmax(0, 1fr))` } }
496+ style = { { gridTemplateColumns : `repeat(${ pool . columns . length } , minmax(0, 1fr))` } }
535497 >
536498 { pool . columns . map ( ( member , position ) =>
537499 member . window ? (
@@ -544,8 +506,7 @@ function PoolBar({
544506 color = { color }
545507 now = { now }
546508 index = { position + 1 }
547- labeled = { labeled }
548- showAccountName = { columns > 1 }
509+ showAccountName = { pool . columns . length > 1 }
549510 />
550511 ) : null ,
551512 ) }
0 commit comments