rofrischmann/inline-style-prefix-all

View on GitHub
modules/plugins/flexboxOld.js

Summary

Maintainability
A
35 mins
Test Coverage
import camelToDashCase from 'hyphenate-style-name'

const alternativeValues = {
  'space-around': 'justify',
  'space-between': 'justify',
  'flex-start': 'start',
  'flex-end': 'end',
  'wrap-reverse': 'multiple',
  wrap: 'multiple'
}

const alternativeProps = {
  alignItems: 'WebkitBoxAlign',
  justifyContent: 'WebkitBoxPack',
  flexWrap: 'WebkitBoxLines'
}

export default function flexboxOld(property, value) {
  if (property === 'flexDirection') {
    return {
      WebkitBoxOrient: value.indexOf('column') > -1 ? 'vertical' : 'horizontal',
      WebkitBoxDirection: value.indexOf('reverse') > -1 ? 'reverse' : 'normal'
    }
  }
  if (alternativeProps[property]) {
    return {
      [alternativeProps[property]]: alternativeValues[value] || value
    }
  }
}