Skip to content

Commit

Permalink
Merge pull request #1 from KaboCash/v1.1
Browse files Browse the repository at this point in the history
Upgraded the component to v1.1
  • Loading branch information
Octagon-simon authored Mar 28, 2024
2 parents 7578fa6 + 98794e1 commit 1b2a310
Show file tree
Hide file tree
Showing 6 changed files with 343 additions and 453 deletions.
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
### OTP-APP
### React-OTP Component

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

## INSTALLATION STEPS

After cloning or downloading the code, run `npm install` to install all dependencies
> 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
After cloning the repo or downloading the source code, run `npm install` to install all dependencies.

```bash
$ npm install

```

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

Now Fire up your server
Now Fire up your server 🔥

```bash
$ npm run start
```

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

## CONFIGURATION

- From `v1.1`, `autoSubmit` is configurable when you call the component `<OTPInputGroup autoSubmit={false} />`.
- 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.

- This simple app supports both Numbers and Letters.
- If you need only numbers or letters, be sure to modify it to suit your project.


## Read the article here

[On Medium](https://simon-ugorji.medium.com/how-to-create-an-otp-input-box-in-react-js-next-js-3acc6adf5d6b)
Expand Down
50 changes: 45 additions & 5 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,53 @@
import OTPInputGroup from "./otpInputs";

function App() {

const styles = {
app: {
fontSize: '.89rem',
height: '100dvh',
display: 'flex',
justifyContent: 'center',
flexDirection: 'column',
backgroundColor: '#f9f9f9'
},

formWrapper: {
padding: '20px',
maxWidth: 'calc(340px - 20px)',
width: '100%',
margin: 'auto',
boxShadow: '0px 0px 8px #ddd',
// borderRadius: '10px',.
backgroundColor: '#fff',
border: '1px solid #ffffff'
},

title: {
textAlign: 'center',
margin: '0 0 1.4rem 0',
fontSize: '1.3rem',
fontWeight: '500',
},

notification: {
margin: '20px 0',
padding: '20px',
backgroundColor: '#eff5fb',
color: '#296fa8',
fontWeight: '500'
}
}

return (
<div className="app">
<form method="post">
<h2>Verify Email Address</h2>
<div className="app" style={styles.app}>
<div style={styles.formWrapper}>
<form method="post">
<h2 style={styles.title}>Enter verification code</h2>
<div style={styles.notification}>Check your inbox for a verification code and enter it below</div>
<OTPInputGroup />
</form>

</form>
</div>
</div>
);
}
Expand Down
105 changes: 0 additions & 105 deletions src/otpInputs.css

This file was deleted.

Loading

0 comments on commit 1b2a310

Please sign in to comment.