Skip to content

Instantly share code, notes, and snippets.

@robertvanhoesel
Created August 23, 2018 19:59
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertvanhoesel/28a20b00df3c02e813970c49bc0c8c26 to your computer and use it in GitHub Desktop.
Save robertvanhoesel/28a20b00df3c02e813970c49bc0c8c26 to your computer and use it in GitHub Desktop.
Make any keyboard design in Framer interactive, using the text on the button as input onTap
import { Override, Data } from "framer";
const app = Data({ Text: "" });
export const Input: Override = props => {
return {
text: app.Text.length > 0 ? app.Text : "Type something...",
opacity: app.Text.length > 0 ? 1 : 0.6
};
};
export const Button: Override = props => {
return {
onTap: e => {
app.Text += e.target.innerText || "";
}
};
};
export const ClearInput: Override = props => ({
onTap: () => (app.Text = "")
});
export const SpaceBar: Override = props => ({
onTap: () => (app.Text += " ")
});
export const Delete: Override = props => ({
onTap: () => (app.Text = app.Text.substr(0, app.Text.length - 1))
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment