overleaf/services/web/frontend/js/shared/components/icon.js
Jessica Lawshe d87ad11719 Merge pull request #3210 from overleaf/ta-icon-component
Create Icon Component in React

GitOrigin-RevId: 34161b3afa2c00dbca2423b1e5a42b29846fa6e4
2020-09-22 02:05:09 +00:00

36 lines
763 B
JavaScript

import React from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
function Icon({ type, spin, modifier, classes = {}, accessibilityLabel }) {
const iconClassName = classNames(
'fa',
`fa-${type}`,
{
'fa-spin': spin,
[`fa-${modifier}`]: modifier
},
classes.icon
)
return (
<>
<i className={iconClassName} aria-hidden="true" />
{accessibilityLabel ? (
<span className="sr-only">{accessibilityLabel}</span>
) : null}
</>
)
}
Icon.propTypes = {
type: PropTypes.string.isRequired,
spin: PropTypes.bool,
modifier: PropTypes.string,
classes: PropTypes.exact({
icon: PropTypes.string
}),
accessibilityLabel: PropTypes.string
}
export default Icon