Skip to content

Commit 95f0f4e

Browse files
committed
fix positioning
1 parent d748a82 commit 95f0f4e

File tree

1 file changed

+56
-60
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block

1 file changed

+56
-60
lines changed

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

Lines changed: 56 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { type JSX, type MouseEvent, memo, useRef, useState } from 'react'
22
import { AlertTriangle, ArrowLeftRight, Wand2 } from 'lucide-react'
33
import { Label, Tooltip } from '@/components/emcn/components'
4-
import { Button } from '@/components/ui/button'
54
import { cn } from '@/lib/core/utils/cn'
65
import type { FieldDiffStatus } from '@/lib/workflows/diff/types'
76
import {
@@ -216,69 +215,33 @@ const renderLabel = (
216215
const required = isFieldRequired(config, subBlockValues)
217216
const showCanonicalToggle = !!canonicalToggle && !isPreview
218217
const canonicalToggleDisabled = disabled || canonicalToggle?.disabled
218+
const showWand = isWandEnabled && !isPreview && !disabled
219219

220220
return (
221-
<Label className='flex items-center justify-between gap-[6px] pl-[2px]'>
222-
<div className='flex items-center gap-[6px] whitespace-nowrap'>
223-
{config.title}
224-
{required && <span className='ml-0.5'>*</span>}
225-
{showCanonicalToggle && (
226-
<Tooltip.Root>
227-
<Tooltip.Trigger asChild>
228-
<Button
229-
variant='ghost'
230-
className='h-[12px] w-[12px] flex-shrink-0 p-0 hover:bg-transparent'
231-
onClick={canonicalToggle?.onToggle}
232-
disabled={canonicalToggleDisabled}
233-
aria-label={
234-
canonicalToggle?.mode === 'advanced' ? 'Use selector' : 'Enter manual ID'
235-
}
236-
>
237-
<ArrowLeftRight
221+
<Label asChild className='flex items-center justify-between gap-[6px] pl-[2px]'>
222+
<div>
223+
<div className='flex items-center gap-[6px] whitespace-nowrap'>
224+
{config.title}
225+
{required && <span className='ml-0.5'>*</span>}
226+
{config.type === 'code' && config.language === 'json' && (
227+
<Tooltip.Root>
228+
<Tooltip.Trigger asChild>
229+
<AlertTriangle
238230
className={cn(
239-
'!h-[12px] !w-[12px]',
240-
canonicalToggle?.mode === 'advanced'
241-
? 'text-[var(--text-primary)]'
242-
: 'text-[var(--text-secondary)]'
231+
'h-4 w-4 cursor-pointer text-destructive',
232+
!isValidJson ? 'opacity-100' : 'opacity-0'
243233
)}
244234
/>
245-
</Button>
246-
</Tooltip.Trigger>
247-
<Tooltip.Content side='top'>
248-
<p>{canonicalToggle?.mode === 'advanced' ? 'Use selector' : 'Enter manual ID'}</p>
249-
</Tooltip.Content>
250-
</Tooltip.Root>
251-
)}
252-
{config.type === 'code' && config.language === 'json' && (
253-
<Tooltip.Root>
254-
<Tooltip.Trigger asChild>
255-
<AlertTriangle
256-
className={cn(
257-
'h-4 w-4 cursor-pointer text-destructive',
258-
!isValidJson ? 'opacity-100' : 'opacity-0'
259-
)}
260-
/>
261-
</Tooltip.Trigger>
262-
<Tooltip.Content side='top'>
263-
<p>Invalid JSON</p>
264-
</Tooltip.Content>
265-
</Tooltip.Root>
266-
)}
267-
</div>
235+
</Tooltip.Trigger>
236+
<Tooltip.Content side='top'>
237+
<p>Invalid JSON</p>
238+
</Tooltip.Content>
239+
</Tooltip.Root>
240+
)}
241+
</div>
268242

269-
{/* Wand inline prompt */}
270-
{isWandEnabled && !isPreview && !disabled && (
271-
<div className='flex min-w-0 flex-1 items-center justify-end pr-[4px]'>
272-
{!isSearchActive ? (
273-
<Button
274-
variant='ghost'
275-
className='h-[12px] w-[12px] flex-shrink-0 p-0 hover:bg-transparent'
276-
aria-label='Generate with AI'
277-
onClick={onSearchClick}
278-
>
279-
<Wand2 className='!h-[12px] !w-[12px] bg-transparent text-[var(--text-secondary)]' />
280-
</Button>
281-
) : (
243+
<div className='flex min-w-0 flex-1 items-center justify-end gap-[6px] pr-[4px]'>
244+
{isSearchActive && showWand ? (
282245
<input
283246
ref={searchInputRef}
284247
type='text'
@@ -294,14 +257,47 @@ const renderLabel = (
294257
}}
295258
disabled={isStreaming}
296259
className={cn(
297-
'h-[12px] w-full min-w-[100px] border-none bg-transparent py-0 pr-[2px] text-right font-medium text-[12px] text-[var(--text-primary)] leading-[14px] placeholder:text-[var(--text-muted)] focus:outline-none',
260+
'h-[12px] w-full min-w-[100px] border-none bg-transparent py-0 text-right font-medium text-[12px] text-[var(--text-primary)] leading-[14px] placeholder:text-[var(--text-muted)] focus:outline-none',
298261
isStreaming && 'text-muted-foreground'
299262
)}
300263
placeholder='Describe...'
301264
/>
265+
) : (
266+
<>
267+
{showWand && (
268+
<button
269+
type='button'
270+
className='flex h-[12px] w-[12px] flex-shrink-0 items-center justify-center bg-transparent p-0'
271+
aria-label='Generate with AI'
272+
onClick={onSearchClick}
273+
>
274+
<Wand2 className='!h-[12px] !w-[12px] text-[var(--text-secondary)]' />
275+
</button>
276+
)}
277+
{showCanonicalToggle && (
278+
<button
279+
type='button'
280+
className='flex h-[12px] w-[12px] flex-shrink-0 items-center justify-center bg-transparent p-0 disabled:opacity-50'
281+
onClick={canonicalToggle?.onToggle}
282+
disabled={canonicalToggleDisabled}
283+
aria-label={
284+
canonicalToggle?.mode === 'advanced' ? 'Use selector' : 'Enter manual ID'
285+
}
286+
>
287+
<ArrowLeftRight
288+
className={cn(
289+
'!h-[12px] !w-[12px]',
290+
canonicalToggle?.mode === 'advanced'
291+
? 'text-[var(--text-primary)]'
292+
: 'text-[var(--text-secondary)]'
293+
)}
294+
/>
295+
</button>
296+
)}
297+
</>
302298
)}
303299
</div>
304-
)}
300+
</div>
305301
</Label>
306302
)
307303
}

0 commit comments

Comments
 (0)