2020-09-21 10:14:36 -04:00
|
|
|
import React from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import classNames from 'classnames'
|
|
|
|
|
2020-11-26 09:22:30 -05:00
|
|
|
function Icon({
|
|
|
|
type,
|
|
|
|
spin,
|
|
|
|
modifier,
|
|
|
|
classes = {},
|
|
|
|
accessibilityLabel,
|
2021-04-27 03:52:58 -04:00
|
|
|
children,
|
2020-11-26 09:22:30 -05:00
|
|
|
}) {
|
2020-09-21 10:14:36 -04:00
|
|
|
const iconClassName = classNames(
|
|
|
|
'fa',
|
|
|
|
`fa-${type}`,
|
|
|
|
{
|
|
|
|
'fa-spin': spin,
|
2021-04-27 03:52:58 -04:00
|
|
|
[`fa-${modifier}`]: modifier,
|
2020-09-21 10:14:36 -04:00
|
|
|
},
|
|
|
|
classes.icon
|
|
|
|
)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2020-11-26 09:22:30 -05:00
|
|
|
<i className={iconClassName} aria-hidden="true">
|
|
|
|
{children}
|
|
|
|
</i>
|
2020-09-21 10:14:36 -04:00
|
|
|
{accessibilityLabel ? (
|
|
|
|
<span className="sr-only">{accessibilityLabel}</span>
|
|
|
|
) : null}
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
Icon.propTypes = {
|
|
|
|
type: PropTypes.string.isRequired,
|
|
|
|
spin: PropTypes.bool,
|
|
|
|
modifier: PropTypes.string,
|
|
|
|
classes: PropTypes.exact({
|
2021-04-27 03:52:58 -04:00
|
|
|
icon: PropTypes.string,
|
2020-09-21 10:14:36 -04:00
|
|
|
}),
|
2020-11-26 09:22:30 -05:00
|
|
|
accessibilityLabel: PropTypes.string,
|
|
|
|
children: PropTypes.oneOfType([
|
|
|
|
PropTypes.arrayOf(PropTypes.node),
|
2021-04-27 03:52:58 -04:00
|
|
|
PropTypes.node,
|
|
|
|
]),
|
2020-09-21 10:14:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export default Icon
|