From 33da01610b6e79d0291de610432b9bd580f26d44 Mon Sep 17 00:00:00 2001 From: Nicholas Cassera Date: Tue, 27 Nov 2018 18:20:28 -0600 Subject: [PATCH] fix(spacing): spacing rule was not defaulting back to value (#33) --- src/utils/rules.ts | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/utils/rules.ts b/src/utils/rules.ts index 9435f936..498e5618 100644 --- a/src/utils/rules.ts +++ b/src/utils/rules.ts @@ -233,7 +233,7 @@ const getProperties = key => { }; // @ts-ignore FIXME -const getSpaceValue = scale => propVal => { +const getSpaceValue = (scale: any = {}) => propVal => { let val = propVal; let isNegative; @@ -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 @@ -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, {}); };