Skip to content

Commit

Permalink
Allow labels and legends to be rendered on mutually exclusive fields (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bameyrick authored Jul 1, 2019
1 parent d0c2de1 commit 9dfc38e
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/components/input/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
"classes": params.fieldClasses,
"legendClasses": params.legendClasses,
"noField": params.noField,
"legend": params.label.text if params.mutuallyExclusive,
"legend": params.legend or params.label.text if params.mutuallyExclusive,
"dontVisuallyHideLegend": params.dontVisuallyHideLegend,
"description": params.label.description if params.mutuallyExclusive,
"mutuallyExclusive": params.mutuallyExclusive
}) %}
{% if params.label and not params.mutuallyExclusive %}
{% if params.label and not (params.mutuallyExclusive and not params.legend) %}
{{
onsLabel({
"for": params.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{{
onsCheckboxes({
"legend": "What type of central heating do you have?",
"dontVisuallyHideLegend": true,
"checkboxesLabel": "Select all that apply",
"name": "mutually-exclusive",
"checkboxes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
onsDateInput({
"id": "date-mutually-exclusive",
"legend": "When did you leave your last paid job?",
"dontVisuallyHideLegend": true,
"description": "For example, 31 3 2018",
"day": {
"label": {
Expand Down
1 change: 1 addition & 0 deletions src/components/mutually-exclusive/examples/email/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
onsInput({
"id": "email",
"type": "email",
"dontVisuallyHideLegend": true,
"label": {
"text": "Enter an email"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"id": "currency",
"type": "number",
"classes": "input--w-5",
"dontVisuallyHideLegend": true,
"attributes": {
"min": 0
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"id": "feedback",
"name": "feedback",
"classes": "input--w-30",
"dontVisuallyHideLegend": true,
"label": {
"text": "Why did you leave your last job?"
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/select/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{% call onsField({
"id": params.fieldId,
"legend": params.label.text if params.mutuallyExclusive,
"legend": params.legend or params.label.text if params.mutuallyExclusive,
"dontVisuallyHideLegend": params.dontVisuallyHideLegend,
"description": params.label.description if params.mutuallyExclusive,
"mutuallyExclusive": params.mutuallyExclusive,
Expand Down
2 changes: 1 addition & 1 deletion src/components/textarea/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{% call onsField({
"id": params.fieldId,
"legend": params.label.text if params.mutuallyExclusive,
"legend": params.legend or params.label.text if params.mutuallyExclusive,
"dontVisuallyHideLegend": params.dontVisuallyHideLegend,
"description": params.label.description if params.mutuallyExclusive,
"mutuallyExclusive": params.mutuallyExclusive,
Expand Down

0 comments on commit 9dfc38e

Please sign in to comment.