Skip to content

Commit

Permalink
fix(spacing): spacing rule was not defaulting back to value (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
casserni authored and lottamus committed Nov 28, 2018
1 parent a26eed2 commit 33da016
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/utils/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ const getProperties = key => {
};

// @ts-ignore FIXME
const getSpaceValue = scale => propVal => {
const getSpaceValue = (scale: any = {}) => propVal => {
let val = propVal;
let isNegative;

Expand All @@ -244,7 +244,7 @@ const getSpaceValue = scale => propVal => {
}

// check the theme config for a value, or just use the prop
val = scale !== undefined ? scale[val] : val;
val = scale[val] || val;
}

// if was negative string/add the '-' back
Expand All @@ -267,18 +267,15 @@ export const space = props => {
const innerProperties = getProperties(key);

// @ts-ignore FIXME
const innerStyle = n =>
is(n)
? innerProperties.reduce(
(a, prop) => ({
...a,
[prop]: getStyle(n),
}),
{}
)
: null;

return innerStyle(value);
if (!is(value)) return null;

return innerProperties.reduce(
(a, prop) => ({
...a,
[prop]: getStyle(value),
}),
{}
);
})
.reduce(merge, {});
};
Expand Down

0 comments on commit 33da016

Please sign in to comment.