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

reCAPTCHA: Elig Index, Elig Confirm - Add reCAPTCHA text, hide flag #2586

Open
wants to merge 18 commits into
base: refactor/recaptcha-copy
Choose a base branch
from

Conversation

machikoyasuda
Copy link
Member

@machikoyasuda machikoyasuda commented Dec 11, 2024

closes #2541

What this PR does

This ticket actually adds the reCAPTCHA text to 2 forms (Eligibility Confirm, Eligibility Index) and hides the badge.

  • Creates a recaptcha-text includes with the English and Spanish text
  • Includes recaptcha-text in form.html within the if request.recaptcha block, so that it shows up automatically on where recaptcha is used
  • Adds CSS to: hide the badge via visibility hidden, updates form-text class to fix the form field helper letter-spacing, and use that same class for the recaptcha text, adds styling so that the external link icon is smaller for the smaller text
  • Minor div/spacing refactors on form and template pages.

Testing notes

  • Use Fix: reCAPTCHA + HTML5 form validation #1071 instructions to test in Dev. The reCAPTCHA test environment key/secret are in LastPass, under Benefits reCAPTCHA configuration.
  • Post-merge test plan: When this PR is merged into dev, we can first test that the reCAPTCHA message does not show up. It should not show up b/c reCAPTCHA is not enabled. Once we do turn reCAPTCHA on, then we can test that the reCAPTCHA text turns on and the feature is enabled.

Screenshots

Desktop Mobile
Screenshot 2024-12-16 at 16-48-34 Choose benefit option Cal-ITP Benefits Screenshot 2024-12-16 at 16-49-02 Choose benefit option Cal-ITP Benefits
Screenshot 2024-12-16 at 16-48-44 Agency card information Cal-ITP Benefits Screenshot 2024-12-16 at 16-48-54 Agency card information Cal-ITP Benefits

@machikoyasuda machikoyasuda self-assigned this Dec 11, 2024
@github-actions github-actions bot added i18n Copy: Language files or Django i18n framework front-end HTML/CSS/JavaScript and Django templates labels Dec 11, 2024
Copy link

github-actions bot commented Dec 11, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  benefits/eligibility
  forms.py
Project Total  

This report was generated by python-coverage-comment-action

Comment on lines 31 to 37

{% block call-to-action %}
{% endblock call-to-action %}
Copy link
Member Author

Choose a reason for hiding this comment

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

Why is this here?

It's here to ensure that more spacing is not created. If this is not here, then the base.html will put this HTML on the page, which includes pt-8 -- which we do not want:

            <div class="row d-flex justify-content-center pt-8">
              <div class="col-12 col-lg-6">
                {% block call-to-action-button %}
                {% endblock call-to-action-button %}
              </div>
            </div>

There's an alternate way to achieve this. I could have put this code on both eligibility/confirm.html and eligibility/index.html:

                {% block call-to-action-button %}
                    {% include "core/includes/recaptcha-text.html" %}
                {% endblock call-to-action-button %}

But it felt semantically incorrect to put text into code that was meant to be for a button only. And I didn't want to come up with a more generic name to rename call-to-action-button or rename all those on the other templates... So I went with this method instead.

Copy link
Member

Choose a reason for hiding this comment

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

This sounds reasonable 👍 I think a comment above the empty block in this file just indicating that it is there for a reason (maybe a link to this thread here?) would be helpful for the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added comments in both templates to clarify what is going on there

Comment on lines 14 to 16
--bs-font-sans-serif: Roboto, system-ui, -apple-system, "Segoe UI", sans-serif,
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
--bs-font-sans-serif: Roboto, system-ui, -apple-system, "Segoe UI",
sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
"Noto Color Emoji";
Copy link
Member Author

Choose a reason for hiding this comment

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

Wait why does pre-commit do this to me T_T

@machikoyasuda machikoyasuda force-pushed the feat/2541-recaptcha-add-link-hide-flag branch from dee6b3f to 303a5b1 Compare December 11, 2024 23:01
@@ -556,7 +564,7 @@ footer .footer-links li a.footer-link:visited {
.form-text {
font-size: var(--font-size-14px);
line-height: var(--form-field-text-line-height);
letter-spacing: var(--letter-spacing-5);
letter-spacing: calc(var(--font-size-14px) * var(--letter-spacing-5));
Copy link
Member Author

Choose a reason for hiding this comment

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

image This letter-spacing update affects not just reCAPTCHA text, but the form field helper text as well. It was not updated on Production.

The way this is calculated: In Figma, click on the text. In the Dev resources sidebar, ensure Properties is enabled (instead of Code). Look for the letter spacing percentage:
image

Multiply the percentage with the font size.

@@ -517,26 +533,18 @@ footer .footer-links li a.footer-link:visited {
}

/* Forms: Text Inputs */
/* Form Container: Must use .form-container parent to use these styles */
/* Form Field Container: Must use .form-container parent to use these styles */
Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed this for clarity. Each .form-field-container wraps one of these as a unit
image

.form-container made it seem like it was wrapping the entire form, which is kinda true for Elig Index but not on Elig Confirm.

Comment on lines -9 to -27
<div class="row form-container justify-content-center">
<div class="{{ form.classes }}">
{% for field in form %}
<div class="row form-group mb-0">
<div class="col-12">
{# djlint:off #}
{% if field.label %}
<label for="{{ field.id_for_label }}" class="form-control-label">{{ field.label }}{% if field.field.required %}<span class="required-label text-body">*</span>{% endif %}
</label>
{% endif %}
{# djlint:on #}

{{ field }}

{% if field.help_text %}<small class="d-block mt-2 pt-1 form-text text-body">{{ field.help_text }}</small>{% endif %}
</div>
</div>
{% endfor %}
</div>
Copy link
Member Author

Choose a reason for hiding this comment

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

All of these row justify-content-center, row, col-12 are unnecessary.

Comment on lines -31 to -32
<div class="row d-flex justify-content-center pt-8">
<div class="col-lg-6">
Copy link
Member Author

Choose a reason for hiding this comment

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

Now longer needed.

@machikoyasuda machikoyasuda force-pushed the feat/2541-recaptcha-add-link-hide-flag branch from f19ba58 to 36b9a3b Compare December 11, 2024 23:32
Comment on lines 300 to 303
.eligibility-confirm footer {
margin-top: 24px;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

image

The Elig Index page's reCAPTCHA text has 64px padding both above and below the text, but the Elig Confirm's has 64px above and 24px below. So this class allows us to get that. This is the only page on the whole app, aside from the Index page, to not have that 64px buffer above the footer.

Copy link
Member

@angela-tran angela-tran Dec 17, 2024

Choose a reason for hiding this comment

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

I narrowed down the issue I mentioned in #2586 (comment) for confirm.html to this style... somehow this is causing the footer to have spacing on the bottom?

Screenshot from 2024-12-17 13-51-25

Screenshot from 2024-12-17 13-51-43

@@ -517,26 +533,18 @@ footer .footer-links li a.footer-link:visited {
}

/* Forms: Text Inputs */
/* Form Container: Must use .form-container parent to use these styles */
/* Form Field Container: Must use .form-field-container parent to use these styles */
Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed this b/c this div is a container around one form field, rather than the entire form.

Comment on lines 522 to 524
:root {
--form-input-gap: calc(24rem / 16);
}

.form-container .form-group:not(:first-child) {
padding-top: var(--form-input-gap);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Use the d-flex flex-column gap-4 CSS class to achieve this instead.

@machikoyasuda machikoyasuda marked this pull request as ready for review December 11, 2024 23:43
@machikoyasuda machikoyasuda requested a review from a team as a code owner December 11, 2024 23:43
@machikoyasuda machikoyasuda changed the title reCAPTCHA: Add text, hide flag reCAPTCHA: Elig Index, Elig Confirm: Add text, hide flag Dec 12, 2024
@machikoyasuda machikoyasuda changed the title reCAPTCHA: Elig Index, Elig Confirm: Add text, hide flag reCAPTCHA: Elig Index, Elig Confirm - Add text, hide flag Dec 12, 2024
@machikoyasuda machikoyasuda marked this pull request as draft December 12, 2024 00:15
@machikoyasuda machikoyasuda marked this pull request as ready for review December 12, 2024 01:25
@machikoyasuda
Copy link
Member Author

This is ready for review.

Copy link
Member

@thekaveman thekaveman left a comment

Choose a reason for hiding this comment

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

Looking really good. Just a couple of questions.

@machikoyasuda machikoyasuda changed the title reCAPTCHA: Elig Index, Elig Confirm - Add text, hide flag reCAPTCHA: Elig Index, Elig Confirm - Add reCAPTCHA text, hide flag Dec 16, 2024
@machikoyasuda
Copy link
Member Author

machikoyasuda commented Dec 16, 2024

How to test reCAPTCHA locally: #1071

I added the test reCAPTCHA keys to the Benefits reCAPTCHA file in the Compiler Engineering LastPass shared doc.

@machikoyasuda machikoyasuda force-pushed the feat/2541-recaptcha-add-link-hide-flag branch from 9cefd75 to 9cfd2c6 Compare December 16, 2024 19:35
Copy link
Member

@angela-tran angela-tran left a comment

Choose a reason for hiding this comment

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

Changes are looking good. I noticed an odd CSS issue though with how we're trying to override the 64px top spacing for the footer with 24px.

Comment on lines 300 to 303
.eligibility-confirm footer {
margin-top: 24px;
}

Copy link
Member

@angela-tran angela-tran Dec 17, 2024

Choose a reason for hiding this comment

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

I narrowed down the issue I mentioned in #2586 (comment) for confirm.html to this style... somehow this is causing the footer to have spacing on the bottom?

Screenshot from 2024-12-17 13-51-25

Screenshot from 2024-12-17 13-51-43

@angela-tran
Copy link
Member

angela-tran commented Dec 17, 2024

@machikoyasuda can you check on this alignment issue on Enrollment Index? I see it only in this branch.

image

edit: maybe you've fixed it in #2588? I haven't checked yet

@machikoyasuda
Copy link
Member Author

@angela-tran Oh wow I don't know how those non-fixes on in there. For now, I just added those good ole divs on divs back again. But they'll all be removed in #2588

@machikoyasuda machikoyasuda linked an issue Dec 19, 2024 that may be closed by this pull request
{% csrf_token %}

<div class="row form-container justify-content-center">
<div class="{{ form.classes }}">
Copy link
Member

Choose a reason for hiding this comment

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

I think there's a regression in Benefits Admin coming from this change.

We have some styles in admin/styles.css so that descendant checkboxes will be on the left side:

/* Eligibility Page */
.checkbox-parent .form-group:last-of-type .col-12 {
display: flex;
flex-direction: row-reverse;
justify-content: start;
column-gap: 0.5rem;
margin-top: 2rem;
}
.checkbox-parent,
.checkbox-parent .form-group .col-12,
.checkbox-parent .form-group .col-12 #id_flow {
display: flex;
flex-direction: column;
row-gap: 1rem;
}

InPersonEligibilityForm has checkbox-parent in its classes, which would end up on this line, but now it's on the <form> element.

main this branch (with #2555 merged in locally... *)
image image

Not sure if we should put this <div> back or try to tweak the CSS?

(*When we're back in the new year, it'd be good to get all this reCAPTCHA work caught up with the fixes that are in main.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
front-end HTML/CSS/JavaScript and Django templates i18n Copy: Language files or Django i18n framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

reCAPTCHA: Add reCAPTCHA text and hide button
3 participants