Created
July 25, 2019 07:16
-
-
Save addisonschultz/7f8ac345145297ded8fe04e14f51c668 to your computer and use it in GitHub Desktop.
A template for Code Components in Framer X
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 { Frame, addPropertyControls, ControlType } from "framer"; | |
/** | |
* This import will allow Overrides made in another file available to use in our component | |
* | |
* Change the override names and file name if yours is different | |
*/ | |
// import { Primary, Secondary, Destructive } from "./Examples"; | |
/** | |
* This import allows us to use colors from the Loupe Store Package | |
* | |
* You can use a color by referencing it like: colors.primary | |
*/ | |
//@ts-ignore | |
import { colors } from "@framer/addison.loupe-colors/code/canvas"; | |
export function Component(props) { | |
if (props.kind == "primary") { | |
return ( | |
<Frame | |
style={ | |
{ | |
// Primary styles go here | |
} | |
} | |
//Atach an imported Overrides to your component | |
// {...Primary()} | |
size={"100%"} | |
/> | |
); | |
} | |
// If you don't have a secondary style, you won't need more if statement blocks | |
if (props.kind == "secondary") { | |
return ( | |
<Frame | |
style={ | |
{ | |
// Secondary styles go here | |
} | |
} | |
//Atach an imported Overrides to your component | |
// {...Secondary()} | |
size={"100%"} | |
/> | |
); | |
} | |
// Defualt to render a Frame if the kind prop isn't set or available | |
return <Frame />; | |
} | |
/** | |
* Default props for our component. | |
* | |
* Change the height and width to match your different component size | |
*/ | |
Component.defaultProps = { | |
height: 200, | |
width: 200, | |
kind: "primary" | |
}; | |
/** | |
* Adding propertyControls to control the component kind | |
*/ | |
addPropertyControls(Component, { | |
kind: { | |
type: ControlType.Enum, | |
options: ["primary", "secondary", "destructive"], | |
optionTitles: ["Primary", "Secondary", "Destructive"] | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment