mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
refactor(Icon): simplify return value
This commit is contained in:
parent
929dc0f1b5
commit
e33f270f1a
1 changed files with 11 additions and 8 deletions
|
|
@ -125,16 +125,19 @@ type Props = {
|
|||
}
|
||||
|
||||
export function Icon({ type, className = undefined, placeholder, ...otherProps }: Props) {
|
||||
if (placeholder) return <div className={cx('octicon-wrapper')} />
|
||||
const { name, IconComponent } = getSVGIconComponent(type)
|
||||
const mergedClassName = cx('octicon', name)
|
||||
let children: React.ReactNode = null
|
||||
if (!placeholder) {
|
||||
const { name, IconComponent } = getSVGIconComponent(type)
|
||||
const mergedClassName = cx('octicon', name)
|
||||
children = React.createElement(Octicon, {
|
||||
icon: IconComponent,
|
||||
className: mergedClassName,
|
||||
verticalAlign: 'text-bottom',
|
||||
})
|
||||
}
|
||||
return (
|
||||
<div className={cx('octicon-wrapper', className)} {...otherProps}>
|
||||
{React.createElement(Octicon, {
|
||||
icon: IconComponent,
|
||||
className: mergedClassName,
|
||||
verticalAlign: 'text-bottom',
|
||||
})}
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue