Skip to content

Commit

Permalink
EWPP-756: Add highlighted field to file_teaser pattern.
Browse files Browse the repository at this point in the history
  • Loading branch information
22Alexandra committed Oct 1, 2021
1 parent 20eb7c9 commit ecd15b5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions templates/patterns/file_teaser/file_teaser.ui_patterns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion templates/patterns/file_teaser/pattern-file-teaser.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -72,5 +78,6 @@
'items': _translations,
},
'detail_meta': _detail_meta,
'variant': 'thumbnail'
'variant': 'thumbnail',
'label': _label,
} only %}
5 changes: 5 additions & 0 deletions tests/Kernel/fixtures/rendering.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.'
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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...'
Expand Down
2 changes: 1 addition & 1 deletion tests/PatternAssertions/ListItemAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down

0 comments on commit ecd15b5

Please sign in to comment.