forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwithPseudoBox.js
More file actions
49 lines (47 loc) · 1.08 KB
/
withPseudoBox.js
File metadata and controls
49 lines (47 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import React from 'react'
import { PseudoBox } from '@chakra-ui/core'
import { string, number, oneOfType } from 'prop-types'
const WithPseudoBox = (WrappedComponent) => {
return function WrappedWithPseudoBox(props) {
WrappedWithPseudoBox.propTypes = {
mb: oneOfType([string, number]),
ml: oneOfType([string, number]),
mt: oneOfType([string, number]),
mr: oneOfType([string, number]),
w: oneOfType([string, number]),
width: oneOfType([string, number]),
h: oneOfType([string, number]),
height: oneOfType([string, number]),
mx: oneOfType([string, number]),
my: oneOfType([string, number]),
}
const {
mb,
ml,
mt,
mr,
w,
width,
h,
height,
mx,
...passThroughProps
} = props
return (
<PseudoBox
mb={mb}
ml={ml}
mt={mt}
mr={mr}
w={w}
width={width}
h={h}
height={height}
mx={mx}
>
<WrappedComponent {...passThroughProps} />
</PseudoBox>
)
}
}
export default WithPseudoBox