Skip to content

Commit b254667

Browse files
committed
fix: fix double negative value with strings
1 parent 3888c53 commit b254667

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/system/src/styles/space.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ export const getSpace = themeGetter({
1313
transform: (_, { rawValue, variants }) => {
1414
if (string(rawValue)) {
1515
const neg = rawValue.startsWith('-')
16-
const variantKey = neg ? rawValue.substr(1) : rawValue
17-
const variantValue = variants[variantKey]
18-
const value = is(variantValue) ? variantValue : rawValue
16+
const absoluteValue = neg ? rawValue.substr(1) : rawValue
17+
const variantValue = variants[absoluteValue]
18+
const value = is(variantValue) ? variantValue : absoluteValue
1919
return pxUnit(neg ? toNegative(value) : value)
2020
}
2121
const abs = Math.abs(rawValue)

packages/system/src/styles/space.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ describe('#getSpace', () => {
2525
const props = { theme: { space: { md: 10 } } }
2626
expect(getSpace('md')(props)).toEqual('10px')
2727
expect(getSpace('-md')(props)).toEqual('-10px')
28+
expect(getSpace('-10')(props)).toEqual('-10')
29+
expect(getSpace('-10px')(props)).toEqual('-10px')
2830
})
2931
})
3032

0 commit comments

Comments
 (0)