Created
October 15, 2019 19:05
-
-
Save bryanberger/b2681bfba807d795a12fb31a465158b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react" | |
import { | |
addPropertyControls, | |
ControlType, | |
BooleanControlDescription, | |
EnumControlDescription | |
} from "framer" | |
import * as Cog from '../../../dist/framer/' | |
import { BoxProps, BoxTheme } from '../../../dist/Box' | |
import { withHOC } from "./withHOC" | |
type Props = BoxProps & { | |
width: number, | |
height: number, | |
} | |
type Controls = { | |
border: BooleanControlDescription, | |
theme: EnumControlDescription | |
} | |
const controls: Controls = { | |
border: { title: "Border", defaultValue: false, type: ControlType.Boolean }, | |
theme: { | |
title: "Theme", | |
options: BoxTheme[], | |
defaultValue: "light", | |
type: ControlType.Enum, | |
}, | |
} | |
const _Box: React.FC<Props> = ({ | |
theme = 'dark', | |
border = false, | |
padding, | |
children, | |
...props | |
}) => { | |
return ( | |
<Cog.Box | |
theme={theme} | |
border={border} | |
padding={padding} | |
{...props} | |
> | |
{React.Children.map(children, content => | |
React.cloneElement(content, { | |
...content.props, | |
style: { | |
position: 'relative', | |
}, | |
}), | |
)} | |
</Cog.Box> | |
) | |
} | |
export const Box = withHOC(_Box) | |
Box.defaultProps = { | |
width: 200, | |
height: 50, | |
} | |
addPropertyControls(Box, controls) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment