Feat/add icons (#450)

This commit is contained in:
zxhlyh 2023-06-26 15:36:52 +08:00 • committed by GitHub
commit 17d196126c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 609 additions and 44 deletions

View file

@ -0,0 +1,31 @@
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,
})
})
export default IconBase