Skip to content

Commit af8b8cb

Browse files
committed
fix(ui): align fallback model subblock styling
1 parent 4e72b2b commit af8b8cb

2 files changed

Lines changed: 44 additions & 25 deletions

File tree

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/model-fallback-list/model-fallback-list.test.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ vi.mock('next/navigation', () => ({
3030
}))
3131

3232
vi.mock('@sim/emcn', () => ({
33+
Button: ({ children, ...props }: React.ButtonHTMLAttributes<HTMLButtonElement>) => (
34+
<button {...props}>{children}</button>
35+
),
3336
Chip: ({
3437
children,
3538
disabled,

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/model-fallback-list/model-fallback-list.tsx‎

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

33
import { memo, useCallback, useEffect, useMemo, useRef } from 'react'
4-
import { Chip, ChipCombobox, ChipDropdown, type ComboboxOption, Label, Tooltip } from '@sim/emcn'
4+
import {
5+
Button,
6+
Chip,
7+
ChipCombobox,
8+
ChipDropdown,
9+
type ComboboxOption,
10+
Label,
11+
Tooltip,
12+
} from '@sim/emcn'
513
import { ChevronDown, ChevronUp, Plus, Trash } from '@sim/emcn/icons'
614
import { generateShortId } from '@sim/utils/id'
715
import { useParams } from 'next/navigation'
@@ -123,54 +131,63 @@ const FallbackRow = memo(function FallbackRow({
123131
const apiKeyValue = isWholeEnvVarReference(row.apiKey) ? row.apiKey : ''
124132

125133
return (
126-
<div
127-
data-fallback-row-id={row.id}
128-
className='space-y-3 rounded-lg border border-[var(--border)] p-3'
129-
>
130-
<div className='flex items-center justify-between'>
131-
<span className='text-[var(--text-muted)] text-small'>{ordinalChoiceLabel(index)}</span>
132-
<div className='flex items-center'>
134+
<div data-fallback-row-id={row.id} className='min-w-0 rounded-sm border border-[var(--border)]'>
135+
<div className='flex items-center justify-between gap-2 rounded-t-[4px] bg-[var(--surface-4)] px-2 py-1'>
136+
<span className='text-[var(--text-secondary)] text-small'>{ordinalChoiceLabel(index)}</span>
137+
<div className='flex shrink-0 items-center gap-1'>
133138
{canMove && (
134139
<>
135140
<Tooltip.Root>
136141
<Tooltip.Trigger asChild>
137-
<Chip
138-
leftIcon={ChevronUp}
142+
<Button
143+
type='button'
144+
variant='ghost'
145+
size='icon'
139146
onClick={() => onMove(row.id, -1)}
140147
disabled={readOnly || index === 0}
141148
aria-label='Move up'
142-
/>
149+
>
150+
<ChevronUp className='size-[14px]' />
151+
</Button>
143152
</Tooltip.Trigger>
144153
<Tooltip.Content>Move up</Tooltip.Content>
145154
</Tooltip.Root>
146155
<Tooltip.Root>
147156
<Tooltip.Trigger asChild>
148-
<Chip
149-
leftIcon={ChevronDown}
157+
<Button
158+
type='button'
159+
variant='ghost'
160+
size='icon'
150161
onClick={() => onMove(row.id, 1)}
151162
disabled={readOnly || isLast}
152163
aria-label='Move down'
153-
/>
164+
>
165+
<ChevronDown className='size-[14px]' />
166+
</Button>
154167
</Tooltip.Trigger>
155168
<Tooltip.Content>Move down</Tooltip.Content>
156169
</Tooltip.Root>
157170
</>
158171
)}
159172
<Tooltip.Root>
160173
<Tooltip.Trigger asChild>
161-
<Chip
162-
leftIcon={Trash}
174+
<Button
175+
type='button'
176+
variant='ghost'
177+
size='icon'
163178
onClick={() => onRemove(row.id)}
164179
disabled={readOnly}
165180
aria-label='Remove fallback model'
166-
/>
181+
>
182+
<Trash className='size-[14px]' />
183+
</Button>
167184
</Tooltip.Trigger>
168185
<Tooltip.Content>Remove</Tooltip.Content>
169186
</Tooltip.Root>
170187
</div>
171188
</div>
172189

173-
<div className='flex flex-col gap-3'>
190+
<div className='flex flex-col gap-2.5 rounded-b-[4px] border-[var(--border)] border-t bg-[var(--surface-2)] p-2'>
174191
<ChipCombobox
175192
options={modelOptions}
176193
value={row.model}
@@ -184,8 +201,8 @@ const FallbackRow = memo(function FallbackRow({
184201
emptyMessage='No models available'
185202
/>
186203
{needsApiKey && (
187-
<div className='flex flex-col gap-1.5'>
188-
<Label>API key</Label>
204+
<div className='flex flex-col gap-2.5'>
205+
<Label className='pl-0.5'>API key</Label>
189206
<ChipCombobox
190207
options={envVarOptions}
191208
value={apiKeyValue}
@@ -201,8 +218,8 @@ const FallbackRow = memo(function FallbackRow({
201218
</div>
202219
)}
203220
{tuningFields.map(({ knob, options }) => (
204-
<div key={knob} className='flex flex-col gap-1.5'>
205-
<Label>{FALLBACK_TUNING_LABELS[knob]}</Label>
221+
<div key={knob} className='flex flex-col gap-2.5'>
222+
<Label className='pl-0.5'>{FALLBACK_TUNING_LABELS[knob]}</Label>
206223
<ChipDropdown
207224
options={options}
208225
value={row[knob] ?? options[0]?.value ?? ''}
@@ -387,7 +404,7 @@ export function ModelFallbackList({
387404
)
388405

389406
return (
390-
<div className='space-y-2'>
407+
<div className='flex w-full min-w-0 flex-col gap-2.5'>
391408
{rows.map((row, index) => (
392409
<FallbackRow
393410
key={row.id}
@@ -410,9 +427,8 @@ export function ModelFallbackList({
410427
))}
411428
{!readOnly && (
412429
<Chip
413-
variant='outline'
414430
leftIcon={Plus}
415-
fullWidth
431+
className='self-start'
416432
onClick={handleAdd}
417433
disabled={rows.length >= MAX_FALLBACK_MODELS}
418434
>

0 commit comments

Comments
 (0)