A small React single-page app that simulates a PIN keypad.
- The PIN is 4 digits by default.
- Entered digits are masked except for the latest digit.
- The PIN is validated once all digits have been entered.
- A correct PIN displays
ok, then resets. - An incorrect PIN displays
error, then resets. - After 3 incorrect attempts, the keypad displays
lockedfor 30 seconds.
- React 19
- TypeScript
- Vite
- Vitest
- Testing Library
- Sass modules
Install dependencies:
npm installRun the development server:
npm startRun tests:
npm testBuild for production:
npm run buildsrc/main.tsx: app entrypoint.src/components/App/PinPadApp.tsx: presentational keypad composition.src/components/App/usePinPad.ts: PIN state machine, masking, reset timer, lockout rules.src/components/Button/PinPadButton.tsx: keypad button.src/components/Icons/HoneycombIcon.tsx: animated background icon.
PinPadApp accepts optional props for the PIN and timings:
<PinPadApp
correctPin="4747"
maxAttempts={3}
resetTime={1200}
lockedTime={30000}
/>