import type { ReactNode } from 'react'; import { cn } from '@/lib/utils'; import { MastheadRail } from '@/components/ui/MastheadRail'; export type MastheadTone = 'live' | 'idle' | 'warn' | 'error'; export interface MastheadMetadataItem { label: string; value: string; tone?: 'value' | 'warn' | 'error' | 'subtitle'; } export interface PageMastheadProps { /** Small uppercase label above the state word. Omit to show only the state. */ kicker?: string; state: string; tone: MastheadTone; /** When true with tone `live`, the left rail shimmers; otherwise the rail glows subtly. */ pulsing?: boolean; metadata?: MastheadMetadataItem[]; /** Optional meta line under the state word (e.g. a one-line posture summary). */ subtitle?: ReactNode; children?: ReactNode; className?: string; /** * `hero` matches the larger title of the primary nav pages (Home, Fleet); * `default` is the compact title used by the secondary tool pages (Settings, * Console, Logs). */ size?: 'default' | 'hero'; } const toneConfig: Record = { live: { railClass: 'bg-brand/70', stateTextClass: 'text-stat-value', tintClass: 'from-brand/[0.06] via-transparent to-transparent', }, idle: { railClass: 'bg-stat-subtitle/70', stateTextClass: 'text-stat-title', tintClass: 'from-transparent via-transparent to-transparent', }, warn: { railClass: 'bg-warning/70', stateTextClass: 'text-warning', tintClass: 'from-warning/[0.06] via-transparent to-transparent', }, error: { railClass: 'bg-destructive/70', stateTextClass: 'text-destructive', tintClass: 'from-destructive/[0.06] via-transparent to-transparent', }, }; const metadataToneClass: Record, string> = { value: 'text-stat-value', warn: 'text-warning', error: 'text-destructive', subtitle: 'text-stat-subtitle', }; export function PageMasthead({ kicker, state, tone, pulsing = false, metadata, subtitle, children, className, size = 'default', }: PageMastheadProps) { const config = toneConfig[tone]; const railVariant = tone === 'live' && pulsing ? 'shimmer' : 'glow'; return (
{kicker ? ( {kicker} ) : null} {state} {subtitle ? ( {subtitle} ) : null}
{children ?
{children}
: null}
{metadata && metadata.length > 0 ? (
{metadata.map((item, idx) => (
0 && 'border-l border-border/60', )} > {item.label} {item.value}
))}
) : null}
); }