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
34 lines (30 loc) · 802 Bytes
/
Box.js
File metadata and controls
34 lines (30 loc) · 802 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
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 shouldForwardProp = createShouldForwardProp([
...space.propNames,
...color.propNames,
])
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,
label: 'Box',
})(
{
boxSizing: 'border-box',
margin: 0,
minWidth: 0,
},
base,
variant,
space,
color,
sx,
props => props.css
)
export default Box