import { Maximize2, Minimize2 } from 'lucide-react'; import * as React from 'react'; import { __ } from '@wordpress/i18n'; import { periods as PERIODS } from '../../../data/periods'; import { Duration } from '../../../utils/admin'; import { RealtimeRing } from '../../content-explorer/RealtimeRing'; import { AltisMark } from './AltisMark'; import { AnimatedTabs } from '@/components/ui/animated-tabs'; import { Button } from '@/components/ui/button'; import { cn } from '@/lib/utils'; export const REALTIME_INTERVAL_SECONDS = 15; // WP admin bar height. The bar is `position: fixed; top: 0; height: 32px` // on widths >=783px. const ADMIN_BAR_PX = 32; interface Props { period: Duration; onChange: ( v: Duration ) => void; realtimeTick: number; isFullscreen: boolean; onToggleFullscreen: () => void; } /** * Full-width muted strip that pins to the top of the page (or the * viewport in fullscreen mode). Drops a subtle shadow when stuck. * Hosts the global period chips, the realtime countdown ring inside * the Realtime chip, and the wall-display fullscreen toggle. */ export function StickyPeriodBar( { period, onChange, realtimeTick, isFullscreen, onToggleFullscreen, }: Props ) { const sentinelRef = React.useRef( null ); const [ stuck, setStuck ] = React.useState( false ); React.useEffect( () => { const sentinel = sentinelRef.current; if ( ! sentinel ) { return; } const obs = new IntersectionObserver( ( [ entry ] ) => setStuck( entry.intersectionRatio < 1 ), { threshold: [ 1 ], rootMargin: `-${ ( isFullscreen ? 0 : ADMIN_BAR_PX ) + 1 }px 0px 0px 0px`, } ); obs.observe( sentinel ); return () => obs.disconnect(); }, [ isFullscreen ] ); const isRealtime = period === 'PT30M'; const options = PERIODS.map( p => { if ( p.value === 'PT30M' ) { return { value: p.value, label: ( { p.label } ), }; } return { value: p.value, label: p.label, }; } ); const FullscreenIcon = isFullscreen ? Minimize2 : Maximize2; return ( <>