From 303a5b141a1d6bc56fce6266798d5485524ae4de Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 11 Dec 2024 23:01:32 +0000 Subject: [PATCH] refactor: refactor form to allow for a mb-fix that shortens space under text for elig-confirm --- .../core/templates/core/includes/form.html | 63 +++++++++---------- benefits/eligibility/forms.py | 3 +- benefits/static/css/styles.css | 26 ++++---- 3 files changed, 43 insertions(+), 49 deletions(-) diff --git a/benefits/core/templates/core/includes/form.html b/benefits/core/templates/core/includes/form.html index 5b27ca3e9..695d9a9aa 100644 --- a/benefits/core/templates/core/includes/form.html +++ b/benefits/core/templates/core/includes/form.html @@ -3,41 +3,39 @@ {% url form.action_url as form_action %} -
+ {% csrf_token %} -
-
- {% for field in form %} -
-
- {# djlint:off #} - {% if field.label %} - - {% endif %} - {# djlint:on #} - - {{ field }} - - {% if field.help_text %}{{ field.help_text }}{% endif %} -
-
- {% endfor %} -
+
+ {% for field in form %} +
+ {# djlint:off #} + {% if field.label %} + + {% endif %} + {# djlint:on #} + + {{ field }} + + {% if field.help_text %}{{ field.help_text }}{% endif %} +
+ {% endfor %}
{% if form.submit_value %} -
-
- -
+
+
{% endif %} @@ -94,6 +92,8 @@ {% endcomment %} +
{% include "core/includes/recaptcha-text.html" %}
+ {% endif %} - -
{% include "core/includes/recaptcha-text.html" %}
- {% endif %} diff --git a/benefits/eligibility/forms.py b/benefits/eligibility/forms.py index 00baf1eff..3b7a74e46 100644 --- a/benefits/eligibility/forms.py +++ b/benefits/eligibility/forms.py @@ -28,7 +28,6 @@ def __init__(self, agency: models.TransitAgency, *args, **kwargs): super().__init__(*args, **kwargs) flows = agency.enrollment_flows.filter(supported_enrollment_methods__contains=models.EnrollmentMethods.DIGITAL) - self.classes = "col-lg-6" # second element is not used since we render the whole label using selection_label_template, # therefore set to None flow_field = self.fields["flow"] @@ -110,7 +109,7 @@ def __init__( self.headline = headline self.blurb = blurb - self.classes = "col-lg-6" + self.classes = "mb-fix" sub_widget = widgets.FormControlTextInput(placeholder=sub_placeholder) if sub_pattern: sub_widget.attrs.update({"pattern": sub_pattern}) diff --git a/benefits/static/css/styles.css b/benefits/static/css/styles.css index 99f5b2dd9..94346bd3c 100644 --- a/benefits/static/css/styles.css +++ b/benefits/static/css/styles.css @@ -58,6 +58,8 @@ li { margin: 0; } +/* Utility Classes */ + @media (min-width: 992px) { /* Utility Class: Padding bottom 64px on Desktop */ /* Pair with pb-4 on Form pages to get 24px on Mobile, 64px on Desktop */ @@ -86,6 +88,10 @@ li { list-style-type: disc; } +.mb-fix { + margin-bottom: -40px; +} + /* Links */ /* Same sizes for all screen widths: 18px */ a:not(.btn):not(.card) { @@ -527,18 +533,10 @@ footer .footer-links li a.footer-link:visited { } /* Forms: Text Inputs */ -/* Form Container: Must use .form-container parent to use these styles */ - -:root { - --form-input-gap: calc(24rem / 16); -} - -.form-container .form-group:not(:first-child) { - padding-top: var(--form-input-gap); -} +/* Form Field Container: Must use .form-container parent to use these styles */ -.form-container .form-control-label, -.form-container .required-label { +.form-field-container .form-control-label, +.form-field-container .required-label { font-size: var(--font-size-16px); font-weight: var(--medium-font-weight); line-height: var(--form-field-text-line-height); @@ -546,7 +544,7 @@ footer .footer-links li a.footer-link:visited { padding-bottom: calc(12rem / 16); } -.form-container .form-control { +.form-field-container .form-control { border-width: var(--border-width); border-radius: var(--border-radius); border-color: var(--primary-color); @@ -556,8 +554,8 @@ footer .footer-links li a.footer-link:visited { /* Input height should be 60px */ } -.form-container .form-control:focus, -.form-container .form-control:focus-visible { +.form-field-container .form-control:focus, +.form-field-container .form-control:focus-visible { outline: 3px solid var(--focus-color) !important; outline-offset: 2px !important; box-shadow: none !important;