From 5233a930a0a7256abadd2d0a0b27bc54ad27236d Mon Sep 17 00:00:00 2001 From: Baozier Date: Fri, 6 Dec 2024 22:16:40 -0500 Subject: [PATCH] Improve UI for code input (#198) --- package.json | 2 +- server/src/configs/locale.ts | 4 + server/src/views/AuthorizeEmailMfa.tsx | 5 +- server/src/views/AuthorizeReset.tsx | 3 +- server/src/views/AuthorizeSmsMfa.tsx | 3 +- server/src/views/ChangeEmail.tsx | 3 +- server/src/views/VerifyEmail.tsx | 4 +- server/src/views/components/CodeInput.tsx | 117 ++++++++++++++++++++++ server/src/views/components/Layout.tsx | 8 ++ server/src/views/scripts/resetError.ts | 2 +- 10 files changed, 142 insertions(+), 9 deletions(-) create mode 100644 server/src/views/components/CodeInput.tsx diff --git a/package.json b/package.json index 57da5f5..eaf2834 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "melody-auth", - "version": "1.1.1", + "version": "1.1.2", "description": "A turnkey OAuth & authentication system.", "license": "MIT", "author": "Baozier", diff --git a/server/src/configs/locale.ts b/server/src/configs/locale.ts index 9aa86ed..d99ddcb 100644 --- a/server/src/configs/locale.ts +++ b/server/src/configs/locale.ts @@ -329,6 +329,10 @@ export const authorizeEmailMfa = Object.freeze({ en: 'Verify', fr: 'Vérifier', }, + code: { + en: 'Enter your verification code here', + fr: 'Entrez votre code de vérification ici', + }, resend: { en: 'Resend a new code', fr: 'Renvoyer un nouveau code', diff --git a/server/src/views/AuthorizeEmailMfa.tsx b/server/src/views/AuthorizeEmailMfa.tsx index b75770b..0b4647e 100644 --- a/server/src/views/AuthorizeEmailMfa.tsx +++ b/server/src/views/AuthorizeEmailMfa.tsx @@ -11,8 +11,8 @@ import { resetErrorScript, } from 'views/scripts' import SubmitError from 'views/components/SubmitError' -import Field from 'views/components/Field' import SubmitButton from 'views/components/SubmitButton' +import CodeInput from 'views/components/CodeInput' const AuthorizeEmailMfa = ({ queryDto, logoUrl, locales, error, @@ -40,10 +40,11 @@ const AuthorizeEmailMfa = ({ onsubmit='return handleSubmit(event)' >
- - -
- { + return ( +
+ +
+ + + + + + +
+ + + {html` + + `} +
+ ) +} + +export default CodeInput diff --git a/server/src/views/components/Layout.tsx b/server/src/views/components/Layout.tsx index 900f7c9..bf28847 100644 --- a/server/src/views/components/Layout.tsx +++ b/server/src/views/components/Layout.tsx @@ -112,6 +112,14 @@ const Layout = ({ font-size: 16px; color: darkslategray; } + .code-input { + background-color: white; + border: 1px solid lightgray; + text-align: center; + border-radius: 12px; + width: 42px; + height: 42px; + } .input { background-color: white; border: 1px solid lightgray; diff --git a/server/src/views/scripts/resetError.ts b/server/src/views/scripts/resetError.ts index df0e878..b500ff0 100644 --- a/server/src/views/scripts/resetError.ts +++ b/server/src/views/scripts/resetError.ts @@ -1,6 +1,6 @@ import { html } from 'hono/html' -const resetSubmitError = () => html` +export const resetSubmitError = () => html` var submitBtn = document.getElementById('submit-button'); if (submitBtn) submitBtn.disabled = false; var errorEl = document.getElementById('submit-error');