Adding more functionality examples to demo

This commit is contained in:
Francisco Hodge
2018-03-15 13:07:10 -04:00
parent 857942811c
commit dddd45a220
2 changed files with 70 additions and 3 deletions
+31
View File
@@ -0,0 +1,31 @@
.demoPage {
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
max-width: 1000px;
margin: 0 auto;
padding-top: 20px;
}
.demoPage .screenContainer {
background: rgba(0,0,0,0.8);
border: 20px solid;
height: 300px;
border-top-right-radius: 5px;
border-top-left-radius: 5px;
padding: 10px;
box-sizing: border-box;
}
.demoPage .inputContainer {
color: white;
background: transparent;
border: none;
outline: none;
font-family: monospace;
width: 100%;
height: 100%;
}
.simple-keyboard.hg-layout-custom {
border-top-left-radius: 0px;
border-top-right-radius: 0px;
}
+39 -3
View File
@@ -1,23 +1,59 @@
import React, {Component} from 'react';
import Keyboard from '../lib';
import './App.css';
class App extends Component {
state = {
input: '',
layoutName: "default"
}
componentDidMount(){
this.keyboard.setInput("Hello World!")
.then(input => {
this.setState({input: input});
});
}
onChange = (input) => {
console.log("Input changed", input);
this.setState({
input: input
}, () => {
console.log("Input changed", input);
});
}
onKeyPress = (button) => {
console.log("Button pressed", button);
/**
* Shift functionality
*/
if(button === "{lock}" || button === "{shift}")
this.handleShiftButton();
}
handleShiftButton = () => {
let layoutName = this.state.layoutName;
let shiftToggle = layoutName === "default" ? "shift" : "default";
this.setState({
layoutName: shiftToggle
});
}
render(){
return (
<div>
<div className={"demoPage"}>
<div className={"screenContainer"}>
<textarea className={"inputContainer"} value={this.state.input} />
</div>
<Keyboard
ref={r => this.keyboard = r}
onChange={input => this.onChange(input)}
onKeyPress={button => this.onKeyPress(button)}
layoutName={"default"}
layoutName={this.state.layoutName}
layout={{
'default': [
'` 1 2 3 4 5 6 7 8 9 0 - = {bksp}',