import cx from 'classnames'
import mapProps from 'recompose/mapProps'

const withModifiers = (classNames) =>
  mapProps((props) => {
    const newProps = { ...props }
    const classes = []
    Object.keys(classNames).forEach((modifier) => {
      if (props[modifier]) {
        delete newProps[modifier]
        classes.push(classNames[modifier])
      }
    })
    newProps.className = cx(props.className, classes)
    return newProps
  })

export default withModifiers

import cx from 'classnames'
import mapProps from 'recompose/mapProps'

const withModifiers = (classNames) =>
  mapProps((props) => {
    const newProps = { ...props }
    const classes = []
    Object.keys(classNames).forEach((modifier) => {
      if (props[modifier]) {
        delete newProps[modifier]
        classes.push(classNames[modifier])
      }
    })
    newProps.className = cx(props.className, ...classes)
    return newProps
  })

export default withModifiers

Fix trailing whitespace in components with both explicit classname and modifiers.
Fix trailing whitespace in components with both explicit classname and modifiers.
