Skip to content

Commit

Permalink
fix(system): fix space resolution algo
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge committed Aug 11, 2019
1 parent 217d2ee commit f50196b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/system/src/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const themeGetter = ({
res = transform(res, {
rawValue: value,
variants,
props,
})
}
res = compose ? compose(res)(props) : res
Expand Down
6 changes: 3 additions & 3 deletions packages/system/src/styles/space.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { style, themeGetter, compose } from '../style'
import { is, string, negative, get } from '../util'
import { is, string, negative, getThemeValue } from '../util'
import { getPx } from './basics'

function toNegative(value) {
Expand All @@ -14,11 +14,11 @@ export const getSpace = themeGetter({
key: 'space',
defaultVariants: [0, 4, 8, 16, 24, 48, 96, 144, 192, 240],
compose: getPx,
transform: (_, { rawValue, variants }) => {
transform: (_, { rawValue, variants, props }) => {
if (string(rawValue)) {
const neg = rawValue.startsWith('-')
const absoluteValue = neg ? rawValue.substr(1) : rawValue
const variantValue = get(variants, absoluteValue)
const variantValue = getThemeValue(props, absoluteValue, variants)
const value = is(variantValue) ? variantValue : absoluteValue
return neg ? toNegative(value) : value
}
Expand Down

0 comments on commit f50196b

Please sign in to comment.