Skip to content

Instantly share code, notes, and snippets.

@asci
Created September 21, 2018 15:23
Show Gist options
  • Save asci/03af662ec168ea0339943f6c6ba1a656 to your computer and use it in GitHub Desktop.
Save asci/03af662ec168ea0339943f6c6ba1a656 to your computer and use it in GitHub Desktop.
share data
import * as React from 'react';
import { PropertyControls, ControlType } from 'framer';
import { data } from './Examples';
// Define type of property
interface Props {
text: string;
}
export class Display extends React.Component<Props> {
constructor(props) {
super(props);
this.state = {
num: data.rotation.get() || 'empty',
};
}
componentDidMount() {
data.rotation.onUpdate(({ value }) => {
this.setState({ num: value });
});
}
// Set default properties
static defaultProps = {
text: 'Hello World!',
};
// Items shown in property panel
static propertyControls: PropertyControls = {
text: { type: ControlType.String, title: 'Text' },
};
render() {
const style = {
backgroundColor: 'red',
width: this.state.num + '%',
};
return (
<div>
<div style={style}>{this.state.num}</div>
</div>
);
}
}
@vma-ableton
Copy link

Hi Artem, could you also share the Slider component where you set the data.rotation? Thanks for taking the time to help us with this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment