0.1.43 • Published 7 years ago
toobored v0.1.43
##TooBored Keyboard - (/to͞o/ bôrd/) A simple customizable keyboard input for ReactJS
Update: brand new actions API. More customizable than ever.
##Props
value
String - This is the string that the keyboard is to manipulate. requiredvisible
Boolean - default is set to false requiredlayout
Array - this is an array of objects. if you dont specify them the default QWERTY layout will be displayed optionalactions
Array - this lets you override the default action buttons. with your own using an array.handleLayoutToggle
Function - required only when visiblehandleKeyboardVisiblity
Function - required only when visiblehandleSubmit
Function - required only when visiblehandleChange
Function - required only when visiblehandleClear
Function - required only when visibletheme
Object - optional
layout
prop example
[
{
name: "default",
keys: [
// row 1
["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
// row 2
["a", "s", "d", "f", "g", "h", "j", "k", "l"],
// row 3
["z", "x", "c", "v", "b", "n", "m"]
]
},
{
name: "caps",
keys: [
// row 1
["Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P"],
// ROW 2
["A", "S", "D", "F", "G", "H", "J", "K", "L"],
// ROW 3
["Z", "X", "C", "V", "B", "N", "M"]
]
}...
]
actions
prop example
[
{
type: "toggleKeyboard",
text: "Hide"
},
{
type: "spaceKey",
text: "Space"
},
{
type: "deleteKey",
text: "<="
},
{
type: "submitKey",
text: "Send"
}
]
All actions
available types
toggleKeyboard
- this button type is wired to use yourhandleKeyboardVisiblity
function passed down as a prop.toggleLayout
- this button type is wired to use yourhandleLayoutToggle
function passed down as a prop.spaceKey
- this button type acts just like the regular keys keys and simply adds a space to your input.deleteKey
- this button type is wired to use yourhandleSubmit
function passed down as a prop.submitKey
- this button type is wired to use yourhandleSubmit
function passed down as a prop.clearKey
- this button type is wired to use yourhandleClear
function passed down as a prop.
theme
prop example
{
keyboardBackground: 'orange',
keyBackground: 'blue',
keyBackgroundHover: 'red',
keyColor: 'papayawhip',
keyColorHover: 'pink'
}
Example
import React, { Component } from "react";
import TooBored from "toobored";
export default class TooBoredExample extends Component {
constructor() {
super();
this.state = {
value: ""
};
}
handleKeyboardSubmit = () => {
alert(`Submiting: ${this.state.value}`);
};
handleClearValue = () => {
this.setState({
value: ""
});
};
handleChangeValue = value => {
this.setState({
value
});
};
toggleKeyboardVisibility = () => {
this.setState({
toggleKeyboardVisibility: !this.state.toggleKeyboardVisibility
});
};
showKeyboard = () => {
this.setState({
toggleKeyboardVisibility: true
});
};
render() {
return (
<div>
<input
value={this.state.value}
placeholder={"Click me to open keyboard"}
onClick={this.showKeyboard}
onChange={e => this.handleChangeValue(e.target.value)}
/>
<TooBored
value={this.state.value}
// components state
visible={this.state.toggleKeyboardVisibility}
// handlers
handleKeyboardVisiblity={this.toggleKeyboardVisibility}
handleSubmit={this.handleKeyboardSubmit}
handleChange={this.handleChangeValue}
handleClear={this.handleClearValue}
actions={[
{
type: "toggleKeyboard",
text: "Toggle"
},
{
type: "spaceKey",
text: "Space"
},
{
type: "deleteKey",
text: "Delete"
},
{
type: "submitKey",
text: "Submit"
},
{
type: "clearKey",
text: "Clear"
}
]}
/>
</div>
);
}
}
0.1.43
7 years ago
0.1.42
7 years ago
0.1.41
7 years ago
0.1.40
7 years ago
0.1.39
7 years ago
0.1.38
7 years ago
0.1.37
7 years ago
0.1.36
7 years ago
0.1.32
7 years ago
0.1.31
7 years ago
0.1.30
7 years ago
0.1.29
7 years ago
0.1.28
7 years ago
0.1.27
7 years ago
0.1.26
7 years ago
0.1.25
7 years ago
0.1.24
7 years ago
0.1.23
7 years ago
0.1.22
7 years ago
0.1.21
7 years ago
0.1.20
7 years ago
0.1.19
7 years ago
0.1.18
7 years ago
0.1.17
7 years ago
0.1.16
7 years ago
0.1.15
7 years ago
0.1.14
7 years ago
0.1.13
7 years ago
0.1.12
7 years ago
0.1.11
7 years ago
0.1.10
7 years ago
0.1.9
7 years ago
0.1.8
7 years ago
0.1.7
7 years ago
0.1.6
7 years ago
0.1.5
7 years ago
0.1.4
7 years ago
0.1.3
7 years ago
0.1.2
7 years ago
0.1.1
7 years ago
0.1.0
7 years ago