From 91eb497a1ef0155fe7eeb82e94c0597b6ce48bbb Mon Sep 17 00:00:00 2001 From: christopherthomasdesign Date: Wed, 6 Jul 2022 11:32:56 +0100 Subject: [PATCH] Add guidance about summary list card variant --- .../summary-list/card-with-actions/index.njk | 86 +++++++ .../summary-list/card-with-title/index.njk | 223 ++++++++++++++++++ src/components/summary-list/index.md | 91 ++++++- src/patterns/check-answers/index.md | 2 + 4 files changed, 389 insertions(+), 13 deletions(-) create mode 100644 src/components/summary-list/card-with-actions/index.njk create mode 100644 src/components/summary-list/card-with-title/index.njk diff --git a/src/components/summary-list/card-with-actions/index.njk b/src/components/summary-list/card-with-actions/index.njk new file mode 100644 index 0000000000..7ea70965a8 --- /dev/null +++ b/src/components/summary-list/card-with-actions/index.njk @@ -0,0 +1,86 @@ +--- +title: Summary in a card with a title and actions +layout: layout-example.njk +--- + +{% from "govuk/components/summary-list/macro.njk" import govukSummaryList %} + +{{ govukSummaryList({ + card: { + title: { + text: "University of Gloucestershire" + }, + actions: { + items: [ + { + href: "#", + text: "Delete choice", + visuallyHiddenText: "of University of Gloucestershire" + }, + { + href: "#", + text: "Withdraw", + visuallyHiddenText: "from University of Gloucestershire" + } + ] + } + }, + rows: [ + { + key: { + text: "Course" + }, + value: { + html: "English (3DMD)
PGCE with QTS full time" + } + }, + { + key: { + text: "Location" + }, + value: { + html: "School name
Road, City, SW1 1AA" + } + } + ] +}) }} + +{{ govukSummaryList({ + card: { + title: { + text: "University of Bristol" + }, + actions: { + items: [ + { + href: "#", + text: "Delete choice", + visuallyHiddenText: "of University of Bristol" + }, + { + href: "#", + text: "Withdraw", + visuallyHiddenText: "from University of Bristol" + } + ] + } + }, + rows: [ + { + key: { + text: "Course" + }, + value: { + html: "English (Q3X1)
PGCE with QTS full time" + } + }, + { + key: { + text: "Location" + }, + value: { + html: "School name
Road, City, SW2 1AA" + } + } + ] +}) }} diff --git a/src/components/summary-list/card-with-title/index.njk b/src/components/summary-list/card-with-title/index.njk new file mode 100644 index 0000000000..c9da446ec7 --- /dev/null +++ b/src/components/summary-list/card-with-title/index.njk @@ -0,0 +1,223 @@ +--- +title: Summary in a card with a title +layout: layout-example.njk +--- + +{% from "govuk/components/summary-list/macro.njk" import govukSummaryList %} + +{{ govukSummaryList({ + card: { + title: { + text: "Lead tenant" + } + }, + rows: [ + { + key: { + text: "Age" + }, + value: { + html: "38" + }, + actions: { + items: [ + { + href: "#", + text: "Change", + visuallyHiddenText: "age" + } + ] + } + }, + { + key: { + text: "Nationality" + }, + value: { + html: "UK national resident in UK" + }, + actions: { + items: [ + { + href: "#", + text: "Change", + visuallyHiddenText: "nationality" + } + ] + } + }, + { + key: { + text: "Working situation" + }, + value: { + html: "Part time – less than 30 hours a week" + }, + actions: { + items: [ + { + href: "#", + text: "Change", + visuallyHiddenText: "working situation" + } + ] + } + } + ] +}) }} + +{{ govukSummaryList({ + card: { + title: { + text: "Person 2" + } + }, + rows: [ + { + key: { + text: "Details known" + }, + value: { + html: "Yes" + }, + actions: { + items: [ + { + href: "#", + text: "Change", + visuallyHiddenText: "whether details are known" + } + ] + } + }, + { + key: { + text: "Relationship to lead tenant" + }, + value: { + html: "Partner" + }, + actions: { + items: [ + { + href: "#", + text: "Change", + visuallyHiddenText: "relationship to lead tenant" + } + ] + } + }, + { + key: { + text: "Age" + }, + value: { + html: "42" + }, + actions: { + items: [ + { + href: "#", + text: "Change", + visuallyHiddenText: "age" + } + ] + } + }, + { + key: { + text: "Working situation" + }, + value: { + html: "Unable to work because of long-term sickness or disability" + }, + actions: { + items: [ + { + href: "#", + text: "Change", + visuallyHiddenText: "working situation" + } + ] + } + } + ] +}) }} + +{{ govukSummaryList({ + card: { + title: { + text: "Person 3" + } + }, + rows: [ + { + key: { + text: "Details known" + }, + value: { + html: "Yes" + }, + actions: { + items: [ + { + href: "#", + text: "Change", + visuallyHiddenText: "whether details are known" + } + ] + } + }, + { + key: { + text: "Relationship to lead tenant" + }, + value: { + html: "Child" + }, + actions: { + items: [ + { + href: "#", + text: "Change", + visuallyHiddenText: "relationship to lead tenant" + } + ] + } + }, + { + key: { + text: "Age" + }, + value: { + html: "7" + }, + actions: { + items: [ + { + href: "#", + text: "Change", + visuallyHiddenText: "age" + } + ] + } + }, + { + key: { + text: "Working situation" + }, + value: { + html: "Child under 16" + }, + actions: { + items: [ + { + href: "#", + text: "Change", + visuallyHiddenText: "working situation" + } + ] + } + } + ] +}) }} \ No newline at end of file diff --git a/src/components/summary-list/index.md b/src/components/summary-list/index.md index 1e97d122bf..7c24849015 100644 --- a/src/components/summary-list/index.md +++ b/src/components/summary-list/index.md @@ -2,55 +2,65 @@ title: Summary list description: Use the summary list to summarise information, for example, a user’s responses at the end of a form. section: Components -aliases: +aliases: Summary card backlog_issue_id: 182 layout: layout-pane.njk --- {% from "_example.njk" import example %} -Use the summary list to summarise information, for example, a user’s responses at the end of a form. +Use a summary list to summarise information, for example, a user’s responses at the end of a form. {{ example({group: "components", item: "summary-list", example: "default", html: true, nunjucks: true, open: false}) }} ## When to use this component -Use the summary list component to present pairs of related information, known as key-value pairs, in a list. The key is a description or label of a piece of information, like ‘Name’, and the value is the piece of information itself, like ‘John Smith’. +Use a summary list to show information as a list of key facts. You can use it to display metadata like ‘Last updated’ with a date like ‘22 June 2018’, or to summarise a user’s responses at the end of a form like the [check answers](/patterns/check-answers/) pattern. +[Summary cards](#summary-cards) are a variant within this component. You can use summary cards to show multiple summary lists that describe the same type of thing, such as people. You can also add card actions that apply to the entire summary list. + ## When not to use this component The summary list uses the description list (`
`) HTML element, so only use it to present information that has a key and at least one value. Do not use it for tabular data or a simple list of information or tasks, like a [task list](/patterns/task-list-pages/). For those use a ``, `