Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | 'use client' import { useCallback } from 'react' import { useRouter, usePathname } from 'next/navigation' import Link from 'next/link' import { css } from '../../../../styled-system/css' import { Z_INDEX } from '@/constants/zIndex' import type { ModelType } from '../train/components/wizard/types' import { useModelType, getValidModelTypes } from '../hooks/useModelType' import { getModelEntry, TABS, type TabId } from '../registry' /** * Vision Training Navigation Bar * * Fixed nav bar at top of all vision training pages. * - Home link * - Model selector (navigates to different model) * - Tab links (Data, Train, Test, Sessions) * * Uses path-based routing: /vision-training/[model]/[tab] */ export function VisionTrainingNav() { const router = useRouter() const pathname = usePathname() const modelType = useModelType() const allModelTypes = getValidModelTypes() const entry = getModelEntry(modelType) // Determine active tab from pathname const getActiveTab = (): TabId => { if (pathname.includes('/train')) return 'train' if (pathname.includes('/test')) return 'test' if (pathname.includes('/sessions')) return 'sessions' return 'data' } const activeTab = getActiveTab() // Handle model change - preserve current tab const handleModelChange = useCallback( (newModel: ModelType) => { // Get current path suffix (e.g., /train, /test, /sessions) const pathParts = pathname.split('/') const modelIndex = pathParts.indexOf(modelType) const suffix = pathParts.slice(modelIndex + 1).join('/') // Navigate to new model path with same suffix const newPath = suffix ? `/vision-training/${newModel}/${suffix}` : `/vision-training/${newModel}` router.push(newPath) }, [pathname, modelType, router] ) // Get tab path const getTabPath = (tabId: TabId): string => { const basePath = `/vision-training/${modelType}` if (tabId === 'data') return basePath return `${basePath}/${tabId}` } return ( <nav data-component="vision-training-nav" className={css({ position: 'fixed', top: 0, left: 0, right: 0, bg: 'gray.900', borderBottom: '1px solid', borderColor: 'gray.800', display: 'flex', alignItems: 'center', px: 4, gap: 4, })} style={{ height: 'var(--app-nav-height, 72px)', zIndex: Z_INDEX.NAV_BAR }} > {/* Home link */} <Link href="/" data-action="go-home" className={css({ color: 'gray.400', textDecoration: 'none', fontSize: 'sm', _hover: { color: 'gray.200' }, })} > ← Home </Link> <span className={css({ color: 'gray.600' })}>|</span> {/* Title */} <span data-element="nav-title" className={css({ fontSize: 'lg', fontWeight: 'bold', color: 'gray.100', display: { base: 'none', md: 'block' }, })} > Vision Training </span> {/* Model selector */} <div data-element="model-selector-container" className={css({ display: 'flex', alignItems: 'center', gap: 2, ml: { base: 0, md: 'auto' }, })} > <span className={css({ fontSize: 'sm', color: 'gray.400', display: { base: 'none', sm: 'block' }, })} > Model: </span> <select value={modelType} onChange={(e) => handleModelChange(e.target.value as ModelType)} data-action="select-model" className={css({ px: 3, py: 2, bg: 'gray.800', color: 'gray.100', border: '1px solid', borderColor: 'gray.700', borderRadius: 'lg', fontSize: 'sm', fontWeight: 'medium', cursor: 'pointer', _hover: { borderColor: 'gray.600' }, _focus: { outline: 'none', borderColor: 'blue.500' }, })} > {allModelTypes.map((type) => ( <option key={type} value={type}> {getModelEntry(type).label} </option> ))} </select> </div> {/* Tab links */} <div data-element="tab-links" className={css({ display: 'flex', ml: { base: 'auto', md: 0 }, gap: 0, })} > {TABS.map((tab) => { const isActive = activeTab === tab.id return ( <Link key={tab.id} href={getTabPath(tab.id)} data-action={`tab-${tab.id}`} data-active={isActive ? 'true' : 'false'} className={css({ display: 'flex', alignItems: 'center', gap: 2, px: 3, py: 2, color: isActive ? 'blue.400' : 'gray.400', textDecoration: 'none', fontWeight: 'medium', fontSize: 'sm', borderBottom: '2px solid', borderColor: isActive ? 'blue.500' : 'transparent', _hover: { color: isActive ? 'blue.400' : 'gray.200' }, })} > <span className={css({ display: { base: 'none', sm: 'block' } })}>{tab.icon}</span> <span>{tab.label}</span> </Link> ) })} </div> </nav> ) } |