Skip to content

Commit b8d1880

Browse files
committed
improvement(emcn): consistent hugging tab bars via ChipModalTabs
- Pin ChipModalTabs to w-fit so the segmented pill always hugs its tabs instead of stretching full-width when dropped into a flex column - Migrate the mothership settings tab bar off a hand-rolled full-width underline bar onto ChipModalTabs - Fix undefined --border-secondary token (fell back to currentColor) in mothership -> --border, matching the admin settings precedent
1 parent da56246 commit b8d1880

2 files changed

Lines changed: 20 additions & 31 deletions

File tree

apps/sim/app/workspace/[workspaceId]/settings/components/mothership/mothership.tsx

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import { useCallback, useMemo, useState } from 'react'
4-
import { Badge, Button, ChipInput, ChipSelect, cn, Label, Skeleton } from '@sim/emcn'
4+
import { Badge, Button, ChipInput, ChipModalTabs, ChipSelect, Label, Skeleton } from '@sim/emcn'
55
import { formatDateTime } from '@sim/utils/formatting'
66
import { useQueryStates } from 'nuqs'
77
import { AnthropicIcon, OpenAIIcon } from '@/components/icons'
@@ -115,26 +115,11 @@ export function Mothership() {
115115
/>
116116
</div>
117117

118-
<div className='flex gap-1 border-[var(--border-secondary)] border-b pb-px'>
119-
{TABS.map((tab) => (
120-
<button
121-
key={tab.id}
122-
type='button'
123-
onClick={() => setMothershipParams({ tab: tab.id })}
124-
className={cn(
125-
'relative px-3 py-2 font-medium text-sm transition-colors',
126-
activeTab === tab.id
127-
? 'text-[var(--text-primary)]'
128-
: 'text-[var(--text-tertiary)] hover-hover:hover:text-[var(--text-secondary)]'
129-
)}
130-
>
131-
{tab.label}
132-
{activeTab === tab.id && (
133-
<span className='absolute right-0 bottom-0 left-0 h-[2px] bg-[var(--text-primary)]' />
134-
)}
135-
</button>
136-
))}
137-
</div>
118+
<ChipModalTabs
119+
tabs={TABS.map((tab) => ({ value: tab.id, label: tab.label }))}
120+
value={activeTab}
121+
onChange={(value) => setMothershipParams({ tab: value as MothershipTab })}
122+
/>
138123

139124
<div className='flex items-center gap-3'>
140125
<div className='flex items-center gap-2'>
@@ -281,7 +266,7 @@ function OverviewTab({
281266
)}
282267
{breakdown?.users && (
283268
<div className='flex flex-col gap-0.5'>
284-
<div className='flex items-center gap-3 border-[var(--border-secondary)] border-b px-3 py-2 text-[var(--text-tertiary)] text-caption'>
269+
<div className='flex items-center gap-3 border-[var(--border)] border-b px-3 py-2 text-[var(--text-tertiary)] text-caption'>
285270
<span className='flex-1'>User ID</span>
286271
<span className='w-[100px] text-right'>Requests</span>
287272
<span className='w-[100px] text-right'>Cost</span>
@@ -296,7 +281,7 @@ function OverviewTab({
296281
}) => (
297282
<div
298283
key={u.user_id}
299-
className='flex items-center gap-3 border-[var(--border-secondary)] border-b px-3 py-2 text-small last:border-b-0'
284+
className='flex items-center gap-3 border-[var(--border)] border-b px-3 py-2 text-small last:border-b-0'
300285
>
301286
<span className='flex-1 truncate font-mono text-[var(--text-primary)] text-caption'>
302287
{u.user_id}
@@ -328,7 +313,7 @@ function OverviewTab({
328313
{requests?.requests && (
329314
<div className='max-h-[400px] overflow-auto'>
330315
<div className='flex flex-col gap-0.5'>
331-
<div className='sticky top-0 z-10 flex items-center gap-3 border-[var(--border-secondary)] border-b bg-[var(--surface-1)] px-3 py-2 text-[var(--text-tertiary)] text-caption'>
316+
<div className='sticky top-0 z-10 flex items-center gap-3 border-[var(--border)] border-b bg-[var(--surface-1)] px-3 py-2 text-[var(--text-tertiary)] text-caption'>
332317
<span className='w-[180px]'>Request ID</span>
333318
<span className='w-[80px]'>Model</span>
334319
<span className='w-[80px] text-right'>Duration</span>
@@ -352,9 +337,9 @@ function OverviewTab({
352337
}) => (
353338
<div
354339
key={r.request_id}
355-
className='flex items-center gap-3 border-[var(--border-secondary)] border-b px-3 py-1.5 text-small last:border-b-0'
340+
className='flex items-center gap-3 border-[var(--border)] border-b px-3 py-1.5 text-small last:border-b-0'
356341
>
357-
<span className='w-[180px] truncate font-mono text-[var(--text-primary)] text-xs'>
342+
<span className='w-[180px] truncate font-mono text-[var(--text-primary)] text-caption'>
358343
{r.request_id ?? '—'}
359344
</span>
360345
<span className='w-[80px] truncate text-[var(--text-secondary)] text-caption'>
@@ -452,7 +437,7 @@ function LicensesTab({ environment }: { environment: MothershipEnv }) {
452437
</div>
453438

454439
{generatedKey && (
455-
<div className='rounded-md border border-[var(--border-secondary)] bg-[var(--surface-hover)] p-3'>
440+
<div className='rounded-md border border-[var(--border)] bg-[var(--surface-hover)] p-3'>
456441
<p className='mb-1 text-[var(--text-secondary)] text-caption'>
457442
License key (only shown once):
458443
</p>
@@ -479,7 +464,7 @@ function LicensesTab({ environment }: { environment: MothershipEnv }) {
479464

480465
{data?.licenses && (
481466
<div className='flex flex-col gap-0.5'>
482-
<div className='flex items-center gap-3 border-[var(--border-secondary)] border-b px-3 py-2 text-[var(--text-tertiary)] text-caption'>
467+
<div className='flex items-center gap-3 border-[var(--border)] border-b px-3 py-2 text-[var(--text-tertiary)] text-caption'>
483468
<span className='flex-1'>Name</span>
484469
<span className='w-[100px] text-right'>Validations</span>
485470
<span className='w-[140px] text-right'>Expiration</span>
@@ -498,7 +483,7 @@ function LicensesTab({ environment }: { environment: MothershipEnv }) {
498483
}) => (
499484
<div
500485
key={lic.id}
501-
className='flex items-center gap-3 border-[var(--border-secondary)] border-b px-3 py-2 text-small last:border-b-0'
486+
className='flex items-center gap-3 border-[var(--border)] border-b px-3 py-2 text-small last:border-b-0'
502487
>
503488
<span className='flex-1 text-[var(--text-primary)]'>{lic.name}</span>
504489
<span className='w-[100px] text-right text-[var(--text-secondary)]'>
@@ -529,7 +514,7 @@ function StatCard({
529514
loading?: boolean
530515
}) {
531516
return (
532-
<div className='rounded-md border border-[var(--border-secondary)] p-3'>
517+
<div className='rounded-md border border-[var(--border)] p-3'>
533518
<p className='text-[var(--text-tertiary)] text-caption'>{label}</p>
534519
{loading ? (
535520
<Skeleton className='mt-1 h-[24px] w-[80px] rounded-sm' />

packages/emcn/src/components/chip-modal/chip-modal.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ export interface ChipModalTabsProps {
237237
* Reusing `ChipSwitch` keeps every tabbed modal visually identical to the
238238
* segmented toggles elsewhere in the app (e.g. the billing-period switch).
239239
*
240+
* Pinned to `w-fit` so the pill always hugs its tabs: dropped directly into a
241+
* flex column the `inline-flex` trough is otherwise blockified and stretched
242+
* full-width by `align-items: stretch`. A caller-supplied width class still wins.
243+
*
240244
* @example
241245
* ```tsx
242246
* <ChipModalBody>
@@ -262,7 +266,7 @@ function ChipModalTabs({
262266
onChange={onChange}
263267
aria-label={ariaLabel}
264268
options={tabs.map((tab) => ({ value: tab.value, label: tab.label, icon: tab.icon }))}
265-
className={className}
269+
className={cn('w-fit', className)}
266270
/>
267271
)
268272
}

0 commit comments

Comments
 (0)