forked from jaredLunde/stellar-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContent.js
52 lines (44 loc) · 1.17 KB
/
Content.js
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
50
51
52
import React from 'react'
import PropTypes from 'prop-types'
import {createComponent, renderNode, FlexBox, memoThemeValue} from 'curls'
import {css} from '@emotion/core'
const as = 'div'
const defaultCSS = css`
width: 100%;
margin-left: auto;
margin-right: auto;
`
const defaultTheme = {
width: 1360,
slimWidth: null
}
const SFC = createComponent({
name: 'content',
styles: {
__base: memoThemeValue((val, theme) => css`max-width: ${theme.width}px;`),
slim: memoThemeValue((val, theme) => val === true && (
css`max-width: ${theme.slimWidth || theme.width * 0.61803398875}px;`
))
},
defaultTheme
})
const Content = React.forwardRef(
function Content (props, innerRef) {
return SFC({
__base: true,
innerRef,
...props,
children: function (boxProps) {
boxProps.children = function (nodeProps) {
nodeProps.children = props.children
nodeProps.as = nodeProps.as || as
delete nodeProps.__base
return renderNode(nodeProps, defaultCSS)
}
return FlexBox(boxProps)
}
})
}
)
export default Content
Content.propTypes /* remove-proptypes */ = {slim: PropTypes.bool}