Skip to content

Instantly share code, notes, and snippets.

@bryanberger
Created October 15, 2019 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryanberger/b2681bfba807d795a12fb31a465158b3 to your computer and use it in GitHub Desktop.
Save bryanberger/b2681bfba807d795a12fb31a465158b3 to your computer and use it in GitHub Desktop.
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