From 4f2eea4792dead66d203b779f597a719232987d1 Mon Sep 17 00:00:00 2001 From: Andrew Hosgood Date: Mon, 7 Oct 2024 12:05:19 +0100 Subject: [PATCH] Fix DAC issues (#165) * Fix link in header components for image link purpose * Add aria-label to image caption on hero components * Add title attributes to social links in footer components * Fix details expanded state not announced on iOS * Add file size and type to file lists * Add html property to buttons * Improve accessibility and usability of the gallery component * Update CHANGELOG.md --- CHANGELOG.md | 9 +++ .../components/button/button-group.stories.js | 7 +++ .../components/button/button.stories.js | 3 + .../components/button/fixtures.json | 8 +++ .../components/button/macro-options.json | 8 ++- .../components/button/template.njk | 6 +- .../components/details/details.scss | 3 +- .../components/files-list/fixtures.json | 42 +++++++------- .../components/files-list/template.njk | 4 +- .../components/footer/fixtures.json | 2 +- .../components/footer/template.njk | 2 +- .../components/gallery/fixtures.json | 4 +- .../components/gallery/gallery.mjs | 57 +++++++++++-------- .../components/gallery/gallery.scss | 5 +- .../components/gallery/template.njk | 8 +-- .../components/global-header/fixtures.json | 14 ++--- .../components/global-header/template.njk | 5 +- .../components/header/fixtures.json | 2 +- .../components/header/template.njk | 15 +++-- .../components/hero/fixtures.json | 14 ++--- .../components/hero/template.njk | 3 +- src/nationalarchives/templates/fixtures.json | 10 ++-- 22 files changed, 143 insertions(+), 88 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bdfbcc3..c2dfc38e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/nationalarchives/tna-frontend/compare/v0.2.14...HEAD) ### Added + +- Buttons can now have an `html` property that allows HTML to be used in place of the `text` property + ### Changed ### Deprecated ### Removed @@ -15,6 +18,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Change border widths on global header items from `0.5px` to `1px` to help with sub-pixel rendering - Missing background colour added for focused buttons with `tna-button--solid-hover` +- Logo link in header and global header components updated to address image link purpose WCAG failure +- Added `aria-label` to image caption on hero components +- Added `title` attributes to social links in footer components +- Fix details expanded state not announced on iOS ([issue #5089 on govuk-frontend](https://github.com/alphagov/govuk-frontend/pull/5089)) +- Fixed file list accessible link names to include file size and type +- Accessibility and usability improvements made to the gallery component with regards to HTML and JavaScript ### Security diff --git a/src/nationalarchives/components/button/button-group.stories.js b/src/nationalarchives/components/button/button-group.stories.js index c11ff8b5..389114c6 100644 --- a/src/nationalarchives/components/button/button-group.stories.js +++ b/src/nationalarchives/components/button/button-group.stories.js @@ -6,6 +6,7 @@ export default { const Template = ({ text, + html, href, title, icon, @@ -23,6 +24,7 @@ const Template = ({ Button({ params: { text, + html, href, title, icon, @@ -58,6 +60,11 @@ Group.args = { accent: true, classes: "tna-button--demo", }, + { + html: "HTML", + href: "#", + classes: "tna-button--demo", + }, { text: "Icon", href: "#", diff --git a/src/nationalarchives/components/button/button.stories.js b/src/nationalarchives/components/button/button.stories.js index 130a5e86..25a026e7 100644 --- a/src/nationalarchives/components/button/button.stories.js +++ b/src/nationalarchives/components/button/button.stories.js @@ -3,6 +3,7 @@ import macroOptions from "./macro-options.json"; const argTypes = { text: { control: "text" }, + html: { control: "text" }, href: { control: "text" }, title: { control: "text" }, icon: { control: "text" }, @@ -32,6 +33,7 @@ export default { const Template = ({ text, + html, href, title, icon, @@ -50,6 +52,7 @@ const Template = ({ Button({ params: { text, + html, href, title, icon, diff --git a/src/nationalarchives/components/button/fixtures.json b/src/nationalarchives/components/button/fixtures.json index c4f35b23..aac6fb0c 100644 --- a/src/nationalarchives/components/button/fixtures.json +++ b/src/nationalarchives/components/button/fixtures.json @@ -9,6 +9,14 @@ }, "html": "Log in" }, + { + "name": "with html", + "options": { + "html": "Log in", + "href": "#" + }, + "html": "Log in" + }, { "name": "with title", "options": { diff --git a/src/nationalarchives/components/button/macro-options.json b/src/nationalarchives/components/button/macro-options.json index 6a59c2ad..62af140b 100644 --- a/src/nationalarchives/components/button/macro-options.json +++ b/src/nationalarchives/components/button/macro-options.json @@ -2,9 +2,15 @@ { "name": "text", "type": "string", - "required": true, + "required": false, "description": "The text of the button." }, + { + "name": "html", + "type": "string", + "required": false, + "description": "The HTML to use as the text of the button. Setting this overwrites the `text` property." + }, { "name": "href", "type": "string", diff --git a/src/nationalarchives/components/button/template.njk b/src/nationalarchives/components/button/template.njk index f3b415c4..88dc1dad 100644 --- a/src/nationalarchives/components/button/template.njk +++ b/src/nationalarchives/components/button/template.njk @@ -24,5 +24,9 @@ {% elif params.iconSvg -%} {{ params.iconSvg | safe }} {% endif -%} + {% if params.html -%} + {{ params.html | safe }} + {% else -%} {{ params.text }} - \ No newline at end of file + {% endif -%} + diff --git a/src/nationalarchives/components/details/details.scss b/src/nationalarchives/components/details/details.scss index cd1c2a1e..f601252f 100644 --- a/src/nationalarchives/components/details/details.scss +++ b/src/nationalarchives/components/details/details.scss @@ -15,10 +15,11 @@ } &__summary { + width: fit-content; padding: spacing.space(0.5) spacing.space(1) spacing.space(0.5) spacing.space(2.75); - display: inline-block; + display: block; position: relative; z-index: 1; diff --git a/src/nationalarchives/components/files-list/fixtures.json b/src/nationalarchives/components/files-list/fixtures.json index be338592..6aba1c75 100644 --- a/src/nationalarchives/components/files-list/fixtures.json +++ b/src/nationalarchives/components/files-list/fixtures.json @@ -10,30 +10,30 @@ "id": "file-1", "text": "Preservation policy part 1", "href": "#", - "file_type": "PDF", - "file_size": "1.7MB", - "file_extent": "120 pages", + "fileType": "PDF", + "fileSize": "1.7MB", + "fileExtent": "120 pages", "description": "The principles according to which The National Archives will preserve and care for our archival collections." }, { "id": "file-2", "text": "Preservation policy part 2", "href": "#", - "file_type": "PDF", - "file_size": "0.9MB", + "fileType": "PDF", + "fileSize": "0.9MB", "description": "The principles according to which The National Archives will preserve and care for our archival collections." }, { "id": "file-3", "text": "Preservation policy part 3", "href": "#", - "file_type": "PDF", - "file_size": "3MB", - "file_extent": "200 pages" + "fileType": "PDF", + "fileSize": "3MB", + "fileExtent": "200 pages" } ] }, - "html": "
" + "html": "
" }, { "name": "fully clickable", @@ -44,15 +44,15 @@ "id": "file-1", "text": "Preservation policy part 1", "href": "#", - "file_type": "PDF", - "file_size": "1.7MB", - "file_extent": "120 pages", + "fileType": "PDF", + "fileSize": "1.7MB", + "fileExtent": "120 pages", "description": "The principles according to which The National Archives will preserve and care for our archival collections." } ], "fullAreaClick": true }, - "html": "
" + "html": "
" }, { "name": "with classes", @@ -63,15 +63,15 @@ "id": "file-1", "text": "Preservation policy part 1", "href": "#", - "file_type": "PDF", - "file_size": "1.7MB", - "file_extent": "120 pages", + "fileType": "PDF", + "fileSize": "1.7MB", + "fileExtent": "120 pages", "description": "The principles according to which The National Archives will preserve and care for our archival collections." } ], "classes": "files__test-class" }, - "html": "
" + "html": "
" }, { "name": "with attributes", @@ -82,9 +82,9 @@ "id": "file-1", "text": "Preservation policy part 1", "href": "#", - "file_type": "PDF", - "file_size": "1.7MB", - "file_extent": "120 pages", + "fileType": "PDF", + "fileSize": "1.7MB", + "fileExtent": "120 pages", "description": "The principles according to which The National Archives will preserve and care for our archival collections." } ], @@ -92,7 +92,7 @@ "data-testattribute": "foobar" } }, - "html": "
" + "html": "
" } ] } diff --git a/src/nationalarchives/components/files-list/template.njk b/src/nationalarchives/components/files-list/template.njk index 29a1d3db..e45f84fd 100644 --- a/src/nationalarchives/components/files-list/template.njk +++ b/src/nationalarchives/components/files-list/template.njk @@ -9,7 +9,7 @@ {%- for item in params.items %}
  • - {{ item.text }} + {{ item.text }} ({{ item.fileType }}, {{ item.fileSize }})
    @@ -24,7 +24,7 @@ {%- if item.fileExtent %}
    Extent
    - {{ item.fileExtent }} + {{ item.fileExtent }}
    {%- endif %}
    diff --git a/src/nationalarchives/components/footer/fixtures.json b/src/nationalarchives/components/footer/fixtures.json index 192e9715..ace8118d 100644 --- a/src/nationalarchives/components/footer/fixtures.json +++ b/src/nationalarchives/components/footer/fixtures.json @@ -142,7 +142,7 @@ } ] }, - "html": "" + "html": "" }, { "name": "with theme selector", diff --git a/src/nationalarchives/components/footer/template.njk b/src/nationalarchives/components/footer/template.njk index e2e7f176..4d899e54 100644 --- a/src/nationalarchives/components/footer/template.njk +++ b/src/nationalarchives/components/footer/template.njk @@ -81,7 +81,7 @@