Skip to content

Commit

Permalink
Add width and height attributes to inline SVGs
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Nov 18, 2024
1 parent ff28896 commit 1377089
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fixed the hover and focus outline colour of the log in the global header component
- Added `width` and `height` attributes to inline SVGs

### Security

Expand Down
8 changes: 4 additions & 4 deletions src/nationalarchives/components/files-list/fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
}
]
},
"html": "<div class=\"tna-files-list\"><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\" class=\"tna-files-list__icon\" width=\"24\"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d=\"M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32V274.7l-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7V32zM64 352c-35.3 0-64 28.7-64 64v32c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V416c0-35.3-28.7-64-64-64H346.5l-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352H64zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z\"/></svg><ul class=\"tna-files-list__items\"><li class=\"tna-files-list__item\"><h3 class=\"tna-files-list__item-title tna-heading-s\"><a href=\"#\" class=\"tna-files-list__link\" aria-describedby=\"file-1-extent\">Preservation policy part 1<span class=\"tna-visually-hidden\"> (PDF, 1.7MB)</span></a></h3><div class=\"tna-files-list__item-body\" id=\"file-1\"><dl class=\"tna-dl-chips tna-dl-chips--plain tna-files-list__item-meta\"><dt>File type</dt><dd><span class=\"tna-dl-chips__item\">PDF</span></dd><dt>File size</dt><dd><span class=\"tna-dl-chips__item\">1.7MB</span></dd><dt>Extent</dt><dd><span id=\"file-1-extent\" class=\"tna-dl-chips__item\">120 pages</span></dd></dl><p class=\"tna-files-list__item-description\">The principles according to which The National Archives will preserve and care for our archival collections.</p></div></li><li class=\"tna-files-list__item\"><h3 class=\"tna-files-list__item-title tna-heading-s\"><a href=\"#\" class=\"tna-files-list__link\">Preservation policy part 2<span class=\"tna-visually-hidden\"> (PDF, 0.9MB)</span></a></h3><div class=\"tna-files-list__item-body\" id=\"file-2\"><dl class=\"tna-dl-chips tna-dl-chips--plain tna-files-list__item-meta\"><dt>File type</dt><dd><span class=\"tna-dl-chips__item\">PDF</span></dd><dt>File size</dt><dd><span class=\"tna-dl-chips__item\">0.9MB</span></dd></dl><p class=\"tna-files-list__item-description\">The principles according to which The National Archives will preserve and care for our archival collections.</p></div></li><li class=\"tna-files-list__item\"><h3 class=\"tna-files-list__item-title tna-heading-s\"><a href=\"#\" class=\"tna-files-list__link\" aria-describedby=\"file-3-extent\">Preservation policy part 3<span class=\"tna-visually-hidden\"> (PDF, 3MB)</span></a></h3><div class=\"tna-files-list__item-body\" id=\"file-3\"><dl class=\"tna-dl-chips tna-dl-chips--plain tna-files-list__item-meta\"><dt>File type</dt><dd><span class=\"tna-dl-chips__item\">PDF</span></dd><dt>File size</dt><dd><span class=\"tna-dl-chips__item\">3MB</span></dd><dt>Extent</dt><dd><span id=\"file-3-extent\" class=\"tna-dl-chips__item\">200 pages</span></dd></dl></div></li></ul></div>"
"html": "<div class=\"tna-files-list\"><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\" class=\"tna-files-list__icon\" width=\"24\" height=\"24\"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d=\"M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32V274.7l-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7V32zM64 352c-35.3 0-64 28.7-64 64v32c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V416c0-35.3-28.7-64-64-64H346.5l-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352H64zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z\"/></svg><ul class=\"tna-files-list__items\"><li class=\"tna-files-list__item\"><h3 class=\"tna-files-list__item-title tna-heading-s\"><a href=\"#\" class=\"tna-files-list__link\" aria-describedby=\"file-1-extent\">Preservation policy part 1<span class=\"tna-visually-hidden\"> (PDF, 1.7MB)</span></a></h3><div class=\"tna-files-list__item-body\" id=\"file-1\"><dl class=\"tna-dl-chips tna-dl-chips--plain tna-files-list__item-meta\"><dt>File type</dt><dd><span class=\"tna-dl-chips__item\">PDF</span></dd><dt>File size</dt><dd><span class=\"tna-dl-chips__item\">1.7MB</span></dd><dt>Extent</dt><dd><span id=\"file-1-extent\" class=\"tna-dl-chips__item\">120 pages</span></dd></dl><p class=\"tna-files-list__item-description\">The principles according to which The National Archives will preserve and care for our archival collections.</p></div></li><li class=\"tna-files-list__item\"><h3 class=\"tna-files-list__item-title tna-heading-s\"><a href=\"#\" class=\"tna-files-list__link\">Preservation policy part 2<span class=\"tna-visually-hidden\"> (PDF, 0.9MB)</span></a></h3><div class=\"tna-files-list__item-body\" id=\"file-2\"><dl class=\"tna-dl-chips tna-dl-chips--plain tna-files-list__item-meta\"><dt>File type</dt><dd><span class=\"tna-dl-chips__item\">PDF</span></dd><dt>File size</dt><dd><span class=\"tna-dl-chips__item\">0.9MB</span></dd></dl><p class=\"tna-files-list__item-description\">The principles according to which The National Archives will preserve and care for our archival collections.</p></div></li><li class=\"tna-files-list__item\"><h3 class=\"tna-files-list__item-title tna-heading-s\"><a href=\"#\" class=\"tna-files-list__link\" aria-describedby=\"file-3-extent\">Preservation policy part 3<span class=\"tna-visually-hidden\"> (PDF, 3MB)</span></a></h3><div class=\"tna-files-list__item-body\" id=\"file-3\"><dl class=\"tna-dl-chips tna-dl-chips--plain tna-files-list__item-meta\"><dt>File type</dt><dd><span class=\"tna-dl-chips__item\">PDF</span></dd><dt>File size</dt><dd><span class=\"tna-dl-chips__item\">3MB</span></dd><dt>Extent</dt><dd><span id=\"file-3-extent\" class=\"tna-dl-chips__item\">200 pages</span></dd></dl></div></li></ul></div>"
},
{
"name": "fully clickable",
Expand All @@ -52,7 +52,7 @@
],
"fullAreaClick": true
},
"html": "<div class=\"tna-files-list tna-files-list--full-click\"><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\" class=\"tna-files-list__icon\" width=\"24\"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d=\"M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32V274.7l-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7V32zM64 352c-35.3 0-64 28.7-64 64v32c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V416c0-35.3-28.7-64-64-64H346.5l-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352H64zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z\"/></svg><ul class=\"tna-files-list__items\"><li class=\"tna-files-list__item\"><h3 class=\"tna-files-list__item-title tna-heading-s\"><a href=\"#\" class=\"tna-files-list__link\" aria-describedby=\"file-1-extent\">Preservation policy part 1<span class=\"tna-visually-hidden\"> (PDF, 1.7MB)</span></a></h3><div class=\"tna-files-list__item-body\" id=\"file-1\"><dl class=\"tna-dl-chips tna-dl-chips--plain tna-files-list__item-meta\"><dt>File type</dt><dd><span class=\"tna-dl-chips__item\">PDF</span></dd><dt>File size</dt><dd><span class=\"tna-dl-chips__item\">1.7MB</span></dd><dt>Extent</dt><dd><span id=\"file-1-extent\" class=\"tna-dl-chips__item\">120 pages</span></dd></dl><p class=\"tna-files-list__item-description\">The principles according to which The National Archives will preserve and care for our archival collections.</p></div></li></ul></div>"
"html": "<div class=\"tna-files-list tna-files-list--full-click\"><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\" class=\"tna-files-list__icon\" width=\"24\" height=\"24\"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d=\"M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32V274.7l-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7V32zM64 352c-35.3 0-64 28.7-64 64v32c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V416c0-35.3-28.7-64-64-64H346.5l-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352H64zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z\"/></svg><ul class=\"tna-files-list__items\"><li class=\"tna-files-list__item\"><h3 class=\"tna-files-list__item-title tna-heading-s\"><a href=\"#\" class=\"tna-files-list__link\" aria-describedby=\"file-1-extent\">Preservation policy part 1<span class=\"tna-visually-hidden\"> (PDF, 1.7MB)</span></a></h3><div class=\"tna-files-list__item-body\" id=\"file-1\"><dl class=\"tna-dl-chips tna-dl-chips--plain tna-files-list__item-meta\"><dt>File type</dt><dd><span class=\"tna-dl-chips__item\">PDF</span></dd><dt>File size</dt><dd><span class=\"tna-dl-chips__item\">1.7MB</span></dd><dt>Extent</dt><dd><span id=\"file-1-extent\" class=\"tna-dl-chips__item\">120 pages</span></dd></dl><p class=\"tna-files-list__item-description\">The principles according to which The National Archives will preserve and care for our archival collections.</p></div></li></ul></div>"
},
{
"name": "with classes",
Expand All @@ -71,7 +71,7 @@
],
"classes": "files__test-class"
},
"html": "<div class=\"tna-files-list files__test-class\"><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\" class=\"tna-files-list__icon\" width=\"24\"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d=\"M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32V274.7l-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7V32zM64 352c-35.3 0-64 28.7-64 64v32c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V416c0-35.3-28.7-64-64-64H346.5l-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352H64zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z\"/></svg><ul class=\"tna-files-list__items\"><li class=\"tna-files-list__item\"><h3 class=\"tna-files-list__item-title tna-heading-s\"><a href=\"#\" class=\"tna-files-list__link\" aria-describedby=\"file-1-extent\">Preservation policy part 1<span class=\"tna-visually-hidden\"> (PDF, 1.7MB)</span></a></h3><div class=\"tna-files-list__item-body\" id=\"file-1\"><dl class=\"tna-dl-chips tna-dl-chips--plain tna-files-list__item-meta\"><dt>File type</dt><dd><span class=\"tna-dl-chips__item\">PDF</span></dd><dt>File size</dt><dd><span class=\"tna-dl-chips__item\">1.7MB</span></dd><dt>Extent</dt><dd><span id=\"file-1-extent\" class=\"tna-dl-chips__item\">120 pages</span></dd></dl><p class=\"tna-files-list__item-description\">The principles according to which The National Archives will preserve and care for our archival collections.</p></div></li></ul></div>"
"html": "<div class=\"tna-files-list files__test-class\"><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\" class=\"tna-files-list__icon\" width=\"24\" height=\"24\"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d=\"M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32V274.7l-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7V32zM64 352c-35.3 0-64 28.7-64 64v32c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V416c0-35.3-28.7-64-64-64H346.5l-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352H64zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z\"/></svg><ul class=\"tna-files-list__items\"><li class=\"tna-files-list__item\"><h3 class=\"tna-files-list__item-title tna-heading-s\"><a href=\"#\" class=\"tna-files-list__link\" aria-describedby=\"file-1-extent\">Preservation policy part 1<span class=\"tna-visually-hidden\"> (PDF, 1.7MB)</span></a></h3><div class=\"tna-files-list__item-body\" id=\"file-1\"><dl class=\"tna-dl-chips tna-dl-chips--plain tna-files-list__item-meta\"><dt>File type</dt><dd><span class=\"tna-dl-chips__item\">PDF</span></dd><dt>File size</dt><dd><span class=\"tna-dl-chips__item\">1.7MB</span></dd><dt>Extent</dt><dd><span id=\"file-1-extent\" class=\"tna-dl-chips__item\">120 pages</span></dd></dl><p class=\"tna-files-list__item-description\">The principles according to which The National Archives will preserve and care for our archival collections.</p></div></li></ul></div>"
},
{
"name": "with attributes",
Expand All @@ -92,7 +92,7 @@
"data-testattribute": "foobar"
}
},
"html": "<div class=\"tna-files-list\" data-testattribute=\"foobar\"><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\" class=\"tna-files-list__icon\" width=\"24\"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d=\"M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32V274.7l-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7V32zM64 352c-35.3 0-64 28.7-64 64v32c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V416c0-35.3-28.7-64-64-64H346.5l-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352H64zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z\"/></svg><ul class=\"tna-files-list__items\"><li class=\"tna-files-list__item\"><h3 class=\"tna-files-list__item-title tna-heading-s\"><a href=\"#\" class=\"tna-files-list__link\" aria-describedby=\"file-1-extent\">Preservation policy part 1<span class=\"tna-visually-hidden\"> (PDF, 1.7MB)</span></a></h3><div class=\"tna-files-list__item-body\" id=\"file-1\"><dl class=\"tna-dl-chips tna-dl-chips--plain tna-files-list__item-meta\"><dt>File type</dt><dd><span class=\"tna-dl-chips__item\">PDF</span></dd><dt>File size</dt><dd><span class=\"tna-dl-chips__item\">1.7MB</span></dd><dt>Extent</dt><dd><span id=\"file-1-extent\" class=\"tna-dl-chips__item\">120 pages</span></dd></dl><p class=\"tna-files-list__item-description\">The principles according to which The National Archives will preserve and care for our archival collections.</p></div></li></ul></div>"
"html": "<div class=\"tna-files-list\" data-testattribute=\"foobar\"><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\" class=\"tna-files-list__icon\" width=\"24\" height=\"24\"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d=\"M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32V274.7l-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7V32zM64 352c-35.3 0-64 28.7-64 64v32c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V416c0-35.3-28.7-64-64-64H346.5l-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352H64zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z\"/></svg><ul class=\"tna-files-list__items\"><li class=\"tna-files-list__item\"><h3 class=\"tna-files-list__item-title tna-heading-s\"><a href=\"#\" class=\"tna-files-list__link\" aria-describedby=\"file-1-extent\">Preservation policy part 1<span class=\"tna-visually-hidden\"> (PDF, 1.7MB)</span></a></h3><div class=\"tna-files-list__item-body\" id=\"file-1\"><dl class=\"tna-dl-chips tna-dl-chips--plain tna-files-list__item-meta\"><dt>File type</dt><dd><span class=\"tna-dl-chips__item\">PDF</span></dd><dt>File size</dt><dd><span class=\"tna-dl-chips__item\">1.7MB</span></dd><dt>Extent</dt><dd><span id=\"file-1-extent\" class=\"tna-dl-chips__item\">120 pages</span></dd></dl><p class=\"tna-files-list__item-description\">The principles according to which The National Archives will preserve and care for our archival collections.</p></div></li></ul></div>"
}
]
}
2 changes: 1 addition & 1 deletion src/nationalarchives/components/files-list/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{%- endif -%}
{%- set classes = containerClasses | join(' ') -%}
<div class="tna-files-list{% if classes %} {{ classes }}{% endif %}"{% for attribute, value in params.attributes %} {{ attribute }}{% if value !== '' %}="{{ value }}"{% endif %}{% endfor %}>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="tna-files-list__icon" width="24"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32V274.7l-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7V32zM64 352c-35.3 0-64 28.7-64 64v32c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V416c0-35.3-28.7-64-64-64H346.5l-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352H64zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="tna-files-list__icon" width="24" height="24"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32V274.7l-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7V32zM64 352c-35.3 0-64 28.7-64 64v32c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V416c0-35.3-28.7-64-64-64H346.5l-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352H64zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z"/></svg>
<ul class="tna-files-list__items">
{%- for item in params.items %}
<li class="tna-files-list__item">
Expand Down
Loading

0 comments on commit 1377089

Please sign in to comment.