mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 04:26:30 +08:00
block-icon
This commit is contained in:
parent
13174aac18
commit
45ef4059f0
@ -14,11 +14,13 @@ import {
|
|||||||
TemplatingTransform,
|
TemplatingTransform,
|
||||||
VariableX,
|
VariableX,
|
||||||
} from '@/app/components/base/icons/src/vender/workflow'
|
} from '@/app/components/base/icons/src/vender/workflow'
|
||||||
|
import AppIcon from '@/app/components/base/app-icon'
|
||||||
|
|
||||||
type BlockIconProps = {
|
type BlockIconProps = {
|
||||||
type: BlockEnum
|
type: BlockEnum
|
||||||
size?: string
|
size?: string
|
||||||
className?: string
|
className?: string
|
||||||
|
icon?: any
|
||||||
}
|
}
|
||||||
const ICON_CONTAINER_CLASSNAME_SIZE_MAP: Record<string, string> = {
|
const ICON_CONTAINER_CLASSNAME_SIZE_MAP: Record<string, string> = {
|
||||||
sm: 'w-5 h-5 rounded-md shadow-xs',
|
sm: 'w-5 h-5 rounded-md shadow-xs',
|
||||||
@ -57,6 +59,7 @@ const BlockIcon: FC<BlockIconProps> = ({
|
|||||||
type,
|
type,
|
||||||
size = 'sm',
|
size = 'sm',
|
||||||
className,
|
className,
|
||||||
|
icon,
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<div className={`
|
<div className={`
|
||||||
@ -66,7 +69,36 @@ const BlockIcon: FC<BlockIconProps> = ({
|
|||||||
${className}
|
${className}
|
||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
{getIcon(type, 'w-3.5 h-3.5')}
|
{
|
||||||
|
type !== BlockEnum.Tool && (
|
||||||
|
getIcon(type, 'w-3.5 h-3.5')
|
||||||
|
)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
type === BlockEnum.Tool && icon && (
|
||||||
|
<>
|
||||||
|
{
|
||||||
|
typeof icon === 'string'
|
||||||
|
? (
|
||||||
|
<div
|
||||||
|
className='shrink-0 w-full h-full bg-cover bg-center rounded-md'
|
||||||
|
style={{
|
||||||
|
backgroundImage: `url(${icon})`,
|
||||||
|
}}
|
||||||
|
></div>
|
||||||
|
)
|
||||||
|
: (
|
||||||
|
<AppIcon
|
||||||
|
className='shrink-0 !w-full !h-full'
|
||||||
|
size='tiny'
|
||||||
|
icon={icon?.content}
|
||||||
|
background={icon?.background}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -107,6 +107,7 @@ const Item = ({
|
|||||||
tool_name: tool.name,
|
tool_name: tool.name,
|
||||||
_icon: data.icon,
|
_icon: data.icon,
|
||||||
title: tool.label[language],
|
title: tool.label[language],
|
||||||
|
desc: tool.description[language],
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<div className='absolute left-[22px] w-[1px] h-8 bg-black/5' />
|
<div className='absolute left-[22px] w-[1px] h-8 bg-black/5' />
|
||||||
|
|||||||
@ -30,5 +30,6 @@ export type ToolDefaultValue = {
|
|||||||
provider_type: string
|
provider_type: string
|
||||||
tool_name: string
|
tool_name: string
|
||||||
title: string
|
title: string
|
||||||
|
desc: string
|
||||||
_icon: Collection['icon']
|
_icon: Collection['icon']
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,10 @@ const NextStep = ({
|
|||||||
return (
|
return (
|
||||||
<div className='flex py-1'>
|
<div className='flex py-1'>
|
||||||
<div className='shrink-0 relative flex items-center justify-center w-9 h-9 bg-white rounded-lg border-[0.5px] border-gray-200 shadow-xs'>
|
<div className='shrink-0 relative flex items-center justify-center w-9 h-9 bg-white rounded-lg border-[0.5px] border-gray-200 shadow-xs'>
|
||||||
<BlockIcon type={selectedNode!.data.type} />
|
<BlockIcon
|
||||||
|
type={selectedNode!.data.type}
|
||||||
|
icon={selectedNode!.data._icon}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Line linesNumber={branches ? branches.length : 1} />
|
<Line linesNumber={branches ? branches.length : 1} />
|
||||||
<div className='grow'>
|
<div className='grow'>
|
||||||
|
|||||||
@ -53,6 +53,7 @@ const Item = ({
|
|||||||
}
|
}
|
||||||
<BlockIcon
|
<BlockIcon
|
||||||
type={data.type}
|
type={data.type}
|
||||||
|
icon={data._icon}
|
||||||
className='shrink-0 mr-1.5'
|
className='shrink-0 mr-1.5'
|
||||||
/>
|
/>
|
||||||
<div className='grow'>{data.title}</div>
|
<div className='grow'>{data.title}</div>
|
||||||
|
|||||||
@ -7,9 +7,7 @@ import {
|
|||||||
memo,
|
memo,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
import type { NodeProps } from '../../types'
|
import type { NodeProps } from '../../types'
|
||||||
import { BlockEnum } from '@/app/components/workflow/types'
|
|
||||||
import BlockIcon from '@/app/components/workflow/block-icon'
|
import BlockIcon from '@/app/components/workflow/block-icon'
|
||||||
import AppIcon from '@/app/components/base/app-icon'
|
|
||||||
|
|
||||||
type BaseNodeProps = {
|
type BaseNodeProps = {
|
||||||
children: ReactElement
|
children: ReactElement
|
||||||
@ -31,40 +29,12 @@ const BaseNode: FC<BaseNodeProps> = ({
|
|||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
<div className='flex items-center px-3 pt-3 pb-2'>
|
<div className='flex items-center px-3 pt-3 pb-2'>
|
||||||
{
|
<BlockIcon
|
||||||
type !== BlockEnum.Tool && (
|
className='shrink-0 mr-2'
|
||||||
<BlockIcon
|
type={data.type}
|
||||||
className='shrink-0 mr-2'
|
size='md'
|
||||||
type={data.type}
|
icon={data._icon}
|
||||||
size='md'
|
/>
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
{
|
|
||||||
type === BlockEnum.Tool && (
|
|
||||||
<>
|
|
||||||
{
|
|
||||||
typeof data._icon === 'string'
|
|
||||||
? (
|
|
||||||
<div
|
|
||||||
className='shrink-0 mr-2 w-6 h-6 bg-cover bg-center rounded-md'
|
|
||||||
style={{
|
|
||||||
backgroundImage: `url(${data._icon})`,
|
|
||||||
}}
|
|
||||||
></div>
|
|
||||||
)
|
|
||||||
: (
|
|
||||||
<AppIcon
|
|
||||||
className='shrink-0 mr-2'
|
|
||||||
size='tiny'
|
|
||||||
icon={data._icon?.content}
|
|
||||||
background={data._icon?.background}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
<div
|
<div
|
||||||
title={data.title}
|
title={data.title}
|
||||||
className='grow text-[13px] font-semibold text-gray-700 truncate'
|
className='grow text-[13px] font-semibold text-gray-700 truncate'
|
||||||
|
|||||||
@ -24,7 +24,6 @@ import { Play } from '@/app/components/base/icons/src/vender/line/mediaAndDevice
|
|||||||
import TooltipPlus from '@/app/components/base/tooltip-plus'
|
import TooltipPlus from '@/app/components/base/tooltip-plus'
|
||||||
import type { Node } from '@/app/components/workflow/types'
|
import type { Node } from '@/app/components/workflow/types'
|
||||||
import { BlockEnum } from '@/app/components/workflow/types'
|
import { BlockEnum } from '@/app/components/workflow/types'
|
||||||
import AppIcon from '@/app/components/base/app-icon'
|
|
||||||
|
|
||||||
type BasePanelProps = {
|
type BasePanelProps = {
|
||||||
children: ReactElement
|
children: ReactElement
|
||||||
@ -51,40 +50,12 @@ const BasePanel: FC<BasePanelProps> = ({
|
|||||||
<div className='w-[420px] h-full bg-white shadow-lg border-[0.5px] border-gray-200 rounded-2xl overflow-y-auto'>
|
<div className='w-[420px] h-full bg-white shadow-lg border-[0.5px] border-gray-200 rounded-2xl overflow-y-auto'>
|
||||||
<div className='sticky top-0 bg-white border-b-[0.5px] border-black/5 z-10'>
|
<div className='sticky top-0 bg-white border-b-[0.5px] border-black/5 z-10'>
|
||||||
<div className='flex items-center px-4 pt-4 pb-1'>
|
<div className='flex items-center px-4 pt-4 pb-1'>
|
||||||
{
|
<BlockIcon
|
||||||
type !== BlockEnum.Tool && (
|
className='shrink-0 mr-1'
|
||||||
<BlockIcon
|
type={data.type}
|
||||||
className='shrink-0 mr-1'
|
icon={data._icon}
|
||||||
type={data.type}
|
size='md'
|
||||||
size='md'
|
/>
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
{
|
|
||||||
type === BlockEnum.Tool && (
|
|
||||||
<>
|
|
||||||
{
|
|
||||||
typeof data._icon === 'string'
|
|
||||||
? (
|
|
||||||
<div
|
|
||||||
className='shrink-0 mr-2 w-6 h-6 bg-cover bg-center rounded-md'
|
|
||||||
style={{
|
|
||||||
backgroundImage: `url(${data._icon})`,
|
|
||||||
}}
|
|
||||||
></div>
|
|
||||||
)
|
|
||||||
: (
|
|
||||||
<AppIcon
|
|
||||||
className='shrink-0 mr-2'
|
|
||||||
size='tiny'
|
|
||||||
icon={data._icon?.content}
|
|
||||||
background={data._icon?.background}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
<TitleInput
|
<TitleInput
|
||||||
value={data.title || ''}
|
value={data.title || ''}
|
||||||
onChange={handleTitleChange}
|
onChange={handleTitleChange}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user