-
Notifications
You must be signed in to change notification settings - Fork 0
FIT-134 Hide password hints and helptext when signing up #364
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
Open
mkirkeng-leukeleu
wants to merge
7
commits into
main
Choose a base branch
from
FIT-134-hide-password-hints-and-helptext-when-signing-up
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b64661d
Only show help text if there are errors on registration form
mkirkeng-leukeleu 89dcb14
Show second password field help text
mkirkeng-leukeleu 09d90ad
Modify the user_creation_template to add a tooltip instead form code
mkirkeng-leukeleu b88874a
Use include instead of extend on base_form
mkirkeng-leukeleu 448b4d9
Manually add request into form render context
mkirkeng-leukeleu ad5139d
Use html element attribute directly
mkirkeng-leukeleu c754f6e
Don't evaluate dictionary access if not necessary
mkirkeng-leukeleu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
packages/hidp/hidp/templates/hidp/accounts/forms/user_creation_form.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,105 @@ | ||
| {% extends 'hidp/includes/forms/base_form.html' %} | ||
|
|
||
| {% block form %} | ||
|
|
||
| {% comment %} | ||
| the following is a modified version of /django/forms/templates/django/forms/div.html | ||
| {% endcomment %} | ||
| <style> | ||
| form label { | ||
| display: inline-block; | ||
| } | ||
|
|
||
| #info-tooltip, | ||
| #info-tooltip summary { | ||
| display: inline; | ||
| } | ||
|
|
||
| #info-tooltip svg { | ||
| width: 1rem; | ||
| height: 1rem; | ||
| vertical-align: sub; | ||
| cursor: pointer; | ||
| user-select: none; | ||
| } | ||
| </style> | ||
|
|
||
| {{ errors }} | ||
| {% if errors and not fields %} | ||
| <div>{% for field in hidden_fields %}{{ field }}{% endfor %}</div> | ||
| {% endif %} | ||
| {% for field, errors in fields %} | ||
| <div | ||
| {% with classes=field.css_classes %} | ||
| {% if classes %} | ||
| class="{{ classes }} input-div" | ||
| {% else %} | ||
| class="input-div" | ||
| {% endif %} | ||
| {% endwith %} | ||
| > | ||
| {% if field.use_fieldset %} | ||
| <fieldset> | ||
| {% if field.label %}{{ field.legend_tag }}{% endif %} | ||
| {% else %} | ||
| {% if field.label %}{{ field.label_tag }}{% endif %} | ||
| {% endif %} | ||
|
|
||
| {% if field.name == "password1" %} | ||
| <details id="info-tooltip"> | ||
| <summary> | ||
| {% comment %} inline svg so stroke can pick up the "currentColor" {% endcomment %} | ||
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> | ||
| <!-- Icon from IconaMoon by Dariush Habibpour - https://creativecommons.org/licenses/by/4.0/ --> | ||
| <g fill="none" stroke="currentColor" stroke-linejoin="round"> | ||
| <circle cx="12" cy="12" r="9" stroke-linecap="round" stroke-width="1.5"/> | ||
| <path stroke-width="2.25" d="M12 8h.01v.01H12z"/> | ||
| <path stroke-linecap="round" stroke-width="1.5" d="M12 12v4"/> | ||
| </g> | ||
| </svg> | ||
| </summary> | ||
| <div class="helptext">{{ field.help_text|safe }}</div> | ||
| </details> | ||
| <script defer> | ||
| let openedByHover = false | ||
| const toolTipElement = document.getElementById('info-tooltip') | ||
|
|
||
| toolTipElement.addEventListener('mouseenter', () => { | ||
| if (!toolTipElement.getAttribute('open')) { | ||
| toolTipElement.setAttribute('open', 'true') | ||
| openedByHover = true | ||
| } | ||
| }) | ||
|
|
||
| toolTipElement.addEventListener('mouseleave', () => { | ||
| if (toolTipElement.getAttribute('open') && openedByHover) { | ||
| toolTipElement.removeAttribute('open') | ||
| openedByHover = false | ||
| } | ||
| }) | ||
|
|
||
| toolTipElement.addEventListener('click', (event) => { | ||
| // if opened by hover and click, keep it open and mark it as not opened by hover | ||
| if (openedByHover) { | ||
| event.stopPropagation() | ||
| event.preventDefault() | ||
| openedByHover = false | ||
| } | ||
| }) | ||
| </script> | ||
| {% elif field.help_text %} | ||
| <div class="helptext">{{ field.help_text|safe }}</div> | ||
| {% endif %} | ||
|
|
||
| {{ errors }} | ||
| {{ field }} | ||
| {% if field.use_fieldset %}</fieldset>{% endif %} | ||
| {% if forloop.last %} | ||
| {% for field in hidden_fields %}{{ field }}{% endfor %} | ||
| {% endif %} | ||
| </div> | ||
| {% endfor %} | ||
| {% if not fields and not errors %} | ||
| {% for field in hidden_fields %}{{ field }}{% endfor %} | ||
| {% endif %} | ||
| {% endblock %} | ||
4 changes: 3 additions & 1 deletion
4
packages/hidp/hidp/templates/hidp/includes/forms/base_form.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| {% extends 'django/forms/div.html' %} | ||
| {% block form %} | ||
| {% include 'django/forms/div.html' %} | ||
| {% endblock form %} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.