All files Base.js

100% Statements 10/10
100% Branches 8/8
100% Functions 6/6
100% Lines 10/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43            6x 6x       14x     16x   16x         11x 63x       3x               3x       3x        
import React from 'react'
import autoBind from 'react-autobind'
import { uniq } from 'lodash'
 
export default class Base extends React.Component {
  constructor(props) {
    super(props)
    autoBind(this)
  }
 
  get classString() {
    return this.classes.join(' ')
  }
  get classes() {
    const fromState = this.state && Array.isArray(this.state.classes) && this.state.classes || []
 
    return uniq([
      'sheetforge',
      this.constructor.name.toLowerCase(),
      this.props.className || '',
      ...this.props.classes || [],
      ...fromState.filter(c => typeof c === 'string'),
    ]).filter(c => !!c)
  }
 
  render() {
    return (
      <div className={this.classString}>
        {this.props.children}
      </div>
    )
  }
}
 
Base.defaultProps = {
  classes: [],
  className: '',
}
Base.propTypes = {
  classes: React.PropTypes.arrayOf(React.PropTypes.string),
  className: React.PropTypes.string,
}