Skip to content

Commit 1f4642f

Browse files
committed
♻️ Use pss utils inside FlexGrid styles
1 parent 2b4d5fd commit 1f4642f

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

src/flex-grid/styles.js

+6-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { isNum, isStr, fallbackTo } from '@exah/utils'
1+
import { isNum, fallbackTo, identity } from '@exah/utils'
2+
23
import {
34
boolValue,
45
createSpaceValue,
@@ -60,26 +61,15 @@ const gridItem = createStyles({
6061
}
6162
})
6263

63-
const getNumericValueAndUnits = (value, step) => {
64-
const [ numericValue = 0, units = 'px' ] =
65-
value == null
66-
? isStr(step)
67-
? splitUnit(step)
68-
: [ 0, 'px' ]
69-
: isNum(value)
70-
? [ value, 'px' ]
71-
: splitUnit(value)
72-
return [ numericValue, units ]
73-
}
74-
7564
const getItemsSpaceStyles = (axis, {
7665
childSelector,
7766
rowSelector
7867
}) => style({
79-
getValue: createSpaceValue()(),
68+
getValue: createSpaceValue()(sizeValue(identity)),
8069
getStyle (value, step, props) {
81-
const [ numericValue, units ] = getNumericValueAndUnits(value, step)
82-
const size = `${numericValue / 2}${units}`
70+
const [ num, unit ] = splitUnit(value)
71+
const size = `${num / 2}${unit || 'px'}`
72+
8373
return {
8474
...(axis.x && {
8575
marginLeft: `-${size}`,

0 commit comments

Comments
 (0)