about summary refs log tree commit diff
path: root/app/javascript/mastodon/components/dropdown_menu.js
diff options
context:
space:
mode:
authorYamagishi Kazutoshi <ykzts@desire.sh>2017-05-12 21:44:10 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-05-12 14:44:10 +0200
commit2991a7cfe685ca9b42230b7030b9e7d0ece94c88 (patch)
tree72da0f02bc6279aeab1e641fb7d51527efcb9066 /app/javascript/mastodon/components/dropdown_menu.js
parent44a3584e2d54488393e6f50e482ed61d2765e312 (diff)
Use ES Class Fields & Static Properties (#3008)
Use ES Class Fields & Static Properties (currently stage 2) for improve class outlook.

Added babel-plugin-transform-class-properties as a Babel plugin.
Diffstat (limited to 'app/javascript/mastodon/components/dropdown_menu.js')
-rw-r--r--app/javascript/mastodon/components/dropdown_menu.js41
1 files changed, 18 insertions, 23 deletions
diff --git a/app/javascript/mastodon/components/dropdown_menu.js b/app/javascript/mastodon/components/dropdown_menu.js
index aed0757b1..99432463c 100644
--- a/app/javascript/mastodon/components/dropdown_menu.js
+++ b/app/javascript/mastodon/components/dropdown_menu.js
@@ -4,20 +4,27 @@ import PropTypes from 'prop-types';
 
 class DropdownMenu extends React.PureComponent {
 
-  constructor (props, context) {
-    super(props, context);
-    this.state = {
-      direction: 'left'
-    };
-    this.setRef = this.setRef.bind(this);
-    this.renderItem = this.renderItem.bind(this);
-  }
+  static propTypes = {
+    icon: PropTypes.string.isRequired,
+    items: PropTypes.array.isRequired,
+    size: PropTypes.number.isRequired,
+    direction: PropTypes.string,
+    ariaLabel: PropTypes.string
+  };
+
+  static defaultProps = {
+    ariaLabel: "Menu"
+  };
+
+  state = {
+    direction: 'left'
+  };
 
-  setRef (c) {
+  setRef = (c) => {
     this.dropdown = c;
   }
 
-  handleClick (i, e) {
+  handleClick = (i, e) => {
     const { action } = this.props.items[i];
 
     if (typeof action === 'function') {
@@ -27,7 +34,7 @@ class DropdownMenu extends React.PureComponent {
     }
   }
 
-  renderItem (item, i) {
+  renderItem = (item, i) => {
     if (item === null) {
       return <li key={ 'sep' + i } className='dropdown__sep' />;
     }
@@ -64,16 +71,4 @@ class DropdownMenu extends React.PureComponent {
 
 }
 
-DropdownMenu.propTypes = {
-  icon: PropTypes.string.isRequired,
-  items: PropTypes.array.isRequired,
-  size: PropTypes.number.isRequired,
-  direction: PropTypes.string,
-  ariaLabel: PropTypes.string
-};
-
-DropdownMenu.defaultProps = {
-  ariaLabel: "Menu"
-};
-
 export default DropdownMenu;