From 5550791070f7a9b67207a8e99bcc0db1850a5841 Mon Sep 17 00:00:00 2001 From: Michael Cheung Date: Fri, 25 Jan 2019 11:23:41 +0000 Subject: [PATCH] [refs #318] Update Nunjucks templates and READMEs Code tidy of the Nunjucks templates and README updates. Components amended: - input - inset text - label - list panel - nav a-z - pagination - panel --- app/components/list-panel/index.njk | 74 ++++++++++----------- app/components/nav-a-z/index.njk | 56 ++++++++-------- packages/components/input/template.njk | 30 +++++---- packages/components/inset-text/template.njk | 4 +- packages/components/label/template.njk | 19 +++--- packages/components/list-panel/README.md | 74 ++++++++++----------- packages/components/list-panel/template.njk | 22 +++--- packages/components/nav-a-z/README.md | 56 ++++++++-------- packages/components/nav-a-z/template.njk | 22 +++--- packages/components/pagination/template.njk | 12 ++-- packages/components/panel/template.njk | 12 ++-- 11 files changed, 199 insertions(+), 182 deletions(-) diff --git a/app/components/list-panel/index.njk b/app/components/list-panel/index.njk index 7b527c354..658f4e8bf 100644 --- a/app/components/list-panel/index.njk +++ b/app/components/list-panel/index.njk @@ -14,72 +14,72 @@
  1. {{ listPanel({ - label: "A", - id: "A", - backToTop: "true", - backToTopLink: "#nhsuk-nav-a-z", - items: [ + "label": "A", + "id": "A", + "backToTop": "true", + "backToTopLink": "#nhsuk-nav-a-z", + "items": [ { - URL: "/conditions/abdominal-aortic-aneurysm/", - link: "AAA" + "URL": "/conditions/abdominal-aortic-aneurysm/", + "link": "AAA" }, { - URL: "/conditions/abdominal-aortic-aneurysm/", - link: "Abdominal aortic aneurysm" + "URL": "/conditions/abdominal-aortic-aneurysm/", + "link": "Abdominal aortic aneurysm" }, { - URL: "/conditions/abscess/", - link: "Abscess" + "URL": "/conditions/abscess/", + "link": "Abscess" } ] }) }}
  2. {{ listPanel({ - label: "B", - id: "B", - disable: "true", - backToTop: "true", - backToTopLink: "#nhsuk-nav-a-z", - message: "There are currently no conditions listed" + "label": "B", + "id": "B", + "disable": "true", + "backToTop": "true", + "backToTopLink": "#nhsuk-nav-a-z", + "message": "There are currently no conditions listed" }) }}
  3. {{ listPanel({ - label: "C", - id: "C", - backToTop: "true", - backToTopLink: "#nhsuk-nav-a-z", - items: [ + "label": "C", + "id": "C", + "backToTop": "true", + "backToTopLink": "#nhsuk-nav-a-z", + "items": [ { - URL: "/conditions/chest-pain/", - link: "Chest pain" + "URL": "/conditions/chest-pain/", + "link": "Chest pain" }, { - URL: "/conditions/cold-sores/", - link: "Cold sore" + "URL": "/conditions/cold-sores/", + "link": "Cold sore" } ] }) }}
  4. {{ listPanel({ - label: "D", - id: "D", - backToTop: "true", - backToTopLink: "#nhsuk-nav-a-z", - items: [ + "label": "D", + "id": "D", + "backToTop": "true", + "backToTopLink": "#nhsuk-nav-a-z", + "items": [ { - URL: "/conditions/dandruff/", - link: "Dandruff" + "URL": "/conditions/dandruff/", + "link": "Dandruff" }, { - URL: "/conditions/dementia/", - link: "Dementia" + "URL": "/conditions/dementia/", + "link": "Dementia" }, { - URL: "/conditions/toothache/", - link: "Dental pain" + "URL": "/conditions/toothache/", + "link": "Dental pain" } ] }) }} diff --git a/app/components/nav-a-z/index.njk b/app/components/nav-a-z/index.njk index ff24476b1..683ac1e02 100644 --- a/app/components/nav-a-z/index.njk +++ b/app/components/nav-a-z/index.njk @@ -11,85 +11,85 @@
    {{ azNav({ - items: [ + "items": [ { - label: "A" + "label": "A" }, { - disable: "true", - label: "B" + "disable": "true", + "label": "B" }, { - label: "C" + "label": "C" }, { - label: "D" + "label": "D" }, { - label: "E" + "label": "E" }, { - label: "F" + "label": "F" }, { - label: "G" + "label": "G" }, { - label: "H" + "label": "H" }, { - label: "I" + "label": "I" }, { - label: "J" + "label": "J" }, { - label: "K" + "label": "K" }, { - label: "L" + "label": "L" }, { - label: "M" + "label": "M" }, { - label: "N" + "label": "N" }, { - label: "O" + "label": "O" }, { - label: "P" + "label": "P" }, { - label: "Q" + "label": "Q" }, { - label: "R" + "label": "R" }, { - label: "S" + "label": "S" }, { - label: "T" + "label": "T" }, { - label: "U" + "label": "U" }, { - label: "V" + "label": "V" }, { - label: "W" + "label": "W" }, { - label: "X" + "label": "X" }, { - label: "Y" + "label": "Y" }, { - label: "Z" + "label": "Z" } ] }) }} diff --git a/packages/components/input/template.njk b/packages/components/input/template.njk index fb14cadcc..afccdf872 100644 --- a/packages/components/input/template.njk +++ b/packages/components/input/template.njk @@ -5,7 +5,9 @@ {#- a record of other elements that we need to associate with the input using aria-describedby – for example hints or error messages -#} {% set describedBy = "" %} -
    +
    {{ label({ html: params.label.html, text: params.label.text, @@ -13,30 +15,32 @@ isPageHeading: params.label.isPageHeading, attributes: params.label.attributes, for: params.id - }) | indent(2) | trim }} -{% if params.hint %} - {% set hintId = params.id + '-hint' %} - {% set describedBy = describedBy + ' ' + hintId if describedBy else hintId %} + }) | indent(2) | trim -}} +{%- if params.hint %} + {%- set hintId = params.id + '-hint' %} + {%- set describedBy = describedBy + ' ' + hintId if describedBy else hintId %} {{ hint({ id: hintId, classes: params.hint.classes, attributes: params.hint.attributes, html: params.hint.html, text: params.hint.text - }) | indent(2) | trim }} -{% endif %} -{% if params.errorMessage %} - {% set errorId = params.id + '-error' %} - {% set describedBy = describedBy + ' ' + errorId if describedBy else errorId %} + }) | indent(2) | trim -}} +{% endif -%} +{%- if params.errorMessage %} + {%- set errorId = params.id + '-error' %} + {%- set describedBy = describedBy + ' ' + errorId if describedBy else errorId %} {{ errorMessage({ id: errorId, classes: params.errorMessage.classes, html: params.errorMessage.html, text: params.errorMessage.text - }) | indent(2) | trim }} + }) | indent(2) | trim -}} {% endif %} - + {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
    diff --git a/packages/components/inset-text/template.njk b/packages/components/inset-text/template.njk index 5f6edb855..6902580f1 100644 --- a/packages/components/inset-text/template.njk +++ b/packages/components/inset-text/template.njk @@ -1,4 +1,6 @@ -
    +
    Information: {{ params.HTML | safe }}
    diff --git a/packages/components/label/template.njk b/packages/components/label/template.njk index 806c8198d..069c5a277 100644 --- a/packages/components/label/template.njk +++ b/packages/components/label/template.njk @@ -1,15 +1,16 @@ {% if params.html or params.text %} -{% set labelHtml %} -