Skip to content

Commit d70115f

Browse files
committed
♻️ Minor improvements
1 parent 11c3987 commit d70115f

File tree

5 files changed

+106
-15
lines changed

5 files changed

+106
-15
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
A fully customizable, one-time password input component for the web built with React.
44

5+
![GIPHY](https://media.giphy.com/media/9JiszPVOX5FuPfJm39/giphy.gif)
6+
7+
[Live Demo](https://ajayns.github.io/react-otp-input)
8+
59
## Installation
610

711
To install the latest stable version:

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"demo:prod": "webpack --mode production",
1212
"format": "prettier --write '**/*.{js,jsx}'",
1313
"lint": "eslint '**/*.{js,jsx}' --quiet",
14-
"prepublish": "npm run build"
14+
"prepublish": "npm run build",
15+
"predeploy": "npm run demo:prod",
16+
"deploy": "gh-pages -d demo"
1517
},
1618
"keywords": [],
1719
"peerDependencies": {
@@ -38,6 +40,7 @@
3840
"eslint-plugin-prettier": "^2.6.0",
3941
"eslint-plugin-react": "^7.9.1",
4042
"flow-bin": "^0.73.0",
43+
"gh-pages": "^1.2.0",
4144
"html-webpack-plugin": "^3.2.0",
4245
"prettier": "^1.13.4",
4346
"react": "^16.4.0",
@@ -49,12 +52,12 @@
4952
},
5053
"author": "Ajay NS <[email protected]>",
5154
"license": "MIT",
55+
"homepage": "https://ajayns.github.io/react-otp-input",
5256
"repository": {
5357
"type": "git",
5458
"url": "[email protected]:ajayns/react-otp-input.git"
5559
},
5660
"bugs": {
5761
"url": "https://github.com/ajayns/react-otp-input/issues"
58-
},
59-
"homepage": "https://github.com/ajayns/react-otp-input#readme"
62+
}
6063
}

src/docs/index.jsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Demo extends Component {
99
this.state = {
1010
otp: '',
1111
numInputs: 4,
12-
separator: '',
12+
separator: '-',
1313
isDisabled: false,
1414
};
1515
}
@@ -28,11 +28,11 @@ class Demo extends Component {
2828

2929
handleSubmit = e => {
3030
e.preventDefault();
31-
console.log(this.state.otp);
31+
alert(this.state.otp);
3232
};
3333

3434
render() {
35-
const { numInputs, separator, isDisabled } = this.state;
35+
const { otp, numInputs, separator, isDisabled } = this.state;
3636

3737
return (
3838
<div className="container">
@@ -59,6 +59,7 @@ class Demo extends Component {
5959
Separator
6060
<input
6161
id="separator"
62+
maxLength={1}
6263
name="separator"
6364
type="text"
6465
value={separator}
@@ -104,7 +105,12 @@ class Demo extends Component {
104105
separator={<span>{separator}</span>}
105106
/>
106107
</div>
107-
<button className="btn margin-top--large">Continue</button>
108+
<button
109+
className="btn margin-top--large"
110+
disabled={otp.length < numInputs}
111+
>
112+
Get OTP
113+
</button>
108114
</form>
109115
</div>
110116
</div>

src/docs/styles.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ a {
8888
padding: 0.5rem 1rem;
8989
color: white;
9090
border-radius: 4px;
91+
cursor: pointer;
92+
}
93+
94+
.btn:disabled {
95+
background-color: rgba(0, 0, 0, 0.4);
96+
cursor: default;
9197
}
9298

9399
.margin-top--small {

yarn.lock

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -404,16 +404,16 @@ async-each@^1.0.0:
404404
version "1.0.1"
405405
resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d"
406406

407-
async@^1.5.0, async@^1.5.2:
408-
version "1.5.2"
409-
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"
410-
411-
async@^2.6.0:
407+
[email protected], async@^2.6.0:
412408
version "2.6.1"
413409
resolved "https://registry.yarnpkg.com/async/-/async-2.6.1.tgz#b245a23ca71930044ec53fa46aa00a3e87c6a610"
414410
dependencies:
415411
lodash "^4.17.10"
416412

413+
async@^1.5.0, async@^1.5.2:
414+
version "1.5.2"
415+
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"
416+
417417
atob@^2.1.1:
418418
version "2.1.1"
419419
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.1.tgz#ae2d5a729477f289d60dd7f96a6314a22dd6c22a"
@@ -1712,7 +1712,7 @@ colors@~1.1.2:
17121712
version "1.1.2"
17131713
resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63"
17141714

1715-
[email protected], commander@^2.11.0, commander@~2.15.0:
1715+
[email protected].1, [email protected].x, commander@^2.11.0, commander@~2.15.0:
17161716
version "2.15.1"
17171717
resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f"
17181718

@@ -2820,6 +2820,25 @@ filename-regex@^2.0.0:
28202820
version "2.0.1"
28212821
resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26"
28222822

2823+
filename-reserved-regex@^1.0.0:
2824+
version "1.0.0"
2825+
resolved "https://registry.yarnpkg.com/filename-reserved-regex/-/filename-reserved-regex-1.0.0.tgz#e61cf805f0de1c984567d0386dc5df50ee5af7e4"
2826+
2827+
filenamify-url@^1.0.0:
2828+
version "1.0.0"
2829+
resolved "https://registry.yarnpkg.com/filenamify-url/-/filenamify-url-1.0.0.tgz#b32bd81319ef5863b73078bed50f46a4f7975f50"
2830+
dependencies:
2831+
filenamify "^1.0.0"
2832+
humanize-url "^1.0.0"
2833+
2834+
filenamify@^1.0.0:
2835+
version "1.2.1"
2836+
resolved "https://registry.yarnpkg.com/filenamify/-/filenamify-1.2.1.tgz#a9f2ffd11c503bed300015029272378f1f1365a5"
2837+
dependencies:
2838+
filename-reserved-regex "^1.0.0"
2839+
strip-outer "^1.0.0"
2840+
trim-repeated "^1.0.0"
2841+
28232842
fill-range@^2.1.0:
28242843
version "2.2.4"
28252844
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.4.tgz#eb1e773abb056dcd8df2bfdf6af59b8b3a936565"
@@ -2947,6 +2966,14 @@ from2@^2.1.0, from2@^2.1.1:
29472966
inherits "^2.0.1"
29482967
readable-stream "^2.0.0"
29492968

2969+
fs-extra@^5.0.0:
2970+
version "5.0.0"
2971+
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-5.0.0.tgz#414d0110cdd06705734d055652c5411260c31abd"
2972+
dependencies:
2973+
graceful-fs "^4.1.2"
2974+
jsonfile "^4.0.0"
2975+
universalify "^0.1.0"
2976+
29502977
fs-minipass@^1.2.5:
29512978
version "1.2.5"
29522979
resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.5.tgz#06c277218454ec288df77ada54a03b8702aacb9d"
@@ -3025,6 +3052,18 @@ gh-got@^6.0.0:
30253052
got "^7.0.0"
30263053
is-plain-obj "^1.1.0"
30273054

3055+
gh-pages@^1.2.0:
3056+
version "1.2.0"
3057+
resolved "https://registry.yarnpkg.com/gh-pages/-/gh-pages-1.2.0.tgz#1acb92801078f7c038a167f447221d1496ccfbee"
3058+
dependencies:
3059+
async "2.6.1"
3060+
commander "2.15.1"
3061+
filenamify-url "^1.0.0"
3062+
fs-extra "^5.0.0"
3063+
globby "^6.1.0"
3064+
graceful-fs "4.1.11"
3065+
rimraf "^2.6.2"
3066+
30283067
github-username@^4.0.0:
30293068
version "4.1.0"
30303069
resolved "https://registry.yarnpkg.com/github-username/-/github-username-4.1.0.tgz#cbe280041883206da4212ae9e4b5f169c30bf417"
@@ -3173,7 +3212,7 @@ got@^8.3.1:
31733212
url-parse-lax "^3.0.0"
31743213
url-to-options "^1.0.1"
31753214

3176-
graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.4:
3215+
graceful-fs@4.1.11, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6:
31773216
version "4.1.11"
31783217
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
31793218

@@ -3406,6 +3445,13 @@ https-browserify@^1.0.0:
34063445
version "1.0.0"
34073446
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
34083447

3448+
humanize-url@^1.0.0:
3449+
version "1.0.1"
3450+
resolved "https://registry.yarnpkg.com/humanize-url/-/humanize-url-1.0.1.tgz#f4ab99e0d288174ca4e1e50407c55fbae464efff"
3451+
dependencies:
3452+
normalize-url "^1.0.0"
3453+
strip-url-auth "^1.0.0"
3454+
34093455
34103456
version "0.4.19"
34113457
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"
@@ -3960,6 +4006,12 @@ json5@^0.5.0, json5@^0.5.1:
39604006
version "0.5.1"
39614007
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
39624008

4009+
jsonfile@^4.0.0:
4010+
version "4.0.0"
4011+
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
4012+
optionalDependencies:
4013+
graceful-fs "^4.1.6"
4014+
39634015
jsx-ast-utils@^2.0.0, jsx-ast-utils@^2.0.1:
39644016
version "2.0.1"
39654017
resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-2.0.1.tgz#e801b1b39985e20fffc87b40e3748080e2dcac7f"
@@ -4638,7 +4690,7 @@ [email protected]:
46384690
query-string "^5.0.1"
46394691
sort-keys "^2.0.0"
46404692

4641-
normalize-url@^1.4.0:
4693+
normalize-url@^1.0.0, normalize-url@^1.4.0:
46424694
version "1.9.1"
46434695
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-1.9.1.tgz#2cc0d66b31ea23036458436e3620d85954c66c3c"
46444696
dependencies:
@@ -6349,6 +6401,16 @@ strip-json-comments@~2.0.1:
63496401
version "2.0.1"
63506402
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
63516403

6404+
strip-outer@^1.0.0:
6405+
version "1.0.1"
6406+
resolved "https://registry.yarnpkg.com/strip-outer/-/strip-outer-1.0.1.tgz#b2fd2abf6604b9d1e6013057195df836b8a9d631"
6407+
dependencies:
6408+
escape-string-regexp "^1.0.2"
6409+
6410+
strip-url-auth@^1.0.0:
6411+
version "1.0.1"
6412+
resolved "https://registry.yarnpkg.com/strip-url-auth/-/strip-url-auth-1.0.1.tgz#22b0fa3a41385b33be3f331551bbb837fa0cd7ae"
6413+
63526414
style-loader@^0.21.0:
63536415
version "0.21.0"
63546416
resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-0.21.0.tgz#68c52e5eb2afc9ca92b6274be277ee59aea3a852"
@@ -6511,6 +6573,12 @@ trim-newlines@^1.0.0:
65116573
version "1.0.0"
65126574
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613"
65136575

6576+
trim-repeated@^1.0.0:
6577+
version "1.0.0"
6578+
resolved "https://registry.yarnpkg.com/trim-repeated/-/trim-repeated-1.0.0.tgz#e3646a2ea4e891312bf7eace6cfb05380bc01c21"
6579+
dependencies:
6580+
escape-string-regexp "^1.0.2"
6581+
65146582
trim-right@^1.0.1:
65156583
version "1.0.1"
65166584
resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"
@@ -6604,6 +6672,10 @@ unique-slug@^2.0.0:
66046672
dependencies:
66056673
imurmurhash "^0.1.4"
66066674

6675+
universalify@^0.1.0:
6676+
version "0.1.1"
6677+
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.1.tgz#fa71badd4437af4c148841e3b3b165f9e9e590b7"
6678+
66076679
[email protected], unpipe@~1.0.0:
66086680
version "1.0.0"
66096681
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"

0 commit comments

Comments
 (0)