|
1 | 1 | 'use client' |
2 | 2 |
|
3 | | -import type React from 'react' |
4 | 3 | import { useMemo } from 'react' |
5 | 4 | import { ChipCombobox, Combobox, type ComboboxOptionGroup, cn } from '@sim/emcn' |
6 | | -import { Repeat, Split } from '@sim/emcn/icons' |
7 | 5 | import { useShallow } from 'zustand/react/shallow' |
8 | 6 | import { |
9 | 7 | type FlattenOutputsBlockInput, |
10 | 8 | flattenWorkflowOutputs, |
11 | 9 | } from '@/lib/workflows/blocks/flatten-outputs' |
12 | | -import { getBlock } from '@/blocks' |
13 | | -import { getTileIconColorClass } from '@/blocks/icon-color' |
| 10 | +import { BlockTile } from '@/blocks/block-tile' |
14 | 11 | import { normalizeName } from '@/executor/constants' |
15 | 12 | import { useWorkflowDiffStore } from '@/stores/workflow-diff/store' |
16 | 13 | import { useSubBlockStore } from '@/stores/workflows/subblock/store' |
17 | 14 | import { useWorkflowStore } from '@/stores/workflows/workflow/store' |
18 | 15 |
|
19 | | -/** |
20 | | - * Renders a tag icon with background color for block section headers. |
21 | | - * |
22 | | - * @param icon - Either a letter string or a Lucide icon component |
23 | | - * @param color - Background color for the icon container |
24 | | - * @returns A styled icon element |
25 | | - */ |
26 | | -const TagIcon: React.FC<{ |
27 | | - icon: string | React.ComponentType<{ className?: string }> |
28 | | - color: string |
29 | | -}> = ({ icon, color }) => ( |
30 | | - <div |
31 | | - className='flex size-[14px] flex-shrink-0 items-center justify-center overflow-hidden rounded [&_img]:size-full' |
32 | | - style={{ background: color }} |
33 | | - > |
34 | | - {typeof icon === 'string' ? ( |
35 | | - <span className={cn(getTileIconColorClass(color, true), 'font-bold text-micro')}>{icon}</span> |
36 | | - ) : ( |
37 | | - (() => { |
38 | | - const IconComponent = icon |
39 | | - return <IconComponent className={cn(getTileIconColorClass(color, true), 'size-[9px]')} /> |
40 | | - })() |
41 | | - )} |
42 | | - </div> |
43 | | -) |
44 | | - |
45 | 16 | const EMPTY_OUTPUTS: string[] = [] |
46 | 17 |
|
47 | 18 | /** |
@@ -200,16 +171,6 @@ export function OutputSelect({ |
200 | 171 | return `${validOutputs.length} outputs` |
201 | 172 | }, [selectedOutputs, workflowOutputs, placeholder]) |
202 | 173 |
|
203 | | - /** |
204 | | - * Gets the background color for a block output based on its type |
205 | | - * @param blockType - The type of the block |
206 | | - * @returns The hex color code for the block |
207 | | - */ |
208 | | - const getOutputColor = (blockType: string) => { |
209 | | - const blockConfig = getBlock(blockType) |
210 | | - return blockConfig?.bgColor || '#2F55FF' |
211 | | - } |
212 | | - |
213 | 174 | /** |
214 | 175 | * Groups outputs by block and sorts by distance from starter block. |
215 | 176 | * Returns ComboboxOptionGroup[] for use with Combobox. |
@@ -261,25 +222,15 @@ export function OutputSelect({ |
261 | 222 |
|
262 | 223 | return sortedGroups.map(({ blockName, outputs }) => { |
263 | 224 | const firstOutput = outputs[0] |
264 | | - const blockConfig = getBlock(firstOutput.blockType) |
265 | | - const blockColor = getOutputColor(firstOutput.blockType) |
266 | | - |
267 | | - let blockIcon: string | React.ComponentType<{ className?: string }> = blockName |
268 | | - .charAt(0) |
269 | | - .toUpperCase() |
270 | | - |
271 | | - if (blockConfig?.icon) { |
272 | | - blockIcon = blockConfig.icon |
273 | | - } else if (firstOutput.blockType === 'loop') { |
274 | | - blockIcon = Repeat |
275 | | - } else if (firstOutput.blockType === 'parallel') { |
276 | | - blockIcon = Split |
277 | | - } |
278 | 225 |
|
279 | 226 | return { |
280 | 227 | sectionElement: ( |
281 | 228 | <div className='flex items-center gap-1.5 px-1.5 py-1'> |
282 | | - <TagIcon icon={blockIcon} color={blockColor} /> |
| 229 | + <BlockTile |
| 230 | + blockType={firstOutput.blockType} |
| 231 | + fallbackLabel={blockName.charAt(0).toUpperCase()} |
| 232 | + size='sm' |
| 233 | + /> |
283 | 234 | <span className='text-small'>{blockName}</span> |
284 | 235 | </div> |
285 | 236 | ), |
|
0 commit comments