Skip to content

Commit

Permalink
Refactor class list generation in Input component
Browse files Browse the repository at this point in the history
  • Loading branch information
jpersson committed Nov 18, 2015
1 parent cdc0814 commit 76a7e91
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
22 changes: 14 additions & 8 deletions components/input/index.jsx
@@ -1,4 +1,5 @@
import React from 'react';
import classNames from 'classnames-minimal';
import style from './style';
import FontIcon from '../font_icon';
import Tooltip from '../tooltip';
Expand Down Expand Up @@ -41,14 +42,19 @@ class Input extends React.Component {
}

render () {
let className = style.root;
let labelClassName = style.label;
if (this.props.error) className += ` ${style.errored}`;
if (this.props.disabled) className += ` ${style.disabled}`;
if (this.props.className) className += ` ${this.props.className}`;
if (this.props.type === 'hidden') className += ` ${style.hidden}`;
if (this.props.icon) className += ` ${style['with-icon']}`;
if (!this.props.floating) labelClassName += ` ${style.fixed}`;
const className = classNames({
[style.root]: true,
[style.errored]: this.props.error,
[style.disabled]: this.props.disabled,
[this.props.className]: this.props.className,
[style.hidden]: this.props.type === 'hidden',
[style['with-icon']]: this.props.icon
});

const labelClassName = classNames({
[style.label]: true,
[style.fixed]: !this.props.floating
});

return (
<div data-react-toolbox='input' className={className}>
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -56,6 +56,7 @@
"babel-eslint": "^4.1.3",
"babel-loader": "^5.3.2",
"babel-plugin-react-transform": "^1.1.1",
"classnames-minimal": "^1.0.0",
"core-js": "^1.2.6",
"cross-env": "^1.0.4",
"cpx": "^1.2.1",
Expand Down

0 comments on commit 76a7e91

Please sign in to comment.