From 510bb062ee1dcc51fec0ca4ccc5be2a6e8573e6e Mon Sep 17 00:00:00 2001 From: M Fahru Date: Thu, 11 Apr 2024 05:36:56 -0700 Subject: [PATCH] Merge pull request #17845 from overleaf/mf-add-icon-error-login-home [web][website-redesign] Add notification icon and make the notification text to be left-justified GitOrigin-RevId: 8a678f05fbd3467be87198aca2a631ff31d1fb7d --- .../js/features/form-helpers/hydrate-form.js | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/services/web/frontend/js/features/form-helpers/hydrate-form.js b/services/web/frontend/js/features/form-helpers/hydrate-form.js index 99c6c8160e..a3eeb8c159 100644 --- a/services/web/frontend/js/features/form-helpers/hydrate-form.js +++ b/services/web/frontend/js/features/form-helpers/hydrate-form.js @@ -222,17 +222,14 @@ function showMessagesNewStyle(formEl, messageBag) { } else { // No custom error element for key on page, append a new error message const messageElContainer = document.createElement('div') - messageElContainer.className = classNames( - 'notification', - 'text-centered', - { - 'notification-type-error': message.type === 'error', - 'notification-type-success': message.type !== 'error', - } - ) + messageElContainer.className = classNames('notification', { + 'notification-type-error': message.type === 'error', + 'notification-type-success': message.type !== 'error', + }) const messageEl = document.createElement('div') - messageEl.className = 'notification-content' + // create the message text + messageEl.className = 'notification-content text-left' messageEl.textContent = message.text || `Error: ${message.key}` messageEl.setAttribute('aria-live', 'assertive') messageEl.setAttribute( @@ -249,6 +246,17 @@ function showMessagesNewStyle(formEl, messageBag) { messageEl.append(listEl) } + // create the left icon + const icon = document.createElement('span') + icon.className = 'material-symbols' + icon.setAttribute('aria-hidden', 'true') + icon.innerText = message.type === 'error' ? 'error' : 'check_circle' + const messageIcon = document.createElement('div') + messageIcon.className = 'notification-icon' + messageIcon.appendChild(icon) + + // append icon first so it's on the left + messageElContainer.appendChild(messageIcon) messageElContainer.appendChild(messageEl) messagesEl.append(messageElContainer) }