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 | 'use client' import Link from 'next/link' import { usePathname, useRouter } from 'next/navigation' import { useCallback } from 'react' import { css } from '../../../../styled-system/css' import { getValidModelTypes, useModelType } from '../hooks/useModelType' import { getModelEntry, TABS, type TabId } from '../registry' import type { ModelType } from '../train/components/wizard/types' /** * Vision Training Nav Slot * * Content for the minimal nav's center slot when on vision training pages. * Contains: * - Model selector dropdown * - Tab links (Data, Train, Test, Sessions) * * Used with PageWithNav's navSlot prop. */ export function VisionTrainingNavSlot() { const router = useRouter() const pathname = usePathname() const modelType = useModelType() const allModelTypes = getValidModelTypes() // 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 ( <div data-component="vision-training-nav-slot" className={css({ display: 'flex', alignItems: 'center', gap: 3, })} > {/* Title - hidden on small screens */} <span className={css({ fontSize: 'sm', fontWeight: 'semibold', color: 'rgba(196, 181, 253, 0.8)', display: { base: 'none', md: 'block' }, whiteSpace: 'nowrap', })} > Vision Training </span> {/* Model selector - dark accent dropdown */} <select value={modelType} onChange={(e) => handleModelChange(e.target.value as ModelType)} data-action="select-model" className={css({ px: 3, py: 1.5, bg: 'rgba(139, 92, 246, 0.25)', color: 'rgba(255, 255, 255, 0.95)', border: '1px solid', borderColor: 'rgba(139, 92, 246, 0.4)', borderRadius: 'lg', fontSize: 'sm', fontWeight: 'semibold', cursor: 'pointer', _hover: { bg: 'rgba(139, 92, 246, 0.35)' }, _focus: { outline: 'none', ring: '2px', ringColor: 'rgba(139, 92, 246, 0.6)', ringOffset: '2px', }, })} > {allModelTypes.map((type) => ( <option key={type} value={type}> {getModelEntry(type).label} </option> ))} </select> {/* Separator */} <span className={css({ color: 'rgba(139, 92, 246, 0.4)', display: { base: 'none', sm: 'block' }, })} > | </span> {/* Tab links */} <div data-element="tab-links" className={css({ display: 'flex', 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: 1.5, px: 2.5, py: 1.5, color: isActive ? 'rgba(196, 181, 253, 1)' : 'rgba(209, 213, 219, 0.9)', textDecoration: 'none', fontWeight: isActive ? 'semibold' : 'medium', fontSize: 'sm', borderBottom: '2px solid', borderColor: isActive ? 'rgba(139, 92, 246, 0.8)' : 'transparent', transition: 'all 0.15s ease', _hover: { color: 'rgba(196, 181, 253, 1)', bg: isActive ? 'transparent' : 'rgba(139, 92, 246, 0.15)', borderRadius: isActive ? '0' : 'md', }, })} > <span className={css({ display: { base: 'none', sm: 'block' } })}>{tab.icon}</span> <span>{tab.label}</span> </Link> ) })} </div> </div> ) } |