diff options
Diffstat (limited to 'vnext/src/ui/Icon.js')
-rw-r--r-- | vnext/src/ui/Icon.js | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/vnext/src/ui/Icon.js b/vnext/src/ui/Icon.js index faf1a704..255bba34 100644 --- a/vnext/src/ui/Icon.js +++ b/vnext/src/ui/Icon.js @@ -1,7 +1,19 @@ -import React from 'react'; +import React, { memo } from 'react'; import PropTypes from 'prop-types'; -const Icon = React.memo(props => { +/** + * @typedef {Object} IconProps + * @property {string} size + * @property {string=} className + * @property {string} name + * @property {boolean=} noFill + */ + + /** + * Icon inner component + * @param {IconProps} props - icon props + */ +function IconElement(props) { var size = props.size ? ' icon--' + props.size : ''; var className = props.className ? ' ' + props.className : ''; var klass = 'icon' + (!props.noFill ? ' icon--' + props.name : '') + size + className; @@ -14,8 +26,12 @@ const Icon = React.memo(props => { { className: klass }, wrapSpinner(Icon, klass) ); -}); +} +/** + * @param {React.ReactElement} Html + * @param {string} klass + */ function wrapSpinner(Html, klass) { if (klass.indexOf('spinner') > -1) { return React.createElement( @@ -28,9 +44,9 @@ function wrapSpinner(Html, klass) { } } -export default Icon; +export default memo(IconElement); -Icon.propTypes = { +IconElement.propTypes = { size: PropTypes.string.isRequired, name: PropTypes.string.isRequired, className: PropTypes.string, |