dify/web/app/components/plugins/card/base/card-icon.tsx

47 lines
1.1 KiB
TypeScript
Raw Permalink Normal View History

2024-10-10 10:40:26 +08:00
import { RiCheckLine } from '@remixicon/react'
2024-10-16 16:28:07 +08:00
import AppIcon from '@/app/components/base/app-icon'
2024-10-10 10:40:26 +08:00
import cn from '@/utils/classnames'
const Icon = ({
className,
src,
installed = false,
}: {
className?: string
2024-10-16 16:28:07 +08:00
src: string | {
'content': string
'background': string
}
2024-10-10 10:40:26 +08:00
installed?: boolean
}) => {
2024-10-16 16:28:07 +08:00
if (typeof src === 'object') {
return (
<div className={cn('relative', className)}>
<AppIcon
size='large'
iconType={'emoji'}
icon={src.content}
background={src.background}
className='rounded-md'
/>
</div>
)
}
2024-10-10 10:40:26 +08:00
return (
<div
className={cn('shrink-0 relative w-10 h-10 rounded-md bg-center bg-no-repeat bg-contain', className)}
style={{
backgroundImage: `url(${src})`,
}}
>
{installed
2024-10-15 14:56:59 +08:00
&& <div className='flex justify-center items-center gap-2 absolute bottom-[-4px] right-[-4px] w-[18px] h-[18px] rounded-full border-2 border-components-panel-bg bg-state-success-solid'>
<RiCheckLine className='w-3 h-3 text-text-primary-on-surface' />
2024-10-10 10:40:26 +08:00
</div>
}
</div>
)
}
export default Icon