diff options
Diffstat (limited to 'app/javascript/mastodon/components/dropdown_menu.js')
-rw-r--r-- | app/javascript/mastodon/components/dropdown_menu.js | 41 |
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; |