about summary refs log tree commit diff
path: root/app/javascript/mastodon/features/compose/components/text_icon_button.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript/mastodon/features/compose/components/text_icon_button.js')
-rw-r--r--app/javascript/mastodon/features/compose/components/text_icon_button.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/app/javascript/mastodon/features/compose/components/text_icon_button.js b/app/javascript/mastodon/features/compose/components/text_icon_button.js
new file mode 100644
index 000000000..bcfa21090
--- /dev/null
+++ b/app/javascript/mastodon/features/compose/components/text_icon_button.js
@@ -0,0 +1,36 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+
+class TextIconButton extends React.PureComponent {
+
+  constructor (props, context) {
+    super(props, context);
+    this.handleClick = this.handleClick.bind(this);
+  }
+
+  handleClick (e) {
+    e.preventDefault();
+    this.props.onClick();
+  }
+
+  render () {
+    const { label, title, active, ariaControls } = this.props;
+
+    return (
+      <button title={title} aria-label={title} className={`text-icon-button ${active ? 'active' : ''}`} aria-expanded={active} onClick={this.handleClick} aria-controls={ariaControls}>
+        {label}
+      </button>
+    );
+  }
+
+}
+
+TextIconButton.propTypes = {
+  label: PropTypes.string.isRequired,
+  title: PropTypes.string,
+  active: PropTypes.bool,
+  onClick: PropTypes.func.isRequired,
+  ariaControls: PropTypes.string
+};
+
+export default TextIconButton;