From 861dda95bc121dcc2db470a149a3930f094db1f0 Mon Sep 17 00:00:00 2001 From: "Ismail H. Ayaz" Date: Mon, 6 May 2024 21:28:53 +0300 Subject: [PATCH] refactor: centralize layout --- src/i18n/en.ts | 11 ++- src/ui/components/WidgetLayout.vue | 71 +++++++++++++++ src/ui/styles/main.css | 130 ++++++++++++++------------- src/ui/utils/index.ts | 11 ++- src/ui/views/Consent.vue | 83 ++++++++--------- src/ui/views/FillMissing.vue | 59 ++++++------ src/ui/views/ForgotPassword.vue | 51 ++++------- src/ui/views/Login.vue | 134 +++++++++++++-------------- src/ui/views/Register.vue | 134 +++++++++++++-------------- src/ui/views/ResetPassword.vue | 38 ++++---- src/ui/views/VerifyEmail.vue | 65 +++++--------- src/ui/views/mfa/Challenge.vue | 41 ++++----- src/ui/views/mfa/Email.vue | 93 +++++++++---------- src/ui/views/mfa/FingerVein.vue | 99 +++++++++----------- src/ui/views/mfa/OTP.vue | 135 +++++++++++----------------- src/ui/views/mfa/Push.vue | 122 ++++++++++--------------- src/ui/views/mfa/SMS.vue | 93 +++++++++---------- src/ui/views/mfa/WebAuthN.vue | 64 ++++++------- src/ui/views/passwordless/Email.vue | 78 +++++++--------- src/ui/views/passwordless/OTP.vue | 115 +++++++++--------------- src/ui/views/passwordless/Push.vue | 90 +++++++------------ src/ui/views/passwordless/SMS.vue | 84 ++++++++--------- src/ui/widget.ts | 20 +---- 23 files changed, 821 insertions(+), 1000 deletions(-) create mode 100644 src/ui/components/WidgetLayout.vue diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 35a8080..f35b949 100755 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -6,6 +6,7 @@ export default { days: 'days', edit: 'Edit', email: 'email', + enterOtp: 'Enter your code', field: 'Field', fields: { code: 'Code', @@ -81,6 +82,7 @@ export default { code_already_used: 'Code was already used', code_expired: 'Code has expired', email_not_verified: 'Email is not verified. Please verify your email by clicking the link that has been sent to your email account.', + invalid_entity: 'Invalid {field}', field_required: '{field} is required.', incorrect_code: 'Verification code is invalid', invalid_code: 'Code is invalid', @@ -114,12 +116,15 @@ export default { }, passwordless: { email: { + magicLinkTitle: 'Check your email', title: 'Enter authorization code sent to: {email}', checkText: "We\'ve sent an email to {email}, please click the link included" + ' to sign in. Make sure to open link in the same device/browser you are trying to sign in.', }, otp: { - title: 'Enter authorization code:' + registerTitle: 'Register Your Authenticator', + registerSubtitle: 'Open your preferred authenticator application and scan the QRCode below. If you have trouble scanning the code you can manually enter the code below image.', + title: 'Enter authorization code' }, sms: { title: 'Enter authorization code sent to: {phone_number}' @@ -156,7 +161,9 @@ export default { verify: 'Click to VERIFY when you are ready to scan your finger.' }, otp: { - title: 'Please enter authorization code' + title: 'Enter authorization code', + registerTitle: 'Register Your Authenticator', + registerSubtitle: 'Open your preferred authenticator application and scan the QRCode below. If you have trouble scanning the code you can manually enter the code below image.', }, push: { selectCode: 'Select number below from your device', diff --git a/src/ui/components/WidgetLayout.vue b/src/ui/components/WidgetLayout.vue new file mode 100644 index 0000000..84d270c --- /dev/null +++ b/src/ui/components/WidgetLayout.vue @@ -0,0 +1,71 @@ + + + + + diff --git a/src/ui/styles/main.css b/src/ui/styles/main.css index d24f333..27c7f79 100644 --- a/src/ui/styles/main.css +++ b/src/ui/styles/main.css @@ -6,6 +6,7 @@ @apply h-full; line-height: 1.5; tab-size: 4; + box-sizing: border-box; font-family: theme('fontFamily.sans', ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"); /* 4 */ -webkit-text-size-adjust: 100%; @@ -113,52 +114,6 @@ }; - &-info-section { - @apply text-center; - } - - &-social-section { - @apply text-center py-6; - } - - &-helpers-section { - @apply text-center py-4; - line-height: 24px; - - a { - padding-left: 4px; - } - + .widget-content-footer { - @apply mt-0; - } - } - - &-social-icons { - @apply flex justify-center pt-2 flex-wrap gap-2; - } - - &-social-button.btn { - @apply capitalize justify-start gap-4 bg-transparent text-gray-800 border border-gray-300 hover:bg-gray-100 hover:opacity-100; - - &-circle { - @apply w-10 h-10 p-0 rounded-full overflow-hidden; - - .widget-social-icon { - @apply w-10 h-10; - } - - &:hover{ - filter: brightness(0.8); - } - } - } - - &-social-icon { - @apply w-8 h-8; - background-repeat: no-repeat; - background-position: center center; - } - &-content { display: flex; flex-direction: column; @@ -169,13 +124,17 @@ @media (min-width: 601px) { display: block; - flex-shrink: 0; - margin: 0 auto; + margin: 16px auto; min-height: 0; width: 450px; } - + &-footer { + p { + @apply text-center; + } + } &-main { + @apply relative; box-flex: 1; flex-grow: 1; overflow: hidden; @@ -208,7 +167,7 @@ } &-footer { - @apply space-y-2; + @apply space-y-2 mt-auto; border: none; font-size: 14px; @@ -223,7 +182,50 @@ } - &-footer { + &-info-section { + @apply text-center pb-4; + } + + &-helpers-section { + @apply text-center py-4; + line-height: 24px; + + a { + padding-left: 4px; + } + + .widget-content-footer { + @apply mt-0; + } + } + + &-social-icons { + @apply flex justify-center py-4 flex-wrap gap-2; + } + + &-social-button.btn { + @apply capitalize justify-start gap-2 bg-transparent text-gray-800 border border-gray-300 hover:bg-gray-100 hover:opacity-100; + + &-circle { + @apply w-10 h-10 p-0 rounded-full overflow-hidden; + + .widget-social-icon { + @apply w-10 h-10 ; + } + + &:hover{ + filter: brightness(0.8); + } + } + } + + &-social-icon { + @apply w-8 h-8 flex-shrink-0; + background-repeat: no-repeat; + background-position: center center; + } + + + &-footer { align-items: center; display: flex; flex-wrap: wrap; @@ -313,18 +315,10 @@ } .qr-code { + @apply mx-auto mb-4; border: 1px solid lightgray; - } - - .column { - display: flex; - flex-direction: column; - } - - .row { - display: flex; - flex-direction: row; - flex-wrap: wrap; + object-position: center; + max-width: 220px; max-height: 220px; } .challenge-timer { @@ -341,7 +335,7 @@ } hr { - @apply flex items-center text-center text-gray-500 mb-3; + @apply flex items-center text-center text-gray-500 my-0; &::before, &::after { @@ -357,5 +351,15 @@ @apply ml-4; } } + input::-webkit-outer-spin-button, + input::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; + } + + /* Firefox */ + input[type=number] { + -moz-appearance: textfield; + } } diff --git a/src/ui/utils/index.ts b/src/ui/utils/index.ts index 8455e5a..a088c21 100755 --- a/src/ui/utils/index.ts +++ b/src/ui/utils/index.ts @@ -103,8 +103,15 @@ export function looseEqual(a: any, b: any): boolean { } } -export function resolveClientLogo(client: IClient) { - return client?.logoUri || 'https://static.plusauth.com/images/logo.png' +export function resolveLogo(logoOrObj: string | IClient) { + if(typeof logoOrObj === 'string'){ + if(logoOrObj.startsWith('http') || logoOrObj.startsWith('/')){ + return logoOrObj + } else { + return `https://static.plusauth.com/${logoOrObj}` + } + } + return logoOrObj?.logoUri || 'https://static.plusauth.com/images/logo.png' } export function keysToDotNotation(obj: Record, diff --git a/src/ui/views/Consent.vue b/src/ui/views/Consent.vue index 71b62ca..03b1c39 100755 --- a/src/ui/views/Consent.vue +++ b/src/ui/views/Consent.vue @@ -1,68 +1,61 @@