-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #756 from nhsuk/feature/checkboxes-none-of-these
Checkboxes - none of these JS behaviour
- Loading branch information
Showing
17 changed files
with
560 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
{% set html_style = 'background-color: #f0f4f5;' %} | ||
{% set title = 'Checkboxes with "none of the above" option' %} | ||
{% from 'components/checkboxes/macro.njk' import checkboxes %} | ||
{% from 'components/input/macro.njk' import input %} | ||
{% extends 'layout.njk' %} | ||
|
||
{% set emailHtml %} | ||
{{ input({ | ||
id: "email", | ||
name: "email", | ||
classes: "nhsuk-u-width-two-thirds", | ||
label: { | ||
text: "Email address" | ||
} | ||
}) }} | ||
{% endset -%} | ||
|
||
{% set phoneHtml %} | ||
{{ input({ | ||
id: "phone", | ||
name: "phone", | ||
classes: "nhsuk-u-width-two-thirds", | ||
label: { | ||
text: "Phone number" | ||
} | ||
}) }} | ||
{% endset -%} | ||
|
||
{% set mobileHtml %} | ||
{{ input({ | ||
id: "mobile", | ||
name: "mobile", | ||
classes: "nhsuk-u-width-two-thirds", | ||
label: { | ||
text: "Mobile phone number" | ||
} | ||
}) }} | ||
{% endset -%} | ||
|
||
{% block body %} | ||
|
||
<div class="nhsuk-width-container"> | ||
<main class="nhsuk-main-wrapper" id="maincontent"> | ||
|
||
<div class="nhsuk-grid-row"> | ||
<div class="nhsuk-grid-column-two-thirds"> | ||
<form> | ||
{{ checkboxes({ | ||
"idPrefix": "contact", | ||
"name": "contact", | ||
"fieldset": { | ||
"legend": { | ||
"text": "How would you prefer to be contacted?", | ||
"classes": "nhsuk-fieldset__legend--l", | ||
"isPageHeading": "true" | ||
} | ||
}, | ||
"hint": { | ||
"text": "Select all options that are relevant to you." | ||
}, | ||
"items": [ | ||
{ | ||
"value": "email", | ||
"text": "Email", | ||
"name": "email", | ||
"exclusiveGroup": "communication-preferences", | ||
"conditional": { | ||
"html": emailHtml | ||
} | ||
}, | ||
{ | ||
"value": "phone", | ||
"text": "Phone", | ||
"name": "phone", | ||
"exclusiveGroup": "communication-preferences", | ||
"conditional": { | ||
"html": phoneHtml | ||
} | ||
}, | ||
{ | ||
"value": "text", | ||
"text": "Text message", | ||
"name": "text", | ||
"exclusiveGroup": "communication-preferences", | ||
"conditional": { | ||
"html": mobileHtml | ||
} | ||
}, | ||
{ | ||
"divider": "or" | ||
}, | ||
{ | ||
"value": "none", | ||
"text": "None of the above", | ||
"name": "none", | ||
"exclusive": true, | ||
"exclusiveGroup": "communication-preferences" | ||
} | ||
] | ||
}) }} | ||
</form> | ||
</div> | ||
</div> | ||
|
||
</main> | ||
</div> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
{% set html_style = 'background-color: #f0f4f5;' %} | ||
{% set title = 'Radios with nested conditonal content' %} | ||
{% from 'components/radios/macro.njk' import radios %} | ||
{% from 'components/input/macro.njk' import input %} | ||
{% from 'components/warning-callout/macro.njk' import warningCallout %} | ||
{% extends 'layout.njk' %} | ||
|
||
{% set emailHtml %} | ||
{{ input({ | ||
id: "email", | ||
name: "email", | ||
classes: "nhsuk-u-width-two-thirds", | ||
label: { | ||
text: "Email address" | ||
} | ||
}) }} | ||
{% endset -%} | ||
|
||
{% set phoneHtml %} | ||
{{ input({ | ||
id: "phone", | ||
name: "phone", | ||
classes: "nhsuk-u-width-two-thirds", | ||
label: { | ||
text: "Phone number" | ||
} | ||
}) }} | ||
{% endset -%} | ||
|
||
{% set mobileHtml %} | ||
{{ input({ | ||
id: "mobile", | ||
name: "mobile", | ||
classes: "nhsuk-u-width-two-thirds", | ||
label: { | ||
text: "Mobile phone number" | ||
} | ||
}) }} | ||
{% endset -%} | ||
|
||
{%- set nestedConditional %} | ||
{{ radios({ | ||
"idPrefix": "inner", | ||
"name": "inner", | ||
"fieldset": { | ||
"legend": { | ||
"text": "How would you prefer to be contacted?", | ||
"classes": "nhsuk-fieldset__legend--l" | ||
} | ||
}, | ||
"hint": { | ||
"text": "Select one option." | ||
}, | ||
"items": [ | ||
{ | ||
"value": "email", | ||
"text": "Email", | ||
"conditional": { | ||
"html": emailHtml | ||
} | ||
}, | ||
{ | ||
"value": "phone", | ||
"text": "Phone", | ||
"conditional": { | ||
"html": phoneHtml | ||
} | ||
}, | ||
{ | ||
"value": "text", | ||
"text": "Text message", | ||
"conditional": { | ||
"html": mobileHtml | ||
} | ||
} | ||
] | ||
}) }} | ||
{% endset -%} | ||
|
||
{% block body %} | ||
|
||
<div class="nhsuk-width-container"> | ||
<main class="nhsuk-main-wrapper" id="maincontent"> | ||
|
||
<div class="nhsuk-grid-row"> | ||
<div class="nhsuk-grid-column-two-thirds"> | ||
|
||
{{ warningCallout({ | ||
"heading": "Important", | ||
"HTML": "<p>Please do everything in your power to avoid nested conditionals like this. The example is here to demonstrate that it works - not as a recommendation!</p>" | ||
}) }} | ||
<form> | ||
{{ radios({ | ||
"idPrefix": "outer", | ||
"name": "outer", | ||
"fieldset": { | ||
"legend": { | ||
"text": "How would you prefer to be contacted?", | ||
"classes": "nhsuk-fieldset__legend--l", | ||
"isPageHeading": "true" | ||
} | ||
}, | ||
"hint": { | ||
"text": "Select one option." | ||
}, | ||
"items": [ | ||
{ | ||
"value": "no-conditional", | ||
"text": "No conditional" | ||
}, | ||
{ | ||
"value": "nested", | ||
"text": "Nested conditional", | ||
"conditional": { | ||
"html": nestedConditional | ||
} | ||
} | ||
] | ||
}) }} | ||
</form> | ||
</div> | ||
</div> | ||
|
||
</main> | ||
</div> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.