diff --git a/.prettierrc.yml b/.prettierrc.yml index f105a4a8b1..f79c105d2f 100644 --- a/.prettierrc.yml +++ b/.prettierrc.yml @@ -1,3 +1,7 @@ -singleQuote: true -printWidth: 140 -trailingComma: all +{ + 'plugins': ['prettier-plugin-jinja-template'], + 'singleQuote': true, + 'printWidth': 140, + 'trailingComma': all, + 'overrides': [{ 'files': ['*.html', '*.njk'], 'options': { 'parser': 'jinja-template' } }], +} diff --git a/__snapshots__/layout/_template.spec.js.snap b/__snapshots__/layout/_template.spec.js.snap index b442da99c9..0433ebd75c 100644 --- a/__snapshots__/layout/_template.spec.js.snap +++ b/__snapshots__/layout/_template.spec.js.snap @@ -42,14 +42,17 @@ exports[`base page template matches the body block override snapshot 1`] = ` - + + + Content + + + " @@ -111,10 +116,12 @@ exports[`base page template matches the favicons block override snapshot 1`] = ` - + + +
@@ -122,7 +129,7 @@ exports[`base page template matches the favicons block override snapshot 1`] = ` - + Skip to main content @@ -132,7 +139,8 @@ exports[`base page template matches the favicons block override snapshot 1`] = ` - + + @@ -148,7 +156,9 @@ exports[`base page template matches the favicons block override snapshot 1`] = `
-

This website no longer supports your browser. You can upgrade your browser to the latest version.

+

+ This website no longer supports your browser. You can upgrade your browser to the latest version. +

@@ -156,9 +166,13 @@ exports[`base page template matches the favicons block override snapshot 1`] = `
-
@@ -219,12 +236,17 @@ exports[`base page template matches the favicons block override snapshot 1`] = `
-
+
+ + + +
Social survey
+
@@ -261,6 +283,7 @@ exports[`base page template matches the favicons block override snapshot 1`] = ` + + + " @@ -330,10 +355,12 @@ exports[`base page template matches the footer block override snapshot 1`] = ` - + + +
@@ -341,7 +368,7 @@ exports[`base page template matches the footer block override snapshot 1`] = ` - + Skip to main content @@ -351,7 +378,8 @@ exports[`base page template matches the footer block override snapshot 1`] = ` - + + @@ -367,7 +395,9 @@ exports[`base page template matches the footer block override snapshot 1`] = `
-

This website no longer supports your browser. You can upgrade your browser to the latest version.

+

+ This website no longer supports your browser. You can upgrade your browser to the latest version. +

@@ -375,9 +405,13 @@ exports[`base page template matches the footer block override snapshot 1`] = `
-
@@ -438,12 +475,17 @@ exports[`base page template matches the footer block override snapshot 1`] = `
-
+
+ + + +
Social survey
+
@@ -478,6 +520,7 @@ exports[`base page template matches the footer block override snapshot 1`] = ` + + + " @@ -571,10 +616,11 @@ exports[`base page template matches the full configuration snapshot 1`] = ` Some head content - + +
@@ -584,7 +630,7 @@ exports[`base page template matches the full configuration snapshot 1`] = ` Some preHeader content - + Skip to main content @@ -594,7 +640,8 @@ exports[`base page template matches the full configuration snapshot 1`] = ` - + + @@ -613,7 +660,9 @@ exports[`base page template matches the full configuration snapshot 1`] = `
-

This website no longer supports your browser. You can upgrade your browser to the latest version.

+

+ This website no longer supports your browser. You can upgrade your browser to the latest version. +

@@ -624,9 +673,9 @@ exports[`base page template matches the full configuration snapshot 1`] = `
-
- BETA -
+
+ BETA +

This is a new service – your feedback will help us improve it.

@@ -639,11 +688,12 @@ exports[`base page template matches the full configuration snapshot 1`] = `
-
- - @@ -724,24 +775,24 @@ exports[`base page template matches the full configuration snapshot 1`] = `
-
@@ -836,12 +887,13 @@ exports[`base page template matches the full configuration snapshot 1`] = `
+ - + +
ONS Service
- -
+ @@ -871,17 +923,17 @@ exports[`base page template matches the full configuration snapshot 1`] = ` - - + +
@@ -913,16 +965,16 @@ exports[`base page template matches the full configuration snapshot 1`] = ` - - + + @@ -943,35 +995,40 @@ exports[`base page template matches the full configuration snapshot 1`] = `
  • - Service standard + + Service standard
  • - Design system + + Design system
  • - Accessibility + + Accessibility
  • - Brand guidelines + + Brand guidelines
  • - Content style guide + + Content style guide
  • @@ -986,30 +1043,34 @@ exports[`base page template matches the full configuration snapshot 1`] = `
    - @@ -1245,7 +1322,6 @@ exports[`base page template matches the full configuration snapshot 1`] = ` - @@ -1256,7 +1332,6 @@ exports[`base page template matches the full configuration snapshot 1`] = `
    - @@ -1281,17 +1356,17 @@ exports[`base page template matches the full configuration snapshot 1`] = ` - - + +
    @@ -1320,47 +1395,52 @@ exports[`base page template matches the full configuration snapshot 1`] = ` + + + + + Respondent Charter + +
    @@ -1380,47 +1460,52 @@ exports[`base page template matches the full configuration snapshot 1`] = ` + + + + + Contact us + +
    @@ -1440,54 +1525,59 @@ exports[`base page template matches the full configuration snapshot 1`] = ` + + + + + News + +
    @@ -1516,60 +1606,66 @@ exports[`base page template matches the full configuration snapshot 1`] = ` + + + + + Terms and conditions + + @@ -1580,10 +1676,11 @@ exports[`base page template matches the full configuration snapshot 1`] = ` Open Government License logo - + - All content is available under the + All content is available under the + Open Government Licence v3.0  +
    @@ -1649,7 +1746,6 @@ exports[`base page template matches the full configuration snapshot 1`] = `
    -
    @@ -1658,6 +1754,7 @@ exports[`base page template matches the full configuration snapshot 1`] = `
    + + @@ -1725,10 +1823,12 @@ exports[`base page template matches the meta block override snapshot 1`] = ` - + + +
    @@ -1736,7 +1836,7 @@ exports[`base page template matches the meta block override snapshot 1`] = ` - + Skip to main content @@ -1746,7 +1846,8 @@ exports[`base page template matches the meta block override snapshot 1`] = ` - + + @@ -1762,7 +1863,9 @@ exports[`base page template matches the meta block override snapshot 1`] = `
    -

    This website no longer supports your browser. You can upgrade your browser to the latest version.

    +

    + This website no longer supports your browser. You can upgrade your browser to the latest version. +

    @@ -1770,9 +1873,13 @@ exports[`base page template matches the meta block override snapshot 1`] = `
    -
    @@ -1833,12 +1943,17 @@ exports[`base page template matches the meta block override snapshot 1`] = `
    -
    +
    + + + +
    Social survey
    +
    @@ -1875,6 +1990,7 @@ exports[`base page template matches the meta block override snapshot 1`] = ` + + + " @@ -1928,10 +2046,12 @@ exports[`base page template matches the social block override snapshot 1`] = ` - + + +
    @@ -1939,7 +2059,7 @@ exports[`base page template matches the social block override snapshot 1`] = ` - + Skip to main content @@ -1949,7 +2069,8 @@ exports[`base page template matches the social block override snapshot 1`] = ` - + + @@ -1965,7 +2086,9 @@ exports[`base page template matches the social block override snapshot 1`] = `
    -

    This website no longer supports your browser. You can upgrade your browser to the latest version.

    +

    + This website no longer supports your browser. You can upgrade your browser to the latest version. +

    @@ -1973,9 +2096,13 @@ exports[`base page template matches the social block override snapshot 1`] = `
    -
    @@ -2036,12 +2166,17 @@ exports[`base page template matches the social block override snapshot 1`] = `
    -
    +
    + + + +
    Social survey
    +
    @@ -2078,6 +2213,7 @@ exports[`base page template matches the social block override snapshot 1`] = ` + + + " diff --git a/package.json b/package.json index b9bc63c2ff..024b795f99 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "prettier --write", "yarn run stylelint-fix" ], - "*.{yml,yaml}": [ + "*.{yml,yaml,njk,html}": [ "prettier --write" ] }, @@ -109,7 +109,8 @@ "postcss": "^8.3.5", "postcss-url": "^10.1.3", "prepend-file": "^2.0.1", - "prettier": "^3.0.0", + "prettier": "^3.2.5", + "prettier-plugin-jinja-template": "^1.4.0", "puppeteer": "^21.0.2", "remark-cli": "^12.0.0", "remark-lint": "^9.1.2", diff --git a/src/components/access-code/_macro.njk b/src/components/access-code/_macro.njk index 0f9f0c92f3..4279f016c6 100644 --- a/src/components/access-code/_macro.njk +++ b/src/components/access-code/_macro.njk @@ -7,29 +7,33 @@ {% set maxlength = params.maxlength | default(16) + extraSpaces %} {% set content %} - {{ onsInput({ - "id": params.id, - "type": params.type, - "name": params.name, - "classes": "ons-access-code__input ons-js-access-code" + (" ons-u-mb-xs" if params.postTextboxLinkText else ""), - "label": params.label, - "attributes": { - "maxlength": maxlength, - "data-group-size": groupSize, - "autocomplete": "off", - "autocapitalize": "characters" - }, - "fieldClasses": "ons-question__answer", - "error": params.error, - "postTextboxLinkText": params.postTextboxLinkText, - "postTextboxLinkUrl": params.postTextboxLinkUrl - }) }} + {{ + onsInput({ + "id": params.id, + "type": params.type, + "name": params.name, + "classes": "ons-access-code__input ons-js-access-code" + (" ons-u-mb-xs" if params.postTextboxLinkText else ""), + "label": params.label, + "attributes": { + "maxlength": maxlength, + "data-group-size": groupSize, + "autocomplete": "off", + "autocapitalize": "characters" + }, + "fieldClasses": "ons-question__answer", + "error": params.error, + "postTextboxLinkText": params.postTextboxLinkText, + "postTextboxLinkUrl": params.postTextboxLinkUrl + }) + }} {% endset %} {% if not params.error %} - {% call onsPanel({ - "classes": "ons-u-mb-s" + (' ' + params.classes if params.classes else '') - }) %} + {% + call onsPanel({ + "classes": "ons-u-mb-s" + (" " + params.classes if params.classes else "") + }) + %} {{ content | safe }} {% endcall %} {% else %} @@ -37,11 +41,13 @@ {% endif %} {% if params.securityMessage %} - {% call onsPanel({ - "variant": "bare", - "iconType": "lock", - "classes": "ons-u-mb-s" - }) %} + {% + call onsPanel({ + "variant": "bare", + "iconType": "lock", + "classes": "ons-u-mb-s" + }) + %} {{ params.securityMessage }} {% endcall %} {% endif %} diff --git a/src/components/access-code/example-access-code-error.njk b/src/components/access-code/example-access-code-error.njk index 350d76c67e..52a904278a 100644 --- a/src/components/access-code/example-access-code-error.njk +++ b/src/components/access-code/example-access-code-error.njk @@ -1,22 +1,26 @@ --- -title: "Example: Access code error" +title: 'Example: Access code error' layout: ~ --- + {% extends "layout/_template.njk" %} {% from "components/access-code/_macro.njk" import onsAccessCode %} {% from "components/button/_macro.njk" import onsButton %} {% from "components/panel/_macro.njk" import onsPanel %} {% from "components/details/_macro.njk" import onsDetails %} - -{% set pageConfig = { - "title": "Study title" -} %} +{% + set pageConfig = { + "title": "Study title" + } +%} {% block main %} - {% call onsPanel({ - "title": "There is a problem with this page", - "variant": "error" - }) %} + {% + call onsPanel({ + "title": "There is a problem with this page", + "variant": "error" + }) + %} {% from "components/list/_macro.njk" import onsList %} {{ onsList({ @@ -34,46 +38,54 @@ layout: ~

    Start study

    - {{ onsAccessCode({ - "id": "access-code", - "name": "access-code", - "postTextboxLinkText": "Where to find your access code", - "postTextboxLinkUrl": "#0", - "label": { - "text": "Enter your 16-character access code", - "description": "Keep this code safe. You will need to enter it every time you access your survey" - }, - "securityMessage": "Your personal information is protected by law and will be kept confidential", - "error": { - "id": "access-code-error", - "text": "Enter an access code" - } - }) }} + {{ + onsAccessCode({ + "id": "access-code", + "name": "access-code", + "postTextboxLinkText": "Where to find your access code", + "postTextboxLinkUrl": "#0", + "label": { + "text": "Enter your 16-character access code", + "description": "Keep this code safe. You will need to enter it every time you access your survey" + }, + "securityMessage": "Your personal information is protected by law and will be kept confidential", + "error": { + "id": "access-code-error", + "text": "Enter an access code" + } + }) + }} - {{ onsButton({ - "text": "Access study", - "classes": "ons-u-mb-xl" - }) }} + {{ + onsButton({ + "text": "Access study", + "classes": "ons-u-mb-xl" + }) + }}

    If you do not have an access code

    - If you have lost or not received an access code, you can request a new access code. - This can be sent to you by text or post. + If you have lost or not received an access code, you can request a new access code. This can be sent to you by text + or post.

    {% set content %}

    If you need to answer separately from the people you live with, you can request an individual access code.

    - {% call onsPanel({ - "variant": "warn" - }) %} + {% + call onsPanel({ + "variant": "warn" + }) + %} Someone in your household must still complete a study using this household access code {% endcall %} {% endset %} - {% call onsDetails({ - "id": "details-access-code-error", - "title": "Need to answer separately from your household?" - }) %} + {% + call onsDetails({ + "id": "details-access-code-error", + "title": "Need to answer separately from your household?" + }) + %} {{ content | safe }} {% endcall %} {% endblock %} diff --git a/src/components/access-code/example-access-code.njk b/src/components/access-code/example-access-code.njk index f8cca16218..978fe640c1 100644 --- a/src/components/access-code/example-access-code.njk +++ b/src/components/access-code/example-access-code.njk @@ -1,58 +1,68 @@ --- -title: "Example: Access code" +title: 'Example: Access code' layout: ~ --- + {% extends "layout/_template.njk" %} {% from "components/access-code/_macro.njk" import onsAccessCode %} {% from "components/button/_macro.njk" import onsButton %} {% from "components/panel/_macro.njk" import onsPanel %} {% from "components/details/_macro.njk" import onsDetails %} - -{% set pageConfig = { - "header": { - "title": "Study title" +{% + set pageConfig = { + "header": { + "title": "Study title" + } } -} %} +%} {% block main %}

    Start study

    - {{ onsAccessCode({ - "id": "access-code-example", - "name": "access-code", - "postTextboxLinkText": "Where to find your access code", - "postTextboxLinkUrl": "#0", - "label": { - "text": "Enter your 16-character access code", - "description": "Keep this code safe. You will need to enter it every time you access your study" - }, - "securityMessage": "Your personal information is protected by law and will be kept confidential" - }) }} + {{ + onsAccessCode({ + "id": "access-code-example", + "name": "access-code", + "postTextboxLinkText": "Where to find your access code", + "postTextboxLinkUrl": "#0", + "label": { + "text": "Enter your 16-character access code", + "description": "Keep this code safe. You will need to enter it every time you access your study" + }, + "securityMessage": "Your personal information is protected by law and will be kept confidential" + }) + }} - {{ onsButton({ - "text": "Access study", - "classes": "ons-u-mb-xl" - }) }} + {{ + onsButton({ + "text": "Access study", + "classes": "ons-u-mb-xl" + }) + }}

    If you do not have an access code

    - If you have lost or not received an access code, you can request a new access code. - This can be sent to you by text or post. + If you have lost or not received an access code, you can request a new access code. This can be sent to you by text + or post.

    {% set content %}

    If you need to answer separately from the people you live with, you can request an individual access code.

    - {% call onsPanel({ - "variant": "warn" - }) %} + {% + call onsPanel({ + "variant": "warn" + }) + %} Someone in your household must still complete a study using this household access code {% endcall %} {% endset %} - {% call onsDetails({ - "id": "details", - "title": "Need to answer separately from your household?" - }) %} + {% + call onsDetails({ + "id": "details", + "title": "Need to answer separately from your household?" + }) + %} {{ content | safe }} {% endcall %} {% endblock %} diff --git a/src/components/accordion/_macro.njk b/src/components/accordion/_macro.njk index 1282d63595..e9134a67fd 100644 --- a/src/components/accordion/_macro.njk +++ b/src/components/accordion/_macro.njk @@ -1,15 +1,16 @@ {% macro onsAccordion(params) %} {% from "components/details/_macro.njk" import onsDetails %} -
    +
    {% if params.allButton %} {% from "components/button/_macro.njk" import onsButton %} {% set attributes = params.allButton.attributes | default({}) %} - - {% set attributes = attributes | setAttributes({ - "data-close-all": params.allButton.close, - "data-group": params.id - }) %} + {% + set attributes = attributes | setAttributes({ + "data-close-all": params.allButton.close, + "data-group": params.id + }) + %} {{ onsButton({ diff --git a/src/components/accordion/example-accordion-open.njk b/src/components/accordion/example-accordion-open.njk index 723940a13e..f814642b59 100644 --- a/src/components/accordion/example-accordion-open.njk +++ b/src/components/accordion/example-accordion-open.njk @@ -1,7 +1,6 @@ {% from "components/accordion/_macro.njk" import onsAccordion %} {% from "components/checkboxes/_macro.njk" import onsCheckboxes %} - {% set content1 %} {{ onsCheckboxes({ diff --git a/src/components/address-input/_macro.njk b/src/components/address-input/_macro.njk index cd4ce44d05..4e12a8ac90 100644 --- a/src/components/address-input/_macro.njk +++ b/src/components/address-input/_macro.njk @@ -3,10 +3,13 @@ {% from "components/input/_macro.njk" import onsInput %} {% macro onsAddressInput(params) %} - {% set fields %} -