about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/components/icon.js
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-09-09 15:28:45 +0200
committerThibG <thib@sitedethib.com>2019-09-09 19:00:20 +0200
commitf154d9d6e9ca461cf608674494cb23eee6db6534 (patch)
tree13384a3c89cb9abc9bff0e7019c9c1cbb56f5fd3 /app/javascript/flavours/glitch/components/icon.js
parentf2b307af25ca53f062f1a9e50dc1724b7550fd71 (diff)
Use upstream's Icon component
Rework the codebase to avoid unnecessary differences with upstream
Diffstat (limited to 'app/javascript/flavours/glitch/components/icon.js')
-rw-r--r--app/javascript/flavours/glitch/components/icon.js41
1 files changed, 18 insertions, 23 deletions
diff --git a/app/javascript/flavours/glitch/components/icon.js b/app/javascript/flavours/glitch/components/icon.js
index 8f55a0115..d8a17722f 100644
--- a/app/javascript/flavours/glitch/components/icon.js
+++ b/app/javascript/flavours/glitch/components/icon.js
@@ -1,26 +1,21 @@
-//  Package imports.
-import classNames from 'classnames';
-import PropTypes from 'prop-types';
 import React from 'react';
+import PropTypes from 'prop-types';
+import classNames from 'classnames';
 
-//  This just renders a FontAwesome icon.
-export default function Icon ({
-  className,
-  fullwidth,
-  icon,
-}) {
-  const computedClass = classNames('icon', 'fa', { 'fa-fw': fullwidth }, `fa-${icon}`, className);
-  return icon ? (
-    <span
-      aria-hidden='true'
-      className={computedClass}
-    />
-  ) : null;
-}
+export default class Icon extends React.PureComponent {
 
-//  Props.
-Icon.propTypes = {
-  className: PropTypes.string,
-  fullwidth: PropTypes.bool,
-  icon: PropTypes.string,
-};
+  static propTypes = {
+    id: PropTypes.string.isRequired,
+    className: PropTypes.string,
+    fixedWidth: PropTypes.bool,
+  };
+
+  render () {
+    const { id, className, fixedWidth, ...other } = this.props;
+
+    return (
+      <i role='img' className={classNames('fa', `fa-${id}`, className, { 'fa-fw': fixedWidth })} {...other} />
+    );
+  }
+
+}