dify/web/app/components/base/icons/IconBase.tsx
zxhlyh 3c014f3ae5
Feat/plugins (#12547)
Co-authored-by: AkaraChen <akarachen@outlook.com>
Co-authored-by: Yi <yxiaoisme@gmail.com>
Co-authored-by: Joel <iamjoel007@gmail.com>
Co-authored-by: JzoNg <jzongcode@gmail.com>
Co-authored-by: twwu <twwu@dify.ai>
Co-authored-by: kurokobo <kuro664@gmail.com>
Co-authored-by: Hiroshi Fujita <fujita-h@users.noreply.github.com>
2025-01-09 18:47:41 +08:00

34 lines
745 B
TypeScript

import { forwardRef } from 'react'
import { generate } from './utils'
import type { AbstractNode } from './utils'
export type IconData = {
name: string
icon: AbstractNode
}
export type IconBaseProps = {
data: IconData
className?: string
onClick?: React.MouseEventHandler<SVGElement>
style?: React.CSSProperties
}
const IconBase = forwardRef<React.MutableRefObject<HTMLOrSVGElement>, IconBaseProps>((props, ref) => {
const { data, className, onClick, style, ...restProps } = props
return generate(data.icon, `svg-${data.name}`, {
className,
onClick,
style,
'data-icon': data.name,
'aria-hidden': 'true',
...restProps,
'ref': ref,
})
})
IconBase.displayName = 'IconBase'
export default IconBase