diff --git a/templates/patterns/file_teaser/file_teaser.ui_patterns.yml b/templates/patterns/file_teaser/file_teaser.ui_patterns.yml index 58028cbca3..e6010355cd 100644 --- a/templates/patterns/file_teaser/file_teaser.ui_patterns.yml +++ b/templates/patterns/file_teaser/file_teaser.ui_patterns.yml @@ -85,3 +85,9 @@ file_teaser: description: "Used to trim the length of the 'Teaser' fields (optional)." preview: 10 escape: false + highlighted: + type: "boolean" + label: "Highlighted" + description: "Define if the file should be labeled as highlighted." + preview: true + escape: false diff --git a/templates/patterns/file_teaser/pattern-file-teaser.html.twig b/templates/patterns/file_teaser/pattern-file-teaser.html.twig index 957117bc93..9abf92aa12 100644 --- a/templates/patterns/file_teaser/pattern-file-teaser.html.twig +++ b/templates/patterns/file_teaser/pattern-file-teaser.html.twig @@ -38,6 +38,12 @@ {% if file.size %} {% set _meta = '(' ~ file.size|format_size ~ ' - ' ~ file.extension|upper ~ ')' %} {% endif %} +{% if highlighted %} + {% set _label = { + 'label': 'Highlighted'|t, + 'variant': 'highlight', + } %} +{% endif %} {% include '@ecl-twig/file' with { 'title': file.title, 'description': teaser|smart_trim(length), @@ -72,5 +78,6 @@ 'items': _translations, }, 'detail_meta': _detail_meta, - 'variant': 'thumbnail' + 'variant': 'thumbnail', + 'label': _label, } only %} diff --git a/tests/Kernel/fixtures/rendering.yml b/tests/Kernel/fixtures/rendering.yml index d5b27cc6e2..6f0e17e64b 100644 --- a/tests/Kernel/fixtures/rendering.yml +++ b/tests/Kernel/fixtures/rendering.yml @@ -577,6 +577,7 @@ language_code: "hu" translation_toggle_label: "Other translations" more_info: "Looking for another language which is not on the list? Find out why." + highlighted: true assertions: count: 'img.ecl-file__image[src="https://inno-ecl.s3.amazonaws.com/media/examples/example-image.jpg"]': 1 @@ -591,6 +592,7 @@ 'a.ecl-file__translation-download[href="http://example.com/document_fr.xls"]': 1 'a.ecl-file__translation-download[href="http://example.com/document_it.ppt"]': 1 'a.ecl-file__translation-download[href="http://example.com/document_hu.pdf"]': 1 + 'div.ecl-file__label span.ecl-label.ecl-label--highlight': 1 equals: 'div.ecl-file__detail-info div.ecl-file__title': "Example document" 'div.ecl-file__detail-info div.ecl-file__description': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer quis lorem tellus. Nullam sollicitudin suscipit diam, ac blandit ipsum tempor consectetur. Duis vitae pulvinar turpis. Donec maximus pharetra ex a ultricies.' @@ -616,6 +618,7 @@ '.ecl-file__translation-item:nth-child(3) div.ecl-file__translation-meta': "(166.02 KB - PDF)" '.ecl-file__translation-item:nth-child(3) .ecl-link__label': "Download" 'li.ecl-file__translation-item.ecl-file__translation-description': "Looking for another language which is not on the list? Find out why." + 'div.ecl-file__label span.ecl-label.ecl-label--highlight': "Highlighted" - array: '#type': pattern '#id': file_teaser @@ -645,6 +648,7 @@ language_code: "fr" more_info: "Looking for another language which is not on the list? Find out why." length: 10 + highlighted: false assertions: count: 'img.ecl-file__image[src="https://inno-ecl.s3.amazonaws.com/media/examples/example-image.jpg"]': 1 @@ -657,6 +661,7 @@ 'ul.ecl-file__translation-list': 1 'li.ecl-file__translation-item a.ecl-file__translation-download': 1 'a.ecl-file__translation-download[href="http://example.com/document_fr.xls"]': 1 + 'div.ecl-file__label span.ecl-label.ecl-label--highlight': 0 equals: 'div.ecl-file__detail-info div.ecl-file__title': "Example document" 'div.ecl-file__detail-info div.ecl-file__description': 'Lorem...' diff --git a/tests/PatternAssertions/ListItemAssert.php b/tests/PatternAssertions/ListItemAssert.php index 3d35add00e..cc2b0079ea 100644 --- a/tests/PatternAssertions/ListItemAssert.php +++ b/tests/PatternAssertions/ListItemAssert.php @@ -71,7 +71,7 @@ protected function getAssertions($variant): array { ], 'highlighted' => [ [$this, 'assertElementText'], - $base_selector . '__meta div.ecl-label.ecl-label--highlight.ecl-u-mr-xs', + $base_selector . '__meta span.ecl-label.ecl-label--highlight.ecl-u-mr-xs', ], 'status' => [ [$this, 'assertElementText'],