Skip to content

Instantly share code, notes, and snippets.

@silicakes
Created January 1, 2019 15:04
Show Gist options
  • Save silicakes/4b5e4c097c6daa0986144574c45b3ed5 to your computer and use it in GitHub Desktop.
Save silicakes/4b5e4c097c6daa0986144574c45b3ed5 to your computer and use it in GitHub Desktop.
FramerX component interaction
import * as React from "react";
import { PropertyControls, ControlType } from "framer";
import { data } from "./Examples";
export class ClickTrigger extends React.Component<any> {
static propertyControls: PropertyControls = {
number: { type: ControlType.Number, defaultValue: 0 }
};
onClick = () => {
console.log("click click");
data.randomNumber = this.props.number;
};
render() {
return <div onClick={this.onClick}>{this.props.children}</div>;
}
}
import { Data, Override } from "framer";
export const data = Data({
randomNumber: 0
});
export const randomizer: Override = () => ({
text: data.randomNumber
});
import * as React from "react";
import { PropertyControls, ControlType } from "framer";
const style: React.CSSProperties = {
height: "100%",
display: "flex",
alignItems: "center",
justifyContent: "center",
textAlign: "center",
color: "#8855FF",
background: "rgba(136, 85, 255, 0.1)",
overflow: "hidden",
};
// Define type of property
interface Props {
text: string;
}
export class NumberDisplay extends React.Component<Props> {
// Set default properties
static defaultProps = {
text: "Hello World!"
}
// Items shown in property panel
static propertyControls: PropertyControls = {
text: { type: ControlType.String, title: "Text" },
}
render() {
return <div style={style}>{this.props.text}</div>;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment