Skip to content

Commit

Permalink
Hint text radios fix (#88)
Browse files Browse the repository at this point in the history
* Add hint text to radio button fieldsets

* Add hint to radiobutton macro

* Add endif

* fix up a bit (Thanks Steve!)
  • Loading branch information
Keith Emmerson authored Oct 9, 2019
1 parent 6822cad commit a696e23
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
1 change: 0 additions & 1 deletion assets/scss/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@

&__legend {
border-bottom: 0;
margin-bottom: $space-md;

* {
margin: 0;
Expand Down
4 changes: 4 additions & 0 deletions assets/scss/components/_multiple-choice.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
}
}

.multiple-choice--radios {
margin-top: $space-md;
}

.multiple-choice--radios .multiple-choice__item {
> input[type='radio'] {
top: -2px;
Expand Down
2 changes: 1 addition & 1 deletion routes/questions-1/questions-1.njk
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

{{ radioButtons('consent', { '1':'Verbally','2':'On paper'}, data.consent, 'form.consent', errors) }}

{{ radioButtons('is_business', { '1':'Yes','2':'No'}, data.is_business, 'form.is_business', {hint: 'form.is_business.desc'}, errors) }}
{{ radioButtons('is_business', { '1':'Yes','2':'No'}, data.is_business, 'form.is_business', errors, {hint: 'form.is_business.desc'}) }}

<div class="toggle-area">
{{ radioButtons('recording_type', { 'on-1':'Video and audio','on-2':'Audio only','on-3':'Screen recording with audio','off-1':'Screen recording only','off-2':'No recording'}, data.recording_type, 'form.recording_type', errors) }}
Expand Down
9 changes: 7 additions & 2 deletions views/macros/radios.njk
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{% macro radioButtons(key, values, value, question, errors, attributes) %}
<div class="{{ 'has-error' if errors and errors[key] }}">
<fieldset class="fieldset">
<legend class="fieldset__legend">{{ __(question) }}</legend>
<legend class="fieldset__legend">
{{ __(question) }}
</legend>
{% if attributes.hint %}
<span class="form-message">{{ __(attributes.hint) }}</span>
{% endif %}
<div class="multiple-choice multiple-choice--radios" id="{{ key }}">
{% if errors and errors[key] %}
{{ validationMessage(errors[key].msg, key) }}
Expand All @@ -15,4 +20,4 @@
</div>
</fieldset>
</div>
{% endmacro %}
{% endmacro %}

0 comments on commit a696e23

Please sign in to comment.