Skip to content

Commit

Permalink
Fix select help text spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
mmazanec22 authored and arinchoi03 committed Feb 6, 2025
1 parent aeedc1c commit 0ded2d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions app/assets/stylesheets/honeycrisp/atoms/_form-elements.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ label {
display: block;
margin-bottom: $s25;
font-weight: $font-weight-bold;
&.has-help {
margin-bottom: unset;
}
}

.text-input {
Expand Down
11 changes: 8 additions & 3 deletions app/helpers/cfa/styleguide/cfa_form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ def cfa_select(
label_contents(
label_text,
optional: options[:optional],
has_help_text: !!help_text,
),
class: options[:hide_label] ? "sr-only" : "",
)
Expand Down Expand Up @@ -457,9 +458,13 @@ def fieldset_label_contents(
label_html.html_safe
end

def label_contents(label_text, optional: false)
def label_contents(label_text, optional: false, has_help_text: false)
classes = ["form-question"]
if has_help_text
classes << "has-help"
end
label_text = <<~HTML
<span class="form-question">#{label_text + optional_text(optional)}</span>
<span class="#{classes.join(' ')}">#{label_text + optional_text(optional)}</span>
HTML

label_text.html_safe
Expand Down Expand Up @@ -495,7 +500,7 @@ def label_and_field(

formatted_label = label(
method,
label_contents(label_text, optional: optional),
label_contents(label_text, optional: optional, has_help_text: !!help_text),
(for_options || options),
)
formatted_label += notice_html(notice).html_safe if notice
Expand Down

0 comments on commit 0ded2d0

Please sign in to comment.