From e7ab9bf8b4e4897b99937d43b9e4810462dd2714 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Mon, 16 Oct 2017 00:30:09 -0700 Subject: Refactor and simplify icon_button.js (#5413) --- app/javascript/mastodon/components/icon_button.js | 56 +++++++++++------------ 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'app') diff --git a/app/javascript/mastodon/components/icon_button.js b/app/javascript/mastodon/components/icon_button.js index 3e5f8ac8c..68d1a2735 100644 --- a/app/javascript/mastodon/components/icon_button.js +++ b/app/javascript/mastodon/components/icon_button.js @@ -2,6 +2,7 @@ import React from 'react'; import Motion from 'react-motion/lib/Motion'; import spring from 'react-motion/lib/spring'; import PropTypes from 'prop-types'; +import classNames from 'classnames'; export default class IconButton extends React.PureComponent { @@ -50,42 +51,41 @@ export default class IconButton extends React.PureComponent { ...(this.props.active ? this.props.activeStyle : {}), }; - const classes = ['icon-button']; + const { + active, + animate, + className, + disabled, + expanded, + icon, + inverted, + overlay, + pressed, + tabIndex, + title, + } = this.props; - if (this.props.active) { - classes.push('active'); - } - - if (this.props.disabled) { - classes.push('disabled'); - } - - if (this.props.inverted) { - classes.push('inverted'); - } - - if (this.props.overlay) { - classes.push('overlayed'); - } - - if (this.props.className) { - classes.push(this.props.className); - } + const classes = classNames(className, 'icon-button', { + active, + disabled, + inverted, + overlayed: overlay, + }); return ( - + {({ rotate }) =>