Skip to content

Commit

Permalink
jss border cases
Browse files Browse the repository at this point in the history
  • Loading branch information
janakg committed Jun 5, 2018
1 parent f809c89 commit f3efbad
Show file tree
Hide file tree
Showing 3 changed files with 1,183 additions and 1,151 deletions.
52 changes: 35 additions & 17 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,37 @@ function processArray(value, prop, scheme, rule) {
return [value];
}

/**
* Check for separate properties.
*
*/
function checkForSeperateProp(value, prop) {
var seperateProp = true,
extraValue = {},
isCustomProp = true;
switch (prop) {
case 'border':
if (value['width'] && value['width'].split(' ').length > 1) {
seperateProp = value['width'].split(' ').reduce(function (a, b) {
return a === b ? a : false;
});
if (seperateProp) {
value['width'] = seperateProp; //Pass by reference, so changes the value directly.
extraValue = {
radius: value['radius'],
image: value['image']
};
isCustomProp = !seperateProp;
}
}
break;

default:
break;
}
return { isCustomProp: isCustomProp, extraValue: extraValue };
}

/**
* Convert object to array.
*
Expand All @@ -63,24 +94,11 @@ function objectToArray(value, prop, rule, isFallback, isInArray) {

// Check if exists any non-standart property
if (_props.customPropObj[prop]) {
var seperate_prop = true;
var extraValue;
if (prop == "border") {
if (value['width'] && value['width'].split(' ').length > 1) {
seperate_prop = value['width'].split(' ').reduce(function (a, b) {
return a === b ? a : NaN;
});
if (seperate_prop) {
value['width'] = seperate_prop;
extraValue = {
radius: value['radius']
};
seperate_prop = !seperate_prop;
}
}
}
var _checkForSeperateProp = checkForSeperateProp(value, prop),
isCustomProp = _checkForSeperateProp.isCustomProp,
extraValue = _checkForSeperateProp.extraValue;

if (seperate_prop) {
if (isCustomProp) {
value = customPropsToStyle(value, rule, _props.customPropObj[prop], isFallback);
}
if (extraValue) {
Expand Down
Loading

0 comments on commit f3efbad

Please sign in to comment.