forked from system-ui/theme-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBox.js
More file actions
40 lines (33 loc) · 987 Bytes
/
Box.js
File metadata and controls
40 lines (33 loc) · 987 Bytes
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
import styled from '@emotion/styled'
import { css, get } from '@theme-ui/css'
import { createShouldForwardProp } from '@styled-system/should-forward-prop'
import space from '@styled-system/space'
import color from '@styled-system/color'
const boxSystemProps = [...space.propNames, ...color.propNames]
/**
* @internal
* @type {(prop: string) => boolean}
*/
export const __isBoxStyledSystemProp = (prop) => boxSystemProps.includes(prop)
const shouldForwardProp = createShouldForwardProp(boxSystemProps)
const sx = (props) => css(props.sx)(props.theme)
const base = (props) => css(props.__css)(props.theme)
const variant = ({ theme, variant, __themeKey = 'variants' }) =>
css(get(theme, __themeKey + '.' + variant, get(theme, variant)))
export const Box = styled('div', {
shouldForwardProp,
})(
{
boxSizing: 'border-box',
margin: 0,
minWidth: 0,
},
base,
variant,
space,
color,
sx,
(props) => props.css
)
Box.displayName = 'Box'
export default Box