node-variable-item.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { memo } from 'react'
  2. import cn from '@/utils/classnames'
  3. import { VarBlockIcon } from '@/app/components/workflow/block-icon'
  4. import { Line3 } from '@/app/components/base/icons/src/public/common'
  5. import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development'
  6. import { Env } from '@/app/components/base/icons/src/vender/line/others'
  7. import type { Node } from '@/app/components/workflow/types'
  8. import { BlockEnum } from '@/app/components/workflow/types'
  9. type NodeVariableItemProps = {
  10. isEnv: boolean
  11. node: Node
  12. varName: string
  13. showBorder?: boolean
  14. }
  15. const NodeVariableItem = ({
  16. isEnv,
  17. node,
  18. varName,
  19. showBorder,
  20. }: NodeVariableItemProps) => {
  21. return (
  22. <div className={cn(
  23. 'relative flex items-center mt-0.5 h-6 bg-gray-100 rounded-md px-1 text-xs font-normal text-gray-700',
  24. showBorder && '!bg-black/[0.02]',
  25. )}>
  26. {!isEnv && (
  27. <div className='flex items-center'>
  28. <div className='p-[1px]'>
  29. <VarBlockIcon
  30. className='!text-gray-900'
  31. type={node?.data.type || BlockEnum.Start}
  32. />
  33. </div>
  34. <div className='max-w-[85px] truncate mx-0.5 text-xs font-medium text-gray-700' title={node?.data.title}>{node?.data.title}</div>
  35. <Line3 className='mr-0.5'></Line3>
  36. </div>
  37. )}
  38. <div className='flex items-center text-primary-600'>
  39. {!isEnv && <Variable02 className='shrink-0 w-3.5 h-3.5 text-primary-500' />}
  40. {isEnv && <Env className='shrink-0 w-3.5 h-3.5 text-util-colors-violet-violet-600' />}
  41. <div className={cn('max-w-[75px] truncate ml-0.5 text-xs font-medium', isEnv && 'text-gray-900')} title={varName}>{varName}</div>
  42. </div>
  43. </div>
  44. )
  45. }
  46. export default memo(NodeVariableItem)