Skip to content

Commit 287679c

Browse files
committed
refactor(components): simplify CodeBlock usage in workflow-value-renderer and improve styling
1 parent 6e678fb commit 287679c

2 files changed

Lines changed: 14 additions & 15 deletions

File tree

apps/web/src/components/docs/code-block.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ export function CodeBlock({ children, className, language }: CodeBlockProps) {
9292
<Button
9393
size="icon"
9494
variant="ghost"
95-
className="absolute right-2 top-2 opacity-0 group-hover:opacity-100 transition-opacity h-8 w-8 text-zinc-400 hover:text-zinc-100 hover:bg-transparent z-10"
95+
className="absolute right-0 top-0 h-8 w-8 text-zinc-400 z-10"
9696
onClick={handleCopy}
9797
>
9898
{copied ? <Check className="h-4 w-4" /> : <Copy className="h-4 w-4" />}
9999
</Button>
100100
<div
101101
className={cn(
102-
"mb-4 mt-2 overflow-x-auto rounded-md text-sm [&_pre]:m-0 [&_pre]:p-4 [&_pre]:!bg-secondary [&_pre]:dark:!bg-neutral-900 [&_code]:whitespace-pre-wrap",
102+
"overflow-y-auto overflow-x-auto nowheel mb-4 mt-2 text-sm [&_pre]:m-0 [&_pre]:p-4 [&_pre]:!bg-secondary [&_pre]:dark:!bg-neutral-900 [&_code]:whitespace-pre",
103103
className
104104
)}
105105
dangerouslySetInnerHTML={{ __html: highlightedCode }}

apps/web/src/components/workflow/workflow-value-renderer.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,13 @@ const GeoJSONRenderer = ({
221221
width={compact ? 300 : 400}
222222
height={compact ? 200 : 300}
223223
/>
224-
225-
<div
226-
className={`${compact ? "max-h-[300px] overflow-y-auto nowheel" : ""}`}
227-
>
228-
<CodeBlock
229-
language="json"
230-
className="text-xs my-0 border [&_pre]:p-2"
231-
>
232-
{formattedValue}
233-
</CodeBlock>
234-
</div>
224+
<CodeRenderer
225+
value={formattedValue}
226+
type="json"
227+
compact={compact}
228+
readonly={readonly}
229+
onChange={onChange}
230+
/>
235231
</div>
236232
);
237233
}
@@ -312,11 +308,14 @@ const CodeRenderer = ({
312308
if (readonly) {
313309
return (
314310
<div
315-
className={`${compact ? "mt-1 max-h-[300px] overflow-y-auto nowheel" : "mt-2"}`}
311+
className={
312+
"border rounded-md bg-muted overflow-auto " +
313+
`${compact ? "mt-1 h-32" : "mt-2"}`
314+
}
316315
>
317316
<CodeBlock
318317
language={getLanguage(type)}
319-
className="text-xs my-0 border [&_pre]:p-2"
318+
className="text-xs my-0 [&_pre]:p-2"
320319
>
321320
{value}
322321
</CodeBlock>

0 commit comments

Comments
 (0)