Created
January 1, 2019 15:04
-
-
Save silicakes/4b5e4c097c6daa0986144574c45b3ed5 to your computer and use it in GitHub Desktop.
FramerX component interaction
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 { 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>; | |
} | |
} |
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 { Data, Override } from "framer"; | |
export const data = Data({ | |
randomNumber: 0 | |
}); | |
export const randomizer: Override = () => ({ | |
text: data.randomNumber | |
}); | |
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 { 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