Skip to content
This repository was archived by the owner on Jun 20, 2022. It is now read-only.

Commit f003fac

Browse files
committed
fix: fix grid responsive values
1 parent 0b10721 commit f003fac

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

packages/shared/core/Col.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import PropTypes from 'prop-types'
2-
import { pr, pl } from '@smooth-ui/system'
2+
import { pr, pl, merge } from '@smooth-ui/system'
33
import { css } from './styled-engine'
44
import { gridGutter, gridColumns, breakpoints } from './theming/index'
55
import { mediaMinWidth } from './utils/index'
@@ -74,20 +74,21 @@ function getStyleFromProps(p) {
7474
const { gutter = gridGutter(p) } = p
7575
const bk = breakpoints(p)
7676
const breakpointsKeys = Object.keys(bk)
77-
const style = {
77+
let style = {
7878
boxSizing: 'border-box',
79-
...pr({ pr: gutter })(p),
80-
...pl({ pl: gutter })(p),
8179
flexBasis: 0,
8280
flexGrow: 1,
8381
maxWidth: '100%',
8482
}
8583

84+
style = merge(style, pl({ pl: gutter })(p))
85+
style = merge(style, pr({ pr: gutter })(p))
86+
8687
let index = -1
8788
// eslint-disable-next-line no-plusplus
8889
while (++index < breakpointsKeys.length) {
8990
const breakpoint = breakpointsKeys[index]
90-
Object.assign(style, getBreakPointStyle(breakpoint, bk[breakpoint], p))
91+
style = merge(style, getBreakPointStyle(breakpoint, bk[breakpoint], p))
9192
}
9293

9394
return style

packages/shared/core/utils/misc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const is = n => n !== undefined && n !== null
22
export const num = n => typeof n === 'number' && !Number.isNaN(n)
3+
export const string = n => typeof n === 'string'
34
export const func = n => typeof n === 'function'
45

56
export const get = (obj, ...paths) =>

packages/shared/core/utils/unit.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
import { num } from './misc'
1+
import { num, string } from './misc'
22

33
export const unit = unit => value => (num(value) ? `${value}${unit}` : value)
4-
export const negative = value => (num(value) ? -value : `-${value}`)
4+
export const negative = value => {
5+
if (!value) return value
6+
if (num(value)) return -value
7+
if (string(value)) return `-${value}`
8+
const obj = {}
9+
const keys = Object.keys(value)
10+
for (let i = 0; i < keys.length; i++) {
11+
const key = keys[i]
12+
obj[key] = negative(value[key])
13+
}
14+
return obj
15+
}
516

617
export const px = unit('px')
718

packages/system/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from './style'
22
export * from './styles/index'
33
export * from './cx'
44
export { universalSystem as default } from './universalSystem'
5+
export { merge } from './util'

0 commit comments

Comments
 (0)