Skip to content

Commit 1b2a310

Browse files
Merge pull request #1 from KaboCash/v1.1
Upgraded the component to v1.1
2 parents 7578fa6 + 98794e1 commit 1b2a310

File tree

6 files changed

+343
-453
lines changed

6 files changed

+343
-453
lines changed

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
### OTP-APP
1+
### React-OTP Component
22

3-
This React / NextJS App helps you add an OTP input box in your REACTJS / Next JS app
3+
This is a highly customizable React JS component that you use within your project to enable OTP Code submissions.
44

55
## INSTALLATION STEPS
66

7-
After cloning or downloading the code, run `npm install` to install all dependencies
7+
> Please note that this component does not make use of any external library and this means that you can literally copy these files `otpInputs.js` && `otpInputs.module.css` into your project and you're good to go
8+
9+
After cloning the repo or downloading the source code, run `npm install` to install all dependencies.
810

911
```bash
1012
$ npm install
11-
1213
```
1314

1415
When the dependencies are installed, and you encounter a babel error, run the command below to resolve this error
@@ -17,14 +18,23 @@ When the dependencies are installed, and you encounter a babel error, run the co
1718
$ npm install --save-dev @babel/plugin-proposal-private-property-in-object --legacy-peer-deps
1819
```
1920

20-
Now Fire up your server
21+
Now Fire up your server 🔥
2122

2223
```bash
2324
$ npm run start
2425
```
2526

2627
Visit the server at `http://localhost:3000` to view the app
2728

29+
## CONFIGURATION
30+
31+
- From `v1.1`, `autoSubmit` is configurable when you call the component `<OTPInputGroup autoSubmit={false} />`.
32+
- If you set this prop to `true`, the form will call the submit function once all boxes has been filled, otherwise, you need to hit the submit button for the form to be submitted.
33+
34+
- This simple app supports both Numbers and Letters.
35+
- If you need only numbers or letters, be sure to modify it to suit your project.
36+
37+
2838
## Read the article here
2939

3040
[On Medium](https://simon-ugorji.medium.com/how-to-create-an-otp-input-box-in-react-js-next-js-3acc6adf5d6b)

src/App.js

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,53 @@
11
import OTPInputGroup from "./otpInputs";
22

33
function App() {
4+
5+
const styles = {
6+
app: {
7+
fontSize: '.89rem',
8+
height: '100dvh',
9+
display: 'flex',
10+
justifyContent: 'center',
11+
flexDirection: 'column',
12+
backgroundColor: '#f9f9f9'
13+
},
14+
15+
formWrapper: {
16+
padding: '20px',
17+
maxWidth: 'calc(340px - 20px)',
18+
width: '100%',
19+
margin: 'auto',
20+
boxShadow: '0px 0px 8px #ddd',
21+
// borderRadius: '10px',.
22+
backgroundColor: '#fff',
23+
border: '1px solid #ffffff'
24+
},
25+
26+
title: {
27+
textAlign: 'center',
28+
margin: '0 0 1.4rem 0',
29+
fontSize: '1.3rem',
30+
fontWeight: '500',
31+
},
32+
33+
notification: {
34+
margin: '20px 0',
35+
padding: '20px',
36+
backgroundColor: '#eff5fb',
37+
color: '#296fa8',
38+
fontWeight: '500'
39+
}
40+
}
41+
442
return (
5-
<div className="app">
6-
<form method="post">
7-
<h2>Verify Email Address</h2>
43+
<div className="app" style={styles.app}>
44+
<div style={styles.formWrapper}>
45+
<form method="post">
46+
<h2 style={styles.title}>Enter verification code</h2>
47+
<div style={styles.notification}>Check your inbox for a verification code and enter it below</div>
848
<OTPInputGroup />
9-
</form>
10-
49+
</form>
50+
</div>
1151
</div>
1252
);
1353
}

src/otpInputs.css

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

0 commit comments

Comments
 (0)