From 102479524a8a6d4f03242a9740ac632c9469aaee Mon Sep 17 00:00:00 2001 From: Rebecca Shoptaw Date: Fri, 19 Jul 2024 10:38:26 -0400 Subject: [PATCH 1/7] Add loading and success indicators for backend checks --- openlibrary/i18n/messages.pot | 25 ++++++++++++++++---- openlibrary/plugins/openlibrary/js/signup.js | 18 ++++++++++++++ openlibrary/templates/account/create.html | 9 +++++-- static/css/page-signup.less | 4 ++-- 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/openlibrary/i18n/messages.pot b/openlibrary/i18n/messages.pot index 99b61dde84c..5d95836dd7e 100644 --- a/openlibrary/i18n/messages.pot +++ b/openlibrary/i18n/messages.pot @@ -1033,6 +1033,27 @@ msgid "" "nonprofit Internet Archive" msgstr "" +#: account/create.html +msgid "Toggle Password Visibility" +msgstr "" + +#: account/create.html books/custom_carousel.html +#: search/work_search_facets.html +msgid "Loading..." +msgstr "" + +#: account/create.html +msgid "Loading spinner" +msgstr "" + +#: account/create.html type/author/view.html +msgid "Success!" +msgstr "" + +#: account/create.html +msgid "Checkmark" +msgstr "" + #: account/create.html msgid "Your URL" msgstr "" @@ -6479,10 +6500,6 @@ msgstr "" msgid "Refresh the page?" msgstr "" -#: type/author/view.html -msgid "Success!" -msgstr "" - #: type/author/view.html msgid "" "OK. The merge is in motion. It will take a few minutes to " diff --git a/openlibrary/plugins/openlibrary/js/signup.js b/openlibrary/plugins/openlibrary/js/signup.js index 782f801d3cb..32fdfa70683 100644 --- a/openlibrary/plugins/openlibrary/js/signup.js +++ b/openlibrary/plugins/openlibrary/js/signup.js @@ -3,6 +3,10 @@ import { debounce } from './nonjquery_utils.js'; export function initSignupForm() { const signupForm = document.querySelector('form[name=signup]'); const i18nStrings = JSON.parse(signupForm.dataset.i18n); + const emailLoadingIcon = $('.ol-signup-form__input--email .ol-signup-form__icon--loading'); + const usernameLoadingIcon = $('.ol-signup-form__input--username .ol-signup-form__icon--loading'); + const emailSuccessIcon = $('.ol-signup-form__input--email .ol-signup-form__icon--success'); + const usernameSuccessIcon = $('.ol-signup-form__input--username .ol-signup-form__icon--success'); // Keep the same with openlibrary/plugins/upstream/forms.py const VALID_EMAIL_RE = /^.*@.*\..*$/; @@ -60,6 +64,8 @@ export function initSignupForm() { function validateUsername() { const value_username = $('#username').val(); + usernameSuccessIcon.hide(); + if (value_username === '') { clearError('#username', '#usernameMessage'); return; @@ -76,14 +82,19 @@ export function initSignupForm() { } clearError('#username', '#usernameMessage'); + usernameLoadingIcon.show(); $.ajax({ url: '/account/validate', data: { username: value_username }, type: 'GET', success: function(errors) { + usernameLoadingIcon.hide(); + if (errors.username) { renderError('#username', '#usernameMessage', errors.username); + } else { + usernameSuccessIcon.show(); } } }); @@ -92,6 +103,8 @@ export function initSignupForm() { function validateEmail() { const value_email = $('#emailAddr').val(); + emailSuccessIcon.hide(); + if (value_email === '') { clearError('#emailAddr', '#emailAddrMessage'); return; @@ -103,14 +116,19 @@ export function initSignupForm() { } clearError('#emailAddr', '#emailAddrMessage'); + emailLoadingIcon.show(); $.ajax({ url: '/account/validate', data: { email: value_email }, type: 'GET', success: function(errors) { + emailLoadingIcon.hide(); + if (errors.email) { renderError('#emailAddr', '#emailAddrMessage', errors.email); + } else { + emailSuccessIcon.show(); } } }); diff --git a/openlibrary/templates/account/create.html b/openlibrary/templates/account/create.html index 29828a0f954..cfe02696bb0 100644 --- a/openlibrary/templates/account/create.html +++ b/openlibrary/templates/account/create.html @@ -29,7 +29,7 @@

$_("Sign Up")

$# :param openlibrary.utils.form.Input input: $# :param str suffix: HTML to put at bottom of input - From e350230474c535ee44abab52ad9d55c52023ab6b Mon Sep 17 00:00:00 2001 From: Rebecca Shoptaw Date: Fri, 9 Aug 2024 16:14:55 -0400 Subject: [PATCH 5/7] Switch out loading indicator and check mark for new SVGs --- openlibrary/i18n/messages.pot | 12 ++---------- openlibrary/templates/account/create.html | 4 ++-- static/images/bubble-loader.svg | 1 + static/images/icons/icon_check-circle.svg | 1 + 4 files changed, 6 insertions(+), 12 deletions(-) create mode 100644 static/images/bubble-loader.svg create mode 100644 static/images/icons/icon_check-circle.svg diff --git a/openlibrary/i18n/messages.pot b/openlibrary/i18n/messages.pot index 5d95836dd7e..9856311dbde 100644 --- a/openlibrary/i18n/messages.pot +++ b/openlibrary/i18n/messages.pot @@ -429,7 +429,8 @@ msgstr "" msgid "Library Explorer" msgstr "" -#: books/custom_carousel.html login.html search/work_search_facets.html +#: account/create.html books/custom_carousel.html login.html +#: search/work_search_facets.html msgid "Loading..." msgstr "" @@ -1033,15 +1034,6 @@ msgid "" "nonprofit Internet Archive" msgstr "" -#: account/create.html -msgid "Toggle Password Visibility" -msgstr "" - -#: account/create.html books/custom_carousel.html -#: search/work_search_facets.html -msgid "Loading..." -msgstr "" - #: account/create.html msgid "Loading spinner" msgstr "" diff --git a/openlibrary/templates/account/create.html b/openlibrary/templates/account/create.html index c54bdd8b07f..3029dcfb32d 100644 --- a/openlibrary/templates/account/create.html +++ b/openlibrary/templates/account/create.html @@ -44,8 +44,8 @@

$_("Sign Up")

$else: diff --git a/static/images/bubble-loader.svg b/static/images/bubble-loader.svg new file mode 100644 index 00000000000..3dd35191723 --- /dev/null +++ b/static/images/bubble-loader.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/images/icons/icon_check-circle.svg b/static/images/icons/icon_check-circle.svg new file mode 100644 index 00000000000..3c1c2b8ca81 --- /dev/null +++ b/static/images/icons/icon_check-circle.svg @@ -0,0 +1 @@ + \ No newline at end of file From 962e963f2a40279ce79aa93491803d8377d3b1b3 Mon Sep 17 00:00:00 2001 From: Drini Cami Date: Mon, 30 Sep 2024 21:04:29 +0200 Subject: [PATCH 6/7] Use alt text targetted for screen readers --- openlibrary/templates/account/create.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlibrary/templates/account/create.html b/openlibrary/templates/account/create.html index 3029dcfb32d..2db12b20538 100644 --- a/openlibrary/templates/account/create.html +++ b/openlibrary/templates/account/create.html @@ -44,8 +44,8 @@

$_("Sign Up")

$else: From ba3aa44f2cfc111f480ea11a052fbe67948139da Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 19:05:59 +0000 Subject: [PATCH 7/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- openlibrary/i18n/messages.pot | 8 -------- 1 file changed, 8 deletions(-) diff --git a/openlibrary/i18n/messages.pot b/openlibrary/i18n/messages.pot index 9856311dbde..12a99a3b7c3 100644 --- a/openlibrary/i18n/messages.pot +++ b/openlibrary/i18n/messages.pot @@ -1034,18 +1034,10 @@ msgid "" "nonprofit Internet Archive" msgstr "" -#: account/create.html -msgid "Loading spinner" -msgstr "" - #: account/create.html type/author/view.html msgid "Success!" msgstr "" -#: account/create.html -msgid "Checkmark" -msgstr "" - #: account/create.html msgid "Your URL" msgstr ""