@@ -11,7 +11,7 @@ import {
1111} from "../Overview/SlotPerformance/atoms" ;
1212import type { FC , SVGProps } from "react" ;
1313import { useCallback , useEffect , useMemo , useState } from "react" ;
14- import { useUnmount } from "react-use" ;
14+ import { useMedia , useUnmount } from "react-use" ;
1515import { MagnifyingGlassIcon } from "@radix-ui/react-icons" ;
1616import { useSlotInfo } from "../../hooks/useSlotInfo" ;
1717import styles from "./slotDetails.module.css" ;
@@ -282,6 +282,7 @@ function SlotNavigation({ slot }: { slot: number }) {
282282 const mostRecentSlotLeader = useAtomValue ( mostRecentSlotLeaderAtom ) ;
283283
284284 const {
285+ previousSlotGroupLeader,
285286 previousSlotGroupLastSlot,
286287 isPreviousDisabled,
287288 nextSlotGroupLeader,
@@ -312,6 +313,7 @@ function SlotNavigation({ slot }: { slot: number }) {
312313 mostRecentSlotLeader + slotsPerLeader <= nextSlotGroupLeader ;
313314
314315 return {
316+ previousSlotGroupLeader,
315317 previousSlotGroupLastSlot,
316318 isPreviousDisabled,
317319 nextSlotGroupLeader,
@@ -326,57 +328,64 @@ function SlotNavigation({ slot }: { slot: number }) {
326328 pb = "1"
327329 style = { { top : navigationTop , zIndex : maxZIndex - 3 } }
328330 >
329- < Flex
330- className = { clsx (
331- styles . slotNavigation ,
332- styles . previousNavigation ,
333- isPreviousDisabled && styles . disabled ,
334- ) }
335- >
336- { previousSlotGroupLastSlot && (
337- < SlotStatus
338- slot = { previousSlotGroupLastSlot }
339- searchSlot = { previousSlotGroupLastSlot }
340- disabled = { isPreviousDisabled }
341- />
342- ) }
343- </ Flex >
344- < Flex
345- gap = "1"
346- flexGrow = "1"
347- flexShrink = "1"
348- wrap = "wrap"
349- className = { styles . slotNavigation }
350- >
351- { Array . from ( { length : slotsPerLeader } ) . map ( ( _ , slotIdx ) => {
352- const slotNumber = slot + slotIdx ;
353- return (
354- < SlotStatus
355- key = { slotNumber }
356- slot = { slotNumber }
357- searchSlot = { slotNumber }
358- />
359- ) ;
360- } ) }
361- </ Flex >
362- < Flex
363- className = { clsx (
364- styles . slotNavigation ,
365- styles . nextNavigation ,
366- isNextDisabled && styles . disabled ,
367- ) }
368- >
369- { nextSlotGroupLeader && (
331+ < PreviousNextNavigation
332+ slot = { previousSlotGroupLastSlot }
333+ searchSlot = { previousSlotGroupLeader }
334+ isDisabled = { isPreviousDisabled }
335+ isPrevious = { true }
336+ />
337+ < SelectedSlotGroup firstSlot = { slot } />
338+ < PreviousNextNavigation
339+ slot = { nextSlotGroupLeader }
340+ searchSlot = { nextSlotGroupLeader }
341+ isDisabled = { isNextDisabled }
342+ isPrevious = { false }
343+ />
344+ </ Flex >
345+ ) ;
346+ }
347+
348+ function SelectedSlotGroup ( { firstSlot } : { firstSlot : number } ) {
349+ return (
350+ < Flex gap = "1" className = { styles . slotNavigation } >
351+ { Array . from ( { length : slotsPerLeader } ) . map ( ( _ , slotIdx ) => {
352+ const slotNumber = firstSlot + slotIdx ;
353+ return (
370354 < SlotStatus
371- slot = { nextSlotGroupLeader }
372- searchSlot = { nextSlotGroupLeader }
373- disabled = { isNextDisabled }
355+ key = { slotNumber }
356+ slot = { slotNumber }
357+ searchSlot = { slotNumber }
374358 />
375- ) }
376- </ Flex >
359+ ) ;
360+ } ) }
377361 </ Flex >
378362 ) ;
379363}
364+ function PreviousNextNavigation ( {
365+ slot,
366+ searchSlot,
367+ isDisabled,
368+ isPrevious,
369+ } : {
370+ slot ?: number ;
371+ searchSlot ?: number ;
372+ isDisabled ?: boolean ;
373+ isPrevious : boolean ;
374+ } ) {
375+ return (
376+ < div
377+ className = { clsx ( styles . slotNavigation , {
378+ [ styles . previousNavigation ] : isPrevious ,
379+ [ styles . nextNavigation ] : ! isPrevious ,
380+ [ styles . disabled ] : isDisabled ,
381+ } ) }
382+ >
383+ { slot !== undefined && searchSlot !== undefined && (
384+ < SlotStatus slot = { slot } searchSlot = { searchSlot } disabled = { isDisabled } />
385+ ) }
386+ </ div >
387+ ) ;
388+ }
380389
381390function SlotHeader ( { slot } : { slot : number } ) {
382391 const { peer, isLeader, name } = useSlotInfo ( slot ) ;
@@ -407,10 +416,10 @@ function SlotStatus({
407416 searchSlot : number ;
408417 disabled ?: boolean ;
409418} ) {
419+ const includeIcon = ! useMedia ( "(max-width: 920px)" ) ;
410420 const selectedSlot = useAtomValue ( selectedSlotAtom ) ;
411421 const queryPublish = useSlotQueryPublish ( slot ) ;
412422 const isSelected = useMemo ( ( ) => slot === selectedSlot , [ slot , selectedSlot ] ) ;
413-
414423 const isSkipped = useMemo (
415424 ( ) => queryPublish . publish ?. skipped ,
416425 [ queryPublish . publish ?. skipped ] ,
@@ -420,29 +429,19 @@ function SlotStatus({
420429 < Link
421430 to = "/slotDetails"
422431 search = { { slot : searchSlot } }
423- className = { styles . link }
432+ className = { clsx ( styles . slotStatus , {
433+ [ styles . selectedSlot ] : isSelected ,
434+ [ styles . skippedSlot ] : isSkipped ,
435+ } ) }
424436 disabled = { disabled || isSelected }
425437 >
426- < Flex
427- align = "center"
428- justify = "center"
429- className = { clsx (
430- styles . slotStatus ,
431- isSelected && styles . selectedSlot ,
432- isSkipped && styles . skippedSlot ,
433- ) }
434- >
435- { slot !== undefined && (
436- < Text style = { disabled ? { cursor : "default" } : undefined } >
437- { slot }
438- </ Text >
439- ) }
440- { queryPublish . publish ?. skipped ? (
438+ < Text className = { styles . slotStatusText } > { slot } </ Text >
439+ { includeIcon &&
440+ ( isSkipped ? (
441441 < SkippedIcon size = "large" />
442442 ) : (
443443 < StatusIcon isCurrent = { false } slot = { slot } size = "large" />
444- ) }
445- </ Flex >
444+ ) ) }
446445 </ Link >
447446 ) ;
448447}
0 commit comments