This commit is contained in:
zuiidea
2017-09-11 10:18:20 +08:00
2 changed files with 58 additions and 61 deletions
+11 -8
View File
@@ -1,21 +1,24 @@
import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import './iconfont.less'
const Iconfont = ({ type, colorful }) => {
const Iconfont = ({ type, colorful = false, className }) => {
if (colorful) {
return (<span
dangerouslySetInnerHTML={{
__html: `<svg class="colorful-icon" aria-hidden="true"><use xlink:href="#${type.startsWith('#') ? type.replace(/#/, '') : type}"></use></svg>`,
}}
/>)
return (
<svg className={classnames('colorful-icon', className)} aria-hidden="true">
<use xlinkHref={`#${type.startsWith('#') ? type.replace(/#/, '') : type}`} />
</svg>
)
}
return <i className={`antdadmin icon-${type}`} />
return <i className={classnames('antdadmin', [`icon-${type}`], className)} />
}
Iconfont.propTypes = {
type: PropTypes.string,
type: PropTypes.string.isRequired,
colorful: PropTypes.bool,
className: PropTypes.string,
}
export default Iconfont