var singleValue = function (value) {
    return value == ''||value==null ? 'auto' : value;
}

var analySide = function (data) {
    if (!data) {
        return null;
    }
    let type = typeof (data);
    if (type == 'string' || type == 'number') {
        return singleValue(data);
    } else if (type == 'object') {
        return singleValue(data.top) + " "
            + singleValue(data.right) + " "
            + singleValue(data.bottom) + " "
            + singleValue(data.left)
    }
}

var analySize = function (size){
    if(size==null||size==''){
        return 'auto';
    }else{
        return size;
    }
}

var analyColor = function(color){
  if(color){
      if(color.indexOf('#') > -1){
          return color;
      }else{
          return `#${color}`;
      }
  }
}

var analyUnit = function(val){
  if(val){
      val = val.toString();
      if(val.indexOf('px') == -1 && val.indexOf('%') == -1){
          return `${val}px`;
      }else{
          return val;
      }
  }
}

export default {
    analySide:analySide,
    analySize:analySize,
    analyColor:analyColor,
    analyUnit:analyUnit
}