Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving to single password field for registration #7729

Merged
merged 5 commits into from
Feb 13, 2024

Conversation

Ari1009
Copy link
Contributor

@Ari1009 Ari1009 commented Mar 25, 2023

Closes #7645

An button to show and hide password

Technical

Changes in html and a python file. Also used fontawesome eye icon

Testing

docker compose up , then redirect to sign in page.

Screenshot

Before
Screenshot_2023-03-25-06-48-05_1920x1080
After
Screenshot_2023-03-25-06-43-27_1920x1080

Stakeholders

@beccat123

@Ari1009 Ari1009 changed the title Passwd_vis Passwd_visibility Mar 25, 2023
@mekarpeles mekarpeles self-assigned this Mar 27, 2023
@mekarpeles mekarpeles added the Priority: 3 Issues that we can consider at our leisure. [managed] label Mar 27, 2023
@mekarpeles mekarpeles changed the title Passwd_visibility Moving to single passwd for registration Apr 3, 2023
@RayBB RayBB added the Needs: Review This issue/PR needs to be reviewed in order to be closed or merged (see comments). [managed] label Oct 26, 2023
@mekarpeles mekarpeles assigned jimchamp and unassigned mekarpeles Nov 30, 2023
Copy link
Collaborator

@jimchamp jimchamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this @Ari1009! Sorry that this has taken so long to review.

I've left some review notes for this PR. Let me know if you're still interested in finishing this up. If not, I can make any necessary updates to this branch so that your contribution makes it into our codebase.

@@ -28,12 +28,16 @@ <h1>$_("Sign Up")</h1>
<span class="smaller lighter">$input.help</span>
</div>
<div class="input">
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<script src="https://kit.fontawesome.com/a076d05399.js"></script>

This script tag is being added to the page each time that field is called in this template. Anyway, we should save a copy of each visibility icon in our images directory.

$:input.render()
$if input.name == 'password':
$:suffix
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$:suffix
<span class="password-visibility-toggle password-visibility-toggle--hidden"></span>

There is no suffix being passed for the password field. Just render the icon here, instead.

passwordInput.parentNode.appendChild(passwordVisibilityToggle);
});
</script>
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
</div>
</div>

Add a trailing newline character to the end of this file.

Comment on lines 81 to 88
<style>
#password-visibility-toggle {
font-size: 14px;
margin-left: 5px;
cursor: pointer;
}

</style>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<style>
#password-visibility-toggle {
font-size: 14px;
margin-left: 5px;
cursor: pointer;
}
</style>

We try to avoid adding inline styles whenever possible. New rules for the password field should be added to https://github.com/internetarchive/openlibrary/blob/master/static/css/components/form.olform.less

Comment on lines 89 to 107
<script>
window.addEventListener("load", function() {
var passwordInput = document.getElementById("password");
var passwordVisibilityToggle = document.createElement("span");
passwordVisibilityToggle.id = "password-visibility-toggle";
passwordVisibilityToggle.innerHTML = '<i class="far fa-eye"></i>';
passwordVisibilityToggle.addEventListener("click", function(e) {
e.preventDefault();
if (passwordInput.type === "password") {
passwordInput.type = "text";
passwordVisibilityToggle.innerHTML = '<i class="far fa-eye-slash"></i>';
} else {
passwordInput.type = "password";
passwordVisibilityToggle.innerHTML = '<i class="far fa-eye"></i>';
}
});
passwordInput.parentNode.appendChild(passwordVisibilityToggle);
});
</script>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<script>
window.addEventListener("load", function() {
var passwordInput = document.getElementById("password");
var passwordVisibilityToggle = document.createElement("span");
passwordVisibilityToggle.id = "password-visibility-toggle";
passwordVisibilityToggle.innerHTML = '<i class="far fa-eye"></i>';
passwordVisibilityToggle.addEventListener("click", function(e) {
e.preventDefault();
if (passwordInput.type === "password") {
passwordInput.type = "text";
passwordVisibilityToggle.innerHTML = '<i class="far fa-eye-slash"></i>';
} else {
passwordInput.type = "password";
passwordVisibilityToggle.innerHTML = '<i class="far fa-eye"></i>';
}
});
passwordInput.parentNode.appendChild(passwordVisibilityToggle);
});
</script>

We try to avoid adding inline Javascript whenever possible. The click handler for the password visibility toggle affordance should probably be in this file, which contains other functions related to account creation:

https://github.com/internetarchive/openlibrary/blob/master/tests/unit/js/realtime_account_validation.test.js

@jimchamp jimchamp added Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] and removed Needs: Review This issue/PR needs to be reviewed in order to be closed or merged (see comments). [managed] labels Dec 5, 2023
@jimchamp jimchamp changed the title Moving to single passwd for registration Moving to single password field for registration Dec 8, 2023
@jimchamp jimchamp removed the Priority: 3 Issues that we can consider at our leisure. [managed] label Dec 8, 2023
@codecov-commenter
Copy link

codecov-commenter commented Dec 22, 2023

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (5c72f35) 16.68% compared to head (7544828) 16.63%.

Files Patch % Lines
...nlibrary/plugins/openlibrary/js/password-toggle.js 0.00% 9 Missing and 1 partial ⚠️
openlibrary/plugins/openlibrary/js/index.js 0.00% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7729      +/-   ##
==========================================
- Coverage   16.68%   16.63%   -0.05%     
==========================================
  Files          88       89       +1     
  Lines        4681     4695      +14     
  Branches      835      838       +3     
==========================================
  Hits          781      781              
- Misses       3384     3396      +12     
- Partials      516      518       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jimchamp jimchamp added Needs: Review This issue/PR needs to be reviewed in order to be closed or merged (see comments). [managed] and removed Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] labels Dec 22, 2023
@jimchamp
Copy link
Collaborator

Updated the branch with the suggested changes. Using "Show password" and "Hide password" in place of the eye icons, as only one icon was available in the Figma. Suspect that we'll be changing this in the near future.

show_hide_password

Mobile view:
Screenshot from 2023-12-22 13-45-00

@jimchamp jimchamp removed their assignment Jan 4, 2024
@jimchamp
Copy link
Collaborator

jimchamp commented Jan 4, 2024

Somebody other than me needs to review this, as I have added my own commits.

@scottbarnes scottbarnes added On testing.openlibrary.org This PR has been deployed to testing.openlibrary.org for testing and removed Needs: Review This issue/PR needs to be reviewed in order to be closed or merged (see comments). [managed] labels Jan 19, 2024
@scottbarnes scottbarnes merged commit 5098757 into internetarchive:master Feb 13, 2024
4 checks passed
Achorn pushed a commit to Achorn/openlibrary that referenced this pull request Mar 14, 2024
* Use localized strings
* Adjust margin for password inputs
---------

Co-authored-by: James Champ <jameschamp@acm.org>
@jimchamp jimchamp removed the On testing.openlibrary.org This PR has been deployed to testing.openlibrary.org for testing label Apr 2, 2024
@Ari1009 Ari1009 deleted the passwd branch May 22, 2024 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable single-field password entry for email sign-ups
6 participants