Skip to content

Instantly share code, notes, and snippets.

@addisonschultz
Created July 25, 2019 07:16
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 addisonschultz/7f8ac345145297ded8fe04e14f51c668 to your computer and use it in GitHub Desktop.
Save addisonschultz/7f8ac345145297ded8fe04e14f51c668 to your computer and use it in GitHub Desktop.
A template for Code Components in Framer X
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