perf(model-pricing): move pricing tabs into page title

- place the model pricing tab switcher beside the page title instead of spanning the content area.
- keep the switcher width tied to its labels while preserving spacing around title status content.
This commit is contained in:
QuentinHsu
2026-06-06 15:26:53 +08:00
parent 0f043ae404
commit 4dd68bad52
2 changed files with 27 additions and 16 deletions
@@ -70,7 +70,7 @@ function SettingsPageFrame(props: SettingsPageFrameProps) {
<span className='truncate'>{props.title}</span> <span className='truncate'>{props.title}</span>
<span <span
ref={setTitleStatusContainer} ref={setTitleStatusContainer}
className='inline-flex shrink-0' className='inline-flex min-w-0 shrink-0 items-center'
/> />
</span> </span>
</SectionPageLayout.Title> </SectionPageLayout.Title>
@@ -26,6 +26,7 @@ import { toast } from 'sonner'
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs' import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
import { ConfirmDialog } from '@/components/confirm-dialog' import { ConfirmDialog } from '@/components/confirm-dialog'
import { resetModelRatios } from '../api' import { resetModelRatios } from '../api'
import { SettingsPageTitleStatusPortal } from '../components/settings-page-context'
import { SettingsSection } from '../components/settings-section' import { SettingsSection } from '../components/settings-section'
import { useUpdateOption } from '../hooks/use-update-option' import { useUpdateOption } from '../hooks/use-update-option'
import { GroupRatioForm } from './group-ratio-form' import { GroupRatioForm } from './group-ratio-form'
@@ -439,25 +440,35 @@ export function RatioSettingsCard({
) )
} }
return ( const renderTabSwitcher = () => (
<SettingsSection title={t(titleKey)}> <TabsList className={`grid w-fit max-w-full ${tabsGridClass}`}>
{visibleTabs.length === 1 ? (
renderTabContent(defaultTab)
) : (
<Tabs defaultValue={defaultTab} className='space-y-6'>
<TabsList className={`grid w-full ${tabsGridClass}`}>
{visibleTabs.map((tab) => ( {visibleTabs.map((tab) => (
<TabsTrigger key={tab} value={tab}> <TabsTrigger key={tab} value={tab}>
{t(tabLabels[tab])} {t(tabLabels[tab])}
</TabsTrigger> </TabsTrigger>
))} ))}
</TabsList> </TabsList>
)
return (
<>
{visibleTabs.length === 1 ? (
<SettingsSection title={t(titleKey)}>
{renderTabContent(defaultTab)}
</SettingsSection>
) : (
<Tabs defaultValue={defaultTab} className='space-y-6'>
<SettingsPageTitleStatusPortal>
{renderTabSwitcher()}
</SettingsPageTitleStatusPortal>
<SettingsSection title={t(titleKey)}>
{visibleTabs.map((tab) => ( {visibleTabs.map((tab) => (
<TabsContent key={tab} value={tab}> <TabsContent key={tab} value={tab}>
{renderTabContent(tab)} {renderTabContent(tab)}
</TabsContent> </TabsContent>
))} ))}
</SettingsSection>
</Tabs> </Tabs>
)} )}
@@ -473,6 +484,6 @@ export function RatioSettingsCard({
handleConfirm={handleConfirmReset} handleConfirm={handleConfirmReset}
confirmText={t('Reset')} confirmText={t('Reset')}
/> />
</SettingsSection> </>
) )
} }