okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
0fdfa40b4
main
1import { useRef , useState } from 'react' ; 2import { tr } from '../lib/i18n' ; 3import type { CatalogModel } from '../lib/native-catalog' ; 4import { FloatingMenu } from './FloatingMenu' ; 5import { Icon } from './ui' ; 6 7/** 8* The model family in the Models navbar: its icon, its name and a chevron. Opening it lists the families of the catalog (Qwen3.8-Flash-Next, 9* Qwen3.6-35B-A3B, and future ones) to switch between. One family still shows as the same control, so the page looks the same as families arrive. 10*/ 11export function FamilySwitch ({ families, selected, onPick} :{ families :CatalogModel []; selected ?:string ; onPick :( family :CatalogModel ) => void }) { 12const shown = families . filter ( f => f . sizes . length ); 13const missing = families . filter ( f => ! f . sizes . length && f . available === false ); // a model of the update feed this engine does not run: said, never offered 14const trigger = useRef < HTMLButtonElement >( null ); 15const [ open , setOpen ] = useState ( false ); 16if ( ! shown . length ) return null ; 17const current = shown . find ( f => f . family === selected ) ?? shown [ 0 ]; 18return <> 19< button ref = { trigger } type = "button" className = "family-trigger" aria-haspopup = "menu" aria-expanded = { open } aria-label = { tr ( "Model family" )} onClick = {() => setOpen ( v => ! v )}> 20< Icon name = "models" size = { 20 }/>< strong >{ tr ( current . title )}</ strong >< Icon name = "chevron" size = { 16 } className = "family-trigger__chev" /> 21</ button > 22{ tr ( open ?< FloatingMenu anchor = { trigger . current } title = { tr ( "Model family" )} width = { 320 } onClose = {() => setOpen ( false )}> 23< FamilyMenuList shown = { shown } missing = { missing } current = { current } onPick = { f => { setOpen ( false ); if ( f . family !== current . family ) onPick ( f ); }}/> 24</ FloatingMenu > :null )} 25</>; 26} 27 28/** The rows of the family menu: the families to pick, then (as notes, not choices) the models of the update feed this engine cannot use, each with the plain reason. */ 29export function FamilyMenuList ({ shown, missing, current, onPick} :{ shown :CatalogModel []; missing :CatalogModel []; current :CatalogModel ; onPick :( family :CatalogModel ) => void }) { 30return ( 31< div className = "family-menu" > 32{ shown . map ( f => < button key = { f . family } type = "button" role = "menuitemradio" aria-checked = { f . family === current . family } className = "family-menu__item" onClick = {() => onPick ( f )}> 33< Icon name = "models" size = { 18 }/>< span >< strong >{ tr ( f . title )}</ strong >{ f . experimental ?< small >{ tr ( "Experimental" )}</ small > :null }{ f . available === false && f . unavailable_reason ?< small >{ f . unavailable_reason }</ small > :null }</ span > 34{ f . family === current . family ?< Icon name = "check" size = { 16 } className = "family-menu__check" /> :null } 35</ button >)} 36{ missing . map ( f => < div key = { f . family } className = "family-menu__item" role = "note" aria-disabled = "true" >< Icon name = "models" size = { 18 }/>< span >< strong >{ f . title }</ strong >< small >{ f . unavailable_reason }</ small ></ span ></ div >)} 37</ div > 38); 39}