Skip to content

Commit 6f28e5e

Browse files
committed
1.0.0 stable release
1 parent f4d0a4a commit 6f28e5e

28 files changed

+191
-197
lines changed

README.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,54 @@
33
<a href="https://franciscohodge.com/projects/simple-keyboard/"><img src="https://franciscohodge.com/project-pages/simple-keyboard/images/simple-keyboard-layouts-banner2.png" align="center"></a>
44
> The multi-language keyboard layout kit for simple-keyboard.
55
6-
Currently in early development. Features can change or be removed without prior warning.
6+
## Installation
7+
8+
### npm
9+
10+
> Install simple-keyboard and simple-keyboard-layouts.
11+
12+
`npm install simple-keyboard-layouts --save`
13+
14+
### zip file (self-hosted)
15+
16+
[Click here to download the latest release (zip format).](https://github.com/hodgef/simple-keyboard-layouts/zipball/master)
17+
18+
> Want to use a CDN instead of self-host? Scroll down to the "Usage with CDN" instructions below.
19+
20+
## Usage with npm
21+
22+
23+
````js
24+
import Keyboard from 'simple-keyboard';
25+
import 'simple-keyboard/build/css/index.css';
26+
27+
/**
28+
* Available layouts
29+
* https://github.com/hodgef/simple-keyboard-layouts/tree/master/src/lib/layouts
30+
*/
31+
import layout from "simple-keyboard-layouts/build/layouts/japanese";
32+
33+
let keyboard = new Keyboard({
34+
onChange: input => onChange(input),
35+
onKeyPress: button => onKeyPress(button),
36+
layout: layout
37+
});
38+
39+
function onChange(input){
40+
document.querySelector(".input").value = input;
41+
console.log("Input changed", input);
42+
}
43+
44+
function onKeyPress(button){
45+
console.log("Button pressed", button);
46+
}
47+
````
48+
49+
### html
50+
51+
````html
52+
<input class="input" />
53+
<div class="simple-keyboard"></div>
54+
````
55+
56+
[![Edit simple-keyboard-layouts demo - npm](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/pk9513441m)

build/layouts/arabic.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/layouts/chinese.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/layouts/french.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/layouts/german.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/layouts/hindi.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/layouts/japanese.js

Lines changed: 1 addition & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/layouts/korean.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/layouts/russian.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/layouts/spanish.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/webpack.config.prod.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
99
const paths = require('./paths');
1010
const getClientEnvironment = require('./env');
1111
const CopyWebpackPlugin = require('copy-webpack-plugin');
12+
const UglifyJS = require('uglify-es');
1213

1314
// Webpack uses `publicPath` to determine where the app is being served from.
1415
// It requires a trailing slash, or the file assets will get an incorrect path.
@@ -59,7 +60,7 @@ module.exports = {
5960
path: paths.appBuild,
6061
filename: 'index.js',
6162
libraryTarget: 'umd',
62-
library: 'SimpleKeyboard'
63+
library: 'SimpleKeyboardLayouts'
6364
},
6465
resolve: {
6566
// This allows you to set a fallback for where Webpack should look for modules.
@@ -259,7 +260,16 @@ module.exports = {
259260
// You can remove this if you don't use Moment.js:
260261
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
261262
new CopyWebpackPlugin([
262-
{ from: `${paths.appLayouts}`, to: paths.appLayoutsBuild },
263+
{
264+
from: `${paths.appLayouts}`,
265+
to: paths.appLayoutsBuild,
266+
transform(content, src) {
267+
// @param content: Buffer
268+
// @param src: String
269+
// @return Buffer
270+
return Promise.resolve(Buffer.from(UglifyJS.minify(content.toString()).code, 'utf8'));
271+
}
272+
}
263273
])
264274
],
265275
// CRL: added externals block for library

package-lock.json

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simple-keyboard-layouts",
3-
"version": "0.0.2",
3+
"version": "1.0.0",
44
"description": "Layouts module for simple-keyboard",
55
"main": "build/index.js",
66
"scripts": {
@@ -13,11 +13,11 @@
1313
},
1414
"repository": {
1515
"type": "git",
16-
"url": "https://github.com/hodgef/simple-keyboard"
16+
"url": "https://github.com/hodgef/simple-keyboard-layouts"
1717
},
1818
"author": "Francisco Hodge <[email protected]> (https://github.com/hodgef)",
1919
"bugs": {
20-
"url": "https://github.com/hodgef/simple-keyboard/issues"
20+
"url": "https://github.com/hodgef/simple-keyboard-layouts/issues"
2121
},
2222
"homepage": "https://franciscohodge.com/simple-keyboard",
2323
"keywords": [
@@ -30,7 +30,9 @@
3030
"component",
3131
"virtual-keyboard",
3232
"touchscreen",
33-
"touch-screen"
33+
"touch-screen",
34+
"layout",
35+
"keyboard-layout"
3436
],
3537
"license": "MIT",
3638
"dependencies": {
@@ -76,7 +78,8 @@
7678
"webpack": "3.8.1",
7779
"webpack-dev-server": "2.9.4",
7880
"webpack-manifest-plugin": "1.3.2",
79-
"whatwg-fetch": "2.0.3"
81+
"whatwg-fetch": "2.0.3",
82+
"uglify-es": "^3.3.9"
8083
},
8184
"jest": {
8285
"collectCoverageFrom": [

src/demo/App.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ import Keyboard from 'simple-keyboard';
22
import 'simple-keyboard/build/css/index.css';
33
import './css/App.css';
44

5-
// Layout
6-
import jp from '../lib/layouts/japanese';
5+
/**
6+
* Available layouts
7+
* https://github.com/hodgef/simple-keyboard-layouts/tree/master/src/lib/layouts
8+
*/
9+
import layout from '../lib/layouts/arabic';
710

811
class App {
912
constructor(){
@@ -12,13 +15,13 @@ class App {
1215
this.layoutName = "default";
1316
}
1417

15-
onDOMLoaded = () => {
18+
onDOMLoaded = async () => {
1619
this.keyboard = new Keyboard({
1720
debug: true,
1821
onChange: input => this.onChange(input),
1922
onKeyPress: button => this.onKeyPress(button),
2023
newLineOnEnter: true,
21-
layout: jp
24+
layout: layout
2225
});
2326

2427
/**

src/lib/components/Keyboard.test.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/lib/components/Layouts.js

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,33 @@
1-
/**
2-
* This class is currently unused.
3-
* You can include your desired layouts from the ./layouts folder
4-
*/
5-
class SimpleKeyboardLayouts {}
1+
import arabic from '../layouts/arabic';
2+
import chinese from'../layouts/chinese';
3+
import french from '../layouts/french';
4+
import german from '../layouts/german';
5+
import hindi from '../layouts/hindi';
6+
import japanese from '../layouts/japanese';
7+
import korean from '../layouts/korean';
8+
import russian from '../layouts/russian';
9+
import spanish from '../layouts/spanish';
10+
import thai from '../layouts/thai';
11+
12+
class SimpleKeyboardLayouts {
13+
14+
get = async (lang) => {
15+
const languages = {
16+
arabic,
17+
chinese,
18+
french,
19+
german,
20+
hindi,
21+
japanese,
22+
korean,
23+
russian,
24+
spanish,
25+
thai
26+
};
27+
28+
return languages[lang];
29+
}
30+
31+
}
632

733
export default SimpleKeyboardLayouts;

src/lib/layouts/arabic.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default {
1+
const arabic = {
22
'default' : [
33
"\u0630 1 2 3 4 5 6 7 8 9 0 - = {bksp}",
44
"{tab} \u0636 \u0635 \u062B \u0642 \u0641 \u063A \u0639 \u0647 \u062E \u062D \u062C \u062F \\",
@@ -13,4 +13,6 @@ export default {
1313
"{shift} ~ \u0652 } { \u0644\u0622 \u0622 \u2019 , . \u061F {shift}",
1414
'.com @ {space}'
1515
]
16-
}
16+
}
17+
18+
export default arabic;

src/lib/layouts/chinese.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default {
1+
const chinese = {
22
'default' : [
33
"\u20AC \u3105 \u3109 \u02C7 \u02CB \u3113 \u02CA \u02D9 \u311A \u311E \u3122 \u3126 = {bksp}",
44
"{tab} \u3106 \u310A \u310D \u3110 \u3114 \u3117 \u3127 \u311B \u311F \u3123 [ ] \\",
@@ -13,4 +13,6 @@ export default {
1313
'{shift} z x c v b n m , < > ? {shift}',
1414
'.com @ {space}'
1515
]
16-
}
16+
}
17+
18+
export default chinese;

src/lib/layouts/french.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default {
1+
const french = {
22
'default' : [
33
"\u00B2 & \u00E9 \" ' ( - \u00E8 _ \u00E7 \u00E0 ) = {bksp}",
44
"{tab} a z e r t y u i o p ^ $",
@@ -13,4 +13,6 @@ export default {
1313
"{shift} > W X C V B N ? . / \u00A7 {shift}",
1414
'.com @ {space}'
1515
]
16-
}
16+
}
17+
18+
export default french;

src/lib/layouts/german.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default {
1+
const german = {
22
'default' : [
33
"^ 1 2 3 4 5 6 7 8 9 0 \u00DF \u00B4 {bksp}",
44
"{tab} q w e r t z u i o p \u00FC +",
@@ -13,4 +13,6 @@ export default {
1313
"{shift} > Y X C V B N M ; : _ {shift}",
1414
'.com @ {space}'
1515
]
16-
}
16+
}
17+
18+
export default german;

src/lib/layouts/hindi.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default {
1+
const hindi = {
22
'default' : [
33
'` \u090D \u0945 \u094D\u0930 \u0930\u094D \u091C\u094D\u091E \u0924\u094D\u0930 \u0915\u094D\u0937 \u0936\u094D\u0930 \u096F \u0966 - \u0943 {bksp}',
44
'{tab} \u094C \u0948 \u093E \u0940 \u0942 \u092C \u0939 \u0917 \u0926 \u091C \u0921 \u093C \u0949 \\',
@@ -13,4 +13,6 @@ export default {
1313
'{shift} "" \u0901 \u0923 \u0928 \u0935 \u0933 \u0936 \u0937 \u0964 \u095F {shift}',
1414
'.com @ {space}'
1515
]
16-
}
16+
}
17+
18+
export default hindi;

src/lib/layouts/japanese.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default {
1+
const japanese = {
22
'default' : [
33
'\u308d \u306c \u3075 \u3042 \u3046 \u3048 \u304a \u3084 \u3086 \u3088 \u308f \u307b \u3078 {bksp}',
44
'{tab} \u305f \u3066 \u3044 \u3059 \u304b \u3093 \u306a \u306b \u3089 \u305b \u309b \u309c \u3080',
@@ -13,4 +13,6 @@ export default {
1313
'{shift} \u3063 \u3055 \u305d \u3072 \u3053 \u307f \u3082 \u3001 \u3002 \u30fb {shift}',
1414
'.com @ {space}'
1515
]
16-
}
16+
}
17+
18+
export default japanese;

0 commit comments

Comments
 (0)