-
Notifications
You must be signed in to change notification settings - Fork 107
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 #603 from nhsuk/feature/173-conditional-inputs
Conditional content for radios and checkboxes
- Loading branch information
Showing
35 changed files
with
2,133 additions
and
3,261 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
{% set html_style = 'background-color: #f0f4f5;' %} | ||
{% set title = 'Checkboxes with conditional content' %} | ||
{% 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"> | ||
{{ 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", | ||
"conditional": { | ||
"html": emailHtml | ||
} | ||
}, | ||
{ | ||
"value": "phone", | ||
"text": "Phone", | ||
"conditional": { | ||
"html": phoneHtml | ||
} | ||
}, | ||
{ | ||
"value": "text", | ||
"text": "Text message", | ||
"conditional": { | ||
"html": mobileHtml | ||
} | ||
} | ||
] | ||
}) }} | ||
</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,90 @@ | ||
{% set html_style = 'background-color: #f0f4f5;' %} | ||
{% set title = 'Radios with conditonal content' %} | ||
{% from 'components/radios/macro.njk' import radios %} | ||
{% 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"> | ||
{{ radios({ | ||
"idPrefix": "contact", | ||
"name": "contact", | ||
"fieldset": { | ||
"legend": { | ||
"text": "How would you prefer to be contacted?", | ||
"classes": "nhsuk-fieldset__legend--l", | ||
"isPageHeading": "true" | ||
} | ||
}, | ||
"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 | ||
} | ||
} | ||
] | ||
}) }} | ||
</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
Oops, something went wrong.