Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EWPP-2126: Fix text with featured media spacing issue between items. #1079

Merged
merged 1 commit into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@
{% endif %}
{% set text = text|render %}

{% set media_position_class = 'right' in variant ? '' : ' ecl-u-order-m-last' %}
{% if 'right' in variant %}
{% if highlighted == true %}
{% set media_class = 'ecl-u-pr-l ecl-u-pl-none' %}
{% else %}
{% set media_class = 'ecl-u-pl-none' %}
{% endif %}
{% else %}
{% set media_class = 'ecl-u-order-m-last ecl-u-pr-none' %}
{% endif %}

{% set call_to_action_link = '' %}
{% if link %}
Expand All @@ -43,7 +51,7 @@
{% endif %}
<article class="ecl-featured-item__container">
{% if image or video %}
<div class="ecl-featured-item__item{{ media_position_class }}">
<div class="ecl-col-m-6 {{ media_class }}">
{% if image %}
{% include '@ecl-twig/media-container' with {
'image': image.src,
Expand Down
20 changes: 12 additions & 8 deletions tests/src/Kernel/fixtures/rendering.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2541,8 +2541,8 @@
'div.ecl-featured-item': 1
'div.ecl-featured-item.ecl-featured-item--extended': 0
'article.ecl-featured-item__container': 1
'div.ecl-featured-item__item': 2
'div.ecl-featured-item__item.ecl-u-order-m-last': 1
'div.ecl-featured-item__item': 1
'div.ecl-col-m-6.ecl-u-order-m-last': 1
'div.ecl-featured-item__title': 1
'figure.ecl-media-container': 1
'img.ecl-media-container__media[src="http://via.placeholder.com/150x150"]': 1
Expand Down Expand Up @@ -2574,7 +2574,8 @@
'div.ecl-featured-item.ecl-featured-item--extended': 1
'div.ecl-featured-item__heading': 0
'article.ecl-featured-item__container': 1
'div.ecl-featured-item__item.ecl-u-order-m-last': 0
'div.ecl-col-m-6.ecl-u-order-m-last': 0
'div.ecl-col-m-6.ecl-u-pr-l.ecl-u-pl-none': 1
'div.ecl-featured-item__title': 1
'figure.ecl-media-container': 1
'img.ecl-media-container__media[src="http://via.placeholder.com/150x150"]': 1
Expand Down Expand Up @@ -2605,7 +2606,8 @@
'div.ecl-featured-item.ecl-featured-item--extended': 1
'div.ecl-featured-item__heading': 1
'article.ecl-featured-item__container': 1
'div.ecl-featured-item__item.ecl-u-order-m-last': 0
'div.ecl-col-m-6.ecl-u-order-m-last': 0
'div.ecl-col-m-6.ecl-u-pr-l.ecl-u-pl-none': 1
'div.ecl-featured-item__title': 0
'figure.ecl-media-container': 1
'img.ecl-media-container__media[src="http://via.placeholder.com/150x150"]': 1
Expand All @@ -2630,7 +2632,7 @@
'div.ecl-featured-item': 1
'div.ecl-featured-item.ecl-featured-item--extended': 0
'article.ecl-featured-item__container': 1
'div.ecl-col-md-6.ecl-u-mb-m.ecl-u-mb-md-none': 0
'div.ecl-col-md-6': 0
'div.ecl-featured-item__title': 1
'figure.ecl-media-container': 0
'div.ecl-featured-item__item.ecl': 0
Expand Down Expand Up @@ -2660,7 +2662,8 @@
'div.ecl-featured-item': 1
'div.ecl-featured-item.ecl-featured-item--extended': 0
'article.ecl-featured-item__container': 1
'div.ecl-featured-item__item.ecl-u-order-m-last': 0
'div.ecl-col-m-6.ecl-u-order-m-last': 0
'div.ecl-col-m-6.ecl-u-pl-none': 1
'div.ecl-featured-item__title': 1
'figure.ecl-media-container': 1
'img.ecl-media-container__media[src="http://via.placeholder.com/150x150"]': 1
Expand All @@ -2683,6 +2686,7 @@
'div.ecl-featured-item': 0
'div.ecl-featured-item.ecl-featured-item--extended': 0
'article.ecl-featured-item__container': 0
'div.ecl-col-m-6': 0
'figure.ecl-media-container': 0
'div.ecl-col-md-6.ecl-u-mb-m.ecl-u-mb-md-none': 0
'img.ecl-media-container__media[src="http://via.placeholder.com/150x150"]': 0
Expand Down Expand Up @@ -2712,7 +2716,7 @@
'div.ecl-featured-item': 1
'div.ecl-featured-item.ecl-featured-item--extended': 0
'article.ecl-featured-item__container': 1
'div.ecl-featured-item__item.ecl-u-order-m-last': 1
'div.ecl-col-m-6.ecl-u-order-m-last': 1
'figure.ecl-media-container': 1
'img.ecl-media-container__media[src="http://via.placeholder.com/150x150"]': 0
'div.ecl-media-container__media--ratio-16-9 iframe[src="//ec.europa.eu/avservices/play.cfm?ref=I-181645"]': 1
Expand Down Expand Up @@ -2753,7 +2757,7 @@
assertions:
count:
'div.ecl-media-container__media--ratio-1-1 iframe[src="//ec.europa.eu/avservices/play.cfm?ref=I-181645"]': 1
'div.ecl-featured-item__item.ecl-u-order-m-last': 1
'div.ecl-col-m-6.ecl-u-order-m-last': 1
'a.ecl-link.ecl-link--standalone[href="http://example.com"]': 1
- array:
'#type': pattern
Expand Down
10 changes: 5 additions & 5 deletions tests/src/PatternAssertions/TextFeaturedMediaAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ protected function getPatternVariant(string $html): string {
$crawler = new Crawler($html);

$position_variant = 'left';
$items = $crawler->filter('article.ecl-featured-item__container div.ecl-featured-item__item');
$media_position = $crawler->filter('.ecl-u-order-m-last');
if ($items->count() === 2 && !$media_position->count()) {
// If we have 2 items rendered but the media position class is not set,
// then we have one of the right variants.
$media_wrapper = $crawler->filter('.ecl-col-m-6');
$media_position = $media_wrapper->filter('.ecl-u-order-m-last');
if ($media_wrapper->count() && !$media_position->count()) {
// If the media item is rendered but the position class is not set, then
// we have one of the right variants.
$position_variant = 'right';
}

Expand Down